Skip to content
Advertisement

Tag: django-forms

IntegrityError NOT NULL constraint failed: – in validating form missing user id (foreing key of anothermodel)

Previous title: Unable to import ‘misaka’ – Django I am following a tutorial about how to build a social network. I run into this error: IntegrityError at /posts/new/ NOT NULL constraint failed: posts_post.user_id Complete traceback (please note the lines in bold): The lines in bold are pointing to these two pieces of code: 1: In my_projectpostsviews.py in form_valid: 2: In

Pass argument to Django form

There are several questions on stackoverflow related to this topic but none of them explains whats happening neither provides working solution. I need to pass user’s first name as an argument to Django ModelForm when rendering template with this form. I have some basic form: Here’s my sample class-based view: What do I pass to MyForm when initialising it and

Specifying both ‘fields’ and ‘form_class’ is not permitted

I have the following form, which I want render it with Django crispy forms. This is my views.py This is my urls.py project main file : This is my medical_encounter_information/urls.py In my forms.py file I have: The template medical_encounter_information/templates/medical_encounter_information/rehabilitationsession_form.html is: When I type in my browser the url http://localhost:8000/sesiones-de-rehabilitacion/nuevo/ I get the following: But, When I type in my browser

Django form – set label

I have a form that inherits from 2 other forms. In my form, I want to change the label of a field that was defined in one of the parent forms. Does anyone know how this can be done? I’m trying to do it in my __init__, but it throws an error saying that “‘RegistrationFormTOS’ object has no attribute ’email'”.

Advertisement