Friday, September 30, 2011

Re: Define Meta attributes at runtime

I don't believe you'd be able to do this without altering the code for
the framework itself; the Django model metaclass hides the Meta
attribute (among other things) for non-abstract-base classes.

On Sep 30, 6:45 am, Isaac <vyrp...@gmail.com> wrote:
> Hi folks,
>
> I'm wondering if it's possible to set / redefine Meta attributes of a
> given model at runtime.
>
> The problem arises because I'm using a framework with many classes
> defined there, and interacting in a right way. I need to redefine some
> of Meta attributes of that class, but without overriding framework file,
> because it can cause many trouble in any update.
>
> Anyone know how I can access them?
>
> To set an example:
>
> folder1
>      __init__.py
>      models.py
>
> from folder1.models import ModelTrouble
>
> ModelTrouble.Meta.verbose_name = "my_verbose_name"
>
> Thanks in advance
> Isaac

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment