Best way to change Site.__str__ to return name not domain

20 views
Skip to first unread message

Michael Jones

unread,
Oct 7, 2014, 9:25:05 AM10/7/14
to django...@googlegroups.com
Hi,

I am using the sites framework and finding it very useful but I would prefer the Site.__str__ method to return the site name instead of the domain. What is the best way of going about that? Is it reasonable to monkey patch it or do I need to make my own sites app with a copy of the code?

It is for situations that I don't control like the admin interface and 3rd party apps displaying the Site objects.

Any help would be much appreciated,
Michael

Collin Anderson

unread,
Oct 13, 2014, 10:55:32 AM10/13/14
to django...@googlegroups.com
Hi Michael,

As you said, it sounds like monkey patching is your best option, besides re-writing the whole sites app.

You could, if you wanted to, explain your use-case on the django-developers mailing list and propose having "swappable" site models, which would help you out.


Collin

Reply all
Reply to author
Forward
0 new messages