Author Picture

Kim Majali


Django Reset Password

Author Avatar wrote on 26/05/2022

urls.py

from django.contrib.auth import views as auth_views
Read more

Djano 404 Page

Author Avatar wrote on 26/05/2022

Create page

Create a page 404.html and add it to the template folder

Test it

In the default settings.py file Django sets DEBUG = True and ALLOWED_HOSTS = []. We want to change both. Turning off debug will show us what a live site would show and ALLOWED_HOSTS restricts which HTTP requests Django will respond to so the URL needs to be explicitly added.

# demo_project/settings.py
DEBUG = False
Read more

Django Search Forms & Results Pages

Author Avatar wrote on 26/05/2022

Setting up the Search results template

We make Listing model is our example

1.Create the url

in listings/urls.py

Read more

Django Single Listing, 404, Attributes from Another Table

Author Avatar wrote on 26/05/2022

404

We want to show a 404 page if user type a URL of a non-exisiting listing, for example, we have only 5 listings but the requested URL is listing/10 which does not exist.

in views.py


from django.shortcuts import get_object_or_404, render
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from .models import Listing
Read more

Django Bringing Data from a Model to Another Model

Author Avatar wrote on 26/05/2022

Assuming that we need to bring listings from the listings model and show it on the home page which is a part of another model pagesRead more

Topics: AppsTemplates

Django.How Python Django Development Guide and Resources, Basics, Admin, DB Handling, Views & Templates, Apps, Resources

© Copyright 2024. All Rights Reserved, Django.How Built with love in Ukraine 🇺🇦 by Kim Majali, & EITO team