diff --git a/example_project/manage.py b/example_project/manage.py index 5e78ea9..f9726f9 100755 --- a/example_project/manage.py +++ b/example_project/manage.py @@ -1,11 +1,10 @@ #!/usr/bin/env python -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) +import os +import sys if __name__ == "__main__": - execute_manager(settings) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/humandt/__init__.py b/humandt/__init__.py index 5e3048b..b650ceb 100644 --- a/humandt/__init__.py +++ b/humandt/__init__.py @@ -1 +1 @@ -__version__ = '0.1' \ No newline at end of file +__version__ = '0.2' diff --git a/humandt/fields.py b/humandt/fields.py index b74d5d6..d84a3be 100644 --- a/humandt/fields.py +++ b/humandt/fields.py @@ -1,8 +1,7 @@ -import datetime from django.core import validators from django.core.exceptions import ValidationError from django.forms.fields import DateField, TimeField, DateTimeField -from parser import parse +from .parser import parse class HumanDateTimeField(DateTimeField): def to_python(self, value): @@ -10,7 +9,7 @@ def to_python(self, value): return None try: return parse(value) - except Exception, e: + except Exception as e: raise ValidationError(self.error_messages['invalid']) class HumanTimeField(TimeField): @@ -19,7 +18,7 @@ def to_python(self, value): return None try: return parse(value).time() - except Exception, e: + except Exception as e: raise ValidationError(self.error_messages['invalid']) class HumanDateField(DateField): @@ -28,5 +27,5 @@ def to_python(self, value): return None try: return parse(value).date() - except Exception, e: - raise ValidationError(self.error_messages['invalid']) \ No newline at end of file + except Exception as e: + raise ValidationError(self.error_messages['invalid']) diff --git a/humandt/tests.py b/humandt/tests.py index acef63e..5c3426d 100644 --- a/humandt/tests.py +++ b/humandt/tests.py @@ -1,5 +1,5 @@ -from django.test import TestCase -from parser import parse +from unittest import TestCase +from .parser import parse from datetime import datetime class HumanTests(TestCase): @@ -10,4 +10,3 @@ def test_tomorrow(self): t = parse('tomorrow 4PM') self.assertEqual(t.day, self.now.day+1) self.assertEqual(t.hour, 16) - diff --git a/setup.py b/setup.py index d7af184..dc87d80 100644 --- a/setup.py +++ b/setup.py @@ -2,19 +2,20 @@ from humandt import __version__ setup(name='django-human-datetime', - version=__version__, - description='Uses the parsedatetime package to parse human readable date/time expressions into Django fields', - long_description=open('README.rst').read(), - author='Justin Quick', - author_email='justquick@gmail.com', - url='http://github.com/justquick/django-human-datetime', - packages=['humandt'], - requires=['parsedatetime','pytz',], - classifiers=['Development Status :: 4 - Beta', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Topic :: Utilities'], - ) + version=__version__, + description='Uses the parsedatetime package to parse human readable date/time expressions into Django fields', + long_description=open('README.rst').read(), + author='Justin Quick', + author_email='justquick@gmail.com', + url='http://github.com/justquick/django-human-datetime', + packages=['humandt'], + install_requires=['django', 'parsedatetime','pytz',], + classifiers=['Development Status :: 4 - Beta', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Utilities'], + )