Problem with django sitemap

480 views
Skip to first unread message

Frankline

unread,
Dec 16, 2012, 12:25:35 PM12/16/12
to django...@googlegroups.com
I'm having a problem implementing the sitemaps in my application. I'm using Virtualenv, django 1.4 and Python 2.7. I would appreciate if you can help me resolve this.

This is what I have done:

1. In my urls.py

from sitemap import JobPostSitemap
sitemaps = {
    'jobs': JobPostSitemap,
}
... # Removed other urls
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),

2. Then in my sitemap.py file

from django.contrib.sitemaps import Sitemap
from jobs.models import JobPost

class JobPostSitemap(Sitemap):
    changefreq = "never"
    priority = 0.5
   
    def items(self):
        return JobPost.objects.filter(approved=True)
       
    def lastmod(self, obj):
        return obj.pub_date


3. My settings.py file is as follows:

...
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sitemaps',
    'jobs',
)

...

Now when I open my browser and navigate to http://localhost:8000/sitemap.xml , I get the following error:


ImportError at /sitemap.xml

No module named django.contrib.sitemaps
Request Method: GET
Request URL: http://localhost:8000/sitemap.xml
Django Version: 1.4.2
Exception Type: ImportError
Exception Value:
No module named django.contrib.sitemaps
Exception Location: /home/frank/Projects/python/django/techjobsea.com/baseline27/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py in import_module, line 35
Python Executable: /home/frank/Projects/python/django/techjobsea.com/baseline27/bin/python
Python Version: 2.7.3

Frankline

unread,
Dec 18, 2012, 2:32:06 AM12/18/12
to django...@googlegroups.com
Anyone???

Sandeep kaur

unread,
Dec 18, 2012, 2:44:59 AM12/18/12
to django...@googlegroups.com
On Sun, Dec 16, 2012 at 10:55 PM, Frankline <frao...@gmail.com> wrote:
>
> I'm having a problem implementing the sitemaps in my application. I'm
<snip>
>
> ImportError at /sitemap.xml
>
> No module named django.contrib.sitemaps
>
> Request Method: GET
> Request URL: http://localhost:8000/sitemap.xml
> Django Version: 1.4.2
> Exception Type: ImportError
> Exception Value:
>
> No module named django.contrib.sitemaps
>
> Exception Location:
> /home/frank/Projects/python/django/techjobsea.com/baseline27/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py
> in import_module, line 35
> Python Executable:
> /home/frank/Projects/python/django/techjobsea.com/baseline27/bin/python
> Python Version: 2.7.3
>

Are you sure, you followed all the installation steps, especially step 3 in :

https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/


--
Sandeep Kaur
E-Mail: mkaur...@gmail.com
Blog: sandymadaan.wordpress.com

Frankline

unread,
Dec 18, 2012, 2:47:22 AM12/18/12
to django...@googlegroups.com
But the sites framework has already been installed, as you can see from my settings file.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
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.


Sandeep kaur

unread,
Dec 18, 2012, 2:55:35 AM12/18/12
to django...@googlegroups.com


On Tue, Dec 18, 2012 at 1:17 PM, Frankline <frao...@gmail.com> wrote:
> But the sites framework has already been installed, as you can see from my
> settings file.
>
According to me, If that is true then it should not have thrown Import error.

To install the sitemap app, follow these steps:

  1. Add 'django.contrib.sitemaps' to your INSTALLED_APPS setting.
  2. Make sure 'django.template.loaders.app_directories.Loader' is in your TEMPLATE_LOADERS setting. It’s in there by default, so you’ll only need to change this if you’ve changed that setting.
  3. Make sure you’ve installed the sites framework.
Reply all
Reply to author
Forward
0 new messages