Skip to content

Instantly share code, notes, and snippets.

@jpatel3
Created September 24, 2012 17:27
Show Gist options
  • Save jpatel3/3777157 to your computer and use it in GitHub Desktop.
Save jpatel3/3777157 to your computer and use it in GitHub Desktop.
django admin.py for content managment.
from django.contrib import admin
from units.models import Unit
from references_u.models import ReferenceU
from qna.models import Question, QuestionHints, QuestionAnswer, QuestionAnswerChoice
class ReferenceUInline(admin.StackedInline):
model = ReferenceU
extra = 1
class QuestionHintsInline(admin.StackedInline):
model = QuestionHints
extra = 2
class QuestionAnswerInline(admin.StackedInline):
model = QuestionAnswer
extra = 1
class QuestionAnswerChoiceInline(admin.StackedInline):
model = QuestionAnswerChoice
extra = 1
class QuestionInline(admin.StackedInline):
#change_form_template = ['admin/qna/change_form.html']
model = Question
inlines = [QuestionHintsInline, QuestionAnswerInline, QuestionAnswerChoiceInline]
extra = 3
class UnitsAdmin(admin.ModelAdmin):
change_form_template = ['admin/units/change_form.html']
date_heiarchy = 'created'
inlines = [ReferenceUInline, QuestionInline]
admin.site.register(Unit, UnitsAdmin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment