Ticket #13068: models.py

File models.py, 1.2 KB (added by Carl Meyer, 14 years ago)

models.py for easily testing this bug and associated ones

Line 
1# Cases tested:
2# - prepop field in inline add another #13608
3# - two prepop fields relying on same field #9264
4# - prepop based on calendar widget #9784
5# - prepop based on dropdown #9983
6
7from django.db import models
8
9class Question(models.Model):
10 name = models.CharField(max_length=100)
11 pubdate = models.DateField()
12 status = models.CharField(max_length=20, choices=(('option one', 'Option One'),
13 ('option two', 'Option Two')))
14 slug1 = models.SlugField()
15 slug2 = models.SlugField()
16
17 parent = models.ForeignKey('self')
18
19from django.contrib import admin
20
21class QuestionInline1(admin.StackedInline):
22 model = Question
23 extra = 1
24 prepopulated_fields = {'slug1': ['name', 'pubdate'],
25 'slug2': ['status', 'name']}
26
27class QuestionInline2(admin.TabularInline):
28 model = Question
29 extra = 1
30 prepopulated_fields = {'slug1': ['name', 'pubdate'],
31 'slug2': ['status', 'name']}
32
33class QuestionAdmin(admin.ModelAdmin):
34 inlines = [QuestionInline1, QuestionInline2]
35 prepopulated_fields = {'slug1': ['name', 'pubdate'],
36 'slug2': ['status', 'name']}
37
38admin.site.register(Question, QuestionAdmin)
Back to Top