0

I'm working on a Django webapp and I'm using Materialize for CSS I have placed the Materialize file in the static folder in the app. I have issues with the Navbar that it works fine when in full-screen but when I resize the browser the hamburger icon for mobile navbar doesn't work. When clicked on it, it just goes to the /# page and doesn't openup from the side as it should. Do I have to make any change in the Django or Javscript files files? How can I fix this issue?

  • Welcome to Stack Overflow. You should share some code, otherwise we have no idea what you have done. For more details read https://stackoverflow.com/help/how-to-ask – Mikkel Oct 08 '17 at 11:11

1 Answers1

1

Materialize uses a materialize.js file. This file needs to be in your static folders under js. (ie js/materialize.js) You then need to declare this file in your html template after the JQuery script statement as below. Have you done this?

<body>
  <!--Import jQuery before materialize.js-->
  <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  <script type="text/javascript" src="js/materialize.min.js"></script>
</body>
cander
  • 279
  • 6
  • 14
  • This is what I have done – Sumedh Karande Oct 08 '17 at 17:43
  • No I wouldn't expect it to have anything to do with django URLs unless you have anything funky going on in there. You have all your static files set correctly right, and do you use the collectstatic method to gather them all together? – cander Oct 08 '17 at 20:01
  • No I don't use the collectstatic method! Should I be using it? – Sumedh Karande Oct 11 '17 at 13:56
  • Sorry...I've been away on holiday. :-) Yes I would suggest you do use the collect static method. When you install apps and plugins they go into the libraries of your python virtualenv. Collectstatic then gathers all the appropriate static files and puts them all in one place. Check out this link where I posted an explanation of how it works. https://stackoverflow.com/questions/46264293/django-admin-wont-allow-me-to-allocate-permissions-to-users-or-groups/46267515#46267515 – cander Oct 20 '17 at 16:51