Page not found (404)
쿼리 결과에 classification가 없습니다.
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/inventory/classification/create_classification/ |
Raised by: | inventory.views.ClassificationDetail |
Using the URLconf defined in SWManagement_prj.urls
, Django tried these URL patterns, in this order:
- customer/
- inventory/ classification/ [name='classification_list']
- inventory/ classification/<str:pk>/ [name='classification_detail']
The current path, inventory/classification/create_classification/
, matched the last one.
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.
다른 앱을 만들 때는 문제가 없었는데 똑같은 방식으로 앱을 만들고 모델, 뷰, 템플릿까지 제대로 만들었다고 생각했는데 문제가 계속 생깁니다. 왜 이런 버그가 발생하는지 이유를 잘 모르겠습니다.
아래는 뷰 소스코드입니다.
class ClassificationCreate(LoginRequiredMixin, UserPassesTestMixin, CreateView):
def test_func(self):
return self.request.user.is_superuser
model = Classification
template_name = 'inventory/classification_form.html'
fields = ['ProductCode', 'ProductType', 'ProductTypeDescription']
login_url = LOGIN_URL
def form_valid(self, form):
current_user = self.request.user
if current_user.is_authenticated and current_user.is_superuser:
return super(ClassificationCreate, self).form_valid(form)
else:
return redirect('inventory/classification/')