2

i want create a custum auto populated field in admin django like slug but calculate another thing , not slugify. how do this ?

Gal Silberman
  • 3,756
  • 4
  • 31
  • 58

1 Answers1

1

Well, what have you tried? There are couple of answers around, and they all talk about the same thing.. Hooking on the save_model method.

def save_model(self, request, obj, form, change): 
    obj.some_field = "some_value"
    obj.save()

You can look the following:

Django: Populate user ID when saving a model

Auto-populating created_by field with Django admin site

https://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser

Gal Silberman
  • 3,756
  • 4
  • 31
  • 58