Thanks for the suggestions, everyone.

It seems to be popping up for all sorts of things -- from changing
verbose_name in order to globally relabel form fields in ModelForms to
changing __unicode__ methods to change template output.  I know there
are workarounds, but they seem less DRY.

On Sep 27, 5:02 pm, Michael Williamson <mikerwilliam...@yahoo.co.uk>
wrote:
> On Sep 25, 9:59 pm, ringemup <ringe...@gmail.com> wrote:
>
> > Is there an easy way to override strings like help_text or
> > verbose_name or __unicode__ methods for models in contrib or third-
> > party apps?  I can't seem to find anything on Google.
>
> > Thanks!
>
> A reasonably hacktastic way of doing this is monkey-patching. For
> instance, say you want to override the __unicode__ method of the class
> Blog. Firstly, write the new method e.g.
>
>     def new_unicode(self):
>         return self._name
>
> Then, set the __unicode__ method of Blog to your new function:
>
>     Blog.__unicode__ = new_unicode
>
> Is this a horrible piece of code? Absolutely. But it is quick, and it
> works. A clean solution depends more on why you actually want to do
> this.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to