img src not working in Django using Bootstrap Carousel - python

Im trying to add an image to my bootstrap carousel but image is not loading.
{% extends 'base.html' %}
{% block html %}
{% load static %}
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
</head>
<body>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="/Users/myname/Documents/django/ldn/static/images/phone.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="{% static 'static/images/network.jpg' %}" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../static/images/phone.jpg" alt="Third slide">
</div>
</div>
</div>
</body>
</html>
{% endblock %}
Ive tried various methods as shown above but none work. My static/images folder is in my project root. Thanks

{% load static %}
<html lang="en">
<body>
<img src="{% static 'img/logo.png' %}" >
</body>
</html>

Related

Login form not initializing not authenticating

When I was adding a template from the internet to my login.html code I encountered a problem. When I try to login it did not work. Even after I added CSRF tokens and login form control code. It has a clickable button that does not thing. I hope someone can help me. If any pictures or other codes needed please feel free to ask.
inn.html(login.html 1'this is a nickname'))
{% extends 'base.html' %}
{% block title %}Login{% endblock %}
{% block content %}
<div class="container">
<br/>
<h1>Login</h1>
<br/> <br/>
<div class="form-group">
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button class="btn btn-secondary">Login</button>
</div>
{% endblock %}
login.html:
{% extends 'base.html' %}
{% load static %}
{% block content %}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{% static 'fonts/icomoon/style.css' %}">
<link rel="stylesheet" href="{% static 'css/owl.carousel.min.css' %}">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<!-- Style -->
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
<div class="content">
<div class="container">
<div class="row">
<div class="col-md-6 order-md-2">
<img src="{% static 'images/undraw_file_sync_ot38.svg' %}" alt="Image" class="img-fluid">
</div>
<div class="col-md-6 contents">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="mb-4">
<h3>Sign In to <strong>C</strong></h3>
<p class="mb-4">Lorem.</p>
</div>
<form method="POST">
{% csrf_token %}
<div class="form-group">
<input type="text" class="form-control" id="username" placeholder="Username">
</div>
<div class="form-group">
<input type="password" class="form-control" id="password" for="password" placeholder="Password">
</div>
<input type="submit" value="Log In" class="btn text-white btn-block btn-primary">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
</body>
</html>
{% endblock %}

How to extend html template with jquery content by jinja2?

Here is my html code
Base.html
<title> {% block title %}{% endblock %} </title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="/content">Home</a>
<a class="dropdown-item" href="#">Calendar</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Still in progress...</a>
</li>
</ul>
</form>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
and then this is my jquery code:
index.html
<html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<title>Datepicker</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/momentjs/2.14.1/moment.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<script>
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
<body>
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">Schedule an Appointment</div>
<div class="panel-body">
<form action="/ok" method="post">
<div class="row">
<div class='col-md-6'>
<div class="form-group">
<label class="control-label">Appointment Time</label>
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" name="Time"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
<input type="submit" class="btn btn-primary" value="Submit">
</form>
</div>
</div>
</div>
</body>
I have tried many times to modify the index.html to be able to extent by the base.html but failed.
Neither only the background color change nor the jquery cannot be load in the chrome, as a result no datetimepicker is appear.
How can I use the {% extends "base.html" %} (jinja2 method) to extend the base.html to index.html?
Thanks very much
First of all you have to define
{% block content %}{% endblock %}
in base.html and then in the index.html.
{% extends "base.html" %} // at top of file
All the content should be between
{% block content %}{% endblock %} in index.html. you can see in documentation
base.html
<html> ...
your_main_html.html
{% extends "base.html" %}
{% block extrahead %}
<style>
<!-- your css codes -->
</style>
{% endblock %}
{% block content %}
<!-- your html and jinja codes -->
{% endblock %}
{% block extrajs %}
<script>
<!-- your js codes -->
</script>
{% endblock %}
you will need to download jQuery js file from https://jquery.com/download/ and use it in your index file inside head tag as
<script src="jquery-3.6.1.min.js"></script>
or
use jQuery CDN as below
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

Not sure why data won't render from file into browser

