Colorless-Green-Ideas / MaterialDjango

:paintbrush: Polymer Paper-UI widgets, vendored polymer, and tools for django
http://tech.getpizza.cat/django/update/tinylibrary/shipit/2015/04/10/MaterialDjango-and-tinylibrary/
MIT License
27 stars 6 forks source link

New to Django - help with setup #18

Closed rosiecakes closed 8 years ago

rosiecakes commented 8 years ago

Sorry to post such a dumb question but I've been playing around for the last week and haven't found a way to get this going. I'm new to django, not so new to polymer, and have implemented a couple apps without issue but they had their own urls.py and a views.py to deal with which aligned with what I learned. I haven't found any resources that helped get this set up without those components.

Could you throw up a basic couple of steps on how to get it going?

jrabbit commented 8 years ago

So in your base template (base.html typically) you should have: {% load staticfiles %} {% load polymerdep %} and in your settings.py you should have materialdjango in your INSTALLED_APPS list.

then you can import polymer deps with just the packagename/filename.html e.g. {{ "polymer/polymer.html" | dep}}.

This is just a thin wrapper around django's builtin staticfiles application that serves up our vendored version of polymer. You don't need any special urls.py or views.py all of the heavy lifting is done in the template tag logic. Is that clearer than the readme?

an example base template is included

To use the included widgets in forms just specify them wherever you create the form e.g.

jrabbit commented 8 years ago

so if you're creating your own project off the bat, use django startproject. Check out the django tutorial for a complete introduction. For each template view you want just write a simple view (either a function or a class based view) you'll need a urls.py entry for each view you want to use.

rosiecakes commented 8 years ago

First of all sorry for leaving this up so long, haven't had a chance to come back. Got it working with your help, thanks!

I couldn't get it running alone so created a dummy project and added it. [for other clueless noobs] I added url(r'^materialdjango/', views.temp, name='temp'), in urls.py and a simple view def temp(request): return render(request, 'materialdjango/vinyl-siding.html')

Thanks again