Skip to content

Commit

Permalink
Move to @admin.register and use more double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
treyhunner committed Jan 13, 2024
1 parent c388cd0 commit d8d45bd
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,12 @@ Code
from .models import Company, Employee
class CompanyAdmin(admin.ModelAdmin):
change_form_template = 'relatives/change_form.html'
admin.site.register(Company, CompanyAdmin)
admin.site.register(Employee)
admin.site.register(Employee)
@admin.register(Company, CompanyAdmin)
class CompanyAdmin(admin.ModelAdmin):
change_form_template = "relatives/change_form.html"
Screenshot
++++++++++
Expand Down Expand Up @@ -170,23 +169,22 @@ Code
from .models import Company, Employee
admin.site.register(Employee)
class EmployeeInline(admin.TabularInline):
model = Employee
fields = [object_link, 'first_name', 'last_name']
fields = [object_link, "first_name", "last_name"]
readonly_fields = fields
extra = 0
max_num = 0
can_delete = False
@admin.register(Company)
class CompanyAdmin(admin.ModelAdmin):
inlines = [EmployeeInline]
admin.site.register(Company, CompanyAdmin)
admin.site.register(Employee)
Screenshot
++++++++++

Expand All @@ -212,21 +210,20 @@ Code
from .models import Company, Employee
admin.site.register(Employee)
class EmployeeInline(admin.TabularInline):
model = Employee
edit_link = object_edit_link("Edit")
fields = [edit_link, 'employee_id', 'first_name', 'last_name']
fields = [edit_link, "employee_id", "first_name", "last_name"]
readonly_fields = [edit_link]
@admin.register(Company)
class CompanyAdmin(admin.ModelAdmin):
inlines = [EmployeeInline]
admin.site.register(Company, CompanyAdmin)
admin.site.register(Employee)
Screenshot
++++++++++

Expand Down

0 comments on commit d8d45bd

Please sign in to comment.