Hi,

I was thinking about something like the following in urls.py :

     (r'(?P<shortcut>\w+)', 'django.views.generic.simple.redirect_to', 
{'url': Shorturl.objects.get(slug=shortcut).url }),

But I did not manage to make it work.

In the meanwhile I did this which works but I'm a little "disappointed" 
with this :

urls.py:
--------

from django.conf.urls.defaults import *
from shorturl.views import redirect_to_url

urlpatterns = patterns('',
     (r'(?P<shortcut>\w+)',  'shorturl.views.redirect_to_url'),
)

views.py:
---------

from django.http import HttpResponsePermanentRedirect
from atome.shorturl.models import Shorturl

def redirect_to_url(request, shortcut):
     return 
HttpResponsePermanentRedirect(Shorturl.objects.get(slug=shortcut).url)

Any idea ?

Regards,
Nicolas


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to