### PART A
#_______________________________________________________________________________
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) # OK
alt_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
#_______________________________________________________________________________
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