Skip to content
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

Exception making migrations with a SortedOneToManyField #1

Open
riconnon opened this issue Oct 1, 2017 · 3 comments
Open

Exception making migrations with a SortedOneToManyField #1

riconnon opened this issue Oct 1, 2017 · 3 comments

Comments

@riconnon
Copy link

riconnon commented Oct 1, 2017

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'
@tony
Copy link

tony commented Oct 22, 2017

When converting a field from Django-sortedm2m to Django-sortedone2many, I encountered this error upon migration also.

Python 3
Django 1.11.6
django-sortedm2m 1.5..0
django-sortedone2many 0.2.2

You'll probably want to fix this, since most users coming from Django-sortedm2m are going to experience this.

@tony
Copy link

tony commented Oct 22, 2017

Even deleted the old sortedm2m field via a migration, and making a new migration won't work. That's no good.

@tony
Copy link

tony commented Oct 22, 2017

I'm probably just going to axe sortedm2m and make a weight/page column and sort through that. Can't deal with the headaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants