I have this in a form in my html file:
<input type="checkbox" id ="hide_name" value="hidden">
what should i put in my models to know whether this checkbox is checked or not.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, here’s the chain of events for someone checking the checkbox and that information reaching your server.
First, they press a “submit” button on the page, and they’re sent to a destination URL that you’ve specified in your form HTML. Their browser requests that page from your server with HTTP POST (usually), which includes all of the data from that form as part of the request.
Django checks that URL against your list of valid urls and sends it to the appropriate view. The view in question can then check the request object passed into the view to get the POST data (it’s stored as a dictionary in request.POST).
You can then do whatever you want with it in your view, including passing it to your model.
If you are working with forms you might be better off letting Django render your forms, instead of coding them in HTML yourself. See the forms documentation for more on this.