1
1

Вот такая ошибка:

File "C:\Project django\password_generator\password_generator\urls.py", line 24, in <module>
path('about', about.home, name ='about'),
NameError: name 'about' is not defined

URL

from django.contrib import admin
from django.urls import path, include
from generator import views


path('', views.home, name = 'home'), 
path('about', about.home, name ='about'), 
path('password/', views.password),


VIEWS

from django.shortcuts import render
from django.http import	HttpResponse
import random

def home(request):
	return render(request, 'generator/home.html') 

def about(request):
	return render(request, 'generator/about.html') 


def password(request):

	
	characters = list('qwertyuiopasdfghjklzxcvbnm')

	if request.GET.get('uppercase'):
			characters.extend(list('QWERTYUIOPASDFGHJKLZXCVBNM'))		

	if request.GET.get('special'):
			characters.extend(list('!@#$%^&*_+'))
	
	if request.GET.get('numbers'):
			characters.extend(list('1234567890'))


	length = int(request.GET.get('length'))	

	thepassword	= ''

	for x in range(length):
		thepassword += random.choice(characters)

	return render(request, 'generator/password.html', {'password':thepassword} ) 
	

	

student_147MLy8S
2 years ago






Вот код, который должен быть:

from django.urls import path
from generator import views

urlpatterns = [
    path('', views.home, name='home'),
    path('password', views.password, name='password'),
    path('about', views.about, name='about'),
]
Пётр Колосов
2 years ago

Один ответ