def log(self, flag, message, obj=None): log = Log(user=self.user, ip_addr=self.request.META['REMOTE_ADDR'], action_flag=flag, message=message) if obj: log.content_type = get_content_type_for_model(obj) log.object_id = obj.pk log.object_repr = force_text(obj) log.save()
def log(request, message, flag='api', obj=None): from xadmin.models import Log log = Log(user=request.user, ip_addr=request.META['REMOTE_ADDR'], action_flag=flag, message=message) if obj: log.content_type = get_content_type_for_model(obj) log.object_id = obj.pk log.object_repr = force_text(obj) log.save()