我正在尝试根据用户的架构名称将用户重定向到各种应用程序。到目前为止我已经写过这个:
def loginUser(request, url):
schema_list1 = ['pierre']
schema_lsit2 = ['itoiz']
if request.method == 'POST':
form = AuthenticationForm(data=request.POST)
t = urlparse(url).netloc
dbschema = '"' + t.split('.', 1)[0] + '"'
if form.is_valid():
user = form.get_user()
login(request, user)
if dbschema in schema_list1:
print('yes')
redirect = '/upload.html'
return HttpResponseRedirect(redirect)
elif dbschema in schema_list2:
print('yes')
redirect = '/dash2.html'
return HttpResponseRedirect(redirect)
else:
form = AuthenticationForm()
context = {
'form': form,
}
return render(request, 'loginUser.html', context)
我的问题是我收到错误:
TypeError at /loginUser
loginUser() missing 1 required positional argument: 'url'
Request Method: GET
Request URL: https://itoiz.exostock.net/loginUser
Django Version: 3.0.5
Exception Type: TypeError
Exception Value:
loginUser() missing 1 required positional argument: 'url'
Exception Location: /home/ubuntu/exo/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response, line 113
我对 django 相当陌生,我很困惑为什么会收到此错误,特别是因为我在其他地方使用了完全相同的方法并且效果很好。我想知道是否有人能看到我所缺少的东西。顺便问一下,还有其他方法获取用户的网址吗?
慕盖茨4494581
慕姐8265434
相关分类