Я новичок в django с небольшим знанием концепции django MVT,
мой вопрос о приложении django, я получаю эту глупую ошибку, но я не знаю, как это произошло, я проверял снова и снова все вкод, и все в порядке, но я не знаю, как это не работает.
![Page not found (404)](https://i.stack.imgur.com/Q7Bdy.jpg)
- Имя MyProject: fusion
- Имя моего приложения: django_adminlte
- python 3.7
- django 2.0
- MySql
Моя ошибка:
Page not found (404)
Request Method: POST
Request URL: http://127.0.0.1:8000/emp
Using the URLconf defined in fusion.urls, Django tried these URL patterns, in this order:
admin/
[name='login']
home/ [name='home']
signup/ [name='signup']
employee/ [name='emp']
show/ [name='show']
edit/<int:id>
update/<int:id>
delete/<int:id>
accounts/
The current path, emp, didn't match any of these.
метод emp не перенаправляет на метод отображения
views.py
from django.shortcuts import render,redirect
from django.contrib.auth.forms import UserCreationForm,AuthenticationForm
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django_adminlte.forms import EmployeeForm
from django_adminlte.models import Employee
def emp(request):
if request.method == "POST":
form = EmployeeForm (request.POST) # here "form" is one varible
if form.is_valid():
try:
form.save()
return redirect("/show")
except:
pass
else:
form = EmployeeForm()
return render(request,"employee/employee_index.html",{'form':form})
def show(request):
employees = Employee.objects.all()
return render(request,"employee/show.html",{'employees': employees})
urls.py
from django.conf.urls import url
from django.contrib import admin
from django.urls import path,include
from django_adminlte import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.login,name='login'),
path('home/',views.home,name='home'),
path('signup/',views.signup,name='signup'),
path('employee/',views.emp,name='emp'),
path('show/',views.show,name='show'),
path('edit/<int:id>',views.edit),
path('update/<int:id>',views.update),
path('delete/<int:id>',views.delete),
path('accounts/',include('django.contrib.auth.urls')),
]
HTML
{% extends 'adminlte/base.html' %}
{% block content %}
<!-- Horizontal Form -->
<form method="POST" class="post-form" action="/emp">
{% csrf_token %}
<div class="container">
<br>
<div class="form-group row">
<label class="col-sm-1 col-form-lable"></label>
<div class="col-sm-4">
<h3>Enter Details</h3>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-lable">Employee ID : </label>
<div class="col-sm-4">
{{ form.eid }}
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-lable">Employee Name : </label>
<div class="col-sm-4">
{{ form.ename }}
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-lable">Employee Email : </label>
<div class="col-sm-4">
{{ form.eemail }}
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-lable">Employee Contact :</label>
<div class="col-sm-4">
{{ form.econtact }}
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
Спасибо !!