from django.contrib import admin
from .models import Post
# Register your models here.
class PostAdmin(admin.ModelAdmin):
list_display = ('title','slug','author','publish','status')
list_filter =('status','created','publish','author')
search_fields = ('title','body')
prepopulated_fields = {'slug': ('title',)}
raw_id_fields = ('author',)
date_hierarchy = 'publish'
ordering = ['status', 'publish']
admin.site.register(Post,PostAdmin)
First install all necessary step $ sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib Second $ sudo su - postgres $ psql Create User name with password $ CREATE USER user_name WITH PASSWORD ' password '; Create New Database $ CREATE DATABASE database_name WITH OWNER user_name ; Give permission $ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user_name ; Update settings.py DATABASES = { ' default ' : { ' ENGINE ' : ' django.db.backends.postgresql_psycopg2 ' , ' NAME ' : 'database_name ' , ' USER ' : ' user_name ' , ' PASSWORD ' : ' password' , ' HOST ' : ' localhost ' , ' PORT ' : ' 5432 ' , } } Then, python3 manage.py migrate and finally create super user python3 man age.py createsuperuser
Comments
Post a Comment