Django formset: unicity constraint pass form_valid()

2023-06-04 Thread Jérôme Le Carrou
Hi,

I've post my issue on Stackoverflow and do not have any ansewer so far.
Hope some Django dev could me here ;)

I try using FBV (logic more easy to understand for me).

Maybe I should have used inlineformset_facory to deal with FK but for 
conception concerns patient is passed in context.

I faced many issues I've tried to solved but it is more "hack" and I would 
like to find a proper way to do the same:

   1. 
   
   empty_forms was submitted and create a record in database; normally, 
   default formset behavior is not to submit empty formset I manage this case 
   using condition form.cleaned_data != {}. It is maybe cause
   2. 
   
   I define unique_together in my model Traitement. But it seems this is 
   not manage by Django in form validation. When submitting a form with 
   duplicates, IntegrityError is raised. I manage this case using a try-catch 
   bloc. I also tried to define a form validation with clean() method in 
   TraitementForm but doesn't seems to works.
   3. 
   
   With traitement_create() code below, all errors can not be displayed at 
   the same time: forma validation will be displayed but not the 
   IntegretyError if any.
   
I have read many documentation and tutorial but could not find answer.

Don't know how I can post code here so I attached txt doc with part of my 
code.

Jérôme

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1245e851-ca03-4ac4-b6e6-7863eb4b2929n%40googlegroups.com.
#models.py

class Patient(models.Model):
ide = models.AutoField(primary_key=True)
pat = models.CharField("Patient",max_length=5, unique=True, null=True, 
blank=True, error_messages={'unique':'Un patient avec ce code existe déjà'})

class Traitement(models.Model):
ide = models.AutoField(primary_key=True)
pat = models.ForeignKey('Patient',on_delete = models.CASCADE, 
related_name='traitement_patient', db_column='pat')
arv_num = models.IntegerField('Réf/code', null=True, blank=True) 


# views.py
def traitements_create(request, pk):
template_name = 'ecrf/traitements_form.html'
patient = Patient.objects.get(ide=pk)

if request.method == 'POST':
formset = TraitementFormSet(request.POST or None, 
queryset=Traitement.objects.filter(pat=pk)) 
if formset.is_valid():
error_occurred = False
for form in formset:
if form.is_valid() and form.cleaned_data != {}:
try:
traitement = form.save(commit=False)
traitement.pat = patient
traitement.arv_sai_log = request.user.username
traitement.save()
except IntegrityError:
form.add_error('arv_num', 'Une fiche Traitement ARV 
existe déjà pour ce patient avec ce numéro')
error_occurred = True
break  
if not error_occurred:
return redirect('ecrf:patient_list')

else:
formset = TraitementFormSet(queryset=Traitement.objects.filter(pat=pk))
return render(request, template_name, {'formset': formset, 'patient': 
patient})

# forms.py

class TraitementForm(forms.ModelForm):

ide = forms.IntegerField()
arv_num = forms.IntegerField(label = 
'Réf/code',widget=forms.TextInput(attrs={'class': 'form-control','placeholder': 
'','data-mask':'00'})) 
arv_deb_dat = forms.DateField(label = 'Date de début', 
widget=forms.DateInput(attrs={'class': 'form-control datepicker2', 
'autocomplete': 'off', 'placeholder': '', 'data-date-format': 'dd/mm/', 
'data-theme':'dark'}, format='%d/%m/%Y') 
,input_formats=settings.DATE_INPUT_FORMATS,required=False)

class Meta:
model = Traitement
fields = ['ide','arv_num','arv_deb_dat',...,]
  

def clean_arv_deb_dat(self):
data = self.cleaned_data['arv_deb_dat']
if data:
entrydate = datetime.datetime.strptime(str(data), "%Y-%m-%d")
currentdate = datetime.datetime.now()
if entrydate > currentdate:
raise forms.ValidationError("Merci de vérifier la date")
return data

TraitementFormSet = modelformset_factory(
Traitement, 
form=TraitementForm,
extra=1,
)

Django selenium (StaticLiverServerTestCase): tests run together fail but pass if run individually

2022-03-30 Thread Jérôme Le Carrou
 

write tests with *StaticLiverServerTestCase* for my Django application.

*My issue: tests runs together fail while pass when run individually.*

I have read much about this behavior on SO but none of answer/comments help.

It seems that issue may come from shared files/fields/data.

I have tried using setUpClass/tearDownClass class methods as well as 
setUp/tearDown methods.

Using fixture did not resolve anymore.

I also tryed to make individual class for each test instead of one class 
with many test ethods but doesn't work anymore.

My tests involve Ajax calls and I think this is related.


You can see code in SO: 
https://stackoverflow.com/questions/71674587/django-selenium-staticliverservertestcase-tests-run-together-fail-but-pass-if
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ee18a18d-c125-47ec-aeac-d4d7b6e10a87n%40googlegroups.com.


Django: date format management and unique_together -> “20/03/2020” value has an invalid date format. It must be in YYYY-MM-DD format.”]

