Code

Ticket #1755: django_1755.patch

File django_1755.patch, 2.8 KB (added by medhat, 8 years ago)
  • conf/project_template/settings.py

     
    2626LANGUAGE_CODE = 'en-us' 
    2727 
    2828SITE_ID = 1 
     29SITE_DOMAIN_NAME = 'example.com' 
     30SITE_DISPLAY_NAME = 'example.com' 
    2931 
     32SUPERUSER_USERNAME = 'root' 
     33SUPERUSER_EMAIL = 'root@example.com' 
     34SUPERUSER_PASSWORD = 'password' 
     35 
    3036# Absolute path to the directory that holds media. 
    3137# Example: "/home/media/media.lawrence.com/" 
    3238MEDIA_ROOT = '' 
  • contrib/auth/management.py

     
    55from django.dispatch import dispatcher 
    66from django.db.models import get_models, signals 
    77from django.contrib.auth import models as auth_app 
     8from django.conf import settings 
    89 
    910def _get_permission_codename(action, opts): 
    1011    return '%s_%s' % (action, opts.object_name.lower()) 
     
    3839    from django.contrib.auth.models import User 
    3940    from django.contrib.auth.create_superuser import createsuperuser as do_create 
    4041    if User in created_models: 
    41         msg = "\nYou just installed Django's auth system, which means you don't have " \ 
    42                 "any superusers defined.\nWould you like to create one now? (yes/no): " 
    43         confirm = raw_input(msg) 
    44         while 1: 
    45             if confirm not in ('yes', 'no'): 
    46                 confirm = raw_input('Please enter either "yes" or "no": ') 
    47                 continue 
    48             if confirm == 'yes': 
    49                 do_create() 
    50             break 
     42        if settings.SUPERUSER_USERNAME and settings.SUPERUSER_EMAIL and settings.SUPERUSER_PASSWORD: 
     43            do_create(settings.SUPERUSER_USERNAME, settings.SUPERUSER_EMAIL, settings.SUPERUSER_PASSWORD) 
    5144 
    5245dispatcher.connect(create_permissions, signal=signals.post_syncdb) 
    5346dispatcher.connect(create_superuser, sender=auth_app, signal=signals.post_syncdb) 
  • contrib/sites/management.py

     
    66from django.db.models import signals 
    77from django.contrib.sites.models import Site 
    88from django.contrib.sites import models as site_app 
     9from django.conf import settings 
    910 
    1011def create_default_site(app, created_models): 
    1112    if Site in created_models: 
    12         print "Creating example.com Site object" 
    13         s = Site(domain="example.com", name="example.com") 
     13        print "Creating default Site object" 
     14        s = Site(domain=settings.SITE_DOMAIN_NAME, name=settings.SITE_DISPLAY_NAME) 
    1415        s.save() 
    1516 
    1617dispatcher.connect(create_default_site, sender=site_app, signal=signals.post_syncdb)