Sphene Community Tools


Copyright © 2007-2018 by Herbert Poul

You are not logged in.

Change Language:

AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools
Board » General » Bug report: SCT is not compatibile with FlatPageSitemap

The bug is reported because SCT is not compatibile with django.contrib.sitemaps.FlatPageSitemap.

Steps to reproduce:
1. configure SCT so that it uses:

2. add some flatpages to your project (see official Django docs)

3. make use of django.contrib.sitemaps.FlatPageSitemap (see official Django docs)

4. start you project and go to domain/sitemap.xml

You should get:
ValueError: 'Site' instance needs to have a primary key value before a many-to-many relationship can be used.

The error is raised when Site.flatpages_set.all() is called. The reason is that this call is going to use m2m relation, which is not valid because Site object is not saved in db. Why? See what happends if group exists (from community.middleware.py):

def my_get_current(self):
    group = get_current_group()

    if not group:
        from django.conf import settings
        return self.get(pk=settings.SITE_ID)
        return Site( domain = group.baseurl, name = group.name )

SiteManager.get_current = my_get_current

In fact instance of Site is created and returned but it is not in db so it doesn't have a pk.


return Site( domain = group.baseurl, name = group.name )

return Site( pk=settings.SITE_ID, domain = group.baseurl, name = group.name )

(don't forget about from django.conf import settings).
hi, thanks i just committed your fix.
Hey, we have Signatures !!! Great, isn't it ? ;)

Please login to post a reply.

Powered by Sphene Community Tools