I have to display a calculated property in the model admin's list_display.

```python
class A:
    # attributes

class B:
    a = models.OneToOneField(A, on_delete=models.CASCADE, 
related_name='b_obj')
    timestamp = models.DateTimeField()

class AProxy(A):
    @property
    def calc_prop(self):
        return self.b_obj.timestamp if self.b_obj else 'Some text'

    class Meta:
        proxy = True
```

When I display this `calc_prop` in model admin's list view I always get `-` 
if there is no corresponding `b_obj` related object on AProxy's object. 
What am I doing wrong here?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ff382c07-63fb-4be9-a011-01da80e33f09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to