User.get() throws an exception if it can't find the user (rather than the much
more sensible option of returning None). Fix the script to account for that.
cd /home/kp/domotica ; python manage.py shell -c '
import sys
from django.contrib.auth.models import User
- if User.objects.get(username="natalie"):
+ try:
+ User.objects.get(username="natalie")
sys.exit(0)
- user = User.objects.create_user("natalie", "natalie@sigsegv.be", "nienkeistwee")
- user.save()
+ except User.DoesNotExist:
+ user = User.objects.create_user("natalie", "natalie@sigsegv.be", "nienkeistwee")
+ user.save()
'
environment:
- PYTHONPATH: /home/kp/libs7comm-python/