Django:
Animate your element
after cloned a django project:
execute the following command
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ pip install -r requirement.txt
(venv) $ pythong manage.py runserver 127.0.0.1:8080 #(or some other port)
Django admin site
-
$ python manage.py creatsuperuser
creates users with attris_superuser
oris_staff
-
class ModelAdmin
fromdjango.contrib.admin
- if you need to make changes to the default admin interface, you need to create a object of
ModelAdmin
like so:class AuthorAdmin(admin.ModelAdmin):
, this representAuthor
model on admin dashboard - instead of registering like this:
admin.site.register(Author)
, you have to use a decorator to yourAuthorAdmin
class like so:
from django.contrib import admin from .models import Author from myproject.admin_site import custom_admin_site # Reader and Editor objects have to have a ForeignKey field pointing at Author @admin.register(Author, Reader, Editor, site=custom_admin_site) class AuthorAdmin(admin.ModelAdmin): pass
- Create InlineModelAdmin object to display extra info on a model in admin add page.
- if you need to make changes to the default admin interface, you need to create a object of
Top comments (0)