I have changed my django debug to false. I am now missing the bootstrap files, previously found in the static directory. The console output shows i'm getting 404s on the bootstrap files.
debug output:
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
[23/Sep/2022 12:49:42] "GET /login/?next=/ HTTP/1.1" 200 2853
[23/Sep/2022 12:49:42] "GET /static/css/bootstrap.min.css HTTP/1.1" 404 179
[23/Sep/2022 12:49:42] "GET /static/orchestration/main.css HTTP/1.1" 404 179
[23/Sep/2022 12:49:42] "GET /static/js/jquery.min.js HTTP/1.1" 404 179
[23/Sep/2022 12:49:42] "GET /static/js/popper.min.js HTTP/1.1" 404 179
[23/Sep/2022 12:49:42] "GET /static/js/bootstrap.min.js HTTP/1.1" 404 179
[23/Sep/2022 12:49:42] "GET /static/js/bootstrap.min.js HTTP/1.1" 404 179
settings.py
STATIC_URL = 'static/'
#----
STATIC_ROOT = os.path.join(BASE_DIR, 'root')
#----
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, 'boot'),
]
I have run python3 manage.py collectstatic. It has copied all these files to the root directory. I was expecting it just to look in the root directory to find them.
Related
I am following this tutorial in order to serve React through Django server, but I only get a blank page when I access http://localhost:8000/admin, and I get the following errors on Django local server console:
[20/Jun/2020 17:05:08] "GET /admin HTTP/1.1" 200 2217
[20/Jun/2020 17:05:08] "GET /static/css/main.5f361e03.chunk.css HTTP/1.1" 404 1821
[20/Jun/2020 17:05:08] "GET /static/js/main.853c8ab9.chunk.js HTTP/1.1" 404 1815
[20/Jun/2020 17:05:08] "GET /static/js/2.6d20342a.chunk.js HTTP/1.1" 404 1806
[20/Jun/2020 17:05:08] "GET /static/js/2.6d20342a.chunk.js HTTP/1.1" 404 1806
[20/Jun/2020 17:05:08] "GET /static/js/main.853c8ab9.chunk.js HTTP/1.1" 404 1815
I made all, and only, the changes stated in the tutorial.
EDIT
I have managed to make http://localhost:8000/admin work. I just had to add a coma in TEMPLATES:
TEMPLATES = [
{
# ...
'DIRS': [
os.path.join(BASE_DIR, 'build'),
],
# ...
}
]
But I still get the same error with http://localhost:8000/.
Thanks for your help.
Am getting back the last line after i navigate to the 127.0.0.1:8000/admin
the browser message
This site can’t be reached127.0.0.1 refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
my terminal message
"C:\Program Files\JetBrains\PyCharm 2019.2\bin\runnerw64.exe" C:\Users\UCHE\PycharmProjects\blog\venv\Scripts\python.exe C:/Users/UCHE/PycharmProjects/blog/manage.py runserver 8000
Performing system checks...
Watching for file changes with StatReloader
System check identified no issues (0 silenced).
March 16, 2020 - 22:15:50
Django version 3.0.4, using settings 'blog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[16/Mar/2020 22:16:26] "GET / HTTP/1.1" 200 19
Not Found: /favicon.ico
[16/Mar/2020 22:16:28] "GET /favicon.ico HTTP/1.1" 404 2136
[16/Mar/2020 22:16:34] "GET /admin/ HTTP/1.1" 302 0
[16/Mar/2020 22:16:34] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1913
[16/Mar/2020 22:16:35] "GET /static/admin/css/base.css HTTP/1.1" 304 0
[16/Mar/2020 22:16:35] "GET /static/admin/css/login.css HTTP/1.1" 304 0
[16/Mar/2020 22:16:35] "GET /static/admin/css/responsive.css HTTP/1.1" 304 0
[16/Mar/2020 22:16:35] "GET /static/admin/css/fonts.css HTTP/1.1" 304 0
[16/Mar/2020 22:16:36] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 304 0
[16/Mar/2020 22:16:36] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 304 0
[16/Mar/2020 22:16:49] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
Process finished with exit code -1
Have you created a super user, ? If you haven't created a super user create one and login to admin of django project.
Use following comand to create a super user
python manage.py createsuperuser
I am continuously getting error while trying to log in to django admin page.
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
December 07, 2019 - 13:53:40
Django version 3.0, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /
[07/Dec/2019 13:53:42] "GET / HTTP/1.1" 404 2027
[07/Dec/2019 13:53:47] "GET /admin HTTP/1.1" 301 0
[07/Dec/2019 13:53:47] "GET /admin/ HTTP/1.1" 302 0
[07/Dec/2019 13:53:47] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1913
[07/Dec/2019 13:53:47] "GET /static/admin/css/login.css HTTP/1.1" 200 1233
[07/Dec/2019 13:53:47] "GET /static/admin/css/base.css HTTP/1.1" 200 16378
[07/Dec/2019 13:53:47] "GET /static/admin/css/responsive.css HTTP/1.1" 200 18052
[07/Dec/2019 13:53:47] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[07/Dec/2019 13:53:47] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
[07/Dec/2019 13:53:47] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
[07/Dec/2019 13:53:59] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
And after this it is automatically closing.
I used python v3.7 and got this issue. Solved this problem by using python v3.8 and creating a new venv.
Now my python version FYI:
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
302 is not an error. It is a redirect. When you try to visit /admin/ you are redirected to the login page, and then when you have logged in you are redirected to /admin/.
I set SESSION_COOKIE_SECURE = False in settings.py and works.
I follow the Official Django tutorial, but I´m stucked in the point where I should login into Admin page. I can fill name and password, but after hit Log in button, python development server ends. I´m running them using this command python manage.py runserver 0.0.0.0:3000
I´m running Linux container on Codeanywhere using Python 3.7 and Django 3.1.
Only output I get is:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
October 04, 2019 - 16:14:47
Django version 3.1, using settings 'buky.settings'
Starting development server at http://0.0.0.0:3000/
Quit the server with CONTROL-C.
[04/Oct/2019 16:14:48] "GET /admin/ HTTP/1.1" 302 0
[04/Oct/2019 16:14:49] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1916
[04/Oct/2019 16:14:49] "GET /static/admin/css/base.css HTTP/1.1" 200 16378
[04/Oct/2019 16:14:49] "GET /static/admin/css/login.css HTTP/1.1" 200 1233
[04/Oct/2019 16:14:49] "GET /static/admin/css/responsive.css HTTP/1.1" 200 18052
[04/Oct/2019 16:14:49] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[04/Oct/2019 16:14:50] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
[04/Oct/2019 16:14:50] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
[04/Oct/2019 16:14:57] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
My urls.py is like in tutorial:
urlpatterns = [
path('admin/', admin.site.urls),
path('polls/', include('polls.urls')),
]
What can be wrong?
Thanks Alex
I updated my python version from 3.7.0 to 3.8.1 and the problem was fixed for me.
Hope it helps for you too! Cheers
I'm using PyInstaller to try and make running of a Django project simple for a user. It works perfectly on my Linux PC but when I try and create it on a Windows PC the static files are not loading and I cannot understand why.
I'm using the following .spec file to create the application.
# -*- mode: python -*-
block_cipher = None
a = Analysis(['manage.py'],
pathex=['C:\\Users\\henry\\potential-waffle'],
binaries=[("C:/Program Files (x86)/Windows Kits/10/Redist/ucrt/DLLs/arm", '.')],
datas=[('media','media'),('potential_waffle/static','static')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='webscraper',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='webscraper')
My static files are defined within settings.py as:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "potential_waffle/static"),
)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
And I'm picking up the static files for runserver:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
The program works fine and does everything it should except the formatting of the browser and within terminal I have the following:
[08/Jun/2018 12:00:57] "GET /login/?next=/ HTTP/1.1" 200 5438
[08/Jun/2018 12:00:57] "GET /static/agency/vendor/bootstrap/css/bootstrap.min.css HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/font-awesome/css/font-awesome.min.css HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/agency/css/agency.css HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/toastr/toastr.min.css HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/js/cookiechoices.js HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/agency/vendor/jquery/jquery.min.js HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/agency/vendor/bootstrap/js/bootstrap.min.js HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/agency/js/jqBootstrapValidation.js HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/agency/js/contact_me.js HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/agency/js/agency.min.js HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /static/toastr/toastr.min.js HTTP/1.1" 302 0
[08/Jun/2018 12:00:57] "GET /login/?next=/static/agency/vendor/bootstrap/css/bootstrap.min.css HTTP/1.1" 200 5490
[08/Jun/2018 12:00:57] "GET /login/?next=/static/font-awesome/css/font-awesome.min.css HTTP/1.1" 200 5482
[08/Jun/2018 12:00:57] "GET /login/?next=/static/agency/css/agency.css HTTP/1.1" 200 5466
[08/Jun/2018 12:00:57] "GET /login/?next=/static/js/cookiechoices.js HTTP/1.1" 200 5464
[08/Jun/2018 12:00:57] "GET /login/?next=/static/toastr/toastr.min.css HTTP/1.1" 200 5466
[08/Jun/2018 12:00:57] "GET /login/?next=/static/agency/vendor/jquery/jquery.min.js HTTP/1.1" 200 5479
[08/Jun/2018 12:00:57] "GET /login/?next=/static/agency/vendor/bootstrap/js/bootstrap.min.js HTTP/1.1" 200 5488
[08/Jun/2018 12:00:57] "GET /login/?next=/static/agency/js/jqBootstrapValidation.js HTTP/1.1" 200 5479
[08/Jun/2018 12:00:57] "GET /login/?next=/static/agency/js/contact_me.js HTTP/1.1" 200 5468
[08/Jun/2018 12:00:57] "GET /login/?next=/static/agency/js/agency.min.js HTTP/1.1" 200 5468
[08/Jun/2018 12:00:57] "GET /login/?next=/static/toastr/toastr.min.js HTTP/1.1" 200 5465
The files are in the /static folder (I've checked) but it seems to be redirecting them to a location where the files do not exist (even though we get a 200 response).
I am guessing there is something wrong with the .spec file for Windows but I've tried changing the slashes every which way to no avail. I do get some warning messages during the build (which could be the issue) of the style:
WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\henry\potential-waffle\env\scripts\python.exe