This is fine, but might be better in SQL:
```python
results = self.container_set.filter(type=container_type).aggregate(Max('num'))
container_num = results.get('num__max', 1)
```

https://docs.djangoproject.com/en/1.6/ref/models/querysets/#max