change password in django
python manage.py changepassword <user_name>
collect static files
python manage.py collectstatic
get the key from dictionary and delete the key at the same time
dict.pop('key', None)
in case of timezone setting, the auto datetime model field should be auto_now=True or like following
from django.utils import timezone
import pytz
timezone.now()
datetime.datetime(2013, 11, 20, 20, 8, 7, 127325, tzinfo=pytz.UTC)
select dataset to export for django migration
python manage.py dumpdata --natural-foreign \
--exclude auth.permission --exclude contenttypes \
--indent 4 > data.json
random number generator
from random import randrange
print(randrange(10))
## results are: 0,1,2,3,4,5,6,7,8,9
class decorator (used for class method)
@method_decorator(login_required)
Was this article helpful?
This article is viewed 60 times!