0

I am struggling with that issue already few days and can't find any solution or what is the problem.

after adding the localization to the app all the links in the main "homepage" (i used bakerydemo https://github.com/wagtail/bakerydemo) all are directing only to the english pages.

https://i.stack.imgur.com/KqSSL.png

my settings


USE_TZ = True
USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'he'

from django.utils.translation import gettext_lazy as _

WAGTAIL_I18N_ENABLED = True

LANGUAGES = WAGTAIL_CONTENT_LANGUAGES = [
    ("he", _("Hebrew")),
    ("en", _("English")),
    ("ru", _("Russian")),
]

LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale/'),
)

on apps "wagtail_localize", #'wagtail.locales', "wagtail_localize.locales", # This replaces "wagtail.locales"

didn't make any other changes on the files.

I have tried to remove WAGTAIL_I18N_ENABLED = True to handle the logic by myself but then there is an error:

Environment:


Request Method: GET
Request URL: http://localhost:8001/he/blog/blog/

Django Version: 3.2.11
Python Version: 3.9.7
Installed Applications:
['main.apps.MainConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sitemaps',
 'cms',
 'cms.base',`
 'cms.blog',
 'cms.breads',
 'cms.locations',
 'cms.search',
 'wagtail.contrib.search_promotions',
 'wagtail.contrib.forms',
 'wagtail.contrib.redirects',
 'wagtail.embeds',
 'wagtail.sites',
 'wagtail.users',
 'wagtail.snippets',
 'wagtail.documents',
 'wagtail.images',
 'wagtail.search',
 'wagtail.api.v2',
 'wagtail.contrib.modeladmin',
 'wagtail.contrib.routable_page',
 'wagtail.core',
 'wagtail_localize',
 'wagtail_localize.locales',
 'wagtail.admin',
 'rest_framework',
 'modelcluster',
 'taggit',
 'wagtailfontawesome']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'wagtail.contrib.redirects.middleware.RedirectMiddleware']


Template error:
In template C:\Users\beit\Desktop\NEWSITE\cms\templates\base.html, error at line 0
   'NoneType' object has no attribute 'strip'
   1 : {% load navigation_tags static wagtailuserbar %}
   2 : 
   3 : {% block head %}
   4 :     {% include "includes/head.html" %}
   5 : {% endblock head %}
   6 : 
   7 : <body class="{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}">
   8 : {% wagtailuserbar %}
   9 : 
   10 : {% block header %}


Traceback (most recent call last):
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\core\handlers\base.py", line 204, in _get_response
    response = response.render()
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\response.py", line 105, in render
    self.content = self.rendered_content
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\response.py", line 83, in rendered_content
    return template.render(context, self._request)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\backends\django.py", line 61, in render
    return self.template.render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 170, in render
    return self._render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\test\utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 938, in render
    bit = node.render_annotated(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 905, in render_annotated
    return self.render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\test\utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 938, in render
    bit = node.render_annotated(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 905, in render_annotated
    return self.render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 938, in render
    bit = node.render_annotated(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 905, in render_annotated
    return self.render(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\defaulttags.py", line 305, in render
    match = condition.eval(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\defaulttags.py", line 889, in eval
    return self.value.resolve(context, ignore_failures=True)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "C:\Users\beit\Desktop\NEWSITE\env\lib\site-packages\django\template\base.py", line 858, in _resolve_lookup
    current = current()
  File "C:\Users\beit\Desktop\NEWSITE\cms\blog\models.py", line 217, in get_child_tags
    tags += post.get_tags
  File "C:\Users\beit\Desktop\NEWSITE\cms\blog\models.py", line 118, in get_tags
    tag.url = '/' + '/'.join(s.strip('/') for s in [
  File "C:\Users\beit\Desktop\NEWSITE\cms\blog\models.py", line 118, in <genexpr>
    tag.url = '/' + '/'.join(s.strip('/') for s in [

Exception Type: AttributeError at /he/blog/blog/
Exception Value: 'NoneType' object has no attribute 'strip'
  """
        Similar to the authors function above we're returning all the tags that
        are related to the blog post into a list we can access on the template.
        We're additionally adding a URL to access BlogPage objects with that tag
        """
        tags = self.tags.all()
        for tag in tags:
            tag.url = '/' + '/'.join(s.strip('/') for s in [ …
                self.get_parent().url,
                'tags',
                tag.slug
            ])
        return tags
.0 <tuple_iterator object at 0x000001871FF09580>
s None

'NoneType' object has no attribute 'strip'

why s.get_parent().url is None?

thanks in advance and will appreciate all the help i can get here.

webmar
  • 7
  • 2
  • Can you try tag.url =[ '/' + '/'.join(s.strip('/') for s in self.get_parent().url, 'tags', tag.slug )] – Jaime Ortiz Jan 12 '22 at 01:34
  • hi, thanks for the reply, your line gave the error: tag.url =[ '/' + '/'.join(s.strip('/') for s in self.get_parent().url, 'tags', tag.slug )]. and same error as before with this tag.url =[ '/' + '/'.join(s.strip('/') for s in [self.get_parent().url, 'tags', tag.slug ])] – webmar Jan 12 '22 at 02:21

0 Answers0