Уведомления

Группа в Telegram: @pythonsu
  • Начало
  • » Django
  • » 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs. [RSS Feed]

#1 Фев. 14, 2013 14:30:16

dnstuff
Зарегистрирован: 2012-11-05
Сообщения: 113
Репутация: +  1  -
Профиль   Отправить e-mail  

'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.

Здравствуйте!
Перешел на релиз 1.5
Ошибка ‘url’ requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.
в строке <a href=“{% url auto.views.viewpost post.slug %}”><h3>{{post.title}}</h3></a>
В доке написано следующее:

One deprecated feature worth noting is the shift to “new-style” url tag. Prior to Django 1.3, syntax like {% url myview %} was interpreted incorrectly (Django considered “myview” to be a literal name of a view, not a template variable named myview). Django 1.3 and above introduced the {% load url from future %} syntax to bring in the corrected behavior where myview was seen as a variable.

The upshot of this is that if you are not using {% load url from future %} in your templates, you’ll need to change tags like {% url myview %} to {% url “myview” %}. If you were using {% load url from future %} you can simply remove that line under Django 1.5

Хотя слова все знакомы, общий смысл мне непонятен. Что за url из будущего? Причем здесь версия 1.3 (я сам начал изучение с 1.4)? И главное, что делать-то? Взятие в кавычки auto.views.viewpost post.slug приводит к ошибке
NoReverseMatch
Reverse for ‘auto.views.view_post post.slug’ with arguments ‘()’ and keyword arguments ‘{}’ not found.
Спасибо!

Отредактировано dnstuff (Фев. 14, 2013 14:42:34)

Офлайн

#2 Фев. 14, 2013 15:53:42

inoks
От: Russia
Зарегистрирован: 2012-12-11
Сообщения: 343
Репутация: +  35  -
Профиль   Адрес электронной почты  

'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.

dnstuff
you’ll need to change tags like {% url myview %} to {% url “myview” %}

<a href=“{% url ‘auto.views.viewpost’ post.slug %}”><h3>{{post.title}}</h3></a>

Отредактировано inoks (Фев. 14, 2013 16:02:15)

Офлайн

#3 Фев. 14, 2013 17:30:39

dnstuff
Зарегистрирован: 2012-11-05
Сообщения: 113
Репутация: +  1  -
Профиль   Отправить e-mail  

'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.

inoks
Вы поставили 3 кавычки. Опечатка наверное.

Отредактировано dnstuff (Фев. 15, 2013 10:08:31)

Офлайн

#4 Фев. 15, 2013 11:11:15

inoks
От: Russia
Зарегистрирован: 2012-12-11
Сообщения: 343
Репутация: +  35  -
Профиль   Адрес электронной почты  

'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.

Где три кавычки? Все ок, если как вам написали на SO, c переменной post.slug все ок - то должно работать.

Офлайн

  • Начало
  • » Django
  • » 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.[RSS Feed]

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version