Skip to content

Commit

Permalink
feat(#1): method in view for create a student
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Gomide <[email protected]>
  • Loading branch information
wdresende and victorcommite committed May 21, 2019
1 parent cdd0c4a commit 4050a6d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
24 changes: 24 additions & 0 deletions students/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.1 on 2019-05-21 02:08

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Student',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.CharField(max_length=100)),
('matricula', models.CharField(max_length=10)),
('email', models.EmailField(max_length=254)),
('senha', models.CharField(max_length=15)),
],
),
]
6 changes: 6 additions & 0 deletions students/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from .views import create_student

urlpatterns = [
path('new', create_student, name='create_students')
]
7 changes: 7 additions & 0 deletions students/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.shortcuts import render
from .models import Student

def create_student(resquest):
form = StudentForm(resquest.POST or None)

if form.is_valid():
form.save()

return render(request, 'student-form.html', {'form': form})

0 comments on commit 4050a6d

Please sign in to comment.