I have one model for different types of entries:
POST = 1
PAGE = 2
ARTICLE = 3
ENTRY_TYPE = (
(POST, "Blog Post"),
(PAGE, "Page"),
(ARTICLE, "Article"),
)
entry_type = models.IntegerField(choices=ENTRY_TYPE, default=POST)
And function to find out absolute url for different types of entries based on it type:
def get_absolute_url(self):
if self.PAGE:
return '/%s/' % (self.slug)
elif self.ARTICLE:
return '/article/%s/' % (self.slug)
elif self.POST:
return '/blog/%s/' % (self.slug)
But this function doesn’t work, and i can’t find out, why. For all types of entries function return ‘PAGE’ url.
You should be looking at the value of
self.entry_type, e.g.: