-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update mptt.rst #105
Update mptt.rst #105
Conversation
minor edits to mptt example
Hi! Thanks for updating the docs! |
Hi Vdboor, I am using django-mptt==0.7.4 with django-parler==1.5 If I put MPTTModel in second position in my abstract model, i.e., class AbstractNode(AbstractModel, MPTTModel): , I get errors like Traceback (most recent call last): File "./manage.py", line 10, in execute_from_command_line(sys.argv) File "/pythonenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/pythonenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute django.setup() File "/pythonenv/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/pythonenv/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/pythonenv/local/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/data/gits/irc/src/irc/models.py", line 18, in from irc.abstract import * File "/data/gits/irc/src/irc/abstract.py", line 158, in class AbstractNode(AbstractModel, MPTTModel): File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/base.py", line 189, in __new__ new_class.add_to_class(obj_name, obj) File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/base.py", line 324, in add_to_class value.contribute_to_class(cls, name) File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1778, in contribute_to_class super(ForeignObject, self).contribute_to_class(cls, name, virtual_only=virtual_only) File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 313, in contribute_to_class add_lazy_relation(cls, self, other, resolve_related_class) File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 86, in add_lazy_relation operation(field, model, cls) File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 312, in resolve_related_class field.do_related_class(model, cls) File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 355, in do_related_class self.set_attributes_from_rel() File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 345, in set_attributes_from_rel self.rel.set_field_name() File "/pythonenv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1432, in set_field_name self.field_name = self.field_name or self.to._meta.pk.name AttributeError: 'NoneType' object has no attribute 'name' However, if I put MPTTModel first, it works, i.e., class AbstractNode(MPTTModel, AbstractModel): P.S. I am following the same approach as django-categories-i18n, which also listed MPTTModel first: #categories_i18n/abstract.py |
Good to know! If you can update the pull request, I'll merge it! |
Removed fieldsets from CategoryAdmin in the example.
cosmetics
Added switch for MPTTQuerySet or TreeQuerySet
I have updated the pull request with a switch that checks for MPTT version. Should work now with Travis CI with various MPTT versions. |
Based on the hints from PR #105 by @zhangguiyu
I've merged your changes in cb12319! Thanks for the work, and bringing the issues of the docs to our attention! |
Thanks! |
minor edits to mptt example