model subclassing

0 views
Skip to first unread message

Chris

unread,
Apr 9, 2008, 12:30:20 AM4/9/08
to Django users
I am trying create a custom model field that will create 2 field
instances, a CharField and a booleanField. I am using this with
signals and dispatchers to insert data entered from this custom field
into another model/table that contains a boolean and char field. my
question is: how can I return 2 field objects in a single model
subclass class. Seems like it would be similar to what occurs in
datetimeField but not sure how to implement. so end result would look
something like this:

some_model(models.Model):
fields = customFields()

so that I don't have to do something like this in the model that I
will be calling this from

some_model(models.Model):
field_1 = customField1()
field_2 = customField2()

Any pointers on how to do this?

Rajesh Dhawan

unread,
Apr 9, 2008, 10:39:52 AM4/9/08
to Django users
Hi,

On Apr 9, 12:30 am, Chris <macmichae...@gmail.com> wrote:
> I am trying create a custom model field that will create 2 field
> instances, a CharField and a booleanField. I am using this with
> signals and dispatchers to insert data entered from this custom field
> into another model/table that contains a boolean and char field. my
> question is: how can I return 2 field objects in a single model
> subclass class. Seems like it would be similar to what occurs in
> datetimeField but not sure how to implement. so end result would look
> something like this:

<snip>

>
> Any pointers on how to do this?

Download the PDF from here and look at the Custom Model Fields slides:
http://toys.jacobian.org/presentations/2007/oscon/tutorial/

-Rajesh D

Chris

unread,
Apr 9, 2008, 11:04:02 AM4/9/08
to Django users
Thanks looks very helpful. I will look over that when I get a free
moment.
Reply all
Reply to author
Forward
0 new messages