1

I want slug urls. There are Cyrillic chars in urls: https://все-субсидии/раздел/НКО

I handle it:

# -*- coding: utf-8 -*-
from django.urls import path
from django.utils.http import urlquote
from django.utils.encoding import uri_to_iri

from . import views

urlpatterns = [
    path('', views.index),
    path('edit_article/<int:id>', views.edit_article),
    path('add_article/', views.add_article),
    path('article_list/', views.article_list),
    path(urlquote(u'субсидия') + '/<str:category_name>/<str:name>/', views.article),
    path(urlquote(u'раздел') + '/<str:section_name>/', views.category),
]

urlquote(u'раздел') = '%d1%80%d0%b0%d0%b7%d0%b4%d0%b5%d0%b'

When I write the full link(https://все-субсидии/раздел/НКО) on safari, my error is

Page not Found The current path, %25d1%2580%25d0%25b0%25d0%25b7%25d0%25b4%25d0%25b5%25d0%25bb/%25d0%259d%25d0%259a%25d0%259e/, didn't match any of these.

but when I write a (https://все-субсидии/раздел/) my error is:

Page not found(404) The current path, %d1%80%d0%b0%d0%b7%d0%b4%d0%b5%d0%bb, didn't match any of these.

in first, each % convert to %25.

Is my urls.py right?

thanks!

0

1 ответ 1

0

Check u settings.py u use cyrillic character in url.

But I assume your LANGUAGE_CODE setting is equal 'en-us' (by default). change it to 'ru-ru', but then your eng-path will break (maybe).

Скорее всего ошибка в settigs.py т.к по умолчанию там ставится LANGUAGE_CODE='en-us'. А в urls.py используются символы кириллицы можно переопределить LANGUAGE_CODE='ru-ru' в settings.py. Но могут сломаться английские пути.

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.