0👍
✅
Okay I figured it out, I just need to create the user
in my code first. I just added user = User.objects.create_user('charlie', 'charlesdsmith25@gmail.com', 'smith')
so now it’s:
def sign_in(request):
#we need to handle all the data that was just typed, we'll add a condition for that
form = NameForm(request.POST)
if form.is_valid():
post = form.save()
post.save()
username = request.POST.get('username')
password = request.POST.get('password')
user = User.objects.create_user('charlie', 'charlesdsmith25@gmail.com', 'smith')
auth = authenticate(username=username, password=password)
if user is not None:
login(request,user)
return HttpResponse('hi')
else:
return HttpResponse('bye')
else:
form = NameForm()
return render(request, 'checkin/sign_in_new.html', {'form': form})
👤Amon
1👍
The user doesn’t exist. Go to admin and create one first. And yes user needs to be created before you attempt to sign in.
- What is the most effective way to compare, find and return a large set of mobile numbers while identifying contacts?
- Django 1.8 how to retrieve image file path from the database when using upload_to
- Building an API
- Related objects as separate endpoint (the "edge" model) using Django Rest Framework
- Extracting a nested list with Django and replacing values
Source:stackexchange.com