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

Python3 issue #74

Open
pilamb opened this issue Jul 25, 2019 · 1 comment
Open

Python3 issue #74

pilamb opened this issue Jul 25, 2019 · 1 comment

Comments

@pilamb
Copy link

pilamb commented Jul 25, 2019

Hello

I followed the steps using Django 2.2 and python 3.7 (i read it was not compatible but still wanted to give it a try),

And this is the herror that comes up:

TypeError: __init__() missing 1 required positional argument: 'on_delete'

After adding django-geoip with pip and adding it to INSTALLED_APPS at settings file.
I made a python manage.py migrate and this is what is thrown:

Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/Users/bob/.virtualenvs/geo-vinyl/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/Users/bobpiter/.virtualenvs/geo-vinyl/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/Users/bob/.virtualenvs/geo-vinyl/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/bob/.virtualenvs/geo-vinyl/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/Users/bob/.virtualenvs/geo-vinyl/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/Users/bob/.virtualenvs/geo-vinyl/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Users/bob/.virtualenvs/geo-vinyl/lib/python3.7/site-packages/django_geoip/models.py", line 33, in <module> class Region(models.Model): File "/Users/bob/.virtualenvs/geo-vinyl/lib/python3.7/site-packages/django_geoip/models.py", line 38, in Region country = models.ForeignKey(Country, related_name='regions') TypeError: __init__() missing 1 required positional argument: 'on_delete'

I dont know it it is in your plans to make it py3.7 compatible, thanks.

@pilamb
Copy link
Author

pilamb commented Jul 25, 2019

If someone wants to bypass this, by patching directly django-geoip models and migrations files:

just add to ForeignKey models: on_delete=models.CASCADE

and it will execute the migrate command fine. I will update if any other problems pop ups...

SECOND PART [UPDATE]:

BaseCommand error: AttributeError: type object 'BaseCommand' has no attribute 'option_list'
when executing: python manage.py geoip_update

Fixed it by putting this code django_geoip/management/commands/geoip_update.py at line 12:

def add_arguments(self, parser): parser.add_argument('--clear', help="Clear tables prior import", action='store_true', default=False)

instead of:

option_list = BaseCommand.option_list + ( make_option('--clear', action='store_true', default=False, help="Clear tables prior import" ), )

which is Py3.7 uncompatible. I hope this is useful to someone.

[UPDATE]:

There is a PR here with this changes and a comment to fix geoip_update as well.

All now is working with Python3.7 and Django 2.2 using django-geoip ;)

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

1 participant