votes/score

24 views
Skip to first unread message

Érico Oliveira

unread,
Nov 14, 2013, 12:13:13 PM11/14/13
to django...@googlegroups.com
Hy, i'm learning django.
My idea is to give marks / votes for a selected job.
Works but not as I would.

class Job(models.Model):
    title= models.CharField(max_length=20)
    slug = models.SlugField(max_length=40, blank=True)
    def __unicode__(self):
        return self.title  

class Vote(models.Model):
    job = models.ForeignKey(Job)
    score = models.IntegerField(blank=True, default=0)


my forms.py

MYVALUES = (
(5, u'<i class="fa fa-heart fa-2x"></i><span>5 </span>'), # don't work {{ form|safe }}
(5, five'),
(3, u'three'),
(2, u'two'), 
(1, u'one'),
)
class FormVote(forms.ModelForm):
class Meta:
model = Vote
score = forms.ChoiceField(choices=MYVALUES, widget=forms.RadioSelect())

As I did all the html / css. I would not return the form that way.
I tried a different approach, trying to pass the values ​​of the vote through a link using jquery, but I can not mount the garvar to view the value of voting.

It would be a mess trying to return an HTML inside FormVote, something like:







Help?
thanks in advance.

 

Leonardo Giordani

unread,
Nov 19, 2013, 2:36:40 AM11/19/13
to django...@googlegroups.com
Érico,

it is not really clear to me what you are trying to accomplish. That HTML in MYVALUES is a try to show that line in the dropdown? And why is "{{form|safe}}" there?
May you please decribe what you would like to obtain?

Cheers,

Leo



Leonardo Giordani
Author of The Digital Cat
My profile on About.me - My GitHub page - My Coderwall profile


2013/11/14 Érico Oliveira <eric...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/736728d8-dc12-41aa-b223-7c8bed0a2cf4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages