Django admin setup - Sloathking/Foolish-Wizardz GitHub Wiki

Django Admin Setup (Django Docs)

Author Mattie

related assignments: GE3

Step 1

Create a super user by running:

https://docs.djangoproject.com/en/1.8/intro/tutorial02/
```bash
python manage.py createsuperuser

If you are on windows and get the error about not a tty user then run this instead (source)

winpty python manage.py createsuperuser

Follow the steps and create your user.

Step 2

Launch the server and append "/admin/" to your login domain:
e.g., http://127.0.0.1:8000/admin/. You should see the login screen:
image

Step 3

Allow editing of the site.
Create a file, admin.py in the app's folder. and copy this code into it.

from django.contrib import admin

from django.apps import apps

models = apps.get_models()

#you need to verify models are not already registered otherwise the admin login will break
for model in models:
    if(model):
        if(not admin.site.is_registered(model)):
            admin.site.register(model)

This is a simple script to register all models into your admin site

Additional notes.

If the above did not work or you cannot load the page please ensure you have the admin site registered in your urls:
image
image