Я делаю регистрационную форму в django. Я следовал Настройка поддоменов для арендаторов в примере Django веб-приложения? , но я получаю следующую ошибку.
Traceback (most recent call last):
File "/Users/pierre/Desktop/Django-app/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/Users/pierre/Desktop/Django-app/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/pierre/Desktop/Django-app/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
TypeError: __init__() takes 1 positional argument but 2 were given
Прошли часы, и я не могу понять, откуда это взялось. Я надеюсь, что пара свободных sh (и более опытных) глаз увидит мою ошибку.
Вот файлы, с которыми я работаю: models.py
class Client(TenantMixin):
name = models.CharField(max_length=100, default='')
email = models.EmailField(default='')
company = models.CharField(max_length=100, default='')
password = models.CharField(max_length=100, default='')
paid_until = models.DateField()
on_trial = models.BooleanField()
created_on = models.DateField(auto_now_add=True)
#
class Domain(DomainMixin):
pass
forms.py
class NewClientForm(forms.ModelForm):
name = forms.CharField(max_length=100)
email = forms.EmailField(max_length=100)
company = forms.CharField(max_length=100)
password = forms.CharField(widget = forms.PasswordInput)
def clean(self):
email = self.cleaned_data.get('email')
company = self.clean_date.get('company')
email_qs = Client.objects.filter(email=email)
if email_qs.exists():
raise forms.ValidationError(
"this email is already being used"
)
company_qs = Client.objects.filter(company=company)
if company_qs.exists():
raise forms.ValidationError(
'this company name is already identified in our system'
)
return email, company
view.py
class SignupView(View):
def get(self, request):
form = NewClientForm()
return render(request, "register.html", {'form': form})
def post(self, request,*args, **kwargs):
form = NewClientForm(request.POST or None)
if form.is_valid():
instance = form.save(commit=False)
tenant = Client(domain_url='company' + ".inventory4.com", schema_name='company', name= 'name')
tenant.save()
with schema_context(tenant.schema_name):
instance.save()
redirect = 'http://' + 'company' + '.inventory4.com:8000/login'
return HttpResponseRedirect(redirect)
return render(request, "register.html", {'form' : form})
Любая помощь будет принята с благодарностью!