Reputation: 2810
I recently added a package to my project and did a pip freeze > requirements.txt
afterwards. I then did pip install -r requirements.txt
to my local and it added a sidebar.
I did a pip install -r requirements.txt
to the server as well and it produced a different result. It's sidebar was messed up.
I tried removing the sidebar by doing this answer but it did not get removed.
.toggle-nav-sidebar {
z-index: 20;
left: 0;
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 23px;
width: 23px;
border: 0;
border-right: 1px solid var(--hairline-color);
background-color: var(--body-bg);
cursor: pointer;
font-size: 20px;
color: var(--link-fg);
padding: 0;
display: none; /*added*/
}
#nav-sidebar {
z-index: 15;
flex: 0 0 275px;
left: -276px;
margin-left: -276px;
border-top: 1px solid transparent;
border-right: 1px solid var(--hairline-color);
background-color: var(--body-bg);
overflow: auto;
display: none; /*added*/
}
What should I do to fix this?
If there are any other things I can add to help, do ask.
ADD requirements.txt
:
asgiref==3.3.4
certifi==2020.12.5
chardet==4.0.0
defusedxml==0.7.1
diff-match-patch==20200713
Django==3.2.3
django-cors-headers==3.7.0
django-filter==2.4.0
django-import-export==2.5.0
django-property-filter==1.1.0
djangorestframework==3.12.4
et-xmlfile==1.0.1
idna==2.10
MarkupPy==1.14
odfpy==1.4.1
openpyxl==3.0.7
python-decouple==3.4
pytz==2019.2
PyYAML==5.4.1
requests==2.25.1
sqlparse==0.3.0
tablib==3.0.0
urllib3==1.26.4
xlrd==2.0.1
xlwt==1.3.0
ADD sample github repo:
Upvotes: 13
Views: 8394
Reputation: 31
I fixed this by deleting my static directory, then doing a collect static, then forcing my browser to reload.
This had been caused in a Django 3 to 4 upgrade.
Upvotes: 3
Reputation: 359
see this side bar is added by django 3.1 and it is removable
to remove this you have to add below code in admin.py
or urls.py
as you are working with admin you should add below code in admin site
from django.contrib import admin
admin.autodiscover()
admin.site.enable_nav_sidebar = False
autodiscocer(): This function attempts to import an admin module in each installed application
please let me know if worked
Upvotes: 15
Reputation: 88619
First of all, this navbar is added by Django 3.1+
and not by any other 3rd part packages.
Copy & Pasting from Django 3.X admin showing all models in a new navbar,
From the django-3.1 release notes,
The admin now has a sidebar on larger screens for easier navigation. It is enabled by default but can be disabled by using a custom AdminSite and setting
AdminSite.enable_nav_sidebar
toFalse
.
So, this is a feature that added in Django 3.1 and can be removed by settings AdminSite.enable_nav_sidebar = False
(see How to customize AdminSite
class)
You don't have to edit any CSS or HTML file to fix the styling, because Django comes with a new set of CSS and HTML, which usually fix the issue. (That is, it is not recommended to alter the styling file only for this)
If that doesn't work for you, it might be because of your browser cache.
If you are using Chrome,
Ctrl + Shift + i
and select Network
tab and then tick Disable Cache
Upvotes: 18