The Admin Interface
In Django, an admin is readily provided for administration purposes. This interface is determined by the module “django.countrib”. However, you will have to import some modules.
For the case of “INSTALLED_APPS”, you should ensure that you have the following:
INSTALLED_APPS = (
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘myapplication’,
)
For “MIDDLEWARE_CLASSES”, make sure that you have the following:
MIDDLEWARE_CLASSES = (
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
)
To access the Admin interface and before launching the server, you have to initialize the database. The following command can be used to do this:
$ python manage.py syncdb
The above command will then initialize the creation of the necessary tables depending on the type of database that you are using. These are very necessary for the Admin interface to be run. You should then create the URL for the Admin interface.
Open the file “myproject/url.py”. You will see something that looks like this:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns(”,
# Examples:
# url(r’^$’, ‘project1.views.home’, name = ‘home’),
# url(r’^blog/’, include(‘blog.urls’)),
url(r’^admin/’, include(admin.site.urls)),
)
The server can then be started using the following command:
$ python manage.py runserver
Just access your admin interface at the following URL:
http://127.0.0.1:8000/admin/
You will then finally have the Admin interface. This will allow you to perform some administrative tasks as far as your project is concerned.
👈Episode 3(D). Episode 5(D)👉
Share This Post
PRINT THIS POST
No comments:
Post a Comment
If you have any doubts. Please let me know.