Django 1.6: name 'sitemaps' is not defined

前端 未结 2 2007
逝去的感伤
逝去的感伤 2021-01-20 10:44

I\'m trying to implement sitemaps in my django application but i get the following error. I\'m using the django sitemap\'s framework. I don\'t know what I\'m doing wrong.

2条回答
  •  囚心锁ツ
    2021-01-20 11:27

    You imported Sitemaps from the module, not the module itself. Remove the module name:

    class Sitemap(Sitemap):
    

    This will just about work, even though you are replacing the imported class here.

    Alternatively and arguably clearer as to what you are doing, adjust your import of the module. Change the import from:

    from django.contrib.sitemaps import Sitemap
    

    to:

    from django.contrib import sitemaps
    

提交回复
热议问题