The '/' route is returning 'Hello world'. However, the '/data' route will not return anything. I can't figure out why it won't render anything in the browser.
from flask import Flask, render_template
import requests
import logging
from flask_sqlalchemy import SQLAlchemy
from localStoragePy import localStoragePy
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
token = 'Czm5aFtxepvvE4jZddlOsKXiwOzJUfl1BiFW18BfUtsUPPTkZnA663WQ13oQMdEq'
BASE_URL = 'https://canvas.sfu.ca/api/v1/courses/62319/quizzes'
headers = {'Authorization': "Bearer Czm5aFtxepvvE4jZddlOsKXiwOzJUfl1BiFW18BfUtsUPPTkZnA663WQ13oQMdEq".format(token)}
auth_response = requests.get(BASE_URL, headers=headers)
#userStringFromLocalStorage = localStoragePy.getItem('auth_response')
#userFromLocalStorage = JSON.parse(userStringFromLocalStorage)
#print(userStringFromLocalStorage)
print(auth_response.json())
#logging.warning('this is a warning')
#app.route('/')
def hello_world():
return 'Hello world';
#app.route('/data')
def hello_world_cello():
data = [{
"id":164284,
"title":"Quiz 1",
"html_url":"https://canvas.sfu.ca/courses/62319/quizzes/164284",
"mobile_url":"https://canvas.sfu.ca/courses/62319/quizzes/164284?force_user=1&persist_headless=1",
"description":"",
"quiz_type":"assignment",
"time_limit":"None",
"timer_autosubmit_disabled":false,
"shuffle_answers":false,
"show_correct_answers":true,
"scoring_policy":"keep_highest",
"allowed_attempts":1,
"one_question_at_a_time":false,
"question_count":2,
"points_possible":2.0,
"cant_go_back":false,
"access_code":"None",
"ip_filter":"None",
"due_at":"None",
"lock_at":"None",
"unlock_at":"None",
"published":true,
"unpublishable":true,
"locked_for_user":true,
"lock_info":{
"missing_permission":"participate_as_student",
"asset_string":"quizzes:quiz_164284"
},
"lock_explanation":"This quiz is currently locked.",
"hide_results":"None",
"show_correct_answers_at":"None",
"hide_correct_answers_at":"None",
"all_dates":[
{
"id":53086,
"due_at":"2021-05-06T06:59:59Z",
"unlock_at":"None",
"lock_at":"None",
"title":"Entrepreneursity Test",
"set_type":"CourseSection",
"set_id":131870
}
],
"can_unpublish":true,
"can_update":true,
"require_lockdown_browser":false,
"require_lockdown_browser_for_results":false,
"require_lockdown_browser_monitor":false,
"lockdown_browser_monitor_data":"None",
"speed_grader_url":"https://canvas.sfu.ca/courses/62319/gradebook/speed_grader?assignment_id=630900",
"permissions":{
"manage":true,
"read":true,
"update":true,
"create":true,
"submit":true,
"preview":true,
"delete":true,
"read_statistics":true,
"grade":true,
"review_grades":true,
"view_answer_audits":false
},
"quiz_reports_url":"https://canvas.sfu.ca/api/v1/courses/62319/quizzes/164284/reports",
"quiz_statistics_url":"https://canvas.sfu.ca/api/v1/courses/62319/quizzes/164284/statistics",
"message_students_url":"https://canvas.sfu.ca/api/v1/courses/62319/quizzes/164284/submission_users/message",
"section_count":1,
"quiz_submission_versions_html_url":"https://canvas.sfu.ca/courses/62319/quizzes/164284/submission_versions",
"assignment_id":630900,
"one_time_results":false,
"only_visible_to_overrides":true,
"assignment_group_id":154901,
"show_correct_answers_last_attempt":false,
"version_number":3,
"has_access_code":false,
"post_to_sis":false,
"migration_id":"None"
}]
return render_template('pages/venues.html', areas=data);
venues.html looks like the following
{% extends 'layouts/main.html' %}
{% block title %}Fyyur | Venues{% endblock %}
{% block content %}
{% for area in areas %}
<h3>{{ area.id }}, {{ area.title }}</h3>
<ul class="items">
</ul>
{% endfor %}
{% endblock %}
main.html
<!doctype html>
<head>
<meta charset="utf-8">
<title>{% block title %}{% endblock %}</title>
<!-- meta -->
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<!-- /meta -->
<!-- styles -->
<link type="text/css" rel="stylesheet" href="/static/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="/static/css/layout.main.css" />
<link type="text/css" rel="stylesheet" href="/static/css/main.css" />
<link type="text/css" rel="stylesheet" href="/static/css/main.responsive.css" />
<link type="text/css" rel="stylesheet" href="/static/css/main.quickfix.css" />
<!-- /styles -->
<!-- favicons -->
<link rel="shortcut icon" href="/static/ico/favicon.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/static/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="/static/ico/favicon.png">
<!-- /favicons -->
<!-- scripts -->
<script src="https://kit.fontawesome.com/af77674fe5.js"></script>
<script src="/static/js/libs/modernizr-2.8.2.min.js"></script>
<script src="/static/js/libs/moment.min.js"></script>
<script type="text/javascript" src="/static/js/script.js" defer></script>
<!--[if lt IE 9]><script src="/static/js/libs/respond-1.4.2.min.js"></script><![endif]-->
<!-- /scripts -->
</head>
<body>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">🔥</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
{% if (request.endpoint == 'venues') or
(request.endpoint == 'search_venues') or
(request.endpoint == 'show_venue') %}
<form class="search" method="post" action="/venues/search">
<input class="form-control"
type="search"
name="search_term"
placeholder="Find a venue"
aria-label="Search">
</form>
{% endif %}
{% if (request.endpoint == 'artists') or
(request.endpoint == 'search_artists') or
(request.endpoint == 'show_artist') %}
<form class="search" method="post" action="/artists/search">
<input class="form-control"
type="search"
name="search_term"
placeholder="Find an artist"
aria-label="Search">
</form>
{% endif %}
</li>
</ul>
<ul class="nav navbar-nav">
<li {% if request.endpoint == 'venues' %} class="active" {% endif %}>Venues</li>
<li {% if request.endpoint == 'artists' %} class="active" {% endif %}>Artists</li>
<li {% if request.endpoint == 'shows' %} class="active" {% endif %}>Shows</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<!-- Begin page content -->
<main id="content" role="main" class="container">
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-block alert-info fade in">
<a class="close" data-dismiss="alert">×</a>
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</main>
</div>
<div id="footer">
<div class="container">
<p>Fyyur © All Rights Reserved.</p>
{% block footer %}{% endblock %}
</div>
</div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script type="text/javascript" src="/static/js/libs/jquery-1.11.1.min.js"><\/script>')</script>
<script type="text/javascript" src="/static/js/libs/bootstrap-3.1.1.min.js" defer></script>
<script type="text/javascript" src="/static/js/plugins.js" defer></script>
</body>
</html>
I am trying to return 'data' variable in the '/data' route. I am using Flask as my environment. I haven't created a database yet to store these.
Ok, i'm now home, i'll thanks for editing with the main.html
So, your error probably come from here
<li {% if request.endpoint == 'venues' %} class="active" {% endif %}>Venues</li>
<li {% if request.endpoint == 'artists' %} class="active" {% endif %}>Artists</li>
<li {% if request.endpoint == 'shows' %} class="active" {% endif %}>Shows</li>
You're asking flask to generate a url for venues, artist, and shows.
The problem is that you never define these routes, flask can't create a URL for something that doesn't exist.
You have two solution :
You define your href with a relative url : href="/artists" for example, this will lead to http(s)://{host}/artists
This is the good old html way, and it's working easily.
You can define temporary void routes for these, for example :
#app.route('/artists')
def artists():
return ''
This will return a blank page.
With that and the previous comments i leaved, you should be able to make that working.
You should have error on your Flask app, check it out if you can, even if the error code doesn't help you, it can help other people to understand what's wrong.
Tell me if that helped.

