ralphje / django-internationalflavor

Complementing django-localflavor with fields that are applicable to multiple countries
Other
25 stars 19 forks source link

KeyError while making migrations #9

Closed eriktelepovsky closed 7 years ago

eriktelepovsky commented 7 years ago

Hi, I am running into this issue using:

Python 3.5.2 django-internationalflavor==0.3.0 Django==1.10.3

class User(AbstractUser):
    ...
    country = CountryField()
python manage.py makemigrations
File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/core/management/commands/makemigrations.py", line 150, in handle
    ProjectState.from_apps(apps),
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/db/migrations/state.py", line 188, in from_apps
    model_state = ModelState.from_model(model)
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/db/migrations/state.py", line 374, in from_model
    fields.append((name, field.clone()))
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 457, in clone
    name, path, args, kwargs = self.deconstruct()
  File "/Users/erik/env/giaroo/lib/python3.5/site-packages/internationalflavor/countries/models.py", line 32, in deconstruct
    del kwargs["choices"]

Any help is appreciated. Thank you.

ralphje commented 7 years ago

Thank you for your report, @eriktelepovsky

Unfortunately I'm unable to reproduce your problem using Python 3.5.0, Django 1.10.4 and 0.3.0 of the module. I've also added a test for this method, but it does not seem to have any problems anywhere in the test matrix.

Could you provide additional details?

eriktelepovsky commented 7 years ago

Hi @ralphje

What information do you need? I am not sure if I am doing something wrong, but I think I am not. I have custom user model and I want to add a country field into it. So I updated my user model with the CountryField from the library and then I ran the "makemigrations" command (from Django) and this error shows up. Any ideas?

ralphje commented 7 years ago

Could you try to replicate the issue in a new minimal Django project? Since I seem to be unable to do so 😢 .

eriktelepovsky commented 7 years ago

Hi @ralphje,

I have created minimal Django project and it worked fine. Issue was in my project. I was overriding "makemigrations" command with my custom implementation (to ignore some field options like verbose_name, help_text etc).

Thank you for your time and effort and sorry for troubles.