Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bootstrap Django
#1
Hi all.
I want to add nav bar to my Django project. So I copied Html code from Bootstrap to my Django Html. It worked properly.
So, the Youtuber said don't use bootstrap css .They gave bootstrap css & js files . I loaded it in my Django folder , and I changed Django html file like
{% load static %}
<link rel="stylesheet" href="{% static 'css/bootstarp-grid.css' %}">
But I am not getting CSS style to my website.
Please anyone can help to solve this issue.
Thanks in advance for your support!
Larz60+ write Mar-17-2024, 01:32 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Attached Files

Thumbnail(s)
   
Reply
#2
create a static folder and create another folder called css inside the static and paste your bootstrap file into css folder:

static folder must be in the root folder of your project :

like this:

myproject/
└── myproject/
└── registration/
└── static/
└── templates/
├── db.sqlite3
├── manage.py

Now change your static settings look like this:

Now add the following codes to your settings.py file to set up the Django static files.

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')


now in your head section: link your css file like this:
<link href="static/css/bootstarp-grid.css" rel="stylesheet">

Hope it will work fine. for further more tutorial in detail you can check out my blog past as well or dm me:

https://web-spidy.com/manage-django-stat...cript-css/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask - use bootstrap styles in HTML Krayna 1 1,160 Aug-29-2023, 02:33 PM
Last Post: menator01
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,444 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020