P
P
Pkashnichek2019-12-08 10:27:48
Django
Pkashnichek, 2019-12-08 10:27:48

Django: TypeError: 'DeclarativeFieldsMetaclass' object is not iterable. How to solve the problem?

I enter into the console

py manage.py makemigrations
and throws an error
Django: TypeError: 'DeclarativeFieldsMetaclass' object is not iterable.

forms.py
from django import forms

class Accounts(forms.Form):
    email = forms.EmailField(max_length=100)
    password = forms.CharField(max_length=100)

views.py
from django.shortcuts import render
from enter.forms import Accounts

def entering(request):
  if request.method == 'POST':
    email = request.POST['emails']
    passw = request.POST['passwords']
    form = Accounts(email=email, password=passw)
    if form.is_valid():
      form.save()
  else:
    form = Accounts()
  return render(request, 'enter/enter.html', {'datas': datas})

How can this problem be solved?
The same is true when starting the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-12-08
@Pkashnichek

You need to read the documentation and understand that instead of

email = request.POST['emails']
passw = request.POST['passwords']
form = Accounts(email=email, password=passw)

should be
form = Accounts(request.POST)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question