I’ve a settings page where users can select if they want to receive a newsletter or not.
I want a checkbox for this, and I want that Django select it if ‘newsletter’ is true in database. How can I implement in Django?
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.
models.py:
forms.py:
And if you want to automatically set
receive_newslettertoTrueaccording to some criteria in your application, you account for that in the forms__init__:The boolean form field uses a
CheckboxInputwidget by default.