mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f68fa8b45d
commit
9c19aff7c7
@@ -4,16 +4,57 @@ from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
|
||||
from .models import (
|
||||
Author, BinaryTree, CapoFamiglia, Chapter, Child, ChildModel1, ChildModel2,
|
||||
Class, Consigliere, Course, CourseProxy, CourseProxy1, CourseProxy2,
|
||||
EditablePKBook, ExtraTerrestrial, Fashionista, FootNote, Holder, Holder2,
|
||||
Holder3, Holder4, Holder5, Inner, Inner2, Inner3, Inner4Stacked,
|
||||
Inner4Tabular, Inner5Stacked, Inner5Tabular, NonAutoPKBook,
|
||||
NonAutoPKBookChild, Novel, NovelReadonlyChapter, OutfitItem,
|
||||
ParentModelWithCustomPk, Person, Poll, Profile, ProfileCollection,
|
||||
Question, ReadOnlyInline, ShoppingWeakness, ShowInlineChild,
|
||||
ShowInlineParent, Sighting, SomeChildModel, SomeParentModel, SottoCapo,
|
||||
Teacher, Title, TitleCollection,
|
||||
Author,
|
||||
BinaryTree,
|
||||
CapoFamiglia,
|
||||
Chapter,
|
||||
Child,
|
||||
ChildModel1,
|
||||
ChildModel2,
|
||||
Class,
|
||||
Consigliere,
|
||||
Course,
|
||||
CourseProxy,
|
||||
CourseProxy1,
|
||||
CourseProxy2,
|
||||
EditablePKBook,
|
||||
ExtraTerrestrial,
|
||||
Fashionista,
|
||||
FootNote,
|
||||
Holder,
|
||||
Holder2,
|
||||
Holder3,
|
||||
Holder4,
|
||||
Holder5,
|
||||
Inner,
|
||||
Inner2,
|
||||
Inner3,
|
||||
Inner4Stacked,
|
||||
Inner4Tabular,
|
||||
Inner5Stacked,
|
||||
Inner5Tabular,
|
||||
NonAutoPKBook,
|
||||
NonAutoPKBookChild,
|
||||
Novel,
|
||||
NovelReadonlyChapter,
|
||||
OutfitItem,
|
||||
ParentModelWithCustomPk,
|
||||
Person,
|
||||
Poll,
|
||||
Profile,
|
||||
ProfileCollection,
|
||||
Question,
|
||||
ReadOnlyInline,
|
||||
ShoppingWeakness,
|
||||
ShowInlineChild,
|
||||
ShowInlineParent,
|
||||
Sighting,
|
||||
SomeChildModel,
|
||||
SomeParentModel,
|
||||
SottoCapo,
|
||||
Teacher,
|
||||
Title,
|
||||
TitleCollection,
|
||||
)
|
||||
|
||||
site = admin.AdminSite(name="admin")
|
||||
@@ -25,17 +66,17 @@ class BookInline(admin.TabularInline):
|
||||
|
||||
class NonAutoPKBookTabularInline(admin.TabularInline):
|
||||
model = NonAutoPKBook
|
||||
classes = ('collapse',)
|
||||
classes = ("collapse",)
|
||||
|
||||
|
||||
class NonAutoPKBookChildTabularInline(admin.TabularInline):
|
||||
model = NonAutoPKBookChild
|
||||
classes = ('collapse',)
|
||||
classes = ("collapse",)
|
||||
|
||||
|
||||
class NonAutoPKBookStackedInline(admin.StackedInline):
|
||||
model = NonAutoPKBook
|
||||
classes = ('collapse',)
|
||||
classes = ("collapse",)
|
||||
|
||||
|
||||
class EditablePKBookTabularInline(admin.TabularInline):
|
||||
@@ -48,8 +89,11 @@ class EditablePKBookStackedInline(admin.StackedInline):
|
||||
|
||||
class AuthorAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
BookInline, NonAutoPKBookTabularInline, NonAutoPKBookStackedInline,
|
||||
EditablePKBookTabularInline, EditablePKBookStackedInline,
|
||||
BookInline,
|
||||
NonAutoPKBookTabularInline,
|
||||
NonAutoPKBookStackedInline,
|
||||
EditablePKBookTabularInline,
|
||||
EditablePKBookStackedInline,
|
||||
NonAutoPKBookChildTabularInline,
|
||||
]
|
||||
|
||||
@@ -57,25 +101,24 @@ class AuthorAdmin(admin.ModelAdmin):
|
||||
class InnerInline(admin.StackedInline):
|
||||
model = Inner
|
||||
can_delete = False
|
||||
readonly_fields = ('readonly',) # For bug #13174 tests.
|
||||
readonly_fields = ("readonly",) # For bug #13174 tests.
|
||||
|
||||
|
||||
class HolderAdmin(admin.ModelAdmin):
|
||||
|
||||
class Media:
|
||||
js = ('my_awesome_admin_scripts.js',)
|
||||
js = ("my_awesome_admin_scripts.js",)
|
||||
|
||||
|
||||
class ReadOnlyInlineInline(admin.TabularInline):
|
||||
model = ReadOnlyInline
|
||||
readonly_fields = ['name']
|
||||
readonly_fields = ["name"]
|
||||
|
||||
|
||||
class InnerInline2(admin.StackedInline):
|
||||
model = Inner2
|
||||
|
||||
class Media:
|
||||
js = ('my_awesome_inline_scripts.js',)
|
||||
js = ("my_awesome_inline_scripts.js",)
|
||||
|
||||
|
||||
class InnerInline2Tabular(admin.TabularInline):
|
||||
@@ -84,17 +127,17 @@ class InnerInline2Tabular(admin.TabularInline):
|
||||
|
||||
class CustomNumberWidget(forms.NumberInput):
|
||||
class Media:
|
||||
js = ('custom_number.js',)
|
||||
js = ("custom_number.js",)
|
||||
|
||||
|
||||
class InnerInline3(admin.StackedInline):
|
||||
model = Inner3
|
||||
formfield_overrides = {
|
||||
models.IntegerField: {'widget': CustomNumberWidget},
|
||||
models.IntegerField: {"widget": CustomNumberWidget},
|
||||
}
|
||||
|
||||
class Media:
|
||||
js = ('my_awesome_inline_scripts.js',)
|
||||
js = ("my_awesome_inline_scripts.js",)
|
||||
|
||||
|
||||
class TitleForm(forms.ModelForm):
|
||||
@@ -131,12 +174,12 @@ class Holder4Admin(admin.ModelAdmin):
|
||||
|
||||
class Inner5StackedInline(admin.StackedInline):
|
||||
model = Inner5Stacked
|
||||
classes = ('collapse',)
|
||||
classes = ("collapse",)
|
||||
|
||||
|
||||
class Inner5TabularInline(admin.TabularInline):
|
||||
model = Inner5Tabular
|
||||
classes = ('collapse',)
|
||||
classes = ("collapse",)
|
||||
|
||||
|
||||
class Holder5Admin(admin.ModelAdmin):
|
||||
@@ -153,7 +196,7 @@ class WeaknessForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = ShoppingWeakness
|
||||
fields = '__all__'
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class WeaknessInlineCustomForm(admin.TabularInline):
|
||||
@@ -166,7 +209,7 @@ class FootNoteForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = FootNote
|
||||
fields = '__all__'
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class FootNoteNonEditableInlineCustomForm(admin.TabularInline):
|
||||
@@ -179,25 +222,25 @@ class FootNoteNonEditableInlineCustomForm(admin.TabularInline):
|
||||
|
||||
class QuestionInline(admin.TabularInline):
|
||||
model = Question
|
||||
readonly_fields = ['call_me']
|
||||
readonly_fields = ["call_me"]
|
||||
|
||||
def call_me(self, obj):
|
||||
return 'Callable in QuestionInline'
|
||||
return "Callable in QuestionInline"
|
||||
|
||||
|
||||
class PollAdmin(admin.ModelAdmin):
|
||||
inlines = [QuestionInline]
|
||||
|
||||
def call_me(self, obj):
|
||||
return 'Callable in PollAdmin'
|
||||
return "Callable in PollAdmin"
|
||||
|
||||
|
||||
class ChapterInline(admin.TabularInline):
|
||||
model = Chapter
|
||||
readonly_fields = ['call_me']
|
||||
readonly_fields = ["call_me"]
|
||||
|
||||
def call_me(self, obj):
|
||||
return 'Callable in ChapterInline'
|
||||
return "Callable in ChapterInline"
|
||||
|
||||
|
||||
class NovelAdmin(admin.ModelAdmin):
|
||||
@@ -261,32 +304,31 @@ class SightingInline(admin.TabularInline):
|
||||
|
||||
# admin and form for #18263
|
||||
class SomeChildModelForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
fields = '__all__'
|
||||
fields = "__all__"
|
||||
model = SomeChildModel
|
||||
widgets = {
|
||||
'position': forms.HiddenInput,
|
||||
"position": forms.HiddenInput,
|
||||
}
|
||||
labels = {'readonly_field': 'Label from ModelForm.Meta'}
|
||||
help_texts = {'readonly_field': 'Help text from ModelForm.Meta'}
|
||||
labels = {"readonly_field": "Label from ModelForm.Meta"}
|
||||
help_texts = {"readonly_field": "Help text from ModelForm.Meta"}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['name'].label = 'new label'
|
||||
self.fields["name"].label = "new label"
|
||||
|
||||
|
||||
class SomeChildModelInline(admin.TabularInline):
|
||||
model = SomeChildModel
|
||||
form = SomeChildModelForm
|
||||
readonly_fields = ('readonly_field',)
|
||||
readonly_fields = ("readonly_field",)
|
||||
|
||||
|
||||
class StudentInline(admin.StackedInline):
|
||||
model = Child
|
||||
extra = 1
|
||||
fieldsets = [
|
||||
('Name', {'fields': ('name',), 'classes': ('collapse',)}),
|
||||
("Name", {"fields": ("name",), "classes": ("collapse",)}),
|
||||
]
|
||||
|
||||
|
||||
@@ -306,7 +348,7 @@ class FashonistaStackedInline(admin.StackedInline):
|
||||
class ClassStackedHorizontal(admin.StackedInline):
|
||||
model = Class
|
||||
extra = 1
|
||||
filter_horizontal = ['person']
|
||||
filter_horizontal = ["person"]
|
||||
|
||||
|
||||
class ClassAdminStackedHorizontal(admin.ModelAdmin):
|
||||
@@ -316,7 +358,7 @@ class ClassAdminStackedHorizontal(admin.ModelAdmin):
|
||||
class ClassTabularHorizontal(admin.TabularInline):
|
||||
model = Class
|
||||
extra = 1
|
||||
filter_horizontal = ['person']
|
||||
filter_horizontal = ["person"]
|
||||
|
||||
|
||||
class ClassAdminTabularHorizontal(admin.ModelAdmin):
|
||||
@@ -326,7 +368,7 @@ class ClassAdminTabularHorizontal(admin.ModelAdmin):
|
||||
class ClassTabularVertical(admin.TabularInline):
|
||||
model = Class
|
||||
extra = 1
|
||||
filter_vertical = ['person']
|
||||
filter_vertical = ["person"]
|
||||
|
||||
|
||||
class ClassAdminTabularVertical(admin.ModelAdmin):
|
||||
@@ -336,7 +378,7 @@ class ClassAdminTabularVertical(admin.ModelAdmin):
|
||||
class ClassStackedVertical(admin.StackedInline):
|
||||
model = Class
|
||||
extra = 1
|
||||
filter_vertical = ['person']
|
||||
filter_vertical = ["person"]
|
||||
|
||||
|
||||
class ClassAdminStackedVertical(admin.ModelAdmin):
|
||||
@@ -346,13 +388,13 @@ class ClassAdminStackedVertical(admin.ModelAdmin):
|
||||
class ChildHiddenFieldForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = SomeChildModel
|
||||
fields = ['name', 'position', 'parent']
|
||||
widgets = {'position': forms.HiddenInput}
|
||||
fields = ["name", "position", "parent"]
|
||||
widgets = {"position": forms.HiddenInput}
|
||||
|
||||
def _post_clean(self):
|
||||
super()._post_clean()
|
||||
if self.instance is not None and self.instance.position == 1:
|
||||
self.add_error(None, ValidationError('A non-field error'))
|
||||
self.add_error(None, ValidationError("A non-field error"))
|
||||
|
||||
|
||||
class ChildHiddenFieldTabularInline(admin.TabularInline):
|
||||
@@ -363,13 +405,13 @@ class ChildHiddenFieldTabularInline(admin.TabularInline):
|
||||
class ChildHiddenFieldInFieldsGroupStackedInline(admin.StackedInline):
|
||||
model = SomeChildModel
|
||||
form = ChildHiddenFieldForm
|
||||
fields = [('name', 'position')]
|
||||
fields = [("name", "position")]
|
||||
|
||||
|
||||
class ChildHiddenFieldOnSingleLineStackedInline(admin.StackedInline):
|
||||
model = SomeChildModel
|
||||
form = ChildHiddenFieldForm
|
||||
fields = ('name', 'position')
|
||||
fields = ("name", "position")
|
||||
|
||||
|
||||
class ShowInlineChildInline(admin.StackedInline):
|
||||
@@ -399,7 +441,9 @@ site.register(Fashionista, inlines=[InlineWeakness])
|
||||
site.register(Holder4, Holder4Admin)
|
||||
site.register(Holder5, Holder5Admin)
|
||||
site.register(Author, AuthorAdmin)
|
||||
site.register(CapoFamiglia, inlines=[ConsigliereInline, SottoCapoInline, ReadOnlyInlineInline])
|
||||
site.register(
|
||||
CapoFamiglia, inlines=[ConsigliereInline, SottoCapoInline, ReadOnlyInlineInline]
|
||||
)
|
||||
site.register(ProfileCollection, inlines=[ProfileInline])
|
||||
site.register(ParentModelWithCustomPk, inlines=[ChildModel1Inline, ChildModel2Inline])
|
||||
site.register(BinaryTree, inlines=[BinaryTreeAdmin])
|
||||
@@ -416,9 +460,9 @@ site.register(CourseProxy1, ClassAdminTabularVertical)
|
||||
site.register(CourseProxy2, ClassAdminTabularHorizontal)
|
||||
site.register(ShowInlineParent, ShowInlineParentAdmin)
|
||||
# Used to test hidden fields in tabular and stacked inlines.
|
||||
site2 = admin.AdminSite(name='tabular_inline_hidden_field_admin')
|
||||
site2 = admin.AdminSite(name="tabular_inline_hidden_field_admin")
|
||||
site2.register(SomeParentModel, inlines=[ChildHiddenFieldTabularInline])
|
||||
site3 = admin.AdminSite(name='stacked_inline_hidden_field_in_group_admin')
|
||||
site3 = admin.AdminSite(name="stacked_inline_hidden_field_in_group_admin")
|
||||
site3.register(SomeParentModel, inlines=[ChildHiddenFieldInFieldsGroupStackedInline])
|
||||
site4 = admin.AdminSite(name='stacked_inline_hidden_field_on_single_line_admin')
|
||||
site4 = admin.AdminSite(name="stacked_inline_hidden_field_on_single_line_admin")
|
||||
site4.register(SomeParentModel, inlines=[ChildHiddenFieldOnSingleLineStackedInline])
|
||||
|
||||
@@ -31,7 +31,7 @@ class Child(models.Model):
|
||||
parent = GenericForeignKey()
|
||||
|
||||
def __str__(self):
|
||||
return 'I am %s, a child of %s' % (self.name, self.parent)
|
||||
return "I am %s, a child of %s" % (self.name, self.parent)
|
||||
|
||||
|
||||
class Book(models.Model):
|
||||
@@ -44,7 +44,7 @@ class Book(models.Model):
|
||||
class Author(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
books = models.ManyToManyField(Book)
|
||||
person = models.OneToOneField('Person', models.CASCADE, null=True)
|
||||
person = models.OneToOneField("Person", models.CASCADE, null=True)
|
||||
|
||||
|
||||
class NonAutoPKBook(models.Model):
|
||||
@@ -80,7 +80,7 @@ class Inner(models.Model):
|
||||
readonly = models.CharField("Inner readonly label", max_length=1)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/inner/'
|
||||
return "/inner/"
|
||||
|
||||
|
||||
class Holder2(models.Model):
|
||||
@@ -100,6 +100,7 @@ class Inner3(models.Model):
|
||||
dummy = models.IntegerField()
|
||||
holder = models.ForeignKey(Holder3, models.CASCADE)
|
||||
|
||||
|
||||
# Models for ticket #8190
|
||||
|
||||
|
||||
@@ -113,7 +114,9 @@ class Inner4Stacked(models.Model):
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=['dummy', 'holder'], name='unique_stacked_dummy_per_holder')
|
||||
models.UniqueConstraint(
|
||||
fields=["dummy", "holder"], name="unique_stacked_dummy_per_holder"
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -123,9 +126,12 @@ class Inner4Tabular(models.Model):
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=['dummy', 'holder'], name='unique_tabular_dummy_per_holder')
|
||||
models.UniqueConstraint(
|
||||
fields=["dummy", "holder"], name="unique_tabular_dummy_per_holder"
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
# Models for ticket #31441
|
||||
|
||||
|
||||
@@ -135,7 +141,7 @@ class Holder5(models.Model):
|
||||
|
||||
class Inner5Stacked(models.Model):
|
||||
name = models.CharField(max_length=10)
|
||||
select = models.CharField(choices=(('1', 'One'), ('2', 'Two')), max_length=10)
|
||||
select = models.CharField(choices=(("1", "One"), ("2", "Two")), max_length=10)
|
||||
text = models.TextField()
|
||||
dummy = models.IntegerField()
|
||||
holder = models.ForeignKey(Holder5, models.CASCADE)
|
||||
@@ -143,7 +149,7 @@ class Inner5Stacked(models.Model):
|
||||
|
||||
class Inner5Tabular(models.Model):
|
||||
name = models.CharField(max_length=10)
|
||||
select = models.CharField(choices=(('1', 'One'), ('2', 'Two')), max_length=10)
|
||||
select = models.CharField(choices=(("1", "One"), ("2", "Two")), max_length=10)
|
||||
text = models.TextField()
|
||||
dummy = models.IntegerField()
|
||||
holder = models.ForeignKey(Holder5, models.CASCADE)
|
||||
@@ -162,13 +168,16 @@ class OutfitItem(models.Model):
|
||||
|
||||
class Fashionista(models.Model):
|
||||
person = models.OneToOneField(Person, models.CASCADE, primary_key=True)
|
||||
weaknesses = models.ManyToManyField(OutfitItem, through='ShoppingWeakness', blank=True)
|
||||
weaknesses = models.ManyToManyField(
|
||||
OutfitItem, through="ShoppingWeakness", blank=True
|
||||
)
|
||||
|
||||
|
||||
class ShoppingWeakness(models.Model):
|
||||
fashionista = models.ForeignKey(Fashionista, models.CASCADE)
|
||||
item = models.ForeignKey(OutfitItem, models.CASCADE)
|
||||
|
||||
|
||||
# Models for #13510
|
||||
|
||||
|
||||
@@ -177,10 +186,13 @@ class TitleCollection(models.Model):
|
||||
|
||||
|
||||
class Title(models.Model):
|
||||
collection = models.ForeignKey(TitleCollection, models.SET_NULL, blank=True, null=True)
|
||||
collection = models.ForeignKey(
|
||||
TitleCollection, models.SET_NULL, blank=True, null=True
|
||||
)
|
||||
title1 = models.CharField(max_length=100)
|
||||
title2 = models.CharField(max_length=100)
|
||||
|
||||
|
||||
# Models for #15424
|
||||
|
||||
|
||||
@@ -198,7 +210,6 @@ class Novel(models.Model):
|
||||
|
||||
|
||||
class NovelReadonlyChapter(Novel):
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
@@ -212,9 +223,11 @@ class FootNote(models.Model):
|
||||
"""
|
||||
Model added for ticket 19838
|
||||
"""
|
||||
|
||||
chapter = models.ForeignKey(Chapter, models.PROTECT)
|
||||
note = models.CharField(max_length=40)
|
||||
|
||||
|
||||
# Models for #16838
|
||||
|
||||
|
||||
@@ -223,22 +236,23 @@ class CapoFamiglia(models.Model):
|
||||
|
||||
|
||||
class Consigliere(models.Model):
|
||||
name = models.CharField(max_length=100, help_text='Help text for Consigliere')
|
||||
capo_famiglia = models.ForeignKey(CapoFamiglia, models.CASCADE, related_name='+')
|
||||
name = models.CharField(max_length=100, help_text="Help text for Consigliere")
|
||||
capo_famiglia = models.ForeignKey(CapoFamiglia, models.CASCADE, related_name="+")
|
||||
|
||||
|
||||
class SottoCapo(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
capo_famiglia = models.ForeignKey(CapoFamiglia, models.CASCADE, related_name='+')
|
||||
capo_famiglia = models.ForeignKey(CapoFamiglia, models.CASCADE, related_name="+")
|
||||
|
||||
|
||||
class ReadOnlyInline(models.Model):
|
||||
name = models.CharField(max_length=100, help_text='Help text for ReadOnlyInline')
|
||||
name = models.CharField(max_length=100, help_text="Help text for ReadOnlyInline")
|
||||
capo_famiglia = models.ForeignKey(CapoFamiglia, models.CASCADE)
|
||||
|
||||
|
||||
# Models for #18433
|
||||
|
||||
|
||||
class ParentModelWithCustomPk(models.Model):
|
||||
my_own_pk = models.CharField(max_length=100, primary_key=True)
|
||||
name = models.CharField(max_length=100)
|
||||
@@ -250,7 +264,7 @@ class ChildModel1(models.Model):
|
||||
parent = models.ForeignKey(ParentModelWithCustomPk, models.CASCADE)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/child_model1/'
|
||||
return "/child_model1/"
|
||||
|
||||
|
||||
class ChildModel2(models.Model):
|
||||
@@ -259,13 +273,14 @@ class ChildModel2(models.Model):
|
||||
parent = models.ForeignKey(ParentModelWithCustomPk, models.CASCADE)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/child_model2/'
|
||||
return "/child_model2/"
|
||||
|
||||
|
||||
# Models for #19425
|
||||
class BinaryTree(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
parent = models.ForeignKey('self', models.SET_NULL, null=True, blank=True)
|
||||
parent = models.ForeignKey("self", models.SET_NULL, null=True, blank=True)
|
||||
|
||||
|
||||
# Models for #19524
|
||||
|
||||
@@ -304,24 +319,21 @@ class Course(models.Model):
|
||||
|
||||
|
||||
class Class(models.Model):
|
||||
person = models.ManyToManyField(Person, verbose_name='attendant')
|
||||
person = models.ManyToManyField(Person, verbose_name="attendant")
|
||||
course = models.ForeignKey(Course, on_delete=models.CASCADE)
|
||||
|
||||
|
||||
class CourseProxy(Course):
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
class CourseProxy1(Course):
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
class CourseProxy2(Course):
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
@@ -340,22 +352,24 @@ class ProfileCollection(models.Model):
|
||||
|
||||
|
||||
class Profile(models.Model):
|
||||
collection = models.ForeignKey(ProfileCollection, models.SET_NULL, blank=True, null=True)
|
||||
collection = models.ForeignKey(
|
||||
ProfileCollection, models.SET_NULL, blank=True, null=True
|
||||
)
|
||||
first_name = models.CharField(max_length=100)
|
||||
last_name = models.CharField(max_length=100)
|
||||
|
||||
|
||||
class VerboseNameProfile(Profile):
|
||||
class Meta:
|
||||
verbose_name = 'Model with verbose name only'
|
||||
verbose_name = "Model with verbose name only"
|
||||
|
||||
|
||||
class VerboseNamePluralProfile(Profile):
|
||||
class Meta:
|
||||
verbose_name_plural = 'Model with verbose name plural only'
|
||||
verbose_name_plural = "Model with verbose name plural only"
|
||||
|
||||
|
||||
class BothVerboseNameProfile(Profile):
|
||||
class Meta:
|
||||
verbose_name = 'Model with both - name'
|
||||
verbose_name_plural = 'Model with both - plural name'
|
||||
verbose_name = "Model with both - name"
|
||||
verbose_name_plural = "Model with both - plural name"
|
||||
|
||||
@@ -7,17 +7,19 @@ from django.test import SimpleTestCase
|
||||
class TestTemplates(SimpleTestCase):
|
||||
def test_javascript_escaping(self):
|
||||
context = {
|
||||
'inline_admin_formset': {
|
||||
'inline_formset_data': json.dumps({
|
||||
'formset': {'prefix': 'my-prefix'},
|
||||
'opts': {'verbose_name': 'verbose name\\'},
|
||||
}),
|
||||
"inline_admin_formset": {
|
||||
"inline_formset_data": json.dumps(
|
||||
{
|
||||
"formset": {"prefix": "my-prefix"},
|
||||
"opts": {"verbose_name": "verbose name\\"},
|
||||
}
|
||||
),
|
||||
},
|
||||
}
|
||||
output = render_to_string('admin/edit_inline/stacked.html', context)
|
||||
self.assertIn('"prefix": "my-prefix"', output)
|
||||
self.assertIn('"verbose_name": "verbose name\\\\"', output)
|
||||
output = render_to_string("admin/edit_inline/stacked.html", context)
|
||||
self.assertIn(""prefix": "my-prefix"", output)
|
||||
self.assertIn(""verbose_name": "verbose name\\\\"", output)
|
||||
|
||||
output = render_to_string('admin/edit_inline/tabular.html', context)
|
||||
self.assertIn('"prefix": "my-prefix"', output)
|
||||
self.assertIn('"verbose_name": "verbose name\\\\"', output)
|
||||
output = render_to_string("admin/edit_inline/tabular.html", context)
|
||||
self.assertIn(""prefix": "my-prefix"", output)
|
||||
self.assertIn(""verbose_name": "verbose name\\\\"", output)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,8 @@ from django.urls import path
|
||||
from . import admin
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('admin2/', admin.site2.urls),
|
||||
path('admin3/', admin.site3.urls),
|
||||
path('admin4/', admin.site4.urls),
|
||||
path("admin/", admin.site.urls),
|
||||
path("admin2/", admin.site2.urls),
|
||||
path("admin3/", admin.site3.urls),
|
||||
path("admin4/", admin.site4.urls),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user