After long time with Android, I’m doing some part-time web development again, this time with Django. Being Django noob, I’m “OMG” about the vastness of the ecosystem around it. Some pointers and gotchas I’ve encountered in past couple days:
- Django Best Practices document, and linked resources, e.g. Django Coding Style. This lead me to
- Rearranging and renaming my templates
- Splitting up my
urls.pyfile - Getting I18N to work early.
LOCALE_PATHSmust be set insettings.py! - Moving my stuff into an virtualenv
Also reassured some things I had done were right to do:
- Start populating
DEVELOP.txtandREADME.txtearly on - Install requirements with
pipfromrequirements.txt. My app doesn’t havesetup.pyyet, and it isn’t managed by Silver Lining, I’ll think about deployment options when it’s closer to being somewhat ready
-
There was a bit of mess with static files. I’m using django.contrib.staticfiles, and my
STATIC_ROOTandSTATICFILES_DIRSvariables are set like here (except I have “whatever” instead of “bla” inSTATIC_ROOTand this path doesn’t have to exist by the way). - I’m playing with django-cms. Some discoveries:
- CMS toolbar didn’t show up in my templates, turns out had to add
{{ cms_toolbar }}tag in templates. - South, the intelligent schema and data migrations thing seems nice. But it broke my tests, I had to add
SOUTH_TESTS_MIGRATE = Falseinsettings.pyto fix this - Sekizai is a neat useful library. It’s used in django-cms for handling css and js imports in templates
- CMS toolbar didn’t show up in my templates, turns out had to add
- When I run tests with
./manage.py testit appears all the included tests for Django and all of the things in myINSTALLED_APPSare run. Signifcant portion of them fail, and that’s apparently normal. For example, Sekizai ships with tests but with no templates that the tests use–in my setup these tests have no chance to succeed. So apparently I should only test my stuff, like so:./manage.py test my_cool_app my_other_cool_app ... - I’m developing in Eclipse, with PyDev plugin. PyDev has special project type “Django project”. With that set up, I can run
manage.pycommands and development server from within Eclipse. That’s cool, but I’m so used to console… - Overall I’m impressed by readability of the code. When facing a problem, it’s sometimes more productive to view .py source than search on internets
- That’s it for now, but there’s lot more to come, because, LOOK AT THIS
Advertisement
0 Responses to “Hello Django”