Tag: django

Fixing date input in Django

Posted by – February 18, 2009

There’s no doubt about Django and its agile development nature, but there are some circustances where we need take more care on user input, one of these circustances is date input, after few hours googling about it I finally found a way to fix date input by just using DateTimeInput widget on DateField of Django ModelForm.

More

Share

Changing field widget attributes from view code

Posted by – February 3, 2009

Yesterday I finally wrote my first Django application, this application is a basic crud that contains two pages, one to list costumers and another to change costumer data.

My biggest challenge was related with some form features, with Django forms you can programatically create a view form that contains several fields with its constraints and optionally associate a Django widget with this field. Django forms also have a very powerful validation engine and some form field constraints must be defined for this purpose.

This application uses the same page for two purposes, to add new data or edit data, in this scenario I must use a hidden field to be used as flag indicating in which mode the page is, adding or editing data, I must also change the readonly attribute of input widget used by costumer id form field since the user can’t change costumer id.
More

Share

Evaluating Django

Posted by – September 1, 2008

In the next weeks I’ll try to take a closer look on this framework, it has a lot of nice features, one of then is your O/R mapper, very easy to work with, you can create your database using the model classes by running few commands, giving an idea about how much productive this framework can be for database driven applications.

Here’s a example of django model classes:

models.py

1
2
3
4
5
6
from django.db import models

class Friend(models.Model):
    name = models.CharField(max_length=200)
    phone_numer = models.CharField(max_length=200)
    birth_date = models.DateTimeField('birth date')

You can generate the application database containing “friend” table by just running the command python manage.py sql appname and python manage.py syncdb.

But the model layer isn’t enougth on a web application framework, we still still need consider the controller and view layers.
More

Share