Doh! As I stated and figured it would be... a total noob mistake.

Thanks Nathan - I will look even harder before posting next time.

D.


On Jul 25, 12:37 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> As the error says, you're using self.question in the Choice model --
> it should be self.choice.
>
> e.g., change this:
>
> class Choice(models.Model):
>   # ...
>   def __unicode__(self):
>     return self.question
>
> to this:
>
> class Choice(models.Model):
>   # ...
>   def __unicode__(self):
>     return self.choice
>
> On Jul 25, 8:19 am, Dynomite2910 <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > Apologies for a noob question/problem. I have searched the forum and
> > can't find anyone having the same issue. I am working through the
> > tutorial following everything exactly as written. 
> > (http://www.djangoproject.com/documentation/tutorial01/)
>
> > Everything works as expected until I get to the point where I try to
> > add choices to the first poll I created. Here is the shell output I
> > receive.
>
> > D:\django\mysite>manage.py shell
> > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> > (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more information.
> > (InteractiveConsole)>>> from mysite.polls.models import Poll, Choice
> > >>> p = Poll.objects.get(pk=1)
> > >>> p.choice_set.create(choice='Not much',votes=0)
>
> > Traceback (most recent call last):
> >   File "<console>", line 1, in <module>
> >   File "D:\Python25\lib\site-packages\django\db\models\base.py", line
> > 87, in __r
> > epr__
> >     return smart_str(u'<%s: %s>' % (self.__class__.__name__,
> > unicode(self)))
> >   File "D:\django\mysite\..\mysite\polls\models.py", line 16, in
> > __unicode__
> >     return self.question
> > AttributeError: 'Choice' object has no attribute 'question'
>
> > Here is my models.py file:
>
> > from django.db import models
> > import datetime
>
> > class Poll(models.Model):
> >     question = models.CharField(maxlength=200)
> >     pub_date = models.DateTimeField('date published')
>
> >     def __unicode__(self):
> >         return self.question
>
> >     def was_published_today(self):
> >         return self.pub_date.date() == datetime.date.today()
>
> > class Choice(models.Model):
> >     poll = models.ForeignKey(Poll)
> >     choice = models.CharField(maxlength=200)
> >     votes = models.IntegerField()
>
> >     def __unicode__(self):
> >         return self.question
>
> > It appears to be a problem with the foreign - here is the resuts of
> > "manage.py sql polls"
>
> > D:\django\mysite>manage.py sql polls
> > BEGIN;
> > CREATE TABLE "polls_poll" (
> >     "id" serial NOT NULL PRIMARY KEY,
> >     "question" varchar(200) NOT NULL,
> >     "pub_date" timestamp with time zone NOT NULL
> > )
> > ;
> > CREATE TABLE "polls_choice" (
> >     "id" serial NOT NULL PRIMARY KEY,
> >     "poll_id" integer NOT NULL REFERENCES "polls_poll" ("id")
> > DEFERRABLE INITIAL
> > LY DEFERRED,
> >     "choice" varchar(200) NOT NULL,
> >     "votes" integer NOT NULL
> > )
> > ;
> > COMMIT;
>
> > I'm not sure where to go from here or how to figure out what the issue
> > is here. Hoping someone here can provide some guidance.
>
> > Thx,
> > D.- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to