Django form.cleaned_data switches values between Form class choice fields
I am trying to filter a model’s objects dynamically depending on what the user selects in a form. The form allows selecting from two dropdown lists. Selecting from either dropdown is optional. If the user does not select anything and clicks Submit, there will be an empty search results page. I believe I didn’t do some things correctly. When I extract data from form.cleaned_data
, when field_1
is only selected by the user, its value is assigned to field_2
and field_1
ends up being assigned the string “field_1”. Same for when only field_2
is selected. Why is it switching the value assignment and assigning the string name of each to itself?
Output
Django: Allowing a User being able to see, then update, form of their information
Im trying to create a game tracking app and I wanted the user to be able to see, then update if they wanted, a form that turns on and off features to track. I know this should be quite simple but I cannot for the life of me get the form to populate with the user’s data, then be able to update it. Thanks in advance.
Django Model Form, seems like there is an anomaly where my user creation form’s clean_username method is not throwing a ValidationError when it should
Background I have a custom User model that I have extended from BaseUserManager and AbstractBaseUser. Similarly, I have a custom sign-up form that I’ve extended from UserCreationForm (all these custom items are extended from django.contrib.auth). The custom UserCreationForm I’ve made has a method called clean_username() that checks for usernames that do not have any alpha-numerical […]
Is there a way to insert a default field to each user’s ‘wincon’ model or lock the form field to a value based on another form field?
I am building a game tracker. I would like to have it where if the user selects anything other than ‘Win’ then the wincon field of the form is unchangeable or set to a default field. This is to make it easier to understand that when they don’t win they shouldn’t add a wincon. It would also be nice if the user had a blank field that if they didn’t want to input a wincon then it would default to ‘——‘
Django: Update form without updating date/time when Date/TimeField is auto_now=True
I have build a record keeping app. I want the user to be able to edit an event but without updating the Date/TimeField when those are set to auto_now=True.
Problem with patient profile and auth system in Django
Today i met very difficult problem in my project. Idea is simple, in my Doctor model i have a unique_connect_token, which needs for link Patient to the specific Doctor. In my patient profile template i created a simple POST method form to obtain this token from Patient. Patient see this form in his profile if he have no linked Doctor and authenticate. I have problem with my post method in this class:
Not sure why when I press signup it just returns to the blank form, and when i try to log in it does nothing
urls.py