On Mar 26, 12:26 pm, Roman Klesel <[email protected]> wrote:
> Hello,
>
> in my App I would like some Models to accept some custom Meta options like
> this:
>
> class MyModel(models.Model)
>
> name = models.CharField(...)
> other = models.CharField(...)
> more = models.CharField(...)
>
> class Meta:
>
> db_table = "my_table"
> custom_option = True
I think there are three steps to do this:
1. Create a subclass of models.base.ModelBase (called OwnModelBase
for this example)
2. Override methods you want to customize.
3. Model definition:
class MyModel(models.Model):
__metaclass__ = OwnModelBase
...
I think that should work, although I haven't tested this. For examples
transmeta has an overridden metaclass, so you can check what they do
[http://code.google.com/p/django-transmeta/source/browse/trunk/
transmeta/__init__.py].
- Anssi
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.