Django Models
Python manage.py makemigrations
Python manage.py migrate
python manage.py migrate --run-syncdb
Listing 7-12. Django model with custom save() method
class Store(models.Model): name = models.CharField(max_length=30) address = models.CharField(max_length=30) city = models.CharField(max_length=30) state = models.CharField(max_length=2) def save(self, *args, **kwargs): # Do custom logic here (e.g. validation, logging, call third party service) # Run default save() method super(Store,self).save(*args, **kwargs)
ความคิดเห็น
แสดงความคิดเห็น