12 hours
- Medium
Free online content available in this course.
course.header.alt.is_video
course.header.alt.is_certifying
Got it!Last updated on 3/2/22
Build an Authentication App in Django
Evaluated skills
- Build an authentication app in Django
Question 1
The specification for the
User
model in your project matches that of the defaultUser
model. How should you implement it?Extend the
AbstractBaseUser
model and specify all of the fields that you require. Configure Django to use this model.Extend the
AbstractUser
model and specify all the fields that you require. Configure Django to use this model.Do not extend one of the abstract
User
models and configure Django to use the defaultUser
model.Extend the
AbstractUser
model without specifying any fields. Configure Django to use this model.
Question 2
When should you run your initial migrations when starting a project?
When you first create the project.
After you configure a custom
User
modelIt doesn't matter when you run the migrations.
Question 3
Which of these following login view implementations is correct?
- def login_page(request):form = forms.LoginForm()if request.method == 'POST':form = forms.LoginForm(request.POST)if form.is_valid():user = authenticate(form.cleaned_data['username'], form.cleaned_data['password'])if user is not None:login(request, user)return render(request, 'authentication/login.html', context={'form': form})
- def login_page(request):form = forms.LoginForm()if request.method == 'POST':form = forms.LoginForm(request.POST)if form.is_valid():user = login(form.cleaned_data['username'], form.cleaned_data['password'])if user is not None:authenticate(request, user)return render(request, 'authentication/login.html', context={'form': form})
- def login_page(request):form = forms.LoginForm()if request.method == 'POST':form = forms.LoginForm(request.POST)if form.is_valid():authenticate(form.cleaned_data['username'], form.cleaned_data['password'])return render(request, 'authentication/login.html', context={'form': form})
- def login_page(request):form = forms.LoginForm()if request.method == 'POST':form = forms.LoginForm(request.POST)if form.is_valid():user = authenticate(form.cleaned_data['username'], form.cleaned_data['password'])if not user:login()return render(request, 'authentication/login.html', context={'form': form})
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring