Compare commits

..

2 Commits

Author SHA1 Message Date
Benni Bärmann 4e6f36048d lost files added 2020-09-29 09:54:31 +02:00
Benni Bärmann fe727f7fbe first working form 2020-09-29 09:53:29 +02:00
5 changed files with 45 additions and 4 deletions

7
input/forms.py Normal file
View File

@ -0,0 +1,7 @@
from django.db import models
from django.forms import ModelForm
class ProjectForm(ModelForm):
class Meta:
model = Project
fields = '__all__'

View File

@ -0,0 +1,23 @@
# Generated by Django 3.1.1 on 2020-09-22 13:40
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('input', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='project',
old_name='project_name',
new_name='name',
),
migrations.RenameField(
model_name='project',
old_name='project_start',
new_name='start',
),
]

View File

@ -6,4 +6,4 @@ class Project(models.Model):
start = models.DateTimeField('start date') start = models.DateTimeField('start date')
def __str__(self): def __str__(self):
return self.project_name return self.name

View File

@ -0,0 +1 @@
{{formset}}

View File

@ -1,8 +1,18 @@
from django.shortcuts import render from django.shortcuts import render
from django.forms import modelformset_factory
from .models import Project
# Create your views here. # Create your views here.
from django.http import HttpResponse # from django.http import HttpResponse
def index(request): def index(request):
return HttpResponse("Hello, world. You're at the input form") # return HttpResponse("Hello, world. You're at the input form")
ProjectFormSet = modelformset_factory(Project, fields='__all__')
if request.method == 'POST':
formset = ProjectFormSet(request.POST, request.FILES)
if formset.is_valid():
formset.save()
# do something.
else:
formset = ProjectFormSet()
return render(request, 'input/project.html', {'formset': formset})