-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#1): method in view for create a student
Co-authored-by: Victor Gomide <[email protected]>
- Loading branch information
1 parent
cdd0c4a
commit 4050a6d
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |