Skip to content

Commit

Permalink
Exposing the model admin correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Aug 13, 2023
1 parent 2ac6f28 commit dd6b3e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 11 additions & 2 deletions api_v2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ class FromDocumentModelAdmin(admin.ModelAdmin):
class ItemModelAdmin(admin.ModelAdmin):
list_display = ['key', 'category', 'name']

class TraitInline(admin.TabularInline):
model = Trait

class RaceAdmin(admin.ModelAdmin):
inlines = [
TraitInline,
]

admin.site.register(Weapon, admin_class=FromDocumentModelAdmin)
admin.site.register(Armor, admin_class=FromDocumentModelAdmin)

admin.site.register(Item, admin_class=ItemModelAdmin)
admin.site.register(ItemSet, admin_class=FromDocumentModelAdmin)

admin.site.register(Race, admin_class=FromDocumentModelAdmin)
admin.site.register(Trait)
admin.site.register(Race, admin_class=RaceAdmin)

#admin.site.register(Trait)
admin.site.register(Feat, admin_class=FromDocumentModelAdmin)

admin.site.register(Document)
Expand Down
6 changes: 5 additions & 1 deletion api_v2/models/race.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class Race(HasName, HasDescription, FromDocument):
This model can be used to represent races based on parent=null.
"""

subrace_of = models.ForeignKey('self', null=True, on_delete=models.CASCADE)
subrace_of = models.ForeignKey('self',
default=None,
blank=True,
null=True,
on_delete=models.CASCADE)

@property
def is_subrace(self):
Expand Down

0 comments on commit dd6b3e2

Please sign in to comment.