#25882: Deletion on ForeignKey raises TypeError
----------------------------------------------+--------------------
Reporter: gerricom | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Consider following model constellation:
{{{
class Catalog(models.Model):
name = models.CharField(max_length=255)
...
class Reader(models.Model):
name = models.CharField(max_length=255)
catalog = models.ForeignKey(Catalog)
...
class ReaderHasMedia(models.Model):
reader = models.ForeignKey(Reader)
...
}}}
Now in some cases I need to perform following command
{{{
ReaderHasMedia.objects.filter(catalog=Catalog.objects.get(pk=123)).delete()
}}}
With this command, I get following TypeError:
{{{
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py",
line 600, in delete
deleted, _rows_count = collector.delete()
File "/usr/local/lib/python2.7/site-
packages/django/db/models/deletion.py", line 293, in delete
deleted_counter[qs.model._meta.label] += count
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
}}}
With Django 1.8.7 there wasn't a count variable in deletion.py and so I
believe, this is a fresh bug with Django 1.9...
--
Ticket URL: <https://code.djangoproject.com/ticket/25882>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.472de8470a37d541a6b544022444e072%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.