Personal tools
You are here: Home Plone XP leocornus.django.ploneproxy General Tips for Django

General Tips for Django

— filed under:

Keep track the general tips for Django Framework

how to get URLs and URIs

in template {% url leocornus.django.ploneproxy.views.login %}

in code, we use the django.core.urlresolvers.reverse to build the URL for a view.

Set default value for new settings

What I think best now is to set the default value in __init__.py of your Django project:

from django.conf import settings
settings.MY_DJANGO_PROP = getattr(settings, 'MY_DJANGO_PROP', 'default') 

Then we will always pick the value from settings.py first, if not found, we will set the default value.

Built-in template tags and filters

http://docs.djangoproject.com/en/dev/ref/templates/builtins/

default tags and filters are defined in file: django.template.defaulttags.py and django.template.defaultfilters.py

URL resolve in Django

The module django.core.urlresolvers is used to take care of the URL resolve and reverse for a Django application.

Tracking History

When Who What Done
2010-05-20 09:39 Sean Chen better way to set the default values for new introduced Django settings. revision r417
-- 1.0 Hours, 25.0% Done
Document Actions