In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
When Django deploys the production environment, what is the way to deal with the loss of admin background style? many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
Opening remarks:
I wonder if you have ever encountered the deployment of Django code to the generation environment, after changing the DEBUG in settings.py to True, you found that the style of the admin background page was lost. Although the page can be opened, but it is not quite the same as the page you usually see, that is, there is no static file that manages Django correctly.
Procedure:
Make sure that the INSTALLED_APPS of settings.py contains django.contrib.staticfiles.
Add STATIC_URL ='/ static/' and STATIC_ROOT = os.path.join (BASE_DIR, 'static') at the end of the settings.py file
`
Under the root of the project, create a new static folder.
Configure the urls.py file for the project by adding the following:
From project.settings import DEBUG
If not DEBUG: # add static directory routing to production environment
Urlpatterns + = [
Re_path (r'^ static/ (? P.*) $', static.serve, {'document_root': settings.STATIC_ROOT})
]
Under the project directory, execute the command: python manage.py collectstatic
After the above operations, the acquired page of admin can be displayed normally.
Reminder: make sure that the path of static is the same as the directory added in settings.py, otherwise you will still lose the background page style. Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.