old_contents: # Copyright 2012, hast. All rights reserved.
  #
  # This program is free software: you can redistribute it and/or modify it
  # under the terms of the GNU Affero General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or (at
  # your option) any later version.
  
  from django.core.management.base import BaseCommand
  from django.contrib.auth.models import User
  from getpass import getpass, getuser
  from optparse import make_option
  
  
  class Command(BaseCommand):
      help = 'Initialize fognar for developpment'
      option_list = BaseCommand.option_list + (
          make_option('--username', action='store', dest='username', default=None, help='default username'),
          make_option('--password', action='store', dest='password', default=None, help='default password'),
          make_option('--first-name', action='store', dest='first_name', default=None, help='default first name'),
          make_option('--last-name', action='store', dest='last_name', default=None, help='default last name'),
          )
  
      def handle(self, *args, **options):
          self.stdout.write('Creating user\n')
          user = User()
          username = raw_input("Username (default: %s): " % getuser()) if options["username"] is None else options["username"]
          if not username:
              username = getuser()
          user.username = username
          password = getpass("Password (default: 'test'): ") if options["password"] is None else options["password"]
          if not password:
              password = 'test'
          first_name = raw_input("Firstname (default: John): ") if options["first_name"] is None else options["first_name"]
          if not first_name:
              first_name = "John"
          last_name = raw_input("Lastname (default: Smith): ") if options["last_name"] is None else options["last_name"]
          if not last_name:
              last_name = "Smith"
          user.first_name = first_name
          user.last_name = last_name
          user.set_password(password)
          user.save()
          profile = user.get_profile()
          profile.name = first_name + " " + last_name
          profile.email = 'test@mouh.com'
          profile.save()
  
new_contents: # Copyright 2012, hast. All rights reserved.
  #
  # This program is free software: you can redistribute it and/or modify it
  # under the terms of the GNU Affero General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or (at
  # your option) any later version.
  
  from django.core.management.base import BaseCommand
  from django.contrib.auth.models import User
  from getpass import getpass, getuser
  from optparse import make_option
  
  
  class Command(BaseCommand):
      help = 'Initialize fognar for developpment'
      option_list = BaseCommand.option_list + (
          make_option('--username', action='store', dest='username', default=None, help='default username'),
          make_option('--password', action='store', dest='password', default=None, help='default password'),
          make_option('--first-name', action='store', dest='first_name', default=None, help='default first name'),
          make_option('--last-name', action='store', dest='last_name', default=None, help='default last name'),
          )
  
      def handle(self, *args, **options):
          self.stdout.write('Creating user\n')
          user = User()
          username = raw_input("Username (default: %s): " % getuser()) if options["username"] is None else options["username"]
          if not username:
              username = getuser()
          user.username = username
          password = getpass("Password (default: 'test'): ") if options["password"] is None else options["password"]
          if not password:
              password = 'test'
          first_name = raw_input("Firstname (default: John): ") if options["first_name"] is None else options["first_name"]
          if not first_name:
              first_name = "John"
          last_name = raw_input("Lastname (default: Smith): ") if options["last_name"] is None else options["last_name"]
          if not last_name:
              last_name = "Smith"
          user.first_name = first_name
          user.last_name = last_name
          user.set_password(password)
          user.save()
          profile = user.get_profile()
          profile.name = first_name + " " + last_name
          profile.email = 'test@mouh.com'
          profile.save()
          print "User id : " + str(profile.id)
  
  
subject: print userid after creation in django shell