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

View metadata doesn't work #27

Open
emorozov opened this issue Nov 20, 2011 · 1 comment
Open

View metadata doesn't work #27

emorozov opened this issue Nov 20, 2011 · 1 comment

Comments

@emorozov
Copy link

django-seo admin.py contains code:

class ViewAdmin(view_admin):
    form = get_view_form(metadata_class)

get_view_form() function calls systemviews.get_view_names() function that attempts to load and parse application urls. Problem is that urls file contains call to admin.autodiscover() that loads django-seo admin module, so when get_view_form() is called, application urls are not yet loaded.

Also, there's another problem with get_view_names(), although it is much easier to solve:

diff --git a/rollyourown/seo/systemviews.py b/rollyourown/seo/systemviews.py
index b03a824..d56ca57 100644
--- a/rollyourown/seo/systemviews.py
+++ b/rollyourown/seo/systemviews.py
@@ -32,7 +32,7 @@ def get_view_names(seo_views):
                 output.append(name)
             else:
                 for url in urls.urlpatterns:
-                    if url.name:
+                    if getattr(url, 'name', None):
                         output.append(url.name)
     return output
@willhardy
Copy link
Owner

The only suggestion I can make for now would be to overload get_form on the model admin and generate it at runtime.

Ideally, the end developer isn't restricted in this way, I'll keep this ticket open so if I ever get the time, I'll look into structuring things so that it just works. At the very least, there should be something in the docs about doing this.

RE problem #2, sounds good, heppy to include it, can you make a pull request?

Cheers,

Will

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

2 participants