views:

935

answers:

3
+4  A: 

You can do something like this:

class SearchKeywordInline(admin.StackedInline):
    model = SearchKeyword
    extra = 3

class FlatPageAdmin(admin.ModelAdmin):
    inlines = [SearchKeywordInline]

# unregister the FlatPage model from the admin site so I can
# register it again with the inline stuff (Thanks Carl & Jason)
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageAdmin)

More info in the official Django docs

Update: Fixed the code to suit your requirements.

Baishampayan Ghose
hrm, that is basically what I had and it wasn't working, still not working after I copied your code. Guess there is something else wrong...
jasondewitt
With the above code (once you fix FlatpageAdmin to FlatPageAdmin) I would guess you would get an AlreadyRegistered error; you may need to admin.site.unregister(FlatPage) first. And you may also want to inherit your FlatPageAdmin from the one in contrib/flatpages/admin.py
Carl Meyer
I did briefly see an AlreadyRegistered error, but it went away when I refreshed the page. I'll try out the unregister bit, thanks.
jasondewitt
Fixed the Flatpage/FlatPage typo.
Carl Meyer
using the admin.site.unregister(Flatpage) that Carl suggested fixed me right up.
jasondewitt
A: 

Check out link text I think that will hit the spot

Helmut
A: 

Here's the code once I got it working correctly. Thanks for the help guys

from cms.search.models import SearchKeyword
from django.contrib.flatpages.models import FlatPage
from django.contrib import admin

class SearchKeywordInline(admin.StackedInline):

    model = SearchKeyword
    extra = 3

class FlatPageAdmin(admin.ModelAdmin):

    inlines = [SearchKeywordInline]


# unregister the FlatPage model from the admin site so I can
# register it again with the inline stuff.
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageAdmin)
jasondewitt