[Fix] Fix runserver for PyCharm debug #2535
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the Pull Request
When I was developing with PyCharm, I found that the
runservermode was disabled, which made it impossible to add breakpoints for debugging.I modified
manage.pyand tried to allow the project to be started usingrunserver, and found that the application lost its style in this mode.The same problem was asked in A #901 .
This is because
STATICFILES_DIRSis not configured correctly, resulting in failure to obtain static files inrunservermode.During the adjustment process, I found some other problems and fixed them as well:
MIDDLEWARE_CLASSEShas been deprecated in django 1.10, Middleware in this configuration no longer works and needs to be moved to a new configuration item.SessionAuthenticationMiddlewaredepredated from django v2.0.WhiteNoisein Django probject, it is recommended to use middleware for configuration, And cooperate withmanage.py collectstaticcommand to process static files to improve the access performance of static files.After modifying the configuration of
WhiteNoise, if you userun.shto start the application, it will be slower because of processing static files. But I think it is worth it.Checklist for PR
tox -e lint,testStaticAnalyzer/tests.py)Additional Comments (if any)