django - Overriding get_absolute_url from a model for the sitemap -


hey have model can accesed through 2 different urls(depending on domain). , use them in views , templates without problems.

when building sitemap get_absolute_url should not return same thought: can subclass model , override get_absolute_url method:

class fanpitconcert(bandtasticconcert):     def get_absolute_url(self):         return ('event_checkout',(),{'artist_slug':self.slug_name,                                      'year': self.get_date().year,                                      'month': self.get_date().month,                                      'day': self.get_date().day,                                     })     class meta:         abstract = true 

and use subclassed model sitemap class

class concertssitemap(sitemap):     def items(self):         return fanpitconcert.objects.all().filter(app='fanpit') 

but when access /sitemap.xml django still calling get_absolute_url original model

is there dark magic django doing here? or missing obvious?

update

i tried removing abstract = true part , went class meta: db_table = 'same_table_as_base_model'

but django complains not finding columns.

instead of abstraction, better use proxy models in case.

so subclassed models have

class meta:     proxy = true 

more info on proxy models here.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -