Category : django-forms

i have option that allow user to change email in his profile but without confirm new email so when he enter new email i want activate email to save it in his profile , how to add confirm i am using UserCreationForm models.py : from django.db import models from django.contrib.auth.models import User from django.db.models.signals import ..

Read more

I am trying to submit a form but receiving an error: UnboundLocalError at /create/ local variable ‘spr’ referenced before assignment Below is the section of my views.py file that is highlighted in the error, specifically: return HttpResponseRedirect("/%i" %spr.id) def create(response): if response.method == "POST": form = CreateNewSprint(response.POST) if form.is_valid(): n = form.cleaned_data["name"] spr = Sprint(name=n) ..

Read more

def clientinfo(request): clientForm = ClientInfoForm(prefix="client") criminalForm = OCCForm(prefix="criminal") if request.method == ‘POST’: clientForm = ClientInfoForm(request.POST,prefix="client") criminalForm = OCCForm(request.POST,prefix="criminal") criminalForm[‘cust_id_id’] = clientForm[‘id’] if clientForm.is_valid() or criminalForm.is_valid(): clientForm.save() criminalForm.save() print("SUCCESSFUL SUBMISSION") return render(request, ‘submitted.html’) return render(request, ‘clientinfo.html’, {‘form’: clientForm, ‘occform’: OCCForm}) My criminalForm has a ForeignKey field cust_id and i need to set it to the auto-generated ..

Read more

I am using formsets to create a feedback page but I am not able to access foreign key table values in django template. I have this models below that are for a feedback system. Models.py class FeedbackForm(amdl.AagamBaseModel): feedback_form_id = models.AutoField(primary_key=True) subject_teacher = models.ForeignKey(MapMySchoolUserSubject, models.DO_NOTHING) feedback_form_date = models.DateField() feedback_form_status = models.BooleanField() class Meta: db_table = ‘feedback_form’ ..

Read more

I am trying to add created by whoever is logged in user but not getting that saved even though I am logged in. form.created_by = request.user is not adding logged in user. def create_table_allotment(request): form = TableAllotmentForm(request.POST or None) context = {‘form’: form} if request.method == ‘POST’: if form.is_valid(): try: form.save(commit=False) form.created_by = request.user form.save() ..

Read more

I want to Change my project structure so that my project follows MVC structure. Currently my project Structure: My_Ecom_project App_Login admin.py apps.py forms.py models.py urls.py views.py App_Order admin.py …. views.py App_Shop …. My_Ecom_Project init.py settings.py urls.py wsgi.py static … templates … mange.py I want to change this to: My_Ecom_project App_Login admin.py apps.py forms.py models.py urls.py ..

Read more