ways to process a post request in django view and re-send it to another view -


i have view receives post request html form, , process , send post request view of original data, , more data add it,

i read http not allow pass same post request received.

i read official documentation , don't find way of doing so, , read library requests, , when tried using , send request made httpresponseredirect, keeps sending post writing tons of things in address bar, , kind of looks tries use instead of post.

i found here these questions:

which function in django creates httprequest instance , hands view?

simulating post request in django

but don't understand how can create request in efficient way, django app, , send view of app.

post_data = {'name': 'something'} response = requests.post('http://localhost:8000/polls/thanks/', name =  "somthing") content = response.content return httpresponseredirect(content) 

views nothing more functions in python there isn't stopping passing parameters separate view. whether or not thats thing different thing

def view_a(request):     # logic here     return view_b(request) 

based on comment:

what you're trying seems long winded way of can achieved .get method

last_name = request.post.get('last_name', generate_name()) 

what use last name if provided, otherwise generate one.

if you're using form, can same kind of thing, in clean method

def clean_last_name(self):     last_name = self.cleaned_data.get('last_name')     if last_name:         return last_name     else:         return generate_name() 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -