There are a lot of complex forms in my project and I keep getting the feeling that I could be coding them much more elegantly and simply. So my question is what are some good apps and practices that might help me? Specifically, I'm thinking about situations when I need to do stuff like:
Solutions to any other more complex form scenarios also welcome. The above are problems I've already come across, but I'd like to generally find out about what are some best practices with forms.
What is Django? Django is a high-level Python web framework that enables rapid development of secure and maintainable websites. Built by experienced developers, Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel.
Using Form in a View In Django, the request object passed as parameter to your view has an attribute called "method" where the type of the request is set, and all data passed via POST can be accessed via the request. POST dictionary. The view will display the result of the login form posted through the loggedin.
Django provides a Form class which is used to create HTML forms. It describes a form and how it works and appears. It is similar to the ModelForm class that creates a form by using the Model, but it does not require the Model.
I've asked similar questions myself. There's a lot of room for improvement in Django's form handling, and there is some discussion of doing something about that but it isn't moving very quickly. Your asking this question validates this area needs some attention.
That said, the current ways (to the best of my knowledge) to handle those scenarios is:
ModelForm
for the Partnership and inlineformset
for the People. It isn't too difficult, but be aware that there's no easy way to combine them into one form object so you'll have to handle them separately.Inline Formsets: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With