SyntaxError: invalid syntax in dumpscript
See original GitHub issueAfter generating a dumpscrip, I called it somewhere else and I got a syntax error. I’m aware this is not the way the documentation suggest for running the script, but the syntax error shouldn’t be there anyway, I didn’t try but it would also fail doing ./manage.py runscript out
python out.py
File "out.txt", line 136
pictures_picture_3.owner_user = importer.locate_object(User, "id", User, "id", 1, {'id': 1, 'password': 'XXXX', 'last_login': datetime.datetime(2018, 7, 30, 3, 19, 37, 885214, tzinfo=<UTC>), 'is_superuser': True, 'first_name': 'Martín', 'last_name': 'Volpe', 'is_staff': True, 'is_active': True, 'date_joined': datetime.datetime(2010, 1, 11, 21, 45, 36, tzinfo=<UTC>), 'email': 'XX@gmail.com', 'slug': 'martinvol'} )
^
SyntaxError: invalid syntax
The error is with tzinfo=<UTC>
Django 2.0.7 django-extensions 2.0.7 Pyton 3.6.4
If you are struggling with the error yourself, you can walk around generating the user manually (if it doesn’t exist yet) and replace
owner_user = importer.locate_object(User, "id", User, "id", 1, {'id': 1, 'password': 'XXXX', 'last_login': datetime.datetime(2018, 7, 30, 3, 19, 37, 885214, tzinfo=<UTC>), 'is_superuser': True, 'first_name': 'Martín', 'last_name': 'Volpe', 'is_staff': True, 'is_active': True, 'date_joined': datetime.datetime(2010, 1, 11, 21, 45, 36, tzinfo=<UTC>), 'email': 'XX@gmail.com', 'slug': 'martinvol'} )
with:
owner_user = User.objects.get(email='XX@gmail.com')
Best,
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I consider this a bug in
pytz
, notdjango-extensions
. Root cause here is thatrepr(pytz.utc)
is"<UTC>"
, which can’t be eval’ed.See here: https://bugs.launchpad.net/pytz/+bug/1709127
Could you close this issue? I fixed. 😃 @trbs