Я получаю эту ошибку, когда мой SignUp View возвращает функцию reverse_lazy:
AttributeError at /signup/
'__proxy__' object has no attribute 'get'
My view:
class SignUpView(View):
def get(self, request, *args, **kwargs):
return render(request, 'accounts/signup.html', context = {'form':UserCreateForm})
def post(self, request, *args, **kwargs):
print(f'request: {request.POST}')
form = UserCreateForm(request.POST)
if form.is_valid():
user = form.save(commit = False)
user.username = request.POST.get('email')
user.save()
return reverse_lazy('homePage')
Форма:
class UserCreateForm(UserCreationForm):
class Meta():
fields = ('first_name', 'last_name', 'email', 'departments', 'password1', 'password2')
model = get_user_model()
User модель:
class User(AbstractUser):
departments = models.ManyToManyField(Department)
def __str__(self):
return f'{self.first_name} {self.last_name}'
Что вызывает ошибку?
Редактировать - (Отслеживание ошибки)
Environment:
Request Method: POST
Request URL: http://localhost:8000/signup/
Django Version: 3.0.6
Python Version: 3.7.7
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts',
'counts']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "C:\Users\Ricardo\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Ricardo\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\deprecation.py", line 96, in __call__
response = self.process_response(request, response)
File "C:\Users\Ricardo\AppData\Local\Programs\Python\Python37\lib\site-packages\django\middleware\clickjacking.py", line 26, in process_response
if response.get('X-Frame-Options') is not None:
Exception Type: AttributeError at /signup/
Exception Value: '__proxy__' object has no attribute 'get'
Я просто набираю текст, чтобы разбить «Это похоже, что ваше сообщение состоит в основном из кода; пожалуйста, добавьте дополнительные сведения ". правило