Answer the question
In order to leave comments, you need to log in
Does anyone have an example of working with a form?
There are a lot of articles on the Internet, but not one at a time fails, maybe someone has a ready-made example of creating a form from a model. For django 1.9
class Start(models.Model):
number_starts = model.IntegerField
source = models.TextField
Answer the question
In order to leave comments, you need to log in
class StartForm(forms.ModelForm):
class Meta:
model = Start
def view_start(request):
if request.method == "POST":
form = StartForm(request.POST)
if form.is_valid():
form.save() # записывает данные в базу с формы
else:
# lalala
return render(request, "form.html", {'form': form})
else:
form = StartForm()
return render(request, "form.html", {'form': form})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question