Sorry for the weird wording below. Speech to text isn't all is cracked up to be. Just one more point: the JSONField allows your to easily do queries on the individual email addresses if your need to.
On April 17, 2021 12:52:15 PM CDT, Ryan Nowakowski <[email protected]> wrote: >I've had a similar issue in the past. With the latest version of Django >pretty much each database back in now supports JSONField. So I created >a custom field that inherits from JSON field to take a string of comma >delimited values, split them by comma, validate each value >individually, then store the whole thing in the database as a JSON >list. > >In your case you'll use the email validator used by the EmailField to >validate each value. > >On April 15, 2021 3:21:44 PM CDT, Smiley <[email protected]> >wrote: >>Hello, >> >>I have another problem. >> >>I am trying to get CC to accept multiple email addresses but I do not >>seem >>to get it to work as it always says *Enter a valid email address*. >I've >> >>searched for solutions, heard the new field *MultiValueField* but I >>also do >>not know how to use this in *forms.py*. >> >>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> >>This is my *forms.py* code: >> >>from django import forms >># from django.forms.fields import MultiValueField >>from django.forms.widgets import EmailInput, TextInput >> >> >>class ComposeForm(forms.Form): >> email_to = forms.EmailField(label="To", widget=EmailInput(attrs >>={"size": 76})) >> email_cc = forms.EmailField( >> label="CC", >> required=False, >> widget=EmailInput(attrs={"size": 76, "multiple": True}), >> ) >> email_subject = forms.CharField( >> required=False, widget=TextInput(attrs >>={"placeholder": "Subject", "size": 76}) >> ) >> email_message = forms.CharField( >> required=True, label="", widget=forms.Textarea(attrs >>={"rows": 19, "cols": 78}) >> ) >> >>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> >>And this is my *views.py* code: >> >>from django.shortcuts import render >> >>from .forms import ComposeForm >> >> >>def email_template(request): >> if request.method == "GET": >> form = ComposeForm() >> else: >> form = ComposeForm(request.POST) >> if form.is_valid(): >> print(form) >> email_to = form.cleaned_data["email_to"] >> email_cc = form.cleaned_data["email_cc"] >> email_subject = form.cleaned_data["email_subject"] >> email_message = form.cleaned_data["email_message"] >> >> print("Emails:", email_cc) >> else: >> print("DEBUG:", form.errors) >> return render(request, "email_template.html", {"form": form}) >> >>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> >>And this is my *email_template.html* HTML: >> >><!DOCTYPE html> >><html lang="en"> >><head> >> <meta charset="UTF-8"> >> <meta http-equiv="X-UA-Compatible" content="IE=edge"> >> <meta name="viewport" content="width=device-width, >initial-scale=1.0"> >> <title>Home</title> >></head> >><body> >> <form method="POST"> >> {% csrf_token %} >> <table> >> {{ form.as_table }} >> </table> >> <input type="submit" value="Submit"> >> </form> >></body> >></html> >> >> >>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> >>Please tell me whether it's possible to have multiple email addresses >>in >>*email_cc* aka *CC* field in Django or do I have to use frontend >>frameworks >>for this one job or start using one for better practice (get used to >>using >>frameworks to build frontend side)? >> >>Please advise. >> >>Regards, >>Kristen >> >>[email protected] kirjutas teisipäev, 23. märts 2021 kl 22:24:01 >>UTC+2: >> >>> I have implement it as a bootstrap modal where a Form with fields >are >> >>> shown. When User click submit the Page load New but If you don't >want >>that >>> Page is load New you need a Ajax jquery submit to django >>> >>> Kristen <[email protected]> schrieb am Mo., 22. März 2021, 15:46: >>> >>>> Hello, >>>> >>>> Correct. I want to the user to click a button and have a form >appear >> >>>> where the user can compose an email. >>>> >>>> Gmail uses javascript to render their form on top of the inbox >>because >>>>> they don't want you to have to leave the inbox page. You probably >>don't >>>>> have that requirement. >>>>> >>>>> Let me know if that works for you. >>>>> >>>> >>>> I don't really want to redirect the user elsewhere. I would really >>like >>>> to do the Gmail way because I like it and thought maybe it's >>possible with >>>> Django. >>>> >>>> Nonetheless, I will try out your idea because my curiosity wants to >>know >>>> whether it's worth the effort to do it the Gmail way or go easier >>route way >>>> by doing it just as you explained. >>>> >>>> Let me know what you think of it, the Gmail way idea. >>>> >>>> Kind 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 [email protected]. >>>> >>> To view this discussion on the web visit >>>> >>https://groups.google.com/d/msgid/django-users/CADGe-3u6cCMfZ-s2BfmntXK6WMGh7AYO%3D%2BBk7KJyCGJycSp1pw%40mail.gmail.com >> >>>> >><https://groups.google.com/d/msgid/django-users/CADGe-3u6cCMfZ-s2BfmntXK6WMGh7AYO%3D%2BBk7KJyCGJycSp1pw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >> >>-- >>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 [email protected]. >>To view this discussion on the web visit >>https://groups.google.com/d/msgid/django-users/0ca61efa-8033-4e4b-9fa0-7b5805b6cc43n%40googlegroups.com. > >-- >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 [email protected]. >To view this discussion on the web visit >https://groups.google.com/d/msgid/django-users/E3EF3D2C-8B39-4AB3-B176-A32F2AFB0128%40fattuba.com. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1F23BF1B-9725-458C-8AF6-D898FC7623B9%40fattuba.com.

