termie / google-app-engine-django

Automatically exported from code.google.com/p/google-app-engine-django
Apache License 2.0
0 stars 0 forks source link

Django sitemaps not working #102

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to generate a Django sitemap according to the django docs:
http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/?from=olddocs

2. Watch it fail:

AttributeError at /sitemap.xml 
'ModelOptions' object has no attribute 'local_many_to_many' 
Request Method:         GET 
Request URL:    http://localhost:8080/sitemap.xml 
Exception Type:         AttributeError 
Exception Value: 
'ModelOptions' object has no attribute 'local_many_to_many' 
Exception Location:     D:\work\python\gaeprojects\myblog\django\db\models 
\options.py in _fill_related_many_to_many_cache, line 403 
Python Executable:      D:\Python25\python.exe 
Python Version:         2.5.2 
Python Path:    ['D:\\work\\python\\gaeprojects\\myblog', 'd:\\work\ 
\python\\gae', 'd:\\work\\python\\gae\\lib\\django', 'd:\\work\\python\ 
\gae\\lib\\webob', 'd:\\work\\python\\gae\\lib\\yaml\\lib', 'd:\\work\ 
\python\\gae', 'D:\\Python25', 'D:\\Python25\\DLLs', 'D:\\Python25\ 
\lib', 'D:\\Python25\\lib\\lib-tk', 'D:\\Python25\\lib\\plat-win', 'D:\ 
\Python25\\lib\\site-packages', 'D:\\Python25\\lib\\site-packages\ 
\Pythonwin', 'D:\\Python25\\lib\\site-packages\\win32', 'D:\\Python25\ 
\lib\\site-packages\\win32\\lib', 'D:\\Python25\\lib\\site-packages\ 
\wx-2.8-msw-unicode', 'F:\\Windows\\system32\\python25.zip', 'F:\ 
\eclipse\\plugins\\org.python.pydev_1.3.19\\PySrc'] 
Server time:    Sat, 11 Oct 2008 01:36:07 +0000 

What is the expected output? What do you see instead?
A sitemap.

What version of the product are you using? On what operating system?
R66, Windows XP.

Please provide any additional information below.
This is due to a number of unsupported/unimplemented methods on the model 
classes. I would fix this myself, because I could really use sitemaps 
functionality, but I'm afraid I have too little knowledge about django 
sites to understand what the heck it is doing.

Original issue reported on code.google.com by mattias....@gmail.com on 28 Dec 2008 at 10:59

GoogleCodeExporter commented 9 years ago
Note that I was lazy and didn't paste my exact error message - instead I pasted 
an 
error from another report of the issue, which obviously uses an older version 
of the 
sdk which uses 8080. The error does, however, occur in r66 and the latest 
version of 
the app engine SDK.

Original comment by mattias....@gmail.com on 28 Dec 2008 at 11:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The problem is in, that Sites framework requires database. In django/contrib/
sitemaps/__init__.py you can find this lines:
def get_urls(self, page=1):
    from django.contrib.sites.models import Site
    current_site = Site.objects.get_current()

The solution is to create our own Site class with "domain" and "name" fields, 
create 
its instance, for example, in main.py and use it in that way:
def get_urls(self, page=1):
    from models import Site
    current_site = Site.all().get()

Original comment by oleg.mal...@gmail.com on 27 Jan 2009 at 7:55

GoogleCodeExporter commented 9 years ago
This sounds like a reasonable fix. Would you be able to provide a patch? You 
will
also need to sign the CLA (see the README for details).

Original comment by mattbrow...@gmail.com on 27 Jan 2009 at 11:11

GoogleCodeExporter commented 9 years ago

Original comment by mattbrow...@gmail.com on 17 Apr 2009 at 5:37

GoogleCodeExporter commented 9 years ago
The attached patch fixes this issue for me with one exception.  I don't see how 
to
hook the post_syncdb signal the original sites app does to create the first Site
automatically.  If someone has an idea on how to solve this please let me know. 
Otherwise, I just use the method Site.bootstrap and place the site.key().id()
returned in the settings.py file if it is not 1.

Original comment by dherbst on 4 Jan 2010 at 3:51

Attachments:

GoogleCodeExporter commented 9 years ago
If any are interested, I integrated this patch into my fork:
http://code.google.com/p/dherbst-app-engine-django/ though I have modified 
things
slightly from the patch attached above to work better.  Also added a wiki entry 
on
how to enable the sitemap.

Original comment by dherbst on 4 Mar 2010 at 4:00