last day (14 days later) » 

1:50 AM
0
A: Why won't my index.html connect to my index.css file?

Tiny.DYou should load the static files with correct way in Django, better to split static files and templates. Here is one solution based on your case: Fristly, under music folder, create static folder, put your static file index.css. After that, change the loading css file with this way in your inde...

 
I tried this, it didn't work.
 
can you check your console to see what's the error message?
 
index.css Failed to load resource: the server responded with a status of 404 (Not Found) That's the error I'm getting in the console.
 
what's the STATIC_URL in your settings.py?
 
STATIC_URL = '/static/'
 
1:50 AM
can you update your project image and your new html code in the question?
 
Done, I updated it.
By the way, I'm still getting the TemplateDoesNotExist error on the page.
 
right now the issue is TemplateDoesNotExist ?
actually, I have made a demo based on your code, it works for me
 
Yeah, I have no clue why it's doing this.
I even tried to restart my server, still doesn't work.
http://127.0.0.1:8000/music/

TemplateDoesNotExist error
 
so you cannot load the html page now?
not the static file not fond?
 
yeah, that's what it looks like.
so weird
 
1:56 AM
what you have changed the DIRS of TEMPLATES in your settings.py?
 
nothing
 
can share your TEMPLATES in settings.py?
 
sure.
check back on the question in 30 secs
 
no need paste there
paste here
directly to me
 
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '+-9mn+q&u@lw2_=s7&=zin5d7oxbt#v@9jg%2+a7=#noqd_jyf'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
 
2:01 AM
pls share your views.py to me
directly
you settings.py is corret
 
from django.http import HttpResponse
from django.shortcuts import render
from .models import Person

def index(request):
if request.method == 'POST':
first_name = request.POST.get('firstName')
last_name = request.POST.get('lastName')
if first_name and last_name:
user = Person.objects.create(firstName=first_name, lastName=last_name)
user.save()
return render(request, 'static/music/static/templates/music/index.html')

def detail(request, user_id): # Testing out page 2
return HttpResponse("<h2>Page # (testing this out) " + str(user_id) + "</h2>")
 
that's the issue
ok, you render the template incorrectly
change to render(request, 'music/index.html')
 
I tried that, now I'm getting a 'this site can't be reached error'
should I restart my server?
 
yes
pls
 
k restarting
it's taking a while for some reason
got it!
 
2:07 AM
do you run python manage.py runserver to start it?
 
it works!
thank you so much for your time
my css file is recognized
 
glad it works
please mark my answer, thanks :)
 
sure, np :D
I learned a lot from this mistake!
 
yes, great. enjoy the journey
and enjoy the community
 
Will do!
 
2:11 AM
good luck
bye :0
 

last day (14 days later) »