diff --git a/UGSdjangoProject/.idea/UGSdjangoProject.iml b/UGSdjangoProject/.idea/UGSdjangoProject.iml index 38ad95b..4143bb4 100644 --- a/UGSdjangoProject/.idea/UGSdjangoProject.iml +++ b/UGSdjangoProject/.idea/UGSdjangoProject.iml @@ -25,6 +25,7 @@ diff --git a/UGSdjangoProject/UGSdjangoProject/urls.py b/UGSdjangoProject/UGSdjangoProject/urls.py index e390f1e..57801f5 100644 --- a/UGSdjangoProject/UGSdjangoProject/urls.py +++ b/UGSdjangoProject/UGSdjangoProject/urls.py @@ -18,6 +18,8 @@ Including another URLconf from django.contrib import admin from django.urls import path,include + + urlpatterns = [ path('admin/', admin.site.urls), path('ugs/', include('ugssim.urls')), diff --git a/UGSdjangoProject/ugssim/form.py b/UGSdjangoProject/ugssim/form.py new file mode 100644 index 0000000..13def69 --- /dev/null +++ b/UGSdjangoProject/ugssim/form.py @@ -0,0 +1,10 @@ +from django import forms + +from django import forms +from .models import Address + + +class AddressForm(forms.ModelForm): + class Meta: + model = Address + fields = ['vorname', 'nachname', 'geburtstag', 'street', 'hausnummer', 'postleitzahl'] diff --git a/UGSdjangoProject/ugssim/migrations/0001_initial.py b/UGSdjangoProject/ugssim/migrations/0001_initial.py new file mode 100644 index 0000000..84d29ce --- /dev/null +++ b/UGSdjangoProject/ugssim/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 5.0.1 on 2024-03-06 10:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Address', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('vorname', models.CharField(max_length=255)), + ('nachname', models.CharField(max_length=255)), + ('geburtstag', models.DateField()), + ('street', models.CharField(max_length=255)), + ('hausnummer', models.CharField(max_length=255)), + ('postleitzahl', models.PositiveIntegerField()), + ], + ), + ] diff --git a/UGSdjangoProject/ugssim/models.py b/UGSdjangoProject/ugssim/models.py index 71a8362..9979075 100644 --- a/UGSdjangoProject/ugssim/models.py +++ b/UGSdjangoProject/ugssim/models.py @@ -1,3 +1,15 @@ from django.db import models # Create your models here. +class Address(models.Model): + vorname = models.CharField(max_length=255) + nachname = models.CharField(max_length=255) + geburtstag = models.DateField() + street = models.CharField(max_length=255) + hausnummer = models.CharField(max_length=255) + postleitzahl = models.PositiveIntegerField() + + def __str__(self): + return f'{self.vorname} {self.nachname} lives at {self.street} {self.hausnummer}, {self.postleitzahl}' + + diff --git a/UGSdjangoProject/ugssim/templates/ugssim/adresss.html b/UGSdjangoProject/ugssim/templates/ugssim/adresss.html new file mode 100644 index 0000000..9c73fea --- /dev/null +++ b/UGSdjangoProject/ugssim/templates/ugssim/adresss.html @@ -0,0 +1,17 @@ +{% extends 'ugssim/ugssim.html' %} +{% block content %} +
+
+ {% csrf_token %} + {% for field in form %} +
+ + +
+ {% endfor %} + +
+
+ + +{% endblock content %} \ No newline at end of file diff --git a/UGSdjangoProject/ugssim/templates/ugssim/companydata.html b/UGSdjangoProject/ugssim/templates/ugssim/companydata.html new file mode 100644 index 0000000..855409c --- /dev/null +++ b/UGSdjangoProject/ugssim/templates/ugssim/companydata.html @@ -0,0 +1,9 @@ +{% extends 'ugssim/ugssim.html' %} +{% block content %} + Wir haben über 25 Jahre Erfahrung in der Gründungsausbildung, Businessplanentwicklung und Gründerberatung. +
+ + + +
+{% endblock content %} \ No newline at end of file diff --git a/UGSdjangoProject/ugssim/templates/ugssim/name.html b/UGSdjangoProject/ugssim/templates/ugssim/name.html new file mode 100644 index 0000000..bede1d9 --- /dev/null +++ b/UGSdjangoProject/ugssim/templates/ugssim/name.html @@ -0,0 +1,5 @@ +
+ {% csrf_token %} + {{ form }} + +
\ No newline at end of file diff --git a/UGSdjangoProject/ugssim/urls.py b/UGSdjangoProject/ugssim/urls.py index ef9d79e..4665528 100644 --- a/UGSdjangoProject/ugssim/urls.py +++ b/UGSdjangoProject/ugssim/urls.py @@ -3,6 +3,6 @@ from . import views urlpatterns = [ path('',views.index, name='ugs_index'), - # path('input/',views.input, name='ugs_input'), + path('input/',views.input, name='ugs_input'), # path('tables/',views.tables, name='ugstables'), ] \ No newline at end of file diff --git a/UGSdjangoProject/ugssim/views.py b/UGSdjangoProject/ugssim/views.py index daff71d..afcd1ad 100644 --- a/UGSdjangoProject/ugssim/views.py +++ b/UGSdjangoProject/ugssim/views.py @@ -1,13 +1,47 @@ from django.shortcuts import render from django.http import HttpResponse from django.template import loader - +from django.shortcuts import render +from .form import AddressForm from django.views.generic import TemplateView +from ugssim.form import NameForm + # Create your views here. def index(request): template = loader.get_template('ugssim/home.html') - return HttpResponse(template.render()) \ No newline at end of file + return HttpResponse(template.render()) + + +def companydata(request): + template = loader.get_template('ugssim/companydata.html') + return HttpResponse(template.render()) + +def input(request): + template = loader.get_template('ugssim/companydata.html') + return HttpResponse(template.render()) + +def get_name(request): + if request.method == 'POST': + form= NameForm(request.POST) + if form.is_valid(): + return HttpResponse(f"Hello, {form.your_name}!") + else: + form = NameForm() + return render(request, 'ugssim/name.html', {'form': form}) + +from django.shortcuts import render +from .form import AddressForm + +def address(request): + if request.method == 'POST': + form = AddressForm(request.POST) + if form.is_valid(): + form.save() + else: + form = AddressForm() + return render(request, 'address.html', {'form': form}) +