Index of /code/django/fields

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [TXT] forms.py 29-Jul-2006 21:47 2.5K [TXT] models.py 29-Jul-2006 22:04 1.4K
DISCLAYMER:
This is a hack. There will definetly some day be a nicer way to do this in django.
Until then, this is a working alternative.

Currently only CharField and TextField are implemented.

Keep an eye on this thread
http://groups.google.com/group/django-users/browse_frm/thread/88cb63575a8dbd66/70db78dbead62ae8?tvc=1
if you're interested in using this.

As usual, if your computer explodes by using this it's not my fault.


Usage:
Put models.py and forms.py into your project folder.
e.g.
myproject/models.py
myproject/forms.py

In your myproject/myapp/models.py instead of:
from django.db import models

use:
from myproject import models

class Whatever(models.Model):
    ...
    title = models.CharField(maxlength=128,
      html_attributes={
        'size': 15,
        'class': 'myCssClass'
      }
    )
    content = models.TextField(
      html_attributes={
        'dojoType': 'Editor',
        'items': 'formatBlock;textGroup;|;justifyGroup'
      }
    )

The fields are then rendered like:
<input type="text" id="id_title" class="vTextField required myCssClass" name="title" size="15" value="" maxlength="128" />

<textarea rows="10" name="content" cols="40" class="vLargeTextField required" id="id_content" dojoType="Editor" items="formatBlock;textGroup;|;justifyGroup"></textarea>


All other django model fields like DateTimeField, SlugField and so on are passed through unchanged.

have fun :)

Questions? Ideas?
Drop a mail to sa at c-area dot ch