hi again

when looking at the database (sqlite, using SQLite Manager) i saw that the
field item_id in the simplenote table is NULL! after setting is manually to
the id of the task, task.notes.all() returns the correct non-empty list.

so, is this a bug in queryset-refactor or am i doing something wrong?

thanks
André


On Sun, Jul 6, 2008 at 1:36 PM, Andre Meyer <[EMAIL PROTECTED]> wrote:

> hi all
>
> so, i am trying to add notes to tasks in this simple model (using
> newforms-admin 7844):
>
> class SimpleItem(models.Model):
>     title = models.CharField(max_length=512)
>
> class SimpleTask(SimpleItem):
>     done = models.BooleanField()
>     due = models.DateTimeField(null=True, blank=True)
>
> class SimpleNote(SimpleItem):
>     text = models.TextField(null=True, blank=True)
>     item = models.ForeignKey(SimpleItem, related_name='notes', null=True,
> blank=True)
>
> but, when i try to instantiate objects from these model classes, for some
> reason the relation between task and note is there in only one direction.
> the note knows its task, but the task has no notes. why?
>
> >>> t = SimpleTask()
> >>> t.title = 'first task'
> >>> t.done = False
> >>> n = SimpleNote()
> >>> n.title = 'first note'
> >>> n.text = "just some text for this note."
> >>> n.item = t
> >>> n.save()
> >>> t.save()
> >>> n.item
> <SimpleTask: SimpleTask object>
> >>> n.item.title
> 'first task'
> >>> t.notes
> <django.db.models.fields.related.RelatedManager object at 0x0296B070>
> >>> *t.notes.count()*
> *0
> *>>> *t.notes.all()*
> *[]*
>
> btw: where is the API for RelatedManager? can't find it in the docs
>
> thanks
> André
>
>

--~--~---------~--~----~------------~-------~--~----~
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