Some functions in models.py