我的登录应用程序有问题,当我在urls.py中配置注销时,追溯告诉我下一个:
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/management/base.py", line 327, in execute
self.check()
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/dmuino/.virtualenvs/Pruebas/CursoProDjango/eventus/eventus/urls.py", line 23, in <module>
url(r'', include('myapps.users.urls', namespace="users_app")),
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/site-packages/django/conf/urls/__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "/Users/dmuino/.virtualenvs/Pruebas/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/dmuino/.virtualenvs/Pruebas/CursoProDjango/eventus/myapps/users/urls.py", line 2, in <module>
from . import views
File "/Users/dmuino/.virtualenvs/Pruebas/CursoProDjango/eventus/myapps/users/views.py", line 11
if user_register.is_valid():
^
TabError: inconsistent use of tabs and spaces in indentation
我的urls.py是:
from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^', include('myapps.events.urls', namespace="events_app")),
url(r'', include('myapps.users.urls', namespace="users_app")),
url(r'^admin/', admin.site.urls),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我的users / urls.py是:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^login/$', views.UserLogin, name="login"),
url(r'^salir/$', views.LogOut, name = 'logout'),
]
我的users / views.py是:
from django.shortcuts import render
from django.contrib.auth import login, authenticate, logout
from .forms import UserRegisterForm
from .models import User
# Create your views here.
def UserLogin(request):
if request.method == "POST":
if 'register_form' in request.POST:
user_register = UserRegisterForm(request.POST)
if user_register.is_valid():
User.objects.create_user(
username = user_register.cleaned_data['username'],
email = user_register.cleaned_data['email'],
password = user_register.cleaned_data['password'])
LogIn(request, user_register.cleaned_data['username'],
user_register.cleaned_data['password'])
return redirect('/')
if 'login_form' in request.POST:
login_form = LoginForm(request.POST)
if login_form.is_valid():
LogIn(request, login_form.cleaned_data['username'],
login_form.cleaned_data['password'])
return redirect('/')
else:
user_register = UserRegisterForm()
login_form = LoginForm()
return render(request, 'users/login.html',
{'user_register' : user_register,
'login_form' : login_form
})
def LogOut(request):
logout(request)
return redirect('/')
在我配置此注销之前一切正常,但现在我不知道是什么问题,因为我通常不使用Django这是我在Django的第一个应用程序而且我学得很慢,你能帮帮我吗? / p>