geex-arts / django-jet

Modern responsive template for the Django admin interface with improved functionality. We are proud to announce completely new Jet. Please check out Live Demo

Home Page:https://github.com/jet-admin/jet-bridge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Override save for model doesn't work when i save in Django Jet Admin

attadje opened this issue · comments

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 ?

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