Opened 8 years ago

Last modified 8 years ago

#27128 closed Bug

A method model.objects.get(pk=obj.pk) returns many objects, but in a database is one. — at Initial Version

Reported by: Seti Owned by: nobody
Component: Uncategorized Version: 1.9
Severity: Normal Keywords: GenericRelation, Testing, Models
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Very strange behaviour of the Django ORM while testing (now I am using pytest)

I have two apps "books" and "replies".
The app "books" has two models http://pastebin.com/gDMi7UpU
The app "replies" has one model http://pastebin.com/u9FabQQA

For create new objects I am using factories for replies - http://pastebin.com/pGtiwS2m, for books and writers - http://pastebin.com/NQ6AWxib

While testing methods of queryset of the model Book I got error, where it should not be

A file querysets.py of the app "books" http://pastebin.com/FVnLLzxK
Tests for the file querysets.py of the app "books" http://pastebin.com/rmpDm0Ae

For testing I am using the pytest with next configuration in a file pytest.ini

[pytest]
addopts = -s --reuse-db --ff --maxfail=1 apps/books/tests/test_querysets.py::Tests
DJANGO_SETTINGS_MODULE=config.settings.development

Run test as next py.test

Traceback http://pastebin.com/Vv96XLzm

After many time googling and dipping in the Django`s code by the traceback I decided it is bug in the Django

I think it is the problem related with that models the Book and the Reply is related by help the field GenericRelation, but I don`t found facts for it.

Sorry for my grammar mistakes, I was no originally an English

If need another codes from my project, please tell about it

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top