Table of Content
-
Introduction
-
Why Django JET?
-
Step 1: Create Virtual Environment
-
Step 2: Create Project
-
Step 3: Create Application
-
Step 4: Installation
-
Step 5: Install Apps Settings
-
Step 6: Add URL
-
Step 7: Create Model
-
Step 8: Add model to admin.py file
-
Step 9: Create database tables
-
Step 10: Create Superuser
-
Step 11: Run server
Introduction
django-jet is the Modern template for Django admin interface with improved functionality
Why Django JET?
-
New fresh look
-
Responsive mobile interface
-
Useful admin home page
-
Minimal template overriding
-
Easy integration
-
Themes support
-
Autocompletion
-
Handy controls
Step 1: Create Virtual Environment
$ virtualenv ENV
activate environment using following command
$ source ENV/bin/activate
Step 2: Create Project
create project my_project using the following command and enter into that project.
$ django-admin startproject my_project
Step 3: Create Application
create app 'jet_app'
$ python manage.py startapp jet_app
Step 4: Installation
Install django
$ pip install django
Download and install the Django3 compatible version of Django JET:
$ pip install https://github.com/Barukimang/django-jet/archive/dev.zip OR $ easy_install https://github.com/Barukimang/django-jet/archive/dev.zip
Step 5: Install Apps Settings
Add ‘jet’ application to the INSTALLED_APPS setting of your Django project settings.py file.
INSTALLED_APPS = ( ... 'jet', 'django.contrib.admin', ) |
Note: It should be before ‘django.contrib.admin’.
Make sure django.template.context_processors.request context processor is enabled in settings.py (Django 1.8+ way):
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ ... 'django.template.context_processors.request', ... ], }, }, ] |
Before Django 1.8 you should specify context processors different way. Also use
django.core.context_processors.request instead of django.template.context_processors.request.
from django.conf import global_settings TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( 'django.core.context_processors.request', ) |
Step 6: Add URL
Add URL-pattern to the urlpatterns of your Django project urls.py file (they are needed for related–lookups and autocompletes):
urlpatterns [ '', path('jet/', include('jet.urls', 'jet')), # Django JET URLS path('admin/', include(admin.site.urls)), ... ] |
Step 7: Create Model
from django.db import models # Create your models here. class Post(models.Model): title = models.CharField(max_length=255) content = models.TextField() def __str__(self): return self.title |
Step 8: Add model to admin.py file
from django.contrib import admin from .models import *
# Register your models here. admin.site.register(Post) |
Step 9: Create database tables
$ python manage.py makemigrations$ python manage.py migrate jet OR $ python manage.py syncdb
Collect static if you are in the production environment:
$ python manage.py collectstatic
Clear your browser cache
Step 10: Create Superuser
$ python manage.py createsuperuser
Step 11: Run server
$ python manage.py runserver
open http://127.0.0.1:8000/admin URL in browser and login
You will see our admin panel look like this