Hello Django

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.py file
    • Getting I18N to work early. LOCALE_PATHS must be set in settings.py!
    • Moving my stuff into an virtualenv

    Also reassured some things I had done were right to do:

    • Start populating DEVELOP.txt and README.txt early on
    • Install requirements with pip from requirements.txt. My app doesn’t have setup.py yet, 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_ROOT and STATICFILES_DIRS variables are set like here (except I have “whatever” instead of “bla” in STATIC_ROOT and 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 = False in settings.py to fix this
    • Sekizai is a neat useful library. It’s used in django-cms for handling css and js imports in templates
  • When I run tests with ./manage.py test it appears all the included tests for Django and all of the things in my INSTALLED_APPS are 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.py commands 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
Advertisements