That was it, it is working now. Thank you so much Daniel! :) On Thursday, July 26, 2012 4:25:10 AM UTC-4, Daniel Roseman wrote: > > On Thursday, 26 July 2012 03:45:41 UTC+1, Matthew Meyer wrote: >> >> HI daniel, thanks for the reply >> >> After your comments, I have used ModelForm to simplify my code. I have >> also achieved redirecting the desired url by using the redirect() function. >> My issues are still basically the same however: >> >> - I do not know how to tell Django to render a template at the redirected >> url. >> >> I've tried passing redirect differnt views and params etc. to no avail. >> >> Here is my new views.py: http://dpaste.org/EtxdP/ >> >> I am trying to have the event_page view handle the redirect and render >> the template it returns. I know I am not relating the redirect and the view >> at all, this is because I do not know how. If I try to relate them in some >> way like this: return redirect('event_page', event) >> >> I get the error: Reverse for 'event_page' with arguments '(<Event: >> pppzzz>,)' and keyword arguments '{}' not found. >> >> My urls.py looks like this now: http://dpaste.org/UzBcR/ >> >> I am sort of hazy on the use of the third parameter in my second url >> pattern. I know the first param is a regex, the second is the view that >> handles the url, and from what I understand by reading the docs, the third >> param is a type of distinguisher used if you are calling the same view for >> different urls. >> >> Any thoughts on where I would begin to for rendering a template at the >> redirected url? >> >> Thanks, >> Matt >> >> > You haven't quite understood what a redirect is. A redirect doesn't render > a template: a redirect is just a signal to the browser to go and fetch > another, completely different, URL. Naturally, Django will then reply to > that second request with the template rendered by the view pointed to by > that second URL. > > The third parameter to the url pattern is basically a name Django can use > to refer to that URL, so that it can 'reverse' it and produce the actual > URL for use in things like links, redirects and permalink definitions. > > So, the main problem now is that you probably want the absolute URL to be > the `event_page` view. You need to update the get_absolute_url method to > point to that URL - as I said above, you can use the short name 'event_url' > rather than the fully qualified view name. However, you also need to update > the event_page view to accept the `name` parameter, and then to actually > get the relevant Event object from that name - eg `event = > Event.objects.get(name=name)` - and pass it to the event_page.html template. > -- > DR. >
-- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/VVxnOTEWDe8J. 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.