Created
April 25, 2015 11:34
-
-
Save apinsard/43bcc77547a7d9d6fbbc to your computer and use it in GitHub Desktop.
stdin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- accounts/models.py | |
| class Member(models.Model): | |
| class Meta: | |
| abstract = True | |
| ... | |
| user = models.OneToOneField(User) | |
| class Professional(Member): | |
| ... | |
| announces = GenericRelation('services.Announce', | |
| verbose_name=_("annonces"), | |
| content_type_field='announcer_type', | |
| object_id_field='announcer_id', | |
| related_query_name='professionals') | |
| -- services/models.py | |
| class Announce(models.Model): | |
| class Meta: | |
| abstract = True | |
| ... | |
| announcer_type = models.ForeignKey(ContentType) | |
| announcer_id = models.PositiveIntegerField() | |
| announcer = GenericForeignKey('announcer_type', 'announcer_id') | |
| class Service(Announce): | |
| ... | |
| class Job(Announce): | |
| ... | |
| -- manage.py shell | |
| Python 3.3.6 (default, Dec 10 2014, 19:08:56) | |
| [GCC 4.8.3] on linux | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| (InteractiveConsole) | |
| >>> from accounts.models import * | |
| >>> Professional.objects.get(pk=1).delete() | |
| Traceback (most recent call last): | |
| File "<console>", line 1, in <module> | |
| File "/home/tony/.virtualenvs/aladompy/lib/python3.3/site-packages/django/db/models/query.py", line 536, in delete | |
| collector.collect(del_query) | |
| File "/home/tony/.virtualenvs/aladompy/lib/python3.3/site-packages/django/db/models/deletion.py", line 233, in collect | |
| sub_objs = field.bulk_related_objects(new_objs, self.using) | |
| File "/home/tony/.virtualenvs/aladompy/lib/python3.3/site-packages/django/contrib/contenttypes/fields.py", line 379, in bulk_related_objects | |
| return self.rel.to._base_manager.db_manager(using).filter(**{ | |
| AttributeError: 'str' object has no attribute '_base_manager' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment