My original issue was that I was trying to attach the current user to new entries, so I override the save_model
method under admin.ModelAdmin
to do
def save_model(self, request, obj, form, change):
obj.submit_usr = request.user
super().save_model(request, obj, form, change)
This works great when I try to create new object or new entry in my db, but when I try to edit the existing one, it still creates a new entry
my model looks like (I took out all the settings to avoid being messy here)
class AppUser(models.Model):
app_name = model.CharField()
submit_usr = models.ForeignKey()
submit_date = model.DateTimeField()
I know that the change
arg indicates if there's a change in existing entry, but I still don't have a way to tell Django that I only want to modify the current entry instead of creating a new one.
Any ideas how to achieve that?