Re: How sitemaps used in the Django

29 views
Skip to first unread message

Amyth Arora

unread,
Aug 31, 2012, 10:16:19 AM8/31/12
to django...@googlegroups.com
Hey Mugdha,

Have you had a look at django sitemap framework ?

1. add django.contrib.sitemaps to INSTALLED_APPS and then syncdb
2. add (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}) to urls.py
3. Create a sitemap class according to your app.

--
Thanks & Regards
----------------------------

Amyth [Admin - Techstricks]
Email - aroras....@gmail.com, ad...@techstricks.com
Twitter - @a_myth_________
http://techstricks.com/

Phil

unread,
Aug 31, 2012, 11:27:55 AM8/31/12
to django...@googlegroups.com
Hi Mugdha,

First add 'django.contrib.sitemaps' to your installed apps.

Then create a file "sitemap.py" in your project root with something like....

****************
from django.core.urlresolvers import reverse
from django.contrib.sitemaps import Sitemap
from blog.models import Entry

class ViewSitemap(Sitemap):
    """Reverse static views for XML sitemap."""
    def items(self):
        # Return list of url names for views to include in sitemap
        return ['home']

    def location(self, item):
        return reverse(item)

class BlogSitemap(Sitemap):
    changefreq = "never"
    priority = 0.5

    def items(self):
        return Entry.objects.filter(status=1)

    def lastmod(self, obj):
        return obj.pub_date


sitemaps = {'views': ViewSitemap,
                   'blog_posts': BlogSitemap,
                  }
*******************

in urls.py...
**********************
from project.sitemap import sitemaps
.....
url('^$', home, name='home'),
....etc...


On Friday, August 31, 2012 10:04:26 AM UTC+1, Mugdha wrote:
Please help me in generating site maps for app. which is in django.

Phil

unread,
Aug 31, 2012, 11:31:10 AM8/31/12
to django...@googlegroups.com
nearly forgot, also in urls.py...

(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),

mulianto

unread,
Aug 31, 2012, 1:08:05 PM8/31/12
to django...@googlegroups.com
hi 

sitemaps is easy.. last day i implement it in only 2 hours read the documentation in django web. 

just follow the documentation ˆ⌣ˆ 

Sent from my iPhone

On 31 Agt 2012, at 17:04, Mugdha <mni...@gmail.com> wrote:

Please help me in generating site maps for app. which is in django.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ZLpW-xn_TEYJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reply all
Reply to author
Forward
0 new messages