My poll doesn't work when I start using related_name, help please.

2013-08-16 Thread Pepsodent Cola
### PART A

My altword_list template file receives a primary key ID from my Index 
template file.
#___
*altword_list.html*

{{ poll.rosword }}
{% if error_message %}{{ error_message }}{% endif %}

Filter 5

*{% for choice in poll.altword_set.all %}*

*{{ choice.rosword }}*  = {{ choice.votes }} votes
{% endfor %}

#___



### 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+unsubscr...@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.


Re: My poll doesn't work when I start using related_name, help please.

2013-08-16 Thread Daniel Roseman
On Friday, 16 August 2013 14:06:38 UTC+1, Pepsodent Cola wrote:

> ### PART A
>
> My altword_list template file receives a primary key ID from my Index 
> template file.
>
> #___
> *altword_list.html*
>
> {{ poll.rosword }}
> {% if error_message %}{{ error_message }}{% endif 
> %}
>
> Filter 5
> 
> *{% for choice in poll.altword_set.all %}*
> 
> *{{ choice.rosword }}*  = {{ choice.votes }} votes
> {% endfor %}
> 
>
> #___
>
>
>
> ### 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
>
> #___
>
>
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+unsubscr...@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.


Re: My poll doesn't work when I start using related_name, help please.

2013-08-17 Thread Pepsodent Cola
Yay, it worked!  Thank you Dr. Roseman.  :)

*[SOLVED]*
*
*



On Friday, August 16, 2013 4:51:36 PM UTC+2, Daniel Roseman wrote:
>
> On Friday, 16 August 2013 14:06:38 UTC+1, Pepsodent Cola wrote:
>
>> ### PART A
>>
>> My altword_list template file receives a primary key ID from my Index 
>> template file.
>>
>> #___
>> *altword_list.html*
>>
>> {{ poll.rosword }}
>> {% if error_message %}{{ error_message }}{% endif 
>> %}
>>
>> Filter 5
>> 
>> *{% for choice in poll.altword_set.all %}*
>> 
>> *{{ choice.rosword }}*  = {{ choice.votes }} votes
>> {% endfor %}
>> 
>>
>> #___
>>
>>
>>
>> ### 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
>>
>> #___
>>
>>
> 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+unsubscr...@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.