Giter VIP home page Giter VIP logo

django-sortedone2many's People

Contributors

shenggaozhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-sortedone2many's Issues

Exception making migrations with a SortedOneToManyField

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'

Support for Django 2.2

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.