-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: WillAllmeida <will.allmeida@gmail.com> Co-authored-by: aquiles23 <jjoseaquiless@gmail.com> Co-authored-by: jpmota2208 <jpmota.unb@gmail.com> Co-authored-by: igorveludo <velvet.guimaraes@gmail.com>
- Loading branch information
1 parent
f327db5
commit 51841af
Showing
4 changed files
with
50 additions
and
3 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 |
---|---|---|
@@ -1,5 +1,13 @@ | ||
{% extends "base.html" %} | ||
{% block title %}fheihfoehef{% endblock %} | ||
{% block title %}register{% endblock %} | ||
{% block body %} | ||
<h1>gofzao da massa</h1> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
{{usuario_form.as_p}} | ||
|
||
<!--este as_p é pra fazer a quebra dos espaços de cada campo do formulário, se n colocarmos isso fica td um na frente do outro--> | ||
<!--este crsf é pra garantir segurança, se nao colocar o form n funciona--> | ||
<input type="submit" class="btn btn-primary" value="Submit"> | ||
</form> | ||
{% endblock %} |
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,4 @@ | ||
from django.contrib import admin | ||
|
||
from usuario.models import Usuario | ||
# Register your models here. | ||
admin.site.register(Usuario) |
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,12 @@ | ||
from django import forms | ||
from django.contrib.auth.models import User | ||
from usuario.models import Usuario | ||
|
||
class UsuarioForm(forms.ModelForm): | ||
password = forms.CharField(widget=forms.PasswordInput()) | ||
username = forms.CharField() | ||
email = forms.EmailField() | ||
|
||
class Meta(): | ||
model = User | ||
fields = ('username','email','password') |
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,4 +1,30 @@ | ||
from django.shortcuts import render | ||
from usuario.forms import UsuarioForm | ||
from . import forms | ||
from usuario import models | ||
|
||
def register(request): | ||
return render(request, 'register.html') | ||
#form = forms.UsuarioForm() | ||
|
||
if request.method == 'POST': | ||
usuario_form = UsuarioForm(data=request.POST)#to pegando info do form | ||
|
||
if usuario_form.is_valid(): | ||
user = usuario_form.save() | ||
user.set_password(user.password) | ||
user.save() | ||
else: | ||
print(usuario_form.errors) | ||
|
||
else: | ||
usuario_form = UsuarioForm() | ||
|
||
''' | ||
print("validation success") | ||
print("username:"+form.cleaned_data['username']) | ||
print("email:"+form.cleaned_data['email']) | ||
print("password:"+form.cleaned_data['password']) | ||
print("done") | ||
''' | ||
|
||
return render(request,'register.html',{'usuario_form':usuario_form}) |