shenggaozhu / django-sortedone2many Goto Github PK
View Code? Open in Web Editor NEWProvide a one-to-many relationship (SortedOneToManyField) that also remembers the order of related objects.
License: MIT License
Provide a one-to-many relationship (SortedOneToManyField) that also remembers the order of related objects.
License: MIT License
After adding a SortedOneToManyField to my model and running makemigrations I see the following exception.
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/rconnon/src/test_project/test_app/models.py", line 9, in <module>
class B (models.Model):
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/django/db/models/base.py", line 162, in __new__
new_class.add_to_class(obj_name, obj)
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/django/db/models/base.py", line 331, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/sortedm2m/fields.py", line 265, in contribute_to_class
rel.through = self.create_intermediate_model(cls)
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/sortedm2m/fields.py", line 410, in create_intermediate_model
return self.create_intermediate_model_from_attrs(klass, attrs)
File "/Users/rconnon/.virtualenvs/bin/django/lib/python3.6/site-packages/sortedm2m/fields.py", line 386, in create_intermediate_model_from_attrs
base_classes = (self.base_class, models.Model) if self.base_class else (models.Model,)
AttributeError: 'SortedOneToManyField' object has no attribute 'base_class'
Seems like the library is not supported in Django 2.2.
File "/home/repo/venv/lib/python3.8/site-packages/sortedone2many/fields.py", line 277, in contribute_to_related_class
if not self.rel.is_hidden() and not related.related_model._meta.swapped:
AttributeError: 'OneToManyField' object has no attribute 'rel'
Seems like rel
has been removed: https://docs.djangoproject.com/en/2.0/releases/1.9/#field-rel-changes
I could confirm that changing self.rel
to self.remote_field
"worked". That said, 'rel'
seems to be prevalent in multiple places, so this single line patch isn't enough.
hi.
v0.2.2 has runtime error.
get_foreignkey_field_kwargs method used inside fields.py but not exist in compat.py
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.