Sitemap - Attribute error


#1

Hi There,

As a Designer/Frontend Dev with Wordpress experience, its been fantastic learning something new. I’m pretty impressed with Django so far, many thanks for the fantastic tutorial as well.

I have been having some issues with the sitemap page, particularly when I view - http://localhost:8000/sitemap.xml, it throws an error "AttributeError: ‘Thing’ object has no attribute ‘updated’’. From the terminal I can see it doesn’t like the “lastmod” attribute in sitemap.py, and the error is "AttributeError: ‘Thing’ object has no attribute ‘updated’. As soon as I remove the attribute “def lastmod(self, obj): return obj.updated”, the sitemap loads. As far as I can tell I have entered the code correctly for the urls.py, models.py and sitemap.py

I’m completely stumped as to what the error is?


#2

Hi there! Did you follow the previous section (same chapter), “Adding created and last-modified dates using an abstract model”? You add an updated field in that part, which looks to be missing from your code. :)


#3

Hi again,

Oh thanks, I think my problem was that I left in “class Thing(models.Model): name = models.CharField(max_length=255))” etc. in the models.py and it was clashing with “class Thing(Timestamp)”, my bad.

Cheers


#4

I saw your reply before you edited it — there has been no major updates since the Kickstarter, can you confirm that section is indeed in your Kickstarter copy?


#5

Hi sorry if I was confusing.

I purchased through Leanpub and they send a zip with the older pdf versions. As you can see from the screenshot of the two pdfs below for Chapter 3, one has a section of “Adding created and last-modified” etc. and the other doesn’t. The one on the right is the Kickstarter version and the actual content is there and I followed the instructions correctly, I just think my issue was having two of the same classes in my models which were clashing and once deleted it it was fine and the sitemap showed the lastmod.

Thanks.


#6

Ah thanks, didn’t know that about Leanpub! Thanks for letting me know. :)