- Author:
- programmerDan
- Posted:
- September 2, 2011
- Language:
- Python
- Version:
- Not specified
- Score:
- 1 (after 1 ratings)
I have been wrestling with custom app labels and have come to the conclusion that this is the easiest workaround for the problem. Since I name most of my apps as Foo_Bar this makes them look a lot nicer. I just apply the filter to whatever app label and it fixes it.
If you need a more complex replacement, you could just have an if statement that looks for the full app label and replaces it with whatever you want.
1 2 3 4 5 6 | @register.filter
def niceLabel(label, arg=None):
label = label.replace("_", " ")
label = label.title()
return label
|
More like this
- Form field with fixed value by roam 3 days, 22 hours ago
- New Snippet! by Antoliny0919 1 week, 3 days ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 2 months, 4 weeks ago
- get_object_or_none by azwdevops 6 months, 3 weeks ago
- Mask sensitive data from logger by agusmakmun 8 months, 2 weeks ago
Comments
Please login first before commenting.