Answer the question
In order to leave comments, you need to log in
Why is the form behaving strangely?
I don’t understand what’s wrong here, we have such a form
from django import forms
from .models import Customer
class CustomerForm(forms.ModelForm):
class Meta:
model = Customer
fields = ('customer_name', )
class Customer(models.Model):
customer_name = m
odels.CharField(max_length=64, blank=True, null=True, default=None)
customer_phone = models.CharField(max_length=48, blank=True, null=True, default=None)
customer_address = models.CharField(max_length=128, blank=True, null=True, default=None)
session_key = models.CharField(max_length=128, blank=True, null=True, default=None)
order = get_object_or_404(Order, session_key = request.session.session_key, status = status)
form = CustomerForm(request.POST)
if request.method == "POST":
if form.is_valid():
сustomer = form.save(commit=False)
customer.session_key = order.session_key
customer.save()
customer.session_key = order.session_key
NameError: name 'customer' is not defined
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question