Undefined Path In Django - django
I am working on a django application and everything is working fine except I am getting an error Not Found: /about-us/undefined when I visit the url 127.0.0.1:8000/about-us/
With a view as below the error is not showing:
def about_us(request):
if request.method == 'GET':
return HttpResponse('<h1>About Page</h1>')
But when I render an HTML template as shown below then the error shows
def home(request):
if request.method == 'GET':
return render(request, 'website_files/index.html', {'home' : True})
website.urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name="home"),
path('about-us/', views.about_us, name="about-us"),
path('why_us/', views.why_us, name="why_us"),
path('out_team/', views.out_team, name="out_team"),
path('it_solutions/', views.it_solutions, name="it_solutions"),
path('it_solutions/it_management_services', views.it_management_services, name="it_management_services"),
path('it_solutions/cyber_security_services', views.cyber_security_services, name="cyber_security_services"),
path('it_solutions/software_dev_services', views.software_dev_services, name="software_dev_services"),
path('it_solutions/networking_and_cloud_services', views.networking_services, name="networking_and_cloud_services"),
path('it_solutions/it_consultations', views.consulting_services, name="it_consultations"),
path('it_solutions/data_backup_and_recovery', views.backup_services, name="data_backup_and_recovery"),
path('it_solutions/email_hosting', views.email_hosting, name="email_hosting"),
path('it_solutions/web_hosting', views.web_hosting, name="web_hosting"),
path('stories', views.blogging, name="stories"),
path('contact_us', views.contact, name="contact_us"),
path('find_out', views.find_out, name="find_out"),
path('request_quote', views.get_quote, name="request_quote"),
]
main urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# path('admin/', admin.site.urls),
path('', include('website.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
What am I missing? You assistance will greatly appriciated.
Edit
Below is the index.html
index.html
{% extends 'website_files/base.html' %}
{% load static %}
{% block content %}
<section class="slider">
<div class="slick-carousel carousel-arrows-light carousel-dots-light m-slides-0"
data-slick='{"slidesToShow": 1, "arrows": true, "dots": true, "speed": 700,"fade": true,"cssEase": "linear"}'>
<div class="slide-item align-v-h bg-overlay">
<div class="bg-img"><img src="{% static 'assets/images/sliders/Top-6-Software-Development-Methodologies.jpg' %}" alt="slide img"></div>
<div class="container">
<div class="row align-items-center">
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-7">
<div class="slide-item__content">
<h2 class="slide-item__title">Latest Software To Your Possible Customers!!</h2>
<p class="slide-item__desc">We are experienced professionals who understand that IT services are
changing, and are true partners who care about your success.</p>
Get Started
</div>
</div>
</div>
</div>
</div>
<div class="slide-item align-v-h bg-overlay">
<div class="bg-img"><img src="{% static 'assets/images/sliders/Online-Presence.jpg' %}" alt="slide img"></div>
<div class="container">
<div class="row align-items-center">
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-7">
<div class="slide-item__content">
<h2 class="slide-item__title">Online Presence <br> To Ensure High Availability.</h2>
<p class="slide-item__desc">We understand the importance of having an online presence. We are therefore, strive to help you have a digital footprint</p>
Get Started
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="features-layout3 pt-0 pb-90 bg-gray">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-8">
<div class="row features-wrapper">
<div class="col-sm-4 feature-item">
<h4 class="feature-item__title">Software Asset</h4>
<p class="feature-item__desc">All aspects of your software assets including development, purchasing, deployment &
maintenance.</p>
<i class="icon-arrow-right icon-outlined"></i>
</div>
<div class="col-sm-4 feature-item">
<h4 class="feature-item__title">Enterprise Services</h4>
<p class="feature-item__desc">Ranging from but not limited to IT Counsultation, Software Development, Email Hosting etc.</p>
<i class="icon-arrow-right icon-outlined"></i>
</div>
<div class="col-sm-4 feature-item">
<h4 class="feature-item__title">Custom Requests</h4>
<p class="feature-item__desc">We build bespoke and dynamic systems with associated workflows, and tasks.</p>
<i class="icon-arrow-right icon-outlined"></i>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-4">
<div class="feature-item feature-item-custom bg-primary">
<h4 class="feature-item__title">Thinking insights, verified and realtime information help you
make the right decisions!
</h4>
<a href="{% url 'it_solutions' %}" class="btn btn__white btn__link">
<span>Find Your Solution</span><i class="icon-arrow-right icon-outlined"></i>
</a>
</div>
</div>
</div>
</div>
</section>
<section class="about-layout6 bg-gray pt-0 pb-0">
<div class="container">
<div class="row heading-layout2 mb-70">
<div class="col-12">
<h2 class="heading__subtitle color-body">Nationwide Service, Local Expertise</h2>
</div>
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-7">
<h3 class="heading__title mb-30">Keep your business safe & ensure high availability.</h3>
</div>
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-5 about__Text">
<h5 class=" mb-30">Message from our Founder.</h5>
<p>Here at <b>TechTitan</b>, we strive to help you improve efficiency, leverage tech, and provide better customer experiences with the modern technology
services available all over the world. Our skilled personnel, utilising the latest technologies
combined with decades of experience will help you and your business archieve the standard that you strive for and give you a competitive advantage over your peers</p>
<!-- <img src="{% static 'assets/images/about/Isaac.jpg' %}" alt="singnture" class="mb-20"> -->
</div>
</div>
</div>
<div class="image-wrapper bg-white">
<div class="container">
<div class="row align-items-end">
<div class="col-sm-12 col-md-12 col-lg-7">
<div class="about__img">
<img src="{% static 'assets/images/about/IMG_0752.jpg' %}" alt="about">
</div>
</div>
<!-- <div class="col-sm-12 col-md-12 col-lg-5">
<ul class="list-items list-unstyled mb-30" style="margin-top: -500px;">
<li> Continued support to our clients</li>
<li> Provided the best solutions that your need</li>
<li> Ensuring that you are moving with the changing worldmwith our updates</li>
</ul>
<a href="{% url 'about-us' %}" class="btn btn__primary btn__icon btn__xl">
<span>More About Us</span><i class="icon-arrow-right"></i>
</a>
</div> -->
</div>
</div>
</div>
</section>
<section class="services-layout2 services-masonry bg-no-repeat bg-size-auto bg-top-right pt-130 pb-90">
<div class="bg-img"><img src="{% static 'assets/images/backgrounds/6.png' %}" alt="background"></div>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6 offset-lg-3">
<div class="heading heading-layout2 text-center mb-50">
<h2 class="heading__subtitle">Only settle for the best</h2>
<h3 class="heading__title">Our technology allows you to offer the best service to your possible
customers!
</h3>
</div>
</div>
</div>
<div class="row services-wrapper">
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="service-item">
<div class="service-item__content">
<div class="service-item__icon">
<i class="icon-server"></i>
</div>
<h4 class="service-item__title">IT Management <br> Services</h4>
<p class="service-item__desc">IT management services that manages and oversees the IT infrastructure of your
organization responsible for networking and operations.</p>
<a href="{% url 'it_management_services' %}" class="btn btn__secondary btn__link">
<span>Read More</span>
<i class="icon-arrow-right"></i>
</a>
</div>
<div class="service-item__overlay bg-overlay bg-overlay-primary">
<div class="bg-img"><img src="{% static 'assets/images/services/1.jpg' %}" alt="background"></div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="service-item">
<div class="service-item__content">
<div class="service-item__icon">
<i class="icon-cloud"></i>
</div>
<h4 class="service-item__title">Cyber Security<br> Services</h4>
<p class="service-item__desc">Drive your business and manage risk with us when it comes
cyber security, cloud, and manage security services and extend your team with leading experts.</p>
<a href="{% url 'cyber_security_services' %}" class="btn btn__secondary btn__link">
<span>Read More</span>
<i class="icon-arrow-right"></i>
</a>
</div>
<div class="service-item__overlay bg-overlay bg-overlay-primary">
<div class="bg-img"><img src="{% static 'assets/images/services/2.jpg' %}" alt="background"></div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="service-item">
<div class="service-item__content">
<div class="service-item__icon">
<i class="icon-programming"></i>
</div>
<h4 class="service-item__title">Software Development<br> Services</h4>
<p class="service-item__desc">We develop solutions that help you make informed decisions that keep your business going forward especially with rapid changes we face on a daily basis.</p>
<a href="{% url 'software_dev_services' %}" class="btn btn__secondary btn__link">
<span>Read More</span>
<i class="icon-arrow-right"></i>
</a>
</div>
<div class="service-item__overlay bg-overlay bg-overlay-primary">
<div class="bg-img"><img src="{% static 'assets/images/services/5.jpg' %}" alt="background"></div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="service-item">
<div class="service-item__content">
<div class="service-item__icon">
<i class="icon-network"></i>
</div>
<h4 class="service-item__title">Networking and Cloud Computing<br> Services</h4>
<p class="service-item__desc">Cloud computing is the on-demand, availability of computer system
resources, especially data storage and computing power, without direct active management by the user.
</p>
<a href="{% url 'networking_and_cloud_services' %}" class="btn btn__secondary btn__link">
<span>Read More</span>
<i class="icon-arrow-right"></i>
</a>
</div>
<div class="service-item__overlay bg-overlay bg-overlay-primary">
<div class="bg-img"><img src="{% static 'assets/images/services/3.jpg' %}" alt="background"></div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="service-item">
<div class="service-item__content">
<div class="service-item__icon">
<i class="icon-technician"></i>
</div>
<h4 class="service-item__title">IT Consulting <br> Services</h4>
<p class="service-item__desc">Trying to implement new technologies can be a challenge. With us on you side, we will give you information on the current technologies to ensure you have the best technologies possible.</p>
<a href="{% url 'it_consultations' %}" class="btn btn__secondary btn__link">
<span>Read More</span>
<i class="icon-arrow-right"></i>
</a>
</div>
<div class="service-item__overlay bg-overlay bg-overlay-primary">
<div class="bg-img"><img src="{% static 'assets/images/services/4.jpg' %}" alt="background"></div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="service-item">
<div class="service-item__content">
<div class="service-item__icon">
<i class="icon-file"></i>
</div>
<h4 class="service-item__title">Backup & Recovery<br> Services</h4>
<p class="service-item__desc">While you can’t predict unexpected events, we’ll ensure the right
precautions are in place to minimize downtime and keep you moving in the right direction.</p>
<a href="{% url 'data_backup_and_recovery' %}" class="btn btn__secondary btn__link">
<span>Read More</span>
<i class="icon-arrow-right"></i>
</a>
</div>
<div class="service-item__overlay bg-overlay bg-overlay-primary">
<div class="bg-img"><img src="{% static 'assets/images/services/6.jpg' %}" alt="background"></div>
</div>
</div>
</div>
</div>
<div class="row align-items-center">
<div class="col-sm-12 col-md-12 col-lg-5">
<p class="fz-16 my-4">Trusted by multiple organizations, for 5 years and running, it has been
delivering
smiles to hundreds of IT advisors, developers, users, and business owners.
</p>
</div>
<div class="col-sm-12 col-md-12 col-lg-7 d-flex align-items-center justify-content-end">
Find Your Solution
</div>
</div>
</div>
</section>
<section id="features" class="features-layout1 pt-130 pb-220">
<div class="bg-img"><img src="{% static 'assets/images/backgrounds/10.jpg' %}" alt="background"></div>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
<div class="heading heading-layout2 mb-40">
<h2 class="heading__subtitle color-body">Ensure High Availability of Your Services</h2>
<h3 class="heading__title color-white">Easy solutions for all difficult IT problems, keep businesses safe &
ensure high availability.</h3>
</div>
<a href="{% url 'contact_us' %}" class="btn btn__white btn__bordered btn__xl btn__icon minwidth-170">
<span>Get Started</span>
<i class="icon-arrow-right"></i>
</a>
</div>
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
<div class="row features-wrapper mt-40">
<div class="col-sm-6 feature-item">
<div class="feature-item__icon">
<i class="icon-statistic"></i>
</div>
<div class="d-flex align-items-center justify-content-between">
<h4 class="feature-item__title mb-0">Software Development</h4>
<i class="icon-arrow-right icon-outlined"></i>
</div>
</div>
<div class="col-sm-6 feature-item">
<div class="feature-item__icon">
<i class="icon-management"></i>
</div>
<div class="d-flex align-items-center justify-content-between">
<h4 class="feature-item__title mb-0">IT Counsultation</h4>
<i class="icon-arrow-right icon-outlined"></i>
</div>
</div>
<div class="col-sm-6 feature-item">
<div class="feature-item__icon">
<i class="icon-software"></i>
</div>
<div class="d-flex align-items-center justify-content-between">
<h4 class="feature-item__title mb-0">Email Hosting</h4>
<i class="icon-arrow-right icon-outlined"></i>
</div>
</div>
<div class="col-sm-6 feature-item">
<div class="feature-item__icon">
<i class="icon-relational"></i>
</div>
<div class="d-flex align-items-center justify-content-between">
<h4 class="feature-item__title mb-0">Website Hosting</h4>
<i class="icon-arrow-right icon-outlined"></i>
</div>
</div>
</div>
<div class="row mt-50 contact-text">
<div class="col-sm-9 px-0">
<strong class="color-white">If you have any questions or need help, feel free to contact with our team,
or call
(+260) 966477311</strong>
</div>
<div class="col-sm-3 px-0 d-flex justify-content-end">
Contact Us
</div>
</div>
</div>
</div>
</div>
</section>
<div class="bg-no-repeat bg-top">
<div class="bg-img"><img src="{% static 'assets/images/backgrounds/11.jpg' %}" alt="backgrounds"></div>
<section id="contact" class="contact-layout2 pt-0">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="contact-panel d-flex flex-wrap mt--170">
<div class="contact-panel__banner bg-overlay bg-overlay-primary d-flex flex-column justify-content-between" style="background-color:red">
<div class="bg-img"><img src="{% static 'assets/images/banners/6.jpg' %}" alt="background"></div>
<div class="heading heading-layout2 heading-light">
<h3 class="heading__title mb-30">Perfect Solutions For Your Business!</h3>
<p class="heading__desc mb-30">TechTitan has been helping organizations throughout the World to manage
their IT with our unique approach to technology management and consultancy solutions. </p>
</div>
<div class="d-flex flex-wrap">
<a href="{% url 'contact_us' %}" class="btn btn__white btn__bordered btn__icon">
<span>Get Started</span><i class="icon-arrow-right"></i>
</a>
</div>
</div>
<form class="contact-panel__form" method="post" action="{% url 'find_out' %}" id="contactForm">
<div class="row">
<div class="col-sm-6 col-md-6 col-lg-6">
<div class="form-group">
<label for="contact-name">Name (required)</label>
<input type="text" required class="form-control" placeholder="Name" id="contact-name" name="contact-name"
required>
</div>
</div>
<div class="col-sm-6 col-md-6 col-lg-6">
<div class="form-group">
<label for="contact-email">Email (required)</label>
<input type="email" required class="form-control" placeholder="Email" id="contact-email"
name="contact-email" required>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="form-group">
<label for="contact-Phone">Inquiry (required)</label>
<select required class="form-control">
<option value="">Select Service</option>
<option value="Email Hosting">IT Management</option>
<option value="IT Counsultation">Cyber Security</option>
<option value="Software Development">Software Development</option>
<option value="Website Developemnt">Networking And Cloud Computing</option>
<option value="Website Developemnt">IT Consulting</option>
<option value="Website Developemnt">Backup & Recovery</option>
<option value="Website Developemnt">Email Hosting</option>
<option value="Website Developemnt">Website Hosting</option>
</select>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="form-group">
<label for="contact-message">Additional Details (required)</label>
<textarea required class="form-control" placeholder="Describe your inquiry!" id="contact-message"
name="contact-message"></textarea>
</div>
<button type="submit" class="btn btn__secondary btn__xl btn__block">Submit Request </button>
<div class="contact-result"></div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
<section class="clients border-top pt-50 pb-50">
<div class="container">
<div class="row align-items-center">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="slick-carousel"
data-slick='{"slidesToShow": 6, "arrows": false, "dots": false, "autoplay": true,"autoplaySpeed": 2000, "infinite": true, "responsive": [ {"breakpoint": 992, "settings": {"slidesToShow": 4}}, {"breakpoint": 767, "settings": {"slidesToShow": 3}}, {"breakpoint": 480, "settings": {"slidesToShow": 2}}]}'>
<div class="client">
<img src="{% static 'assets/images/clients/1.jpg' %}" alt="client">
<img src="{% static 'assets/images/clients/1.jpg' %}" alt="client">
</div>
<div class="client">
<img src="{% static 'assets/images/clients/Techmasters.png' %}" alt="client">
<img src="{% static 'assets/images/clients/Techmasters.png' %}" alt="client">
</div>
<div class="client">
<img src="{% static 'assets/images/clients/idsp.jpg' %}" alt="client">
<img src="{% static 'assets/images/clients/idsp.jpg' %}" alt="client">
</div>
<div class="client">
<img src="{% static 'assets/images/clients/4.png' %}" alt="client">
<img src="{% static 'assets/images/clients/4.png' %}" alt="client">
</div>
<div class="client">
<img src="{% static 'assets/images/clients/5.png' %}" alt="client">
<img src="{% static 'assets/images/clients/5.png' %}" alt="client">
</div>
<div class="client">
<img src="{% static 'assets/images/clients/6.png' %}" alt="client">
<img src="{% static 'assets/images/clients/6.png' %}" alt="client">
</div>
<div class="client">
<img src="{% static 'assets/images/clients/7.png' %}" alt="client">
<img src="{% static 'assets/images/clients/7.png' %}" alt="client">
</div>
</div>
</div>
</div>
</div>
</section>
<section class="banner-layout2 pt-0 pb-100">
<div class="bg-img"><img src="{% static 'assets/images/backgrounds/brickred.svg' %}" alt="background"></div>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-5">
<div class="banner-text">
<div class="heading-layout2 heading-light mb-40">
<h3 class="heading__title mb-30">Timely service delivery!!</h3>
<p class="heading__desc">We ensure that the services we offer are delivered when they are scheduled for. No delays because we understand that your business as to go forward at all times.
</p>
</div>
Get Started
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-7">
<div class="banner-img">
<img src="{% static 'assets/images/logo/TechTitan_Logo_1.jpg' %}" alt="banner">
</div>
</div>
</div>
</div>
</section>
{% endblock %}
Related
Adding a range price filter
I'm trying to add a range price filter for a list of products with django and I'm having some trouble with how to proceed Here's the code for the template : ( produits.html ) {% load static %} <!DOCTYPE html> <html lang="en"> <head> <script type="text/javascript"> var user = '{{request.user}}' function getToken(name) { var cookieValue = null; if (document.cookie && document.cookie !== '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i].trim(); if (cookie.substring(0, name.length + 1) === (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } var csrftoken = getToken('csrftoken'); </script> </head> <body> {% block content %} <div class="bg-light py-3"> <div class="container"> <div class="row"> <div class="col-md-12 mb-0">Home <span class="mx-2 mb-0">/</span> <strong class="text-black">Shop</strong></div> </div> </div> </div> <div class="site-section"> <div class="container"> <div class="row mb-5"> <div class="col-md-9 order-2"> <ul class="nav nav-pills flex-column mb-md-3"> <li class="nav-item"> <div class="nav-link active">Les Produits :</div> </li> </ul> <div class="row mb-5"> {% for item in prod %} <div class="col-sm-6 col-lg-4 mb-4" data-aos="fade-up"> <div class="block-4 text-center border"> <figure class="block-4-image"> <img src="{{item.imageURL}}" alt="Image placeholder" class="img-fluid"> </figure> <div class="block-4-text p-4"> <p class="text-primary font-weight-bold">{{item.nom}}</p> <p class="mb-0">{{item.description}}</p> <p class="text-primary font-weight-bold">{{item.prix}}</p> <button data-product="{{item.id}}" data-action="add" class="btn btn-outline-secondary add-btn update-cart"> Add to Cart</button> View </div> </div> </div> {% endfor %} </div> <div class="row" data-aos="fade-up"> <div class="col-md-12 text-center"> <div class="site-block-27"> </div> </div> </div> </div> <div class="col-md-3 order-1 mb-5 mb-md-0"> <div class="border p-4 rounded mb-4"> <h3 class="mb-3 h6 text-uppercase text-black d-block">Categories</h3> <ul class="list-unstyled mb-0"> {% for i in categ %} <li class="mb-1"><span>{{i.nom}}</span> <span class="text-black ml-auto">{{nb}}</span></li> {% endfor %} </ul> </div> <div class="border p-4 rounded mb-4"> <div class="mb-4"> <h3 class="mb-3 h6 text-uppercase text-black d-block">Filter by Price</h3> <div id="slider-range" class="border-primary"></div> <input type="text" name="PRICE" id="amount" class="form-control border-0 pl-0 bg-white" disabled="" /> </div> <div class="mb-4"> <h3 class="mb-3 h6 text-uppercase text-black d-block">Size</h3> <label for="s_sm" class="d-flex"> <input type="checkbox" id="s_sm" class="mr-2 mt-1"> <span class="text-black">Small (2,319)</span> </label> <label for="s_md" class="d-flex"> <input type="checkbox" id="s_md" class="mr-2 mt-1"> <span class="text-black">Medium (1,282)</span> </label> <label for="s_lg" class="d-flex"> <input type="checkbox" id="s_lg" class="mr-2 mt-1"> <span class="text-black">Large (1,392)</span> </label> </div> <div class="mb-4"> <h3 class="mb-3 h6 text-uppercase text-black d-block">Color</h3> <a href="#" class="d-flex color-item align-items-center" > <span class="bg-danger color d-inline-block rounded-circle mr-2"></span> <span class="text-black">Red (2,429)</span> </a> <a href="#" class="d-flex color-item align-items-center" > <span class="bg-success color d-inline-block rounded-circle mr-2"></span> <span class="text-black">Green (2,298)</span> </a> <a href="#" class="d-flex color-item align-items-center" > <span class="bg-info color d-inline-block rounded-circle mr-2"></span> <span class="text-black">Blue (1,075)</span> </a> <a href="#" class="d-flex color-item align-items-center" > <span class="bg-primary color d-inline-block rounded-circle mr-2"></span> <span class="text-black">Purple (1,075)</span> </a> </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="site-section site-blocks-2"> <div class="row justify-content-center text-center mb-5"> <div class="col-md-7 site-section-heading pt-4"> <h2>Categories</h2> </div> </div> <div class="row"> <div class="col-sm-6 col-md-6 col-lg-4 mb-4 mb-lg-0" data-aos="fade" data-aos-delay=""> <a class="block-2-item" href="#"> <figure class="image"> <img src="{%static 'images/women.jpg' %}" alt="" class="img-fluid"> </figure> <div class="text"> <span class="text-uppercase">Collections</span> <h3>Women</h3> </div> </a> </div> <div class="col-sm-6 col-md-6 col-lg-4 mb-5 mb-lg-0" data-aos="fade" data-aos-delay="100"> <a class="block-2-item" href="#"> <figure class="image"> <img src="{%static 'images/children.jpg' %}" alt="" class="img-fluid"> </figure> <div class="text"> <span class="text-uppercase">Collections</span> <h3>Children</h3> </div> </a> </div> <div class="col-sm-6 col-md-6 col-lg-4 mb-5 mb-lg-0" data-aos="fade" data-aos-delay="200"> <a class="block-2-item" href="#"> <figure class="image"> <img src="{%static 'images/men.jpg' %}" alt="" class="img-fluid"> </figure> <div class="text"> <span class="text-uppercase">Collections</span> <h3>Men</h3> </div> </a> </div> </div> </div> </div> </div> </div> </div> <script src="{%static 'js/cart.js' %}"></script> {% endblock content %} </body> </html> Here's the model code for products : class Product(models.Model): nom = models.CharField(max_length=200,null= True, blank=True) prix = models.DecimalField(max_digits=7,decimal_places=2,null=True,blank=True) description = models.TextField(null=True,blank=True) nbr_stock = models.IntegerField(null=True,blank=True,default=0) image= models.ImageField(null=True,blank=True) taille= models.CharField(max_length=5,null=True,blank=True) categorie=models.CharField(max_length=200,null= True, blank=True) #property def imageURL(self): try : url = self.image.url except : url = '' return url def __str__(self): return self.nom My question is how can I "retrieve" the value from the range slider and then show the products according to the price? thank you in advance
Count divs with specific class name and add filtering functionality (List.js)
I'm trying to implement a "Count No. of Entries" and "Filtering" functionality to my List.js list, like in this example: Codepen. But in this implementation the list item data is part of the JS file itself and not of the HTML (what I would like to have). So I'm having problems "translating" this JS code for my list. What would I need to write in the JS file? Cf. Codepen Could you please help? 🙏 <div class="container"> <div class="row"> <div class="col-md-12"> <p>Total Number:<span class="count"></span></p> </div> </div> </div> <div id="users"> <div class="container"> <div class="row"> <div class="col-md-12"> <input class="search form-control" placeholder="Search" /> <button class="sort btn btn-primary" data-sort="name"> Sort by name </button> <button class="sort btn btn-primary" data-sort="title"> Sort by title </button> <div class="tags"> <div>Filter by:</div> <div class="tag filter" data-filter="Baseball">Baseball </div> <div class="tag filter" data-filter="Kitties">Kitties </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="list-group list"> <a href="#" class="list-group-item"> <div class="col-md-10"> <h4 class="list-group-item-heading name">Alex</h4> <p class="list-group-item-text title">Leader</p> </div> <div class="col-md-2"> <div class="expertise"> <span class="expertise-label">Tags </span> <p class="labels"> <span class="label label-default expertise">Baseball</span> </p> </div> </div> <div class="clearfix"></div> <a href="#" class="list-group-item"> <div class="col-md-10"> <h4 class="list-group-item-heading name">Dennis</h4> <p class="list-group-item-text title">Super Leader</p> </div> <div class="col-md-2"> <div class="expertise"> <span class="expertise-label">Tags </span> <p class="labels"> <span class="label label-default expertise">Kitties</span> </p> </div> </div> <div class="clearfix"></div> </a> </div> </div> </div> </div> </div>
Not able to load template that has been extended in Django
The django 'extends' template is not loading the content. In this I am trying to extend index.html to homepage.html. Both the files are under the same templates directory. The code snippets are shown below: index.html <!DOCTYPE html> {% load static %} <html lang="en"> <head> <meta charset="UTF-8"> <title> Tashi eComm</title> <!-- adding title icon --> <link rel = "icon" href ="{% static 'images/TecommLogo.png' %}" type = "image/x-icon"> <!-- Bootstrap 5 link --> <link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous"> <!-- Bootstrap 5 popper and javascript link --> <script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.3/dist/umd/popper.min.js" integrity="sha384-W8fXfP3gkOKtndU4JGtKDvXbO53Wy8SZCQHczT5FMiiqmQfUpWbYdTil/SxwZgAN" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/js/bootstrap.min.js" integrity="sha384-skAcpIdS7UcVUC05LJ9Dxay8AXcDYfBJqt1CJ85S/CFujBsIzCIv+l9liuYLaMQ/" crossorigin="anonymous"></script> <!--Bootstrap icons--> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.5.0/font/bootstrap-icons.css"> <!-- stylesheet --> <link rel="stylesheet" type="text/css" href="{% static 'css/stylesheet.css' %}"/> </head> <body> <div class="wrapper"> <div class="panel panel-default"> <div class="panel-heading"> <div class="d-flex justify-content-end "> <div class="top-header m-2 "> Marketplace </div> <div class="top-header m-2 ">|</div> <div class="top-header m-2"> Buyer Protection </div> <div class="top-header m-2 ">|</div> <div class="top-header m-2"> Track Order </div> <div class="top-header m-2 ">|</div> <div class="top-header m-2"> <div class="form-group"> <select id="demo_overview_minimal" class="select-picker" data-role="select-dropdown" data-profile="minimal"> <!-- options --> <option>BTN</option> <option>USD</option> <option>EUR</option> </select> </div> </div> </div> </div> <div class="panel-body"> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <div class="container-fluid"> <a class="navbar-brand ms-5" href="#"><img src="{% static 'images/TecommLogo.png' %}" alt="Logo" height="60px" width="60px"></a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarTogglerDemo01"> <ul class="navbar-nav ms-auto mb-2 mb-lg-0"> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Shop by Category </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li><hr class="dropdown-divider"></li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> </ul> <form class="d-flex Search col-5"> <input class="form-control me-auto col-8" type="search" placeholder="Search for anything" aria-label="Search"> <button class="btn btn-outline-success" type="submit">Search</button> </form> <ul class="navbar-nav ms-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> </div> </div> </nav> </div> </div> {% block content %} {% endblock content%} <footer> <div class="panel panel-default"> <div class="panel-footer bg-light "> <div class="row ms-5 me-5"> <div class="col-sm-3"> <div class="row"> <h3>Policies</h3> </div> <div class="row"> Privacy Policies </div> <div class="row"> Refund Policies </div> <div class="row"> Terms & Conditions </div> </div> <div class="col-sm-3"> <div class="row"> <h3>Vendor</h3> </div> <div class="row"> Start Selling </div> <div class="row"> Learn to Sell </div> </div> <div class="col-sm-3"> <div class="row"> <h3>Connect With Us</h3> </div> <div class="row"> <i class="bi bi-facebook"></i>Facebook </div> <div class="row"> <i class="bi bi-twitter"></i>Twiiter </div> <div class="row"> <i class="bi bi-instagram"></i>Instagram </div> </div> <div class="col-sm-3"> <div class="row"> <h3>Help & Contact</h3> </div> <div class="row"> Contact </div> <div class="row"> About Us </div> <div class="row"> FAQs </div> </div> </div> </div> </div> </footer> </div> </body> </html> homepage.html {% extends 'index.html' %} {% block content %} Hello! this is my block content {% endblock content %} urls.py from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import path, include from . import views urlpatterns = [ path('admin/', admin.site.urls), path('', views.homepage, name="homepage"), # path('accounts/', include('accounts.urls')), ] urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) views.py from django.shortcuts import render def homepage(request): return render(request, 'index.html') I have done the similar projects earlier but it was working fine. I don't know why it doesn't work in this project while i have done everything similar I have been trying this for a whole day. Any help will be appreciated.
You want to extend index.html to homepage.html so you have to call homepage.html in your views.py file. from django.shortcuts import render def homepage(request): return render(request, 'homepage.html')
Django data saved in the database but not show in the template
Django data is saved in the database but, when access the data in template its display nothing.the models.py, views.py and home.html file code is below, when I entered data in the field and print it in add function it display but does not display in the template. Im using the modal to display the data models.py from django.db import models class ToDo(models.Model): title = models.CharField(max_length=100) detail = models.TextField() published_date = models.DateTimeField() def __str__(self): return self.title views.py from django.shortcuts import render, HttpResponse, redirect from django.utils import timezone from todoapp.models import ToDo def home(request): todo_items = ToDo.objects.all() context = {'todoItems': todo_items} return render(request, 'todoapp/home.html', context) def add(request): if request.method=="POST": addTitle = request.POST['addTitle'] addDetail = request.POST['addDetail'] current_date = timezone.now() addedObject = ToDo.objects.create(title=addTitle, detail=addDetail, published_date=current_date) return redirect('home') return render(request, 'todoapp/home.html') home.html "Template file" {%load static%} {%include 'header.html'%} <!-- Navigation --> <nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav"> <div class="container"> <a class="navbar-brand js-scroll-trigger" href="{% url 'home'%}">todo application</a> <button class="navbar-toggler navbar-toggler-right text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> Menu <i class="fas fa-bars"></i> </button> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav ml-auto"> <li class="nav-item mx-0 mx-lg-1"> <a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" data-toggle="modal" data-target="#addModal" href="add">add new</a> </li> <li class="nav-item mx-0 mx-lg-1"> <a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="{%url 'home'%}">todo list</a> </li> </ul> </div> </div> </nav> <!-- Masthead --> <header class="masthead bg-primary text-white text-center"> <div class="container d-flex align-items-center flex-column"> <!-- Masthead Avatar Image --> <img class="masthead-avatar mb-5" src="{%static 'images/avataaars.svg' %}" alt=""> <!-- Masthead Heading --> <h1 class="masthead-heading text-uppercase mb-0">Todo Application </h1> <!-- Icon Divider --> <div class="divider-custom divider-light"> <div class="divider-custom-line"></div> <div class="divider-custom-icon"> <i class="fas fa-star"></i> </div> <div class="divider-custom-line"></div> </div> <!-- Masthead Subheading --> <p class="masthead-subheading font-weight-light mb-0">Web Developer - Web Designer - Coder</p> </div> </header> <!-- Portfolio Section --> <section class="page-section portfolio" id="portfolio"> <div class="container"> <!-- Portfolio Section Heading --> <h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">portfolio</h2> <!-- Icon Divider --> <div class="divider-custom"> <div class="divider-custom-line"></div> <div class="divider-custom-icon"> <i class="fas fa-star"></i> </div> <div class="divider-custom-line"></div> </div> <!-- Portfolio Grid Items --> <div class="row"> <!-- Portfolio Item 1 --> <div class="col-md-6 col-lg-4"> <div class="portfolio-item mx-auto" data-toggle="modal" data-target="#portfolioModal1"> <div class="portfolio-item-caption d-flex align-items-center justify-content-center h-100 w-100"> <div class="portfolio-item-caption-content text-center text-white"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="{% static 'images/portfolio/cabin.png'%}" alt=""> </div> </div> </div> <!-- /.row --> </div> </section> <!-- About Section --> <section class="page-section bg-primary text-white mb-0" id="about"> <div class="container"> <!-- About Section Heading --> <h2 class="page-section-heading text-center text-uppercase text-white">About</h2> <!-- Icon Divider --> <div class="divider-custom divider-light"> <div class="divider-custom-line"></div> <div class="divider-custom-icon"> <i class="fas fa-star"></i> </div> <div class="divider-custom-line"></div> </div> <!-- About Section Content --> <div class="row"> <div class="col-lg-12 ml-auto text-center"> <p class="lead">Hi! Im Zeeshan Tariq. I have 3 plus years of experience in web Application Development, Software Development, Front End Development, WordPress theme customization , woocommerce customization, wordpress security, SEO, keywords research, on-page seo, off-page seo,speed optimization, custom web application development using python django web framework, API design, database design and development.</p> </div> </div> </div> </section> <!-- Portfolio Modals --> <!-- add Modal --> <div class="portfolio-modal modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModal" aria-hidden="true"> <div class="modal-dialog modal-xl" role="document"> <div class="modal-content"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true"> <i class="fas fa-times"></i> </span> </button> <div class="modal-body text-center"> <div class="container"> <div class="row justify-content-center"> <div class="col-lg-8"> <!-- Portfolio Modal - Title --> <h2 class="portfolio-modal-title text-secondary text-uppercase mb-0">Add Todo</h2> <!-- Icon Divider --> <div class="divider-custom"> <div class="divider-custom-line"></div> <div class="divider-custom-icon"> <i class="fas fa-star"></i> </div> <div class="divider-custom-line"></div> </div> <!-- Portfolio Modal - Image --> <!-- Portfolio Modal - Text --> <p class="mb-5"> <div class="row"> <div class="col-lg-8 mx-auto"> <form action="{% url 'add'%}" method="post"> {%csrf_token%} <div class="control-group"> <div class="form-group floating-label-form-group controls mb-0 pb-2"> <label>Title </label> <input class="form-control" id="addTitle" name="addTitle" type="text" placeholder="Title" required="required" data-validation-required-message="Please enter the title."> <p class="help-block text-danger"></p> </div> </div> <div class="control-group"> <div class="form-group floating-label-form-group controls mb-0 pb-2"> <label>Detail</label> <input class="form-control" id="addDetail" name="addDetail" type="text" placeholder="Detail" required="required" data-validation-required-message="Please enter the description."> <p class="help-block text-danger"></p> </div> </div> <br> <div id="success"></div> <div class="form-group"> <button type="submit" class="btn btn-primary btn-xl" id="sendMessageButton">Add</button> </div> </form> </div> </div> </p> <button class="btn btn-primary" href="#" data-dismiss="modal"> <i class="fas fa-times fa-fw"></i> Close Window </button> </div> </div> </div> </div> </div> </div> </div> <!-- Portfolio Modal 1 --> <div class="portfolio-modal modal fade" id="portfolioModal1" tabindex="-1" role="dialog" aria-labelledby="portfolioModal1Label" aria-hidden="true"> <div class="modal-dialog modal-xl" role="document"> <div class="modal-content"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true"> <i class="fas fa-times"></i> </span> </button> <div class="modal-body text-center"> <div class="container"> <div class="row justify-content-center"> <div class="col-lg-8"> <!-- Portfolio Modal - Title --> <h2 class="portfolio-modal-title text-secondary text-uppercase mb-0">{{todoItems.title}}</h2> <!-- Icon Divider --> <div class="divider-custom"> <div class="divider-custom-line"></div> <div class="divider-custom-icon"> <i class="fas fa-star"></i> </div> <div class="divider-custom-line"></div> </div> <!-- Portfolio Modal - Image --> <img class="img-fluid rounded mb-5" src="img/portfolio/cabin.png" alt=""> <!-- Portfolio Modal - Text --> <p class="mb-5">{{todoItems.detail}}</p> <button class="btn btn-primary" href="#" data-dismiss="modal"> <i class="fas fa-times fa-fw"></i> Close Window </button> </div> </div> </div> </div> </div> </div> </div> {%include 'footer.html'%}
Bootstrap, nav-stacked not actually stacking list entries
It seems I'm missing something obvious here I expected the home blog contact entries to be stacked on top of one another at all times. What am I missing? This is what's actually rendering: <body class="body" style="background-color:#f6f6f6"> <div class="container-fluid" style="min-height:95%; "> <hr> <div class="row"> <div class="col-sm-2"> <br> <br> <!-- Great, til you resize. --> <!--<div class="well bs-sidebar affix" id="sidebar" style="background-color:#fff">--> <div class="well bs-sidebar" id="sidebar" style="background-color:#fff"> <ul class="nav nav-pills nav-stacked"> <li role="presentation" class="active"><a href='/'>Home</a></li> <li role="presentation"><a href='/blog/'>Blog</a></li> <li role="presentation"><a href='/contact/'>Contact</a></li> </ul> </div> <!--well bs-sidebar affix--> </div> <!--col-sm-2--> <div class="col-sm-10"> <div class='container-fluid'> <br><br> {% block content %} {% endblock %} </div> </div> </div> </div> <footer> <div class="container-fluid" style='margin-left:15px'> <p>Contact | LinkedIn | Twitter | Google+</p> </div> </footer> </body>
There's no well class in Bootstrap 4. The card class can be used instead. Here's a code snippet that does pretty much what you'd expect: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <div class="container-fluid" style="min-height:90vh; "> <hr> <div class="row"> <div class="col-sm-3 col-md-2"> <br> <br> <!-- There's no "well" class in Bootstrap 4. The "card" class can be used instead. --> <div class="card bs-sidebar" id="sidebar" style="background-color:#fff"> <nav class="nav nav-pills flex-column flex-sm-row2"> <a class="flex-sm-fill text-sm-center nav-link active" href="#">Home</a> <a class="flex-sm-fill text-sm-center nav-link" href="#">Blog</a> <a class="flex-sm-fill text-sm-center nav-link" href="#">Contact</a> </nav> </div> <!--bs-sidebar--> </div> <!--col-sm-3 col-md-2--> <div class="col-sm-9 col-md-10 "> <div class='container-fluid'> <div class="row"> <div class="col"> <br><br> {% block content %} {% endblock %} </div> </div> </div> </div> </div> </div> <footer> <div class="container-fluid"> <div class="row"> <div class="col"> <p>Contact | LinkedIn | Twitter | Google+</p> </div> </div> </div> </footer> Reference: https://getbootstrap.com/docs/4.0/migration/#panels-thumbnails-and-wells https://getbootstrap.com/docs/4.0/components/navs/#working-with-flex-utilities