Compare commits
2 Commits
a25c817728
...
4e6f36048d
Author | SHA1 | Date |
---|---|---|
Benni Bärmann | 4e6f36048d | |
Benni Bärmann | fe727f7fbe |
|
@ -0,0 +1,7 @@
|
|||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
|
||||
class ProjectForm(ModelForm):
|
||||
class Meta:
|
||||
model = Project
|
||||
fields = '__all__'
|
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -6,4 +6,4 @@ class Project(models.Model):
|
|||
start = models.DateTimeField('start date')
|
||||
|
||||
def __str__(self):
|
||||
return self.project_name
|
||||
return self.name
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{{formset}}
|
|
@ -1,8 +1,18 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
from django.forms import modelformset_factory
|
||||
from .models import Project
|
||||
# Create your views here.
|
||||
from django.http import HttpResponse
|
||||
# from django.http import HttpResponse
|
||||
|
||||
|
||||
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})
|
||||
|
|
Loading…
Reference in New Issue