google-code-export / django-page-cms

Automatically exported from code.google.com/p/django-page-cms
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

missing denormalize field on Page model #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
First of all, this is not a bug report or issue. More a feature request :)

I use contrib.sitemaps to generate a sitemap for my django-page-cms. 

Something like this:

from django.contrib.sitemaps import GenericSitemap
from pages.models import Page

root_dict = {
    'queryset': Page.objects.filter(sites=settings.SITE_ID,
status=1,parent__isnull=True),
    'date_field': 'publication_date',
}

child_dict = {
    'queryset': Page.objects.filter(sites=settings.SITE_ID,
status=1,parent__isnull=False),
    'date_field': 'publication_date',
}

sitemaps = {
    'root_pages': GenericSitemap(root_dict, priority=1),
    'child_pages': GenericSitemap(child_dict, priority=0.6),
}

then i add this to my urlconf:
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps':
sitemaps}),

This generates a nice sitemap.xml file 
but there's one catch

Example:

<loc>http://foo.bar/baz/</loc>
<lastmod>2009-02-25</lastmod>
<priority>1</priority>

The lastmod is the pubdate, not when the content on the url actually was
last modified. A denormalised field on the Page model for this would help a
lot, otherwise one would have to iterate over Content models etc and use
the lowlevel sitemap api instead of generic sitemaps.

    lastmod_date = models.DateTimeField()

    def save(self):
        self.lastmod_date=datetime.now() 

Im working on a blog entry on how to setup a multilang, multisite
django-page-cms with staticgenerator, sitemap, robots.txt, performence
tweaks in nginx etc. If this could make it into the trunk the sitemaps part
would be a lot easier! Thanks

Original issue reported on code.google.com by andrii...@gmail.com on 5 Mar 2009 at 12:40

GoogleCodeExporter commented 9 years ago
It's a sensible feature. I think we should add this field.

Original comment by batiste....@gmail.com on 5 Mar 2009 at 9:58

GoogleCodeExporter commented 9 years ago
There is now a last_modification_date in the model.

Original comment by batiste....@gmail.com on 15 Apr 2009 at 7:28

GoogleCodeExporter commented 9 years ago
Thanks! 

Original comment by andrii...@gmail.com on 15 Apr 2009 at 7:43

GoogleCodeExporter commented 9 years ago
Thanks for the cool tip. I'm trying to do that sitemap output. Settings have 
PAGE_HIDE_ROOT_SLUG = True but I get /home/section/1/ urls.

How do I solve that. I want clean urls in sitemap, not that useless "home".

Thanks.

Original comment by tezro...@gmail.com on 17 Jun 2010 at 4:26

GoogleCodeExporter commented 9 years ago
"PAGE_HIDE_ROOT_SLUG = True" hide the /home/ only for the page itself, but not 
for the children. The reason is that it could create some name conflict with 
other pages at the root level.

The solution could to change this line to not add the slug of the root page:

http://github.com/batiste/django-page-cms/blob/master/pages/models.py#L256

Or your could move the root page child's to the same level (as brother instead 
of child). 

Original comment by batiste....@gmail.com on 18 Jun 2010 at 7:06

GoogleCodeExporter commented 9 years ago
Thanks for the answer, but my problem was that I have put all the pages inside 
the /home/ page.

By the way, that is perfectly clear to me, because all the pages on the site 
are the children of the root page. If it is a bit makes sense, there's some 
arguing about it at  another Django cms - 
http://groups.google.com/group/django-cms/browse_thread/thread/952fa4bdb3a91ccd/
50675e491977a1a6

Original comment by tezro...@gmail.com on 18 Jun 2010 at 11:06

GoogleCodeExporter commented 9 years ago
That would make sense to remove the /home/ every time for your case. The 
modification in the source is probably quite straightforward. I gonna have a 
lock at that.

Original comment by batiste....@gmail.com on 18 Jun 2010 at 1:08