0

I have a website showing some news. Some of the article's names are not in English language and they are Persian. If I click on the title of a news, it should show the details of that news.When I test it on local host, it works fine. But on the real host I get internal server (500) error. Does anyone know how should I pass Persian names in the url?

I use Django version 3.1.

This is the model of News app:

class News(models.Model):

    name = models.CharField(max_length = 500, default="-")

This is the url:

    path('details/<word>/', views.news_details, name="news_details"),

It is the template:

{% for i in news %}
         
<a href="{% url 'news_details' word=i.name %}"><img class="img-full" style="width: 390px; height:300px;" src="{{i.picurl}}" alt=""></a>

{% endfor %}

and it is views.py:

def news_details(request,word):

    news = News.objects.get(name = word)

    return render(request, 'front/news_details.html',{'news':news})

Niiiosha
  • 11
  • 2
  • Do not use unprocessed human readable text in URLs. Use a [slug](https://stackoverflow.com/questions/427102/what-is-a-slug-in-django) instead. – Selcuk Oct 16 '20 at 07:08
  • You need to dive into 2 aspects: 1. UTF-8 in URLS in general, see following: https://stackoverflow.com/a/22357686/5274713 and others 2. UTF-8 encoding in Django, see: https://stackoverflow.com/a/14547723/5274713 – frost-nzcr4 Oct 16 '20 at 08:32

0 Answers0