Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
A (last-minute) compromise on {% url %}
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jacob Kaplan-Moss  
View profile  
(1 user)  More options Aug 29 2008, 11:18 am
From: "Jacob Kaplan-Moss" <jacob.kaplanm...@gmail.com>
Date: Fri, 29 Aug 2008 10:18:49 -0500
Local: Fri, Aug 29 2008 11:18 am
Subject: A (last-minute) compromise on {% url %}
Hi folks --

While working on some URL-related issues, I ran across a pretty big
problem with having ``{% url %}`` propagate ``NoReverseMatch`` up into
the templates: if it does that, there's no way to have "optional"
links.  The perfect example is #7810 and the admin docs: if the URLs
for the admin doc views are installed, the admin should show a
(correct) link to the docs; if they're not installed, the link
shouldn't be there. Unfortunately, with the current ``url`` tag, there
isn't any way to make this work.

I started poking at it, and it turned out to be *very* easy to add a
``{% url ... as varname %}`` syntax to capture the URL into a variable
for later use. As a side effect, I made this syntax *not* raise errors
but instead return an empty string. This makes for a very natural
use::

    {% url django-admindocs-docroot as docroot %}
    {% if docroot %}
        <a href="{{ docroot }}">Documentation</a>
    {% endif %}

Patch here: http://code.djangoproject.com/git/?p=django;a=commitdiff;h=6c7d85a3cf...

So: I know this is technically a "feature addition," but it makes the
fixes to some silly bugs far easier. Are there any objections to me
sneaking this into 1.0?

Jacob


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Larlet  
View profile  
 More options Aug 29 2008, 11:43 am
From: David Larlet <lar...@gmail.com>
Date: Fri, 29 Aug 2008 17:43:48 +0200
Local: Fri, Aug 29 2008 11:43 am
Subject: Re: A (last-minute) compromise on {% url %}

Le 29 août 08 à 17:18, Jacob Kaplan-Moss a écrit :

+1 for this, before I test if someone already knows the answer, is it  
possible to use this var in blocktrans?

{% url args as myurl %}
{% blocktrans %}
     foo <a href="{{ myurl }}">baz</a>
{% endblocktrans %}

That's potentially the best solution for the endless discussion about  
urls in blocktrans.

Best,
David


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eduardo O. Padoan  
View profile  
 More options Aug 29 2008, 11:53 am
From: "Eduardo O. Padoan" <eduardo.pad...@gmail.com>
Date: Fri, 29 Aug 2008 12:53:28 -0300
Local: Fri, Aug 29 2008 11:53 am
Subject: Re: A (last-minute) compromise on {% url %}

+1 -- Pinax could deprecate {% captureas %} with this feature. Seems
like  a non-intentional pro :)

--
 Eduardo de Oliveira Padoan
http://djangopeople.net/edcrypt/
http://whoisi.com/p/514
http://pinax.hotcluboffrance.com/profiles/edcrypt/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jannis Leidel  
View profile  
 More options Aug 29 2008, 3:07 pm
From: Jannis Leidel <jan...@leidel.info>
Date: Fri, 29 Aug 2008 21:07:35 +0200
Local: Fri, Aug 29 2008 3:07 pm
Subject: Re: A (last-minute) compromise on {% url %}

Am 29.08.2008 um 17:18 schrieb Jacob Kaplan-Moss:

> Are there any objections to me
> sneaking this into 1.0?

Hell, no! That's perfect and also works with blocktrans.

..and let's us kill that captureas in Pinax, yay!

Cheers,
Jannis


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
daonb  
View profile  
 More options Aug 30 2008, 11:50 am
From: daonb <bennyd...@gmail.com>
Date: Sat, 30 Aug 2008 08:50:12 -0700 (PDT)
Local: Sat, Aug 30 2008 11:50 am
Subject: Re: A (last-minute) compromise on {% url %}
+1 for a sweet feature.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google