How To Setup Admin.Py For Django

django has built in admin feature which is one of the most useful feature. When you create a model in file, it is not displayed by default in admin view. you need to register the model in `app\` file. Here is sample `` file ```python from django.contrib import admin from .models import Post,PostMeta,Tag, PostType # Register your models here. class PostAdmin(admin.ModelAdmin): list_display = ('quote_id', 'quote_title','quote_content') list_filter = ('quote_title', 'quote_content') search_fields = ('quote_title', 'quote_content') list_display_links = ('quote_id',) list_editable=( 'quote_content',),PostAdmin) ``` In above file we have created a custom view to enable editing in main screen itself. Please note `list_display_links` and `list_editable` can not be same.

This post is written by Pravin

Tags : Django

Share it :      

Leave a comment




  1. GitHub
Ad below