Not displaying my navbar {% extends 'base.html' %} when I use django {% block content %}

When I use {% extends 'base.html' %} my navbar displays correctly but when I use {% block content %} Hello World{% endblock content %} my navbar disappears and I only see the text "Hello World". I dont really know what to try it appeared to be straight forward but apparently it isn't until you actually know.
{% extends "base.html" %}
{% block content %}<h1>Hello World</h1>{% endblock content %}
My 'base.html' file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
{% block head %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{% static "css/style.css" %}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<meta charset="UTF-8">
<title>my title goes here</title>
{% endblock %}
</head>
<body>
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col">
<nav class="navbar custom-navbar">
<h1>World Truthers</h1>
<div class="col navbar-buttons">
<button class="btn custom-button"><p><b>Contact</b></p></button>
<button class="btn custom-button"><p><b>About</b></p></button>
<button class="btn custom-button"><p><b>Returns</b></p></button>
<button class="btn custom-button"><p><b>Payment</b></p></button>
<button class="btn custom-button"><p><b>Delivery</b></p></button>
<button class="btn custom-button"><p><b>Store</b></p></button>
</div>
</nav>
</div>
</div>
</div>
{% endblock %}
</body>
Change your base.html to the one below. What is happening is you are overwriting your content block with whats in your template ("Hello world"). If you want to stick with this, in your child template, put {{block.super}} after {% block content %}, but the "correct" way would be to change your base.html with the one below.
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
{% block head %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{% static "css/style.css" %}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<meta charset="UTF-8">
<title>my title goes here</title>
{% endblock %}
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<nav class="navbar custom-navbar">
<h1>World Truthers</h1>
<div class="col navbar-buttons">
<button class="btn custom-button"><p><b>Contact</b></p></button>
<button class="btn custom-button"><p><b>About</b></p></button>
<button class="btn custom-button"><p><b>Returns</b></p></button>
<button class="btn custom-button"><p><b>Payment</b></p></button>
<button class="btn custom-button"><p><b>Delivery</b></p></button>
<button class="btn custom-button"><p><b>Store</b></p></button>
</div>
</nav>
</div>
</div>
</div>
{% block content %}
{% endblock %}
</body>

How to show images using Lightbox in Django

I need your little help. I have set up everything according to the course that I am following but I am not getting images shown as in the course.
Here is the issue: I have fetched some images from database and I want to show them using lightbox. I did everything right but images are not showing.
My views.py
from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator
from .models import Listing
def listing(request, listings_id):
listing = get_object_or_404(Listing, pk=listings_id)
context = {
'listing': listing
}
return render(request, 'listings/listing.html', context)
My listing.html
{% extends 'base.html' %}
{% load humanize %}
{% block content %}
<!-- Listing -->
<section id="listing" class="py-4">
<div class="container">
Back To Listings
<div class="row">
<div class="col-md-9">
<!-- Home Main Image -->
<img src="{{ listing.photo_main.url }}" alt="" class="img-main img-fluid mb-3">
<!-- Thumbnails -->
<div class="row mb-5 thumbs">
<div class="col-md-2">
<a href="{{ listing.photo_1.url }}" data-lightbox="home-images">
<img src="{{ listing.photo_1.url }}" alt="" class="img-fluid">
</a>
</div>
<div class="col-md-2">
<a href="{{ listing.photo_2.url }}" data-lightbox="home-images">
<img src="{{ listing.photo_2.url }}" alt="" class="img-fluid">
</a>
</div>
<div class="col-md-2">
<a href="{{ listing.photo_3.url }}" data-lightbox="home-images">
<img src="{{ listing.photo_3.url }}" alt="" class="img-fluid">
</a>
</div>
<div class="col-md-2">
<a href="{{ listing.photo_4.url }}" data-lightbox="home-images">
<img src="{{ listing.photo_4.url }}" alt="" class="img-fluid">
</a>
</div>
<div class="col-md-2">
<a href="{{ listing.photo_5.url }}" data-lightbox="home-images">
<img src="{{ listing.photo_5.url }}" alt="" class="img-fluid">
</a>
</div>
<div class="col-md-2">
<a href="{{ listing.photo_6.url }}" data-lightbox="home-images">
<img src="{{ listing.photo_6.url }}" alt="" class="img-fluid">
</a>
</div>
</div>
</div>
</div>
</section>
{% endblock %}
Here is my base.html
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Font Awesome -->
<link rel="stylesheet" href="{% static 'css/all.css' %}">
<!-- Bootstrap -->
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">
<!-- Custom -->
<link rel="stylesheet" href="{% static 'css/style.css' %}">
<!-- Lightbox -->
<!-- Please NOTE that I have added the light box correctly from static -->
<link rel="stylesheet" href="{% static 'css/lightbox.min.css' %}">
<title>BT Real Estate</title>
</head>
<body>
<!-- Top Bar -->
{% include 'partials/_topbar.html' %}
<!-- Nav Bar -->
{% include 'partials/_navbar.html' %}
{% block content %}
{% endblock %}
<!-- Footer -->
{% include 'partials/_footer.html' %}
<script src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
<script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
<!-- Please NOTE that I have added the light box correctly from static -->
<script src="{% static 'js/lightbox.min.js' %}"></script>
</body>
</html>
Here is my static directory path:
myproject
>myproject
>static
>admin
>css
>lightbox.min.css
>img
>js
>lightbox.min.js
>myapp
>manage.py
Your help is much appreciated. Thank you!
In your Root urls, try to add the static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
For example:
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),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1st of all inspect your code and see, if any error happend..?
or
check to your django project, are you added .!
static/img/lightbox
>close.png
>loading.gif
>next.png
>pre.png
unless img file lightbox face error.

Categories

Resources