Thursday, November 27, 2014

strange question when i access related object

My EventDate model has a ForeignKey to Event shown as follows:

class EventDate( models.Model ): # {{{1
    """ stores dates for events """
    eventdate_name = models.CharField(
            _( u'Name' ), blank = False, null = False,
            max_length = 80, help_text = _(
            "Example: call for papers" ) )
    eventdate_date = models.DateField( _( u'Date' ), blank = False,
            null = False, db_index = True, validators = [validate_year] )
    event = models.ForeignKey( Event, related_name = 'dates' )
    objects = models.GeoManager()

The shell output is:
In [10]: event.dates.create(eventdate_name='start', eventdate_date=datetime.date.today())
Out[10]: <EventDate: 2014-11-27    start>
In [11]: event.dates.all()
Out[11]: []

Why is event.dates.all() empty?

Does anyone have some advance?


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4655197f.1380a.149f1aab0f2.Coremail.daedae11%40126.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment