On Friday, 16 August 2013 14:06:38 UTC+1, Pepsodent Cola wrote:
-- ### PART AMy altword_list template file receives a primary key ID from my Index template file.#___________________________________________________________ ____________________ altword_list.html<h1>{{ poll.rosword }}</h1>{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}<h3>Filter 5</h3><ul>{% for choice in poll.altword_set.all %}<!-- for choice in poll.altword.all --><li>{{ choice.rosword }} = {{ choice.votes }} votes</li>{% endfor %}</ul>#___________________________________________________________ ____________________ ### PART B* Things work as intended when the rosword field just contain a simple "FK(Word)".* But when I use the other rosword field instead containing "FK(Word, related_name='altword_rosword')", then my altword_list template file doesn't receive a primary key ID from my Index template file anymore.What am I doing wrong when using related_name in my rosword field?#___________________________________________________________ ____________________ class Altword(models.Model):#rosword = models.ForeignKey(Word, related_name='altword_rosword') # altword_list.html doesn't receive pk ID anymore why? rosword = models.ForeignKey(Word) # OKalt_ros_word = models.CharField(max_length=200) #wordy = models.OneToOneField(Word, related_name='wordy', primary_key=True)votes = models.IntegerField(default=0)def __unicode__(self):return self.alt_ros_word#___________________________________________________________ ____________________
I have no idea what "primary key ID" has to do with anything. However, if you've changed the related name in the field, you should change it in the template as well:
{% for choice in poll.altword_rosword.all %}
--
DR.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment