var arr = [];
$('span').each(function() {
var that = $(this).attr('title');
var span = parseInt(that.match(/\d+/ig));
arr.push(span);
var sum = 0;
for (var i = 0; i < arr.length; i++) {
sum = sum + parseInt(arr[i]);
}
$('#id_price').val(sum);
});
class MasterChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return obj.get_full_name()
class MasterAdmin(admin.ModelAdmin):
...
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'master':
return MasterChoiceField(queryset=User.objects.all())
return super().formfield_for_foreignkey(db_field, request, **kwargs)
def abonstat(request):
abons = {}
abform = AbonStatForm(request.GET)
if abform.is_valid():
if abform.cleaned_data['client']:
abons = Uslugi.objects.filter(
client_id=abform.cleaned_data['client'])
return render(request, 'clients/abonstat.html',
{'abons': abons, 'abform': abform})
class JurnalInline(admin.TabularInline):
max_num = 3
ordering = ['-data_poseshenia']