Monday, November 28, 2016

Re: How does django pass data through post?

Hey Jordan, 

Please share your views.py as well. 

On Tuesday, November 29, 2016 at 6:04:19 AM UTC+5:30, Jordan W wrote:
Hi,

I have been working on a small project for myself and some friends, and I seem to have hit a hitch in getting it to work as expected.

In my detail view, I have a small simple form:
    <form class="inline" action="/app/action/" method="POST">
    {% csrf_token %}
       
<button type="submit">Prepare</button>
   
</form>


My main list view and detail view are class based views, with me attempting to use a FBV for prepare because it seems simpler to understand. I've put a breakpoint in the "action" view, and tried to inspect the request and see data from clicking the button come through, but I don't see it. I am clearly missing something about how django sends POST data. I have tried adding the following in bold to see how to get the data through, as well as adding *args, **kwargs, as well as positional and named keyword arguments to my "action" FBV:

    <form class="inline" action="/app/action/" method="POST" id="{{ obj.id }}" objid="{{ obj.id }}">
    {% csrf_token %}
       
{{obj.id}}
       
<input type="hidden" value="{{obj.id}}" />
       
<button type="submit">Prepare</button>
   
</form>

If anyone can explain what I'm missing, it'd be greatly appreciated!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1af22987-1ea2-45a7-88f8-132e43f3dfa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment