2017-10-27 16 views
0

私のDjango Restフレームワークでエラーが発生しました。私はWindows 10 OS上で実行しています。これは全体のエラーです:AttributeError:モジュール 'django.contrib.auth.views'に 'login'という属性がありません

Traceback (most recent call last): 
    File "manage.py", line 15, in <module> 
    execute_from_command_line(sys.argv) 
    File "c:\django\django\django\core\management\__init__.py", line 371, in execute_from_command_line 
    utility.execute() 
    File "c:\django\django\django\core\management\__init__.py", line 365, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "c:\django\django\django\core\management\base.py", line 288, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "c:\django\django\django\core\management\base.py", line 332, in execute 
    self.check() 
    File "c:\django\django\django\core\management\base.py", line 364, in check 
    include_deployment_checks=include_deployment_checks, 
    File "c:\django\django\django\core\management\commands\migrate.py", line 58, in _run_checks 
    issues.extend(super()._run_checks(**kwargs)) 
    File "c:\django\django\django\core\management\base.py", line 351, in _run_checks 
    return checks.run_checks(**kwargs) 
    File "c:\django\django\django\core\checks\registry.py", line 73, in run_checks 
    new_errors = check(app_configs=app_configs) 
    File "c:\django\django\django\core\checks\urls.py", line 13, in check_url_config 
    return check_resolver(resolver) 
    File "c:\django\django\django\core\checks\urls.py", line 23, in check_resolver 
    return check_method() 
    File "c:\django\django\django\urls\resolvers.py", line 385, in check 
    for pattern in self.url_patterns: 
    File "c:\django\django\django\utils\functional.py", line 37, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "c:\django\django\django\urls\resolvers.py", line 524, in url_patterns 
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
    File "c:\django\django\django\utils\functional.py", line 37, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "c:\django\django\django\urls\resolvers.py", line 517, in urlconf_module 
    return import_module(self.urlconf_name) 
    File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 994, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 971, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 665, in _load_unlocked 
    File "<frozen importlib._bootstrap_external>", line 678, in exec_module 
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed 
    File "C:\django\travbudserver\travbudserver\urls.py", line 41, in <module> 
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) 
    File "c:\django\django\django\urls\conf.py", line 34, in include 
    urlconf_module = import_module(urlconf_module) 
    File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 994, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 971, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 665, in _load_unlocked 
    File "<frozen importlib._bootstrap_external>", line 678, in exec_module 
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed 
    File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\rest_framework\urls.py", line 24, in <module> 
    url(r'^login/$', views.login, template_name, name='login'), 
AttributeError: module 'django.contrib.auth.views' has no attribute 'login' 

これは私のurl.py

from django.conf.urls import include, url 
from django.contrib import admin 
from django.urls import path 
from rest_framework import routers, serializers, viewsets 
from polls.models import Question, Choice 

# Serializers define the API representation. 
class QuestionSerializer(serializers.HyperlinkedModelSerializer): 
    class Meta: 
     model = Question 
     fields = ('question_text', 'pub_date') 

# ViewSets define the view behavior. 
class QuestionViewSet(viewsets.ModelViewSet): 
    queryset = Question.objects.all() 
    serializer_class = QuestionSerializer 

# Routers provide an easy way of automatically determining the URL conf. 
router = routers.DefaultRouter() 
router.register(r'question', QuestionViewSet) 

urlpatterns = [ 
    url(r'^', include(router.urls)), 
    url(r'^polls/', include('polls.urls')), 
    path('admin/', admin.site.urls), 
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) 
] 

で誰もが私の状況についての考えを持っているのですか?事前に感謝しています...

答えて

1

Djangoのリリースされていないマスターブランチを使用していますが、これは古い機能ベースのログインビューを削除しています。まだリリースされているバージョン1.11を使用してください(非推奨)。

DRFの最新マスターがこのリファレンスを削除しましたが、とにかくリリース版を使用してください。

関連する問題