Neamar
Neamar

Reputation: 391

Import admin form

I'm trying to retrieve the form django-admin uses to create a model.

Django allows the creation of a form matching some model, however the admin is much more powerful with the use of a ModelAdmin.

For instance, this code lets me add multiple tags to an article :

class ArticleAdmin(admin.ModelAdmin):
    list_display = ('author', 'type', 'date')
    inlines = [
        TagInline,
    ]

I believe Django offers some way to get the resulting HTML and logic, do you know how to do it?

Upvotes: 1

Views: 240

Answers (3)

Satheesh Alathiyur
Satheesh Alathiyur

Reputation: 111

Create inline model for Class TagInline given below:

class TagInline(admin.TabularInline):
    model = Tag

Upvotes: 0

Abin Abraham
Abin Abraham

Reputation: 517

Please Use tabular Inline.....

class Name(admin.TabularInline):
     model = name

Upvotes: 0

Jubin Thomas
Jubin Thomas

Reputation: 1013

You can use Inline Model Admin objects to create Inline tags

Link Here

For ex:

class TagInline(admin.TabularInline):
     model = Tag
     extra = 3

Upvotes: 1

Related Questions