Sunday, January 22, 2012

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

There is still the possibility that you really have a row where the PK
is somehow null. That would need an investigation through SQL. If so,
there is an error somewhere, either in your database schema, or maybe
in Django itself.

- Anssi

On Jan 22, 4:49 am, JohnA <john.armstrong....@gmail.com> wrote:
> Is your code really that simple - I mean get the queryset and
> immediately try to delete something out of it?  If so, maybe it's time
> to step through the delete in the debugger.  Querysets are lazy but I
> assume that referencing an item in the queryset kike you do will cause
> the actual data to get feteched.  Maybe the problem is trying to
> delete something directly out of the queryset, or maybe you're somehow
> deleting the same record twice, or maybe django is somehow getting
> confused while performing the operation.
>
> -- John
>
> On Jan 21, 6:39 pm, 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 crud to quests
> > list?
>
> > cs

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate