Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatpages per page SEO data editing #33

Open
pythonpro opened this issue Apr 30, 2012 · 4 comments
Open

Flatpages per page SEO data editing #33

pythonpro opened this issue Apr 30, 2012 · 4 comments

Comments

@pythonpro
Copy link

Pls, clarify (here or in docs) how to add SEO fields inline to Flatpage creation/editing page without flatpages app admin.py file monkeypatching. Thnx.

@smcoll
Copy link

smcoll commented Jul 30, 2012

You're going to have to unregister the FlatPage from the admin site, and re-register your own ModelAdmin, configured for integration with this app.

What i tend to do is import a custom admin overrides module immediately following the admin.autodiscover() in my project's urls.py:

admin.autodiscover()
# import admin overrides
import myproject.admin

The myproject/admin.py file looks something like this:

from django.contrib import admin
from django.contrib.flatpages.admin import FlatPageAdmin
from django.contrib.flatpages.models import FlatPage

from rollyourown.seo.admin import get_inline
from myproject.myapp.seo import Metadata # your custom metadata model


class CustomFlatPageAdmin(FlatPageAdmin):
    inlines = [get_inline(Metadata)]


admin.site.unregister(FlatPage)
admin.site.register(FlatPage, CustomFlatPageAdmin)

While you're at it, use CustomFlatPage admin to make all those FlatPage ModelAdmin modifications you always wanted to do.

@samzhao
Copy link

samzhao commented Aug 15, 2012

Thank you, smcoll, for your helpful comment. I'm trying to do the exact same thing as what pythonpro is trying to do. I think I understand what you are suggesting in your comment, but could you provide more details on how to actually write the rollyourown.seo.admin model and the myproject.myapp.seo model? I'm a Django noob, so I don't know exactly how to write those models. I do understand how this whole works in theory, though.

Thanks.

@smcoll
Copy link

smcoll commented Aug 15, 2012

The rollyourown.seo.admin module is part of the django-seo package- you don't have to write it.

See the Django SEO docs for help in constructing the metadata model:

http://django-seo.readthedocs.org/en/latest/introduction/tutorial.html#metadata-definition
http://django-seo.readthedocs.org/en/latest/reference/definition.html#reference-definition

@samzhao
Copy link

samzhao commented Aug 15, 2012

Thanks for your response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants