suggestion: Don't make the tag "url" dirty in Django1.5

123 views
Skip to first unread message

gs412

unread,
Mar 27, 2012, 4:22:18 AM3/27/12
to django-d...@googlegroups.com
In Django1.5

{% url app_views.client %}
will change to
{% "url app_views.client" %} 
 
I think it is a stupid idea
Why so many people use django? becouse of 'DRY', but now django become more and more 'dirty'

Shaggy

unread,
Mar 27, 2012, 8:22:18 AM3/27/12
to django-d...@googlegroups.com
from where U have that info?

and btw. is there repo for developing 1.5 with python3 support?

Łukasz Rekucki

unread,
Mar 27, 2012, 8:38:04 AM3/27/12
to django-d...@googlegroups.com
On 27 March 2012 10:22, gs412 <gs...@126.com> wrote:
> In Django1.5
>
>> {% url app_views.client %}
>
> will change to
>>
>> {% "url app_views.client" %}
>
>
> I think it is a stupid idea

Did you read the rationale for this change? How do you want to enable
passing context variables as view names? Did you notice that almost
everywhere in the template language literal strings are quoted?
Technical arguments usualy work better then calling things "stupid".


--
Łukasz Rekucki

Łukasz Rekucki

unread,
Mar 27, 2012, 8:44:48 AM3/27/12
to django-d...@googlegroups.com
On 27 March 2012 14:22, Shaggy <kfu...@gmail.com> wrote:
> from where U have that info?

Docs and Django 1.3 release notes:
https://docs.djangoproject.com/en/dev/releases/1.3/#changes-to-url-and-ssi

>
> and btw. is there repo for developing 1.5 with python3 support?
>

AFAIK, not yet. There's a features/py3k branch, but I'm not sure if
it's up to date with Tarek's bitbucket repo. My bet is that py3k merge
will happen after the GitHub migration which everyone seems to be busy
with ;)

--
Łukasz Rekucki

Jonathan French

unread,
Mar 27, 2012, 8:44:44 AM3/27/12
to django-d...@googlegroups.com
That example is incorrect.

{% url app_views.client %}

will not change to

{% "url app_views.client" %}

it will change to

{% url "app_views.client" %}

which, as you can see, enables passing the view from something other than a literal string.

--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/-kXfyDKv3-MJ.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.

Ramiro Morales

unread,
Mar 27, 2012, 8:45:04 AM3/27/12
to django-d...@googlegroups.com

Please post references from where did you get this nonsense. It is
completely wrong to the point of not even being correct syntax.

Please read the oficial documentation.

--
Ramiro Morales

Alex Ogier

unread,
Mar 27, 2012, 8:51:57 AM3/27/12
to django-d...@googlegroups.com


On Mar 27, 2012 8:45 AM, "Ramiro Morales" <cra...@gmail.com> wrote:
>
> On Tue, Mar 27, 2012 at 5:22 AM, gs412 <gs...@126.com> wrote:
> > In Django1.5
> >
> >> {% url app_views.client %}
> >
> > will change to
> >>
> >> {% "url app_views.client" %}
> >
>

> Please post references from where did you get this nonsense. It is
> completely wrong to the point of not even being correct syntax.
>
> Please read the oficial documentation.
>
> --
> Ramiro Morales

It's actually almost correct. The new syntax will actually be

    {% url "app_views.client" %}

But this change definitely doesn't make things "dirty," in fact it cleans up the tag to have consistent syntax with nearly every other tag, such as {% block %} and {% extends %}

Best,
Alex Ogier

Aymeric Augustin

unread,
Mar 27, 2012, 1:00:00 PM3/27/12
to django-d...@googlegroups.com
Hello,

django-developers isn't a random Internet forum; it's a mailing list for professionals. As such, you're expected to maintain a constructive and professional behavior, even when you disagree. The tone of your message was very inappropriate in this regard.

Thanks,

-- 
Aymeric.

Łukasz Rekucki

unread,
Mar 27, 2012, 1:11:45 PM3/27/12
to django-d...@googlegroups.com

This isn't my best day. First I don't notice the quotes in the example
are misplaced, then I mix up Tarek Ziade with Vinay Sajip. Of course I
meant this repo: https://bitbucket.org/vinay.sajip/django ; Sorry for
the confusion :(

---
Łukasz Rekucki

gs412

unread,
Mar 27, 2012, 3:26:17 PM3/27/12
to django-d...@googlegroups.com
Less symbol is the tide, the future. for example: coffeescript、sass、haml、slim and python, there are all less symbol, this feature make developer fell well

passing context variables for tag "url" is not a good idea, it make the work from easy to hard
{% with url_name="client-detail-view" %}
    {% url url_name client.id %}
{% endwith %}

three lines instead of one lines, just for passing context variables, context variables for url is not widespread


在 2012年3月27日星期二UTC+8下午8时38分04秒,Łukasz Rekucki写道:

Alex Ogier

unread,
Mar 27, 2012, 3:37:30 PM3/27/12
to django-d...@googlegroups.com


On Mar 27, 2012 3:26 PM, "gs412" <gs...@126.com> wrote:
>
> Less symbol is the tide, the future. for example: coffeescript、sass、haml、slim and python, there are all less symbol, this feature make developer fell well
>
> passing context variables for tag "url" is not a good idea, it make the work from easy to hard
>>
>> {% with url_name="client-detail-view" %}
>>     {% url url_name client.id %}
>> {% endwith %}
>
>
> three lines instead of one lines, just for passing context variables, context variables for url is not widespread
>

Well yes, it's not widespread: It's currently impossible. And it's only three lines if you want to explicitly create a context variable inside a template (which you will note is done with a quoted string constant). What your example demonstrates is how to create a constant variable that is used immediately... why would you ever do that?

Alex Ogier

Juan Pablo Martínez

unread,
Mar 27, 2012, 3:36:56 PM3/27/12
to django-d...@googlegroups.com
On Tue, Mar 27, 2012 at 4:26 PM, gs412 <gs...@126.com> wrote:
Less symbol is the tide, the future. for example: coffeescript、sass、haml、slim and python, there are all less symbol, this feature make developer fell well

passing context variables for tag "url" is not a good idea, it make the work from easy to hard
{% with url_name="client-detail-view" %}
    {% url url_name client.id %}
{% endwith %}

This dont work?

{% url "client-detail-view" client.id %}



 
three lines instead of one lines, just for passing context variables, context variables for url is not widespread


在 2012年3月27日星期二UTC+8下午8时38分04秒,Łukasz Rekucki写道:
On 27 March 2012 10:22, gs412 <> wrote:
> In Django1.5
>
>> {% url app_views.client %}
>
> will change to
>>
>> {% "url app_views.client" %}
>
>
> I think it is a stupid idea

Did you read the rationale for this change? How do you want to enable
passing context variables as view names? Did you notice that almost
everywhere in the template language literal strings are quoted?
Technical arguments usualy work better then calling things "stupid".


--
Łukasz Rekucki

--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/kADHFAbppUwJ.

To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.



--
juanpex

Ian Kelly

unread,
Mar 27, 2012, 3:51:19 PM3/27/12
to django-d...@googlegroups.com
On Tue, Mar 27, 2012 at 1:26 PM, gs412 <gs...@126.com> wrote:
> Less symbol is the tide, the future. for example:
> coffeescript、sass、haml、slim and python, there are all less symbol, this
> feature make developer fell well

This is incorrect. If Python were all about "fewer symbols", then we
would favor tabs over spaces, we would not require colons at the ends
of block-starting lines, and we would have operators like "!" instead
of "not".

One of the goals of Python is to be *more readable*, not to be
unnecessarily terse.

> passing context variables for tag "url" is not a good idea, it make the work
> from easy to hard
>>
>> {% with url_name="client-detail-view" %}
>>     {% url url_name client.id %}
>> {% endwith %}
>
>
> three lines instead of one lines, just for passing context variables,
> context variables for url is not widespread

You don't need three lines. There is no reason that the following
shouldn't work, so if it doesn't, then that is something that ought to
be fixed.

{% url "client-detail-view" client.id %}

This syntax has been available since Django 1.3, which was released a
year ago. If Django 1.5 takes the same amount of time that 1.4 did,
then it is still another year away. That is two full years to bring
your templates up-to-date, and it is a simple enough change that you
could probably do it with a short script.

Cheers,
Ian

Russell Keith-Magee

unread,
Mar 27, 2012, 7:01:57 PM3/27/12
to django-d...@googlegroups.com

It should also be added that since Django 1.3, you've been able to put {% load url from future %} at the top of your templates, which allows you to cleanly introduce the use of the new tag into your templates. This was also documented in the release notes for Django 1.3.

To the original poster -- thanks for the suggestion, but no, this isn't going to be reverted.

Ironically, your "3 line" example points out exactly why the change has been made -- it allows you to use a variable to be used as your URL name, whereas the unquoted behavior requires that your url is a known, static string. Without the new behavior of the URL tag, you wouldn't be able to use the URL tag with a value set in a with tag.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages