Do not use Meta.verbose_name as related field name, find a better way

Issue #4 resolved
Branko Vukelic created an issue

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)

  1. Branko Vukelic reporter

    This seems to be the right solution:

    >>> class Foo(object):
    ...     pass
    ... 
    >>> f = Foo()
    >>> f.__class__.__name__.lower()
    'foo'
    
  2. Branko Vukelic 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'
    
  3. Log in to comment