Git Product home page Git Product logo

Comments (7)

beneboy avatar beneboy commented on August 10, 2024

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.

petrenkonikita112263 avatar petrenkonikita112263 commented on August 10, 2024

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.

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.

beneboy avatar beneboy commented on August 10, 2024

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.

petrenkonikita112263 avatar petrenkonikita112263 commented on August 10, 2024

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.

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.

ProgrammerSteve avatar ProgrammerSteve commented on August 10, 2024

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
image

from web-development-with-django.

arunspacek avatar arunspacek commented on August 10, 2024

@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.

petrenkonikita112263 avatar petrenkonikita112263 commented on August 10, 2024

@arunspacek Yeap, I've made it long time ago

from web-development-with-django.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.