djangoman
djangoman

Reputation: 399

What does an '_' in django url do?

what does an '_' in django url means like,

url(_(r'^mylink/'), include('link5.urls')),

_ plus a string should be an error but one public app is using such construct

Upvotes: 1

Views: 122

Answers (1)

Ned Batchelder
Ned Batchelder

Reputation: 375784

_ is often a shortcut for a gettext function that will produce a localized version of the string. It's unusual to do it for URLs, but it's documented: https://docs.djangoproject.com/en/1.11/topics/i18n/translation/#translating-url-patterns

At the top of the file you might find something like:

from django.utils.translation import ugettext as _

Upvotes: 2

Related Questions