Multiple form classes in django generic (class) views

Facing similar problem, I’ve come to conclusion that it’s not possible. Though having multiple forms per page itself turned out to be a design mistake, presenting all sorts of troubles. E.g., user fills two forms, clicks submit on one of them and loses data from the other. Workaround requires complicated controller that needs to be … Read more

context in nested serializers django rest framework

Ok i found a working solution. I replaced the ChildSerializer assignment in the Parent class with a SerializerMethodField which adds the context. This is then passed to the get_fields method in my CustomModelSerializer: class ChildSerializer(CustomModelSerializer): class Meta: fields = (‘c_name’, ) model = Child class ParentSerializer(CustomModelSerializer): child = serializers.SerializerMethodField(‘get_child_serializer’) class Meta: model = Parent fields … Read more

Django – [Errno 111] Connection refused

Looks like you are trying to send a mail (send_mail()) and your mail settings in your are not correct. You should check the docs for sending emails. For debugging purposes you could setup a local smtpserver with this command: python -m smtpd -n -c DebuggingServer localhost:1025 and adjust your mail settings accordingly: EMAIL_HOST = … Read more

Django Rest framework, how to include ‘__all__’ fields and a related field in ModelSerializer ?

Like @DanEEStart said, DjangoRestFramework don’t have a simple way to extend the ‘all‘ value for fields, because the get_field_names methods seems to be designed to work that way. But fortunately you can override this method to allow a simple way to include all fields and relations without enumerate a tons of fields. I override this … Read more