More robus implementation of Post.get_absolute_url
This commit is contained in:
parent
7b040e1b01
commit
0e07f9a850
1 changed files with 19 additions and 15 deletions
|
@ -17,6 +17,7 @@ from djangocms_text_ckeditor.fields import HTMLField
|
|||
from filer.fields.image import FilerImageField
|
||||
from meta_mixin.models import ModelMeta
|
||||
from parler.models import TranslatableModel, TranslatedFields
|
||||
from parler.utils.context import switch_language
|
||||
from taggit_autosuggest.managers import TaggableManager
|
||||
|
||||
from .cms_appconfig import BlogConfig
|
||||
|
@ -203,8 +204,11 @@ class Post(KnockerModel, ModelMeta, TranslatableModel):
|
|||
super(Post, self).save_translation(translation, *args, **kwargs)
|
||||
|
||||
def get_absolute_url(self, lang=None):
|
||||
if not lang:
|
||||
if not lang or lang not in self.get_available_languages():
|
||||
lang = self.get_current_language()
|
||||
if not lang or lang not in self.get_available_languages():
|
||||
lang = get_language()
|
||||
with switch_language(self, lang):
|
||||
category = self.categories.first()
|
||||
kwargs = {}
|
||||
urlconf = get_setting('PERMALINK_URLS')[self.app_config.url_patterns]
|
||||
|
|
Loading…
Reference in a new issue