2020-03-23 Thread Jérôme Le Carrou
Hi,

I develop a Django project with internationalization English/French

dates have to be displayed with the dd/mm/ format when user webbrowser 
is FR and -mm-dd when user webbrowser is EN

to do that, I use JS that test webbrowser user favorite language and 
display format accordingly

That works fine until I change my model to add *unique_together* constraint 
with this date

 

Now, I got the error when webbrowser is in french and I try to register 
date (*asp_ent_dat*)


date format "20/03/2020" is invalid. Correct format is "yyy-mm-dd".
>
>

Reading Django documentation about validation, I 'understand' that 
*unique_together* is the model validation that seems to fail because of 
date format


I try adding DATE_INPUT_FORMATS = ['%Y-%m-%d', '%d-%m-%Y', ] in 
settings.py, the second format corresponding to the french format I need, 
but it does'nt works


*I can I fix my problem:*


*Have unique_together constraint on 3 fields including asp_ent_dat and 
display date in french format in my form?*


*models.py:*

class Entree(models.Model):

asp_ent_cle = models.AutoField(primary_key=True)
asp_ent_loc = models.CharField("Site concerned by the operation", 
max_length=10, null=True, blank=True)
med_num = models.CharField("Trial batch number", max_length=3, null=True, 
blank=True,)
asp_ent_dat = models.DateField("Entry date", null=True, blank=True)
asp_ent_pro_pay = models.CharField("Country of treatment origin in case of 
entry", max_length=10, null=True, blank=True)
asp_ent_pro_sit = models.CharField("Processing source site in case of 
entry", max_length=10, null=True, blank=True)
opr_nom = models.CharField("Input operator", max_length=10, null=True, 
blank=True)
opr_dat = models.DateField("Entry date", null=True, blank=True)
log = HistoricalRecords()

class Meta:

db_table = 'pha_asp_ent'
verbose_name_plural = 'Entries'
ordering = ['asp_ent_cle']
unique_together = ['asp_ent_loc','med_num','asp_ent_dat']  
 
*JS:*

$(function(){

if(window.navigator.language == 'fr-FR' | window.navigator.language == 
'fr'){
$("#id_asp_ent_dat").datepicker(
{
dateFormat: 'dd/mm/yy',
}
);
} 
else
{
$("#id_asp_ent_dat").datepicker(
{
dateFormat: 'yy-mm-dd',
}
);});

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/393c0328-3148-466b-b9e4-eb6111fdaff6%40googlegroups.com.


Django: how to make queries between 2 tables that are not related in the model?

2020-02-13 Thread Jérôme Le Carrou
Hi,

I have 2 models that are not related (maybe it should...)

I need to make a query that select all records of my table Stock WITH 
related rows in Parametrage based on asp_sto_loc=asp_par_loc

Something like SQL: select * from pha_asp_sto left join pha_asp_par on 
pha_asp_par.asp_par_loc=asp_sto_loc;

How can I make such a query in Django?
I have see extra() but seems to be deprecated...
Another option would be to use raw() but not recommended...

class Stock(models.Model):

asp_sto_cle = models.AutoField(primary_key=True)
asp_sto_loc = models.CharField("Site concerned", max_length=10, null=True, 
blank=True)
asp_sto_pla = models.IntegerField("Quantity of placebos available", 
null=True, blank=True,)
asp_sto_asp = models.IntegerField("Quantity of aspirin available", 
null=True, blank=True)
class Parametrage(models.Model):

asp_par_cle = models.AutoField(primary_key=True)
asp_par_loc = models.CharField("Site concerned by settings", max_length=10, 
null=True, blank=True)
asp_par_ale = models.IntegerField("Site alert value for the site", 
null=True, blank=True,)
asp_par_con = models.IntegerField("Site confort value for the site", 
null=True, blank=True,)

thanks for your help 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/029c93e0-4093-4a4f-bc99-b3af000c3c31%40googlegroups.com.


form_add with pre-filled fields

2019-10-17 Thread Jérôme Le Carrou
Hi,

I have a models with 3 classes: Visite, Inclusion, BilanBiologique and 
ExamenBiologique

- Inclusion is linked to Visite (OneToOne)
- BilanBiologique is linked to Visite (ForeignKey)
- ExamenBiologique is linked to BilanBiologique (ForeignKey)
- ExamenBiologique is a subform of BilanBiologique

I use Django admin form
I try to customize my Inclusion admin form to

- have a link that redirect user to BilanBiologique
AND 
- I would like the "vis" field (which is the ForeignKey) to be pre-filled 
with the corresponding value (I can retrieve this value from Inclusion)

I manage to display a link from Inclusion to BilanBiologique using a method 
"examen" in Inclusion class
I have think about using GET method but to be honest I am lost... I have no 
idea how to proceed...

models.py

class Visite(models.Model):
vis_ide = models.AutoField(primary_key=True)
pat = models.ForeignKey(Participante, verbose_name='Participante', 
related_name='visites', on_delete=models.CASCADE)
vis_dat = models.DateField("Date de consultation")

def __str__(self):
return f"{self.pat.pat_ide_prn_cse} / {self.vis_dat}"

class BilanBiologique(models.Model):
bio_ide = models.AutoField(primary_key=True)
vis = models.ForeignKey(Visite, verbose_name='Visite', 
on_delete=models.CASCADE)
bio_dat = models.DateField("Date de prélèvement")

def __str__(self):
return f"{self.bio_ide}"

@property
def date_visite(self):
return self.vis.vis_dat

date_visite.fget.short_description = 'Date de la visite'

@property
def participante(self):
return self.vis.pat.pat_ide_prn_cse

participante.fget.short_description = 'Participante'

class ExamenBiologique(models.Model):
bio_exa_ide = models.AutoField(primary_key=True)
bio = models.ForeignKey(BilanBiologique, verbose_name='Bilans', 
related_name='examens',on_delete=models.CASCADE)
bio_exa_cod = models.IntegerField("Type d'examen")
bio_exa_res_num = models.FloatField("Résultat numérique", 
null=True, blank=True)
bio_exa_res_mod = models.IntegerField("Résultat modalité", 
null=True, blank=True)
bio_exa_uni = models.IntegerField("Unité", null=True, blank=True)
bio_exa_val_inf = models.FloatField("Limite inférieure", null=True, 
blank=True)
bio_exa_val_sup = models.FloatField("Limite supérieure", null=True, 
blank=True)

def __str__(self):
return f"{self.bio_exa_ide}"

class Inclusion(models.Model):
readonly_fields = ('examen',)

inc_ide = models.AutoField(primary_key=True)
vis = models.ForeignKey(Visite, verbose_name='Visite', 
related_name='inclusions', on_delete=models.CASCADE)
inc_tdr = models.IntegerField("Test rapide Determine® VHB (AgHBs)")

def examen(self):
changeform_url = reverse('admin:ecrf_bilanbiologique_add')
return mark_safe('Ajouter un 
bilan'.format(u=changeform_url))
examen.short_description =''
examen.allow_tags = True

def __str__(self):

return f"{self.vis} / {self.inc_ide}"

admin.py

from django.contrib import admin
from .models import Participante, Visite, Inclusion, BilanBiologique, 
ExamenBiologique
from .forms import InclusionFormAdmin, BilanBiologiqueFormAdmin

class ExamenBiologiqueInline(admin.TabularInline):
model = ExamenBiologique
extra = 0

class BilanBiologiqueAdmin(admin.ModelAdmin):
inlines = [ExamenBiologiqueInline,]

class BilanBiologiqueLinkInline(admin.TabularInline):
readonly_fields = ('examen', )
model = BilanBiologique
extra = 0
fields = ('bio_ide', 'vis', 'bio_dat','examen')
form = BilanBiologiqueFormAdmin

class VisiteAdmin(admin.ModelAdmin):
inlines = [BilanBiologiqueLinkInline,]

class InclusionAdmin(admin.ModelAdmin):
readonly_fields = ('examen',)
model = Inclusion
fields = ('vis',('inc_tdr','examen'),)
form = InclusionFormAdmin


admin.site.register(Participante)
admin.site.register(Visite, VisiteAdmin)
admin.site.register(BilanBiologique, BilanBiologiqueAdmin)
admin.site.register(Inclusion, InclusionAdmin)


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fee18697-d98d-40be-b7ed-18322bfc3652%40googlegroups.com.


Why and when I should override the default AdminSite

2019-10-09 Thread Jérôme Le Carrou
I am newbie in DJango
I've started to read Django documentation and particularly the admin 
related documentation

I would like to understand when an why it should be pertinent to override 
the default AdminSite

regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9ecd5e6a-c1b4-4642-8cda-f5746b4b9216%40googlegroups.com.


Re: How to prevent empty record in admin subform

2019-10-09 Thread Jérôme Le Carrou
thanks it works !

Le mercredi 9 octobre 2019 08:54:56 UTC+2, Aldian Fazrihady a écrit :
>
> Can you replace `extra = 1` with `extra = 0` ?
>
> On Wed, Oct 9, 2019 at 1:26 PM Jérôme Le Carrou  > wrote:
>
>> Hello,
>> I am newbie in Django and Python so hope you will be indulgent
>> I've read and read again the Django documentation but for now, some concept 
>> still are very abstract for me...
>>  
>> I have a database and I use ModelForm and I try to customize this admin 
>> forms 
>> I currently have a main form with a subform and both forms are customized
>>
>> I noticed 'abnormal' behavior (unwanted): even when no entry is made in the 
>> subform, empty record is stored in the table corresponding to the subform in 
>> the database
>> how to prevent this?
>> thanks in adavnce fory your help
>>
>> ***
>>
>> Bonjour,
>>
>> Je suis débutant en Django et Python donc j'espère que vous serez indulgent
>> je précise que je lis et relis la doc Django mais pas mal de chose reste 
>> abstraites pour moi pour le moment
>>
>>
>> j'ai mis en place une base de données et des formulaires admin via ModelForm 
>> que j'essaie de personnaliser
>> j'ai donc un formulaire et un sous-formulaire, les deux formulaires sont 
>> personnalisés
>>
>> j'ai noté un comportement 'anormal' (non souhaité) : même lorsqu'aucune 
>> saisie n'est réalisée dans le sous-formulaire, un enregistrement vide est 
>> créé dans la table correspondante au sous-formulaire
>> comment faire pour empêcher cela?
>> d'avance merci pour votre aide
>>
>> models.py : 
>>
>> class SuiviAppuiCommunitaire(SafeDeleteModel):
>>  """ A class to create a Community instance. """
>>  
>>  _safedelete_policy = SOFT_DELETE_CASCADE
>>  com_ide = models.AutoField(primary_key=True)
>>  pat = models.ForeignKey(Participante, verbose_name='Participante', 
>> related_name='community',
>>  on_delete=models.CASCADE)
>>  com_dat = models.DateField("Date de la demande",null=True,blank=True)
>>  com_mot = models.IntegerField("Motif", 
>> max_length=1,null=True,blank=True)
>>  com_det = models.CharField("Détails", 
>> max_length=255,null=True,blank=True)
>>  com_com = models.CharField("", max_length=255,null=True,blank=True)
>>  log = HistoricalRecords()
>>  
>>  class Meta:
>>  
>>  db_table = 'crf_com'
>>  verbose_name_plural = '5.1-Appuis / Suivis communautaires(COM)'
>>  ordering = ['pat', 'com_dat','com_ide']
>>  
>>  def __str__(self):
>>  
>>  return f"{self.com_ide} / {self.pat.pat_ide_prn_cse} / 
>> {self.com_dat}"
>>  @property
>>  def participante(self):
>>  
>>  return self.pat.pat_ide_prn_cse
>>  
>>  participante.fget.short_description = 'Participante'
>>  
>>  class InterventionCommunautaire(SafeDeleteModel):
>>  """ A class to create a Community instance. """
>>  
>>  _safedelete_policy = SOFT_DELETE_CASCADE
>>  com_int_ide = models.AutoField(primary_key=True)
>>  com = models.ForeignKey(SuiviAppuiCommunitaire, verbose_name='Suivi / 
>> appui communautaire', related_name='interventions',
>>  on_delete=models.CASCADE)
>>  com_int_dat = models.DateTimeField("Date", null=True, blank=True)#  
>> com_int_edu = models.CharField("Paire-éducatrice", max_length=1)
>>  com_int_edu = models.ForeignKey(Personnel, verbose_name='Personnel', 
>> related_name='communitiInterventions', on_delete=models.PROTECT, null=True, 
>> blank=True)
>>  com_int_typ = models.IntegerField("Type")
>>  com_int_vue = models.IntegerField("La participante a-t-elle été 
>> contactée/vue ?")
>>  com_int_rea = models.CharField("si oui, intervention réalisées", 
>> max_length=255)
>>  com_int_rdv = models.IntegerField("Avez-vous fixé un nouveau 
>> rendez-vous ?")
>>  com_int_rdv_dat = models.DateTimeField("Si oui, date du prochain 
>> rendez-vous", null=True, blank=True)
>>  com_int_rdv_lie = models.IntegerField("Lieu")
>>  log = Historica

How to prevent empty record in admin subform

2019-10-08 Thread Jérôme Le Carrou


Hello,
I am newbie in Django and Python so hope you will be indulgent
I've read and read again the Django documentation but for now, some concept 
still are very abstract for me...
 
I have a database and I use ModelForm and I try to customize this admin forms 
I currently have a main form with a subform and both forms are customized

I noticed 'abnormal' behavior (unwanted): even when no entry is made in the 
subform, empty record is stored in the table corresponding to the subform in 
the database
how to prevent this?
thanks in adavnce fory your help

***

Bonjour,

Je suis débutant en Django et Python donc j'espère que vous serez indulgent
je précise que je lis et relis la doc Django mais pas mal de chose reste 
abstraites pour moi pour le moment


j'ai mis en place une base de données et des formulaires admin via ModelForm 
que j'essaie de personnaliser
j'ai donc un formulaire et un sous-formulaire, les deux formulaires sont 
personnalisés

j'ai noté un comportement 'anormal' (non souhaité) : même lorsqu'aucune saisie 
n'est réalisée dans le sous-formulaire, un enregistrement vide est créé dans la 
table correspondante au sous-formulaire
comment faire pour empêcher cela?
d'avance merci pour votre aide

models.py : 

class SuiviAppuiCommunitaire(SafeDeleteModel):
""" A class to create a Community instance. """
 
_safedelete_policy = SOFT_DELETE_CASCADE
com_ide = models.AutoField(primary_key=True)
pat = models.ForeignKey(Participante, verbose_name='Participante', 
related_name='community',
on_delete=models.CASCADE)
com_dat = models.DateField("Date de la demande",null=True,blank=True)
com_mot = models.IntegerField("Motif", 
max_length=1,null=True,blank=True)
com_det = models.CharField("Détails", 
max_length=255,null=True,blank=True)
com_com = models.CharField("", max_length=255,null=True,blank=True)
log = HistoricalRecords()
 
class Meta:
 
db_table = 'crf_com'
verbose_name_plural = '5.1-Appuis / Suivis communautaires(COM)'
ordering = ['pat', 'com_dat','com_ide']
 
def __str__(self):
 
return f"{self.com_ide} / {self.pat.pat_ide_prn_cse} / 
{self.com_dat}"
 @property
def participante(self):
 
return self.pat.pat_ide_prn_cse
 
participante.fget.short_description = 'Participante'
 
 class InterventionCommunautaire(SafeDeleteModel):
""" A class to create a Community instance. """
 
_safedelete_policy = SOFT_DELETE_CASCADE
com_int_ide = models.AutoField(primary_key=True)
com = models.ForeignKey(SuiviAppuiCommunitaire, verbose_name='Suivi / 
appui communautaire', related_name='interventions',
on_delete=models.CASCADE)
com_int_dat = models.DateTimeField("Date", null=True, blank=True)#  
com_int_edu = models.CharField("Paire-éducatrice", max_length=1)
com_int_edu = models.ForeignKey(Personnel, verbose_name='Personnel', 
related_name='communitiInterventions', on_delete=models.PROTECT, null=True, 
blank=True)
com_int_typ = models.IntegerField("Type")
com_int_vue = models.IntegerField("La participante a-t-elle été 
contactée/vue ?")
com_int_rea = models.CharField("si oui, intervention réalisées", 
max_length=255)
com_int_rdv = models.IntegerField("Avez-vous fixé un nouveau 
rendez-vous ?")
com_int_rdv_dat = models.DateTimeField("Si oui, date du prochain 
rendez-vous", null=True, blank=True)
com_int_rdv_lie = models.IntegerField("Lieu")
log = HistoricalRecords()
 
class Meta:
 
db_table = 'crf_com_int'
verbose_name_plural = 'Interventions communautaires'
ordering = ['com_int_dat','com', 'com_int_ide']
 
def __str__(self):
return f"{self.com_int_ide} / {(self.com_int_dat)}"

admin.py : 

class InterventionCommunautaireFormAdmin(forms.ModelForm):
""" A class to customised the admin form for community interventions. """
 
TYPES = Thesaurus.options_list(52)
VUES = Thesaurus.options_list(1)
NOUVEAUX = Thesaurus.options_list(53)
LIEUX = Thesaurus.options_list(44)
com_int_dat = forms.DateTimeField(label="Date", required=False)
com_int_typ = forms.ChoiceField(label="Type", widget=forms.Select, 
choices=TYPES)
com_int_rea = forms.CharField(label="si oui, interventions réalisées" , 
widget=forms.Textarea, required=False)
com_int_vue = forms.ChoiceField(label="La participante a-t-elle été 
contactée/vue ?", widget=forms.Select, choices=VUES)
com_int_rdv = forms.ChoiceField(label="Avez-vous fixé un nouveau 
rendez-vous ?", widget=forms.Select, choices=NOUVEAUX)
com_int_rdv_dat = forms.DateTimeField(label="Si oui, date du prochain 
rendez-vous", required=False)
com_int_rdv_lie = forms.ChoiceField(label="Lieu", widget=forms.Select, 
choices=LIEUX)
 

Problem with safedelete implementation

2019-09-30 Thread Jérôme Le Carrou
Hi 

I am new on this forum and very, very new user of Django so hope you will 
be uncensorious

I need to implement the safedelete application 
(https://buildmedia.readthedocs.org/media/pdf/django-safedelete/latest/django-safedelete.pdf)
 
for my project but I should have miss something in the documentation 
because I did non manage tu use it correctly

I will expose you briefly my problem
I have 2 classes BiologyAssessment and BiologyExam linked with a 
foreignKey: a biologicalassessment is linked with multiple biologicalexam

When I delete a biologicalassessment, I want related biologicalexamn to be 
'delete' (but soft delete)
When I delete a biologicalexam, I want biologicalexam to be delete (soft 
delete)

I have implemented in my project but unfortunetly, when I delete a 
biologicalexam, the linked biologicalasessment is also delete
I have try different to use _safedelete_policy = SOFT_DELETE for my 
BiologicalExam class but it does not chage anything 

could you help me ?

models.py

class BiologicalAssessment(SafeDeleteModel):

_safedelete_policy = SOFT_DELETE_CASCADE
ide = models.AutoField(primary_key=True)
vis_ref = models.ForeignKey(Visite, verbose_name='Visite', 
related_name='bilan', on_delete=models.CASCADE)
bio_prv_dat = models.DateField("Date de prélèvement")

class BiologicalExam(SafeDeleteModel):

_safedelete_policy = SOFT_DELETE_CASCADE
ide = models.AutoField(primary_key=True)
bio_ref = models.ForeignKey(BiologicalAssessment, 
verbose_name='Bilans', related_name='examen', on_delete=models.CASCADE)
bio_exa_cod = models.CharField("Type d'examen", max_length=3)
bio_exa_val = models.FloatField("Résultat de l'examen")
bio_exa_uni = models.CharField("Unité", max_length=50)
bio_exa_val_inf = models.FloatField("Limite inférieure")
bio_exa_val_sup = models.FloatField("Limite supérieure")

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e88df26-bd24-430d-a432-7094a194183d%40googlegroups.com.