Override save for model doesn't work when i save in Django Jet Admin
attadje opened this issue · 1 comments
attadje commented
Hi,
I wanted to know if it was possible to override the save method for it work on django jet admin.
I override the save method in my model like bellow:
def save(self, *args, **kwargs): self.user_name = "{} {}".format(self.last_name.title(), self.first_name.title()) super(Customer, self).save(self, *args, **kwargs)
It work perfectly in the standard Django admin but not in Django-Jet admin.
It is possible to do something like this with Django jet ?
ljluestc commented
from django.db import models
from django.contrib.auth.models import AbstractUser
class Customer(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
user_name = models.CharField(max_length=200)
def save(self, *args, **kwargs):
self.user_name = "{} {}".format(self.last_name.title(), self.first_name.title())
super().save(*args, **kwargs) # Corrected call to parent class's save method
# Register your model with Django Jet admin as usual