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

optparse.make_option method is deprecated in Django 1.10 #75

Closed
bctiemann opened this issue Jan 2, 2016 · 7 comments
Closed

optparse.make_option method is deprecated in Django 1.10 #75

bctiemann opened this issue Jan 2, 2016 · 7 comments

Comments

@bctiemann
Copy link

Running runcrons:

.../venv/lib/python2.7/site-packages/django/core/management/base.py:265: RemovedInDjango110Warning: OptionParser usage for Django management commands is deprecated, use ArgumentParser instead
RemovedInDjango110Warning)

Looks like all you need to do is replace the "option_list" block at the top of the Command class with:

def add_arguments(self, parser):
    parser.add_argument('--force', action='store_true', help='Force cron runs')
    parser.add_argument('--silent', action='store_true', help='Do not push any message on console')
@prokaktus
Copy link

Doesn't it break backward-compatibility? Looks like it did. Because add_arguments was added in Django 1.8.

@bctiemann do you know recommended way to check Django version and depending on it define or not define attributes and functions?

@bctiemann
Copy link
Author

I'm not sure if there's a canonical way, but what if you check whether the add_arguments method is defined in the BaseCommand superclass?

@prokaktus
Copy link

@bctiemann thanks for your suggestion!

@akhayyat
Copy link

Django 1.10 has now been released, and this issue no longer is a deprecation warning; it breaks django-cron on Django 1.10. Upon running the manage.py runcrons, I get:

AttributeError: type object 'BaseCommand' has no attribute 'option_list'

Could a fixed release be made available? That would be greatly appreciated!

BTW, it seems to be common to check Django's version using django.get_version() (string) or django.VERSION (tuple) to support multiple versions and avoid breaking backward compatibility, e.g.:

if django.get_version().split('.') < ['1', '10']:
    # old version friendly code
else:
    # new version friendly code

@chachra
Copy link
Member

chachra commented Sep 13, 2016

@akhayyat - acknowledged and we'll work on a fix asap.

@maxim-kht maxim-kht mentioned this issue Sep 13, 2016
3 tasks
@maxim-kht
Copy link
Contributor

The fix is deployed https://pypi.python.org/pypi/django-cron/

@akhayyat
Copy link

Works perfectly! Thank you very much for the prompt resolution.

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

5 participants