Re: Best-practice for building URLs in templates with JavaScript

2011-04-23 Thread akaariai
On Apr 23, 6:43 pm, Shawn Milochik wrote: > It occurs to me now that I could just use a placeholder, and replace > that in JavaScript: >     Update Payment > > Then use the JavaScript to replace the string 'payment_id' (or a regex > on its location in the URL) when the user takes action. It also m

Re: Best-practice for building URLs in templates with JavaScript

2011-04-23 Thread Shawn Milochik
On Sat, Apr 23, 2011 at 3:31 AM, Ryan Osborn wrote: > You could always make the payment_id group optional using a ?: > > update_payment/(?P\w+)? Ryan, Thanks. I considered that first, but rejected it because I want the extra field to be required. If it's missing then it's an error. Giving it a

Re: Best-practice for building URLs in templates with JavaScript

2011-04-23 Thread Artur Wdowiarski
If it's quite a big project with lots of ajax, I'd say it's worth a try to serve your urls to the client in some reasonable way and then write an equivalent of reverse() in javascript. On 23 kwi 2011, at 09:31, Ryan Osborn wrote: > You could always make the payment_id group optional using a

Re: Best-practice for building URLs in templates with JavaScript

2011-04-23 Thread Ryan Osborn
You could always make the payment_id group optional using a ?: update_payment/(?P\w+)? that way this will match either: update_payment/ or update_payment/123 Hope that helps, Ryan -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Best-practice for building URLs in templates with JavaScript

2011-04-22 Thread Shawn Milochik
I'm working on an app which makes extensive use of AJAX. I'm also using named URLs so I don't have to hard-code URLs into my templates. The problem is that if a URL pattern requires extra info after the path, my templates don't render, because the extra parameters aren't known until the user makes