Comments (7)
Hi there, your two logo.png
files will conflict. The path for the one in the reviews app should be reviews/static/reviews/logo.png
. This is for namespacing. Then when including in your template, use reviews/logo.png
as the path.
from web-development-with-django.
Hi there, your two
logo.png
files will conflict. The path for the one in the reviews app should bereviews/static/reviews/logo.png
. This is for namespacing. Then when including in your template, usereviews/logo.png
as the path.
I made it, but still the image doesn't change.
In reviews/templates/reviews/base.html
{% extends 'base.html' %} {% load static %} {% block brand %} <img src="{% static 'reviews/logo.png' %}" alt="logo_reviews"> {% endblock %}
In bookr/templates/base.html
{% block brand %} <img src="{% static 'logo.png' %}" alt="book_logo"> {% endblock %}
I still see the image logo.png in other pages.
from web-development-with-django.
Without seeing your whole project it's hard to tell what's wrong.
You have different alt
tags for each logo which might help you track it down. Try viewing the source on each page with a logo, and see if the alt tag matches the logo you expect. This will help you tell if it's a template problem or static files problem.
Check that your templates are inheriting from the right base, i.e. your reviews templates extend from the reviews base.html
. If your review's base.html
extends the main base.html
, but none of the other templates extend the reviews base.html
then they'll still pick up the main logo.
Finally you can use the findstatic
command to check which files are being found for each URL.
from web-development-with-django.
Without seeing your whole project it's hard to tell what's wrong.
You have different
alt
tags for each logo which might help you track it down. Try viewing the source on each page with a logo, and see if the alt tag matches the logo you expect. This will help you tell if it's a template problem or static files problem.Check that your templates are inheriting from the right base, i.e. your reviews templates extend from the reviews
base.html
. If your review'sbase.html
extends the mainbase.html
, but none of the other templates extend the reviewsbase.html
then they'll still pick up the main logo.Finally you can use the
findstatic
command to check which files are being found for each URL.
Quite a lot of time it'd taken, but I managed it by copying this from repository settings.py
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
Without this my app could find static files from reviews app or other, but I'd got the error from root (bookr) static folder.
from web-development-with-django.
I just had the same issue but realized that my view function in views.py was pointing towards base.html in the root folder when it should have been pointing at the base.html file in the reviews/templates directory. That's where I screwed up.
I ended up renaming the reviews/base.html file to reviews/index.html so that it was easier to make sure the view function was referencing the right file.
probably had something to do with settings.py with the line of code:
'DIRS': [os.path.join(BASE_DIR, 'templates')],
My problem is that I couldn't get base.html in the reviews folder to overwrite the root folder one on page 265
from web-development-with-django.
@petrenkonikita112263 Hello, mate. I know the answer to your problem.
Open the other two templates inside 'reviews/templates/reviews'
(They are named "book_list.html" and "book_detail")
These two templates extends the project level "base.html".
What you need to do is replace this:
{% extends 'base.html' %}
With this:
{% extends 'reviews/base.html' %}
The cause of the problem is when the authors asked us to move the "base.html" to project-level 'templates' directory and create a new "base.html" inside 'reviews/templates/reviews', they forgot to tell us that we should make the "book_detail.html" and "book_list.html" extend the "reviews/base.html".
Don't forget to let me know if it works.
from web-development-with-django.
@arunspacek Yeap, I've made it long time ago
from web-development-with-django.
Related Issues (20)
- [Question] Activity 8.01: book instance is being saved twice if `cover` is provided? HOT 3
- [Question] Customizing the Admin Interface HOT 2
- session_info.py > ValueError: not enough values to unpack (expected 2, got 1) HOT 1
- Exercise 10.3: Admin links to models are displayed on logout page?
- Exercise 12.04 ‘Book’ object has no attribute ‘review_set’
- Exercise 12.05: Visiting /api/books in browser doesn't return a 401
- Typo on Chapter 18 HOT 1
- Activity 17.1 solution for Glances v3.1.3 with psutil v5.5.1 HOT 1
- Ex18.3, step 10: error when migrating, "...module 'bookr.settings' has no attribute 'Prod" HOT 1
- Chapter2 Book model: trying to add a non-nullable field 'publisher' to book without a default
- Activity 8.01 AttributeError at /books/2/media/ 'ImageFieldFile' object has no attribute 'image' HOT 2
- ' in module 'bookr': module 'bookr.settings' has no attribute 'Prod HOT 6
- Working on chapter 9 ERROR: Reverse for 'index' not found. 'index' is not a valid view function or pattern name. HOT 3
- I get an error when running code for chapter 3. HOT 2
- I get an error when populating the database with csv file (Chapter 2) HOT 1
- Chapter 2: Unable to serialize .csv file HOT 1
- Chapter 8 has incorrect reference to reviews app
- Chapter 3: Template tags and whitespace control
- Chapter 4 : ModuleNotFoundError: No module named 'admin' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web-development-with-django.