How to include rows of data in a single django model entry? -
i working on multiple django sites , have been limited in making project nice clients.
for illustration in same app have 2 models images , image galleries. much nicer have admin entry galleries , in table of images.
that's inlinemodeladmin
for. taken models.py this:
class gallery(models.model): name = models.charfield(max_length=100) class image(models.model): image = models.imagefield() gallery = models.foreignkey(gallery)
you create admin.py , register admin class gallery:
class imageinline(admin.tabularinline): model = image class galleryadmin(admin.modeladmin): inlines = [imageinline] admin.site.register(gallery, galleryadmin)
django django-admin
No comments:
Post a Comment