Do not use Meta.verbose_name as related field name, find a better way
Issue #4
resolved
I think I've caught somewhere on the Internet that there's a more generic way, which should work even if verbose_name is not defined. I could also just lowercase the class name (or maybe that's the method I've seen).
Comments (5)
-
reporter -
reporter This seems to be the right solution:
>>> class Foo(object): ... pass ... >>> f = Foo() >>> f.__class__.__name__.lower() 'foo'
-
reporter Confirming that it works as expected with django models:
In [1]: from bus.models import Trip In [2]: t = Trip() In [3]: t.__class__.__name__ Out[3]: 'Trip' In [4]: t.__class__.__name__.lower() Out[4]: 'trip'
-
reporter - changed status to resolved
Fixed
#4: Use class name instead of verbose_name→ <<cset 1256598d959d>>
-
reporter - changed milestone to 0.0.3 COMPLETED
- Log in to comment
str(obj.__class__.__name__).lower()
should work fine in this case.EDIT: braino...