Monday, January 28, 2019

how to aasign id on and how to generates choices on the form of another models for individual id ,choices may be differenet for individual id

class Medical_Meds(models.Model): medicines=models.CharField(max_length=250) amount=models.IntegerField(default=0) # is_purchase=models.BooleanField(default=False) p_date=models.DateTimeField( patient=models.ForeignKey(Patient) medical=models.ForeignKey(Medical) class Medical_Meds_Forms(forms.ModelForm): patient=4, opt = [] # my = Doctor_Patient_Med.objects.all() my = Doctor_Patient_Med.objects.filter(patient=patient) for x in my: opt.append([x.medicines,x.medicines]) total=len(opt) print(total) medicines =forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=opt) amount=forms.IntegerField(label='Amount',initial="0") p_date=forms.widgets.DateTimeInput(attrs={'type':'date'}) # p_date = forms.DateTimeField(label='Purchase-Date', widget=forms.DateTimeInput(attrs={'type':'date'})) class Meta: model=Medical_Meds exclude=['patient','doctor','medical']

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment