Страница 404 не найдена, текущий путь не совпадает ни с одним из перечисленных
PAGE not found (404)
Метод запроса: ПОЛУЧИТЬ
URL запроса: http://127.0.0.1:8000/action_page.php?steam_uid=12345678912345678&email=example%40gmail.com&username=johndoe&password1=123456&password2=123456
Используя URLconf, определенный в ReadyUp.urls, Django попробовал эти шаблоны URL, в таком порядке:
- [name='home']
- account/
- game/
- group/
- login [name = 'login']
- logout [name = 'logout']
- register/ [name ='register']
- admin/
Текущий путь, action_page.php, не совпал ни с одним из этих путей.
Я не совсем уверен, какой именно url создает проблему, и хотел бы получить помощь. Вот взгляд на урл:
from django.contrib import admin
from django.urls import include, path
from account.views import(
register_view,
login_view,
logout_view,
)
from group.views import (
home_screen_view
)
urlpatterns = [
# Te4m Paths
path('', home_screen_view, name='home'),
path('account/', include('account.urls')),
path('game/', include('games.urls')),
path('group/', include('group.urls')),
path('login/', login_view, name="login"),
path('logout/', logout_view, name="logout"),
path('register/', register_view, name="register"),
# Default paths
path('admin/', admin.site.urls),
]
html/form для файла action_page.php:
register.html:
<form class="modal-content" action="/action_page.php" method ="post">
<div class="container">
<h1>Sign Up</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="steamID"><b>Steam ID</b></label>
<input type="text" placeholder="Enter Steam ID" name= "steam_uid" required>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name= "email" required>
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name= "username" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password1" required>
<label for="psw-repeat"><b>Repeat Password</b></label>
<input type="password" placeholder="Repeat Password" name="password2" required>
<label>
<input type="checkbox" checked="checked" name="remember" style="margin-bottom:15px"> Remember me
</label>
<div class="clearfix">
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
<button type="submit" class="signupbtn">Sign Up</button>
</div>
</div>
</form>
логин:
<form class="modal-content animate" action="/action_page.php" method="post">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<img src="img_avatar2.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="username" required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<button type="submit">Login</button>
</div>
<div class="container" style="background-color:#f1f1f1">
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
<span class="psw">Forgot <a href="#">password?</a></span>
</div>
</form>
account.forms:
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import authenticate
from account.models import account
class RegistrationForm(UserCreationForm):
steam_uid = forms.CharField(max_length=17, help_text="Required. Add a valid id")
email = forms.EmailField(max_length=255, help_text="Required. Add a valid email")
class Meta:
model = account
fields = ('steam_uid', 'email', 'username', 'password1', 'password2')
def clean_email(self):
email = self.cleaned_data['email'].lower()
try:
account = account.objects.get(email=email)
except Exception as e:
return email
raise forms.ValidationError(f"Email {email} is already in use.")
def clean_username(self):
username = self.cleaned_data['username']
try:
account = account.objects.get(username=username)
except Exception as e:
return username
raise forms.ValidationError(f"Username {username} is already in use.")
class AccountAuthenticationForm(forms.ModelForm):
password = forms.CharField(label="Password", widget=forms.PasswordInput)
class Meta:
model = account
fields = ("username", "password")
def clean(self):
if self.is_valid():
username = self.cleaned_data['username']
password = self.cleaned_data['password']
if not authenticate(username=username, password=password):
raise forms.ValidationError("Invalid Login")