Ajouter param sur form VHC_info
* Ajouter la possibilité de pré-remplir véhicule dans formulaire ajout VHC_info #17
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from django import forms
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
@@ -30,7 +31,17 @@ class _vhc_admin(admin.ModelAdmin):
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class _vhc_infos_admin_form(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Vehicles_infos
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(_vhc_infos_admin_form, self).__init__(*args, **kwargs)
|
||||||
|
if 'initial' in kwargs and 'Vehicle' in kwargs['initial']:
|
||||||
|
self.fields['Vehicle'].queryset = Vehicles.objects.filter(id=kwargs['initial']['Vehicle'])
|
||||||
class _vhc_infos_admin(admin.ModelAdmin):
|
class _vhc_infos_admin(admin.ModelAdmin):
|
||||||
|
form = _vhc_infos_admin_form
|
||||||
always_show_username = True
|
always_show_username = True
|
||||||
save_as = True
|
save_as = True
|
||||||
list_display = ('Vehicle', 'nType', 'sDesc')
|
list_display = ('Vehicle', 'nType', 'sDesc')
|
||||||
|
Reference in New Issue
Block a user