Monday, January 23, 2012

Re: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

On Jan 22, 12:39 am, Chris Seberino <cseber...@gmail.com> wrote:
> On Jan 21, 2:43 pm, JohnA <john.armstrong....@gmail.com> wrote:
>
> > How are you finding these objects?  That might point to the answer.
>
> > Probably the likeliest explanation is that you are creating the
> > objects but not saving them.
>
> In the Django shell I do
>
> quests = Question.objects.all()
> quests[579].delete()
>
> Why does the objects.all() invocation add this id=None

No reason it should do this, and I really doubt this is the case -
unless you're using a (broken) custom Manager you didn't mention when
you posted your model definition.


> to quests list?

"quests" is not a list, it's a QuerySet (https://
docs.djangoproject.com/en/1.3/ref/models/querysets/).

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment