willhardy / django-seo

Provides a set of tools for managing Search Engine Optimisation (SEO) for Django sites.
BSD 3-Clause "New" or "Revised" License
251 stars 117 forks source link

View metadata doesn't work #27

Open emorozov opened 12 years ago

emorozov commented 12 years ago

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 commented 12 years ago

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