I am beginner in Python and Django. I am using Windows10 and I have installed Python 3.10.0 and pip 21.3.1. I installed Django using following commands
pip install virtualenvwrapper-win
mkvirtualenv firstdjango
pip install django
django-admin startproject demo
then I created APP for just simple static HTML page and now I am trying to use static files. I created a folder having name "static" on root and placed all css, js etc files in it and in settings.py, I mentioned following.
STATIC_URL = '/static/'
STATICFILES_DIR = [
os.path.join(BASE_DIR, 'static')
]
STATIC_ROOT = os.path.join(BASE_DIR,'assets')
Now when I hit
python manage.py collectstatic
then it is not copying, what is in my static folder to assests folder.
When I tried to check from where collectstatic is trying to copy using following command
python manage.py findstatic -v 3 dummy
then I got following
C:\Users\dell\Envs\firstdjango\lib\site-packages\django\contrib\admin\static
but my project location is E:\django\demo
I am not getting, why collectstatic is not able to copy correct files and hence I do not get correct paths of my css, js and images in my web page.
CodePudding user response:
I suspect that your virutalenv and your project aren't in the same location
you can try the following method :
pip install virtualenv // install virtualenv
virtualenv env //create your virutalenv
\pathto\env\Scripts\activate // activate your virtualenv
pip install django
django-admin startproject demo
cd demo
And then collect your statifiles