issue with django model and form

17 views
Skip to first unread message

Pranay reddy

unread,
Apr 20, 2018, 9:48:09 AM4/20/18
to Django users

I have "user" Model

username email phonenumber

I want to access all "user" model emails in other model "B" and make user to select more than one email and store it has commaseperatedvalues

"B" colums are

  organization Designation share_knowledge_with
    abc           manager   (here all emails which user selected
                                     to be stored with commaseperated)   

I tried like this but not working:

MODEL

class B(models.Model):
   organization=models.CharField(max_length=200,blank=False,null=True)
   emails_for_help = models.TextField(null=True,help_text="select with whom 
   you want to share knowledge") 

form

class Bform(ModelForm): 
 emails_for_help=forms.ModelMultipleChoiceField(queryset=User.objects.all(),
 widget=forms.CheckboxSelectMultiple)
 class Meta:
    model=B
    fields=["organization","emails_for_help"]

I tried like this but it is taking null value in "emails_for_help"

Reply all
Reply to author
Forward
0 new messages