Django
10
Вклад в тег
class Order(models.Model):
title = models.CharField(max_length=255)
body = models.TextField()
creator = models.ForeignKey('User', null=True, blank=True)
class OrderAdmin(admin.ModelAdmin):
fieldsets = [....]
def save_model(self, request, obj, form, change):
if getattr(obj, 'creator', None) is None:
obj.creator = request.user
obj.save()