We are a small, intelligent App development studio. We love "Building Amazing Apps", solving problems and cultivating strong relationships with our clients.
The magic of metaclasses in Python
By : Shabda Raaj
Metaclasses are a way for you to have a class act as the template for another class. They are simlar to a classfactory,
in that they create new classes. In words of Tim Peters Metaclasses are deeper magic than 99% of people are going to need.
However, in right hands they can be a potent tool, in particular Django uses metaclasses beautifully to create very beautiful declarative models. Without further ado, here is a very simple (and very wrong) metaclass example.
class Z(type):
def __new__(cls, name, bases, attrs, ):
print cls, name, bases, attrs
class A(object):
__metaclass__ = Z ...Writing your own template loaders
By : Shabda Raaj
Django has three builtin template loaders which are used to get the templates for rendering.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
Writing your template loader is a awfuly easy. It is a callable which
- Returns a tuple of (openfile, filename) if it can find the template.
- Raise TemplateDoesNotExist if the templates cannot be found.
The simplest template loader can be
from django.template import TemplateDoesNotExist
def load_template_source(template_name, template_dirs=None):
try:
return open(template_name).read(), template_name
except IOError:
raise TemplateDoesNotExist, template_name
if you put this to your template loaders directory ...
more info..Django gotchas
By : Shabda Raaj
This is announcement about our new work, Django Gotchas, a teeny tiny ebook about commonly occurring gotchas with Django. Here is the readme copied from the project.
Django-gotchas is a collections of gotchas which happen commonly when you are working with Django. They are some errors which I have made commonly or seen others do, these are not the errors which happen because they are hard to reason about, these are those errors which hapen when you close your eyes for a moment when coding.
This is still very much a work in progress, released in the spirit of release ...
more info..- Common testing scenarios for Django app.
- Logging in Django
- Serving static files in Django
- Two Scoops of Django: Review
- Introduction to Python Workshop on February 15th, 2013
- Easy client side form validations for Django: Django Parsley
- MoreApps - Android Library Project: Open Sourced
- Tutorial: Building a Chrome app
- Password Generator App: Open Sourced
- Todo List App: Open Sourced
- April 2013
- March 2013
- February 2013
- January 2013
- November 2012
- October 2012
- September 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- October 2011
- September 2011
- July 2011
- June 2011
- April 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- June 2010
- April 2010
- March 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- April 2009
- March 2009
- February 2009
- November 2008
- October 2008
- June 2008
- May 2008
- April 2008
Django for a Rails Developer
By : ashok
This is not yet another Django vs Rails blog post. It is a compilation of notes I made working with Django after having worked on Rails for years.
In this post I want to give a brief introduction to Django project layout from a Rails developer point of view, on what is there, what is not there and where to look for things. It should help a rails developer working on django be able to find the necessary files and underatnd the layout of the project files.
Once you have both the frameworks installed on your system you can create ...
more info..