Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Redirect to page with query string
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
 
Barry Morrison  
View profile  
 More options Aug 18 2012, 8:26 pm
From: Barry Morrison <bdmorri...@gmail.com>
Date: Sat, 18 Aug 2012 17:26:32 -0700 (PDT)
Local: Sat, Aug 18 2012 8:26 pm
Subject: Redirect to page with query string

I have a view that displays images and gives me the ability to delete the
images.  

View url == /account/community/images/1 (1 == event_id)

That url will display all images associated with event_id=1

Each image displays a 'delete' url  that calls
/account/press/page/delete/{{ image.pk }}  -- the success_url for this view
is /account/press/page

I'd like the success_url to be /account/community/images{{ event.id }} the
page I came from

Code and lengthier explanation exists here: http://dpaste.org/7SGf8/

Thanks!!


 
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.
Melvyn Sopacua  
View profile   Translate to Translated (View Original)
 More options Aug 18 2012, 8:46 pm
From: Melvyn Sopacua <m.r.sopa...@gmail.com>
Date: Sun, 19 Aug 2012 02:46:28 +0200
Local: Sat, Aug 18 2012 8:46 pm
Subject: Re: Redirect to page with query string
On 19-8-2012 2:26, Barry Morrison wrote:

> I have a view that displays images and gives me the ability to delete the
> images.  

> View url == /account/community/images/1 (1 == event_id)

Change <a href="images/{{event.pk}}"> to:
<a
href="images/{{event.pk}}?return_to=/account/community/images/{{event.pk}}" >.
Keep passing this return_to parameter around. It helps to use the
request context processor so you can just grab it from the request
context in a template.

> I'd like the success_url to be /account/community/images{{ event.id }} the
> page I came from

Subclass the Deleteview and implement get_success_url(), using
request.GET['return_to'] or if you decide to put a hidden input in the
delete form with the return_to value then obviously it's in request.POST.
--
Melvyn Sopacua

 
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.
Barry Morrison  
View profile   Translate to Translated (View Original)
 More options Aug 18 2012, 9:29 pm
From: Barry Morrison <bdmorri...@gmail.com>
Date: Sat, 18 Aug 2012 18:29:36 -0700
Local: Sat, Aug 18 2012 9:29 pm
Subject: Re: Redirect to page with query string

I apologize, I'm new to Django and Python...I've tried every which way I
know how based on what you described, and I can't find success.

Here is what I'm at right now:

http://dpaste.org/7JcGT/

I get this error: 'DeleteCommunityImages' object has no attribute 'GET'

Full traceback: http://dpaste.org/QZ6uB/

Thanks,
Barry

On Sat, Aug 18, 2012 at 5:46 PM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:


 
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.
Barry Morrison  
View profile  
 More options Aug 19 2012, 3:25 am
From: Barry Morrison <bdmorri...@gmail.com>
Date: Sun, 19 Aug 2012 00:25:13 -0700 (PDT)
Local: Sun, Aug 19 2012 3:25 am
Subject: Re: Redirect to page with query string

This actually ended up working: http://dpaste.org/U0uY4/  


 
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.
Melvyn Sopacua  
View profile   Translate to Translated (View Original)
 More options Aug 19 2012, 6:04 am
From: Melvyn Sopacua <m.r.sopa...@gmail.com>
Date: Sun, 19 Aug 2012 12:04:21 +0200
Local: Sun, Aug 19 2012 6:04 am
Subject: Re: Redirect to page with query string
On 19-8-2012 3:29, Barry Morrison wrote:

> I apologize, I'm new to Django and Python...I've tried every which way I
> know how based on what you described, and I can't find success.

> Here is what I'm at right now:

> http://dpaste.org/7JcGT/

> I get this error: 'DeleteCommunityImages' object has no attribute 'GET'

Because the first parameter on an object method is the object:
def get_success_url(self) :
        return self.request.GET['return_to']

On class-based views several things are assigned to the object as
attributes and the request object is one of them:
<https://docs.djangoproject.com/en/1.4/topics/class-based-views/#dynam...>

It probably should be documented better what is available on the view
object and 1.5 docs are improving a lot:
<https://docs.djangoproject.com/en/dev//ref/class-based-views/#specifi...>

(allthough it still doesn't mention request specifically)

<https://docs.djangoproject.com/en/dev//ref/class-based-views/generic-...>
Here you see it uses the DeletionMixin:

<https://docs.djangoproject.com/en/dev//ref/class-based-views/mixins-e...>
and the method signature for get_success_url()

--
Melvyn Sopacua


 
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 »