0

機能していたビューがいくつかありましたが、新しいビューを追加したため、機能しなくなり、エラーが発生し続けますViewDoesNotExist

トレースバック:

  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 101.request.path_info)

  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve 300.sub_match = pattern.resolve(new_path)

  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve 
209. return ResolverMatch(self.callback, args, kwargs, self.name)

  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in callback  216. self._callback = get_callable(self._callback_str)

  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in wrapper 27.result = func(*args)

  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in get_callable 101.(lookup_view, mod_name))

  Exception Type: ViewDoesNotExist at /login/
  Exception Value: Could not import owners.views.login_request. View does not exist in module owners.views.

私が間違っている可能性があることに関する追加情報/ポインタは役に立ちます。

私の見解

def login_request(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/profile')

    elif request.method == 'POST':
        form = Loginform(request.POST)

        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            site_user = authenticate(username= username,password = password )

            if site_user is not None:
                login(request,site_user)
                return HttpResponseRedirect('/profile')
            else:
               return render_to_response('login.html',{'form':form},context_instance = RequestContext(request))
        else:
            return render_to_response('login.html',{'form':form},context_instance = RequestContext(request))

    else:
        '''user not subinting show loging form'''
        form = Loginform()
        context = {'form': form}
        return render_to_response('login.html',context,context_instance = RequestContext(request))

私のURLは次のようになります

(r'^login/$','owners.views.login_request'),

私は約70ビューを持っていますが、すべてダウンしてしまいました '/'作品だけ

4

2 に答える 2

0

ビュー関数の名前が、URL で渡されたものと同じであることを確認してください。それ以外の場合は、ビュー関数とあなたの URL、はい、すべての URL ファイルを渡してください :)

于 2013-01-22T19:50:30.780 に答える
0

問題は、モデルがあちこちからインポートされたため、モデルが混乱したインポートにあったため、すべてを管理する中央アプリを作成しました。

于 2013-01-29T01:26:21.987 に答える