I'm trying to create my own View to register a new User in my website. I'm 
using this tutorial to help me with 
authentication: https://docs.djangoproject.com/en/1.11/topics/auth/default/#

But my problem is: in the same View that i have my form that i use to 
create a new User, i want to, when a person sucessfully registers a new 
user, to display the message "user created!"

First, my first View from my system is the login and its login.html is like 
this:
<form action="{% url 'analisarlogin' %}" method="post">
{% csrf_token %} 
    <label for="usuario">Usuário: </label>
    <input id="usuario" type="text" name="usuario" value=""/>
    <label for="senha">Senha: </label>
    <input id="senha" type="text" name="senha" value=""/>
    <input type="submit" value="Login"/>
</form>
<a href="{% url 'cadastro' cadastrorealizadocomsucesso=false %}">Não tem 
cadastro?</a>


You can see that on the <a href> from the final line that i go to a url 
passing one argument: cadastrorealizadocomsucesso=false
This is because my View called cadastro(portuguese for 'Register' in 
english) is like this:

def cadastro(request,cadastrorealizadocomsucesso):
 return render(request, 'cadastro.html',{'cadastrorealizadocomsucesso':
cadastrorealizadocomsucesso})


And my cadastro.html is like this:
<form action="{% url 'cadastrarprofessor' %}" method="post">
{% csrf_token %}
 <label for="usuario">Usuário: </label>
 <input id="usuario" type="text" name="usuario" value=""/>
 <label for="senha">Senha: </label>
 <input id="senha" type="text" name="senha" value=""/>
 <label for="email">Email: </label>
 <input id="email" type="text" name="email" value=""/>
 <input type="submit" value="Cadastrar"/>
</form>
{% if cadastrorealizadocomsucesso=="true" %}<b>cadastro realizado com 
sucesso!</b>{% endif %}

Notice that last line of code: if cadastrorealizadocomsucesso is false, 
then the phrase "cadastro realizado com sucesso!"(it's portuguese for 
something like "user created!") will not display. But if it's true then 
it'll display.

Here are my urls:
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^analisarlogin/$', views.analisarlogin, name='analisarlogin'),
url(r'^cadastro/$', views.cadastro, name='cadastro'),
url(r'^cadastrarprofessor/$', views.cadastrarprofessor, 
name='cadastrarprofessor'),
url(r'^menuinicial/$', views.menuinicial, name='menuinicial'),
url(r'^genericarmateriais/$', views.gerenciarmateriais, 
name='gerenciarmateriais'),
]

The problem i'm getting is this:

Reverse for 'cadastro' with keyword arguments '{'cadastrorealizadocomsucesso': 
''}' not found. 1 pattern(s) tried: ['shikenapp/cadastro/$']

And django is pointing out to this line of code(from my html login.html):

<a href="{% url 'cadastro' cadastrorealizadocomsucesso=false %}">Não tem 
cadastro?</a>

is there any way i can pass the false value to my url 'cadastro' on the 
login.html template? I've tried to put just(without the name of the variable, 
just the value): 

<a href="{% url 'cadastro' false %}">Não tem cadastro?</a>

But it didn't change anything.

How can i fix this code?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a71e1350-e267-4638-89cf-c3561e89bfba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to