Quando "clico" no botão registrar, a minha pagina esta retornando erro, pelo que entendi é um problema de rota, mas não consegui encontrar ondes esta o erro.
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/registrar/%20method=?csrfmiddlewaretoken=7AeC9Fov8qdRV0mPQaw4beariwqLt8Wk&email=flavio%40flavio.com.br&nome=Flavio+Almeida&senha=&telefone=&nome_empresa=
Using the URLconf defined in connectedin.urls, Django tried these URL patterns, in this order:
^admin/
^ ^$ [name='index']
^ ^perfis/(?P<perfil_id>\d+)$ [name='exibir']
^ ^perfis/(?P<perfil_id>\d+)/convidar$ [name='convidar']
^ ^convite/(?P<convite_id>\d+)/aceitar$ [name='aceitar']
^ ^registrar/$ [name='registrar']
The current URL, registrar/ method=, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
settings.py
"""
Django settings for connectedin project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'as*0@q2nku!1-*v8(#l4@mrsef_u8+lern%uz#%!^p3ivm)agv'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'perfis',
'usuarios'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'connectedin.urls'
WSGI_APPLICATION = 'connectedin.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
connectedin/usuario/urls.py
from django.conf.urls import patterns, url
from views import RegistrarUsuarioView
urlpatterns = patterns('',
#url para a pagina do usuario
url(r'^registrar/$', RegistrarUsuarioView.as_view(), name='registrar')
)
# connectedin/connectedin/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('perfis.urls')),
url(r'^', include('usuarios.urls'))
)
connectedin/usuarios/views.py
# -*- coding: UTF-8 -*-
from django.shortcuts import render
from django.views.generic.base import View
class RegistrarUsuarioView(View):
template_name = 'registrar.html'
#esta classe é destinada a exibir o formulario para o usuario
def get(self, request):
return render(request, self.template_name)
#esta classa lida com os dados enviados no formulario
def post(self, request):
return render(request, self.template_name)
connectedin/usuarios/templates/base_usuario.html
{% load staticfiles %}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-wifth">
<title>
ConnectedIn
</title>
<link rel="stylesheet" href="{% static "styles/bootstrap.css"%}">
<link rel="stylesheet" href="{% static "styles/signin.css"%}">
</head>
<body>
<div class="container">
<div class="row content">
{% block body %}
{% endblock %}
</div>
</div>
</body>
</html>
connectedin/usuarios/templates/registrar.html
{% extends "base_usuario.html" %}
{% block body %}
<form classe="form-signin" action="{% url 'registrar' %} method="post">
{% csrf_token %}
<h2 class="form-signin-heading">
Crie seu usuário
</h2>
<input id="id_email" name="email" type="text"
class="form-control" placeholder="Email *"
requerid>
<input id="id_nome" name="nome" type="text"
class="form-control" placeholder="Nome *"
requerid>
<input id="id_senha" name="senha" type="password"
class="form-control" placeholder="Senha *"
requerid>
<input id="id_telefone" name="telefone" type="text"
class="form-control" placeholder="Telefone">
<input id="id_nome_empresa" name="nome_empresa" type="text"
class="form-control" placeholder="Empresa">
<hr/>
<button class="btn btn-lg btn-primary btn-block" type="submit">
Registrar
</button>
</form>
{% endblock %}