-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQIcBAEBCAAGBQJUfTb3AAoJEC0ft5FqUuEhRQYQAJOOo78AehMdFTigk9f9/KY4
MF31MubqqV+LjGrYNbsbpQyWcQBXf4MrMslhqH/kqG0R1gRLrjp0ACX1hIEYwoVr
eRTmgI2djQfvFfuYopnUh6iZjnRCwcQgNg+Ql29s/aQ3khb4ZiuQjkTt9YpW99RM
y+m/7Z0XBp0T9bPwjhzQbqSJNQRsHNFSIyGXCfFMqOwfAhYVAnhEamvBdIJyPce3
sC1pkm14qO6wE6ZJWofICQDkD5XT6w5eDiAfvGu0n+jF4E0EKMXt/1Ls+AfA3OPJ
+zPP8PN4B4tBrSKurFtxRkX88UCeDiOgitaHPhOpX75BZGunOdYPEeMz/GCEo9Ug
OyVIkZgz2ihezf8mON7On3qQzRe3ZmEzk590wxdyuMSfYF8/oOyoOPJENkfaxhnL
/hm6zGNborVTui5tdZJzTUR+ZapR5QJsDQgclABmdOQuzHygppZ5VYY/I9PvYrlU
SKE4Y1l+oXom+kmoaZqlCtBW3WIozMlIDBMIiGqrgRhrC2iUfdFXj5av5PYyJ7qX
WVlVZ5YlCbAz4E9N9RliP1SRJv7wuo2Y8sF7hkuh0wVPKk0hlJyiD24GOtiI8H5p
cV9i/HHmtVwnkK8De8aBi7hEikKfacSc3EI3KyqIEC++xUDF0kRywhgRGRRKuKYG
gnGCnOQpwNLNlSotmFG1
=kcrP
-----END PGP SIGNATURE-----
Hi JJ,
To make a form for users to add/remove emails with a linked model
approach, you'll need an inline model formset:
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets
Carl
On 12/01/2014 07:47 PM, JJ Zolper wrote:
> Carl,
>
> I went ahead and tried your implementation suggestion and I am at a
> point now that I am not sure what to do next:
>
> # Athlete Email
>
> classAthleteEmail(models.Model):
>
> athlete = models.ForeignKey(Athlete)
>
> email = models.EmailField(unique=True)
>
> verified = models.BooleanField(default=False)
>
>
> This way basically any athlete which is the "profile" user extension
> wants to add an email they can in this way as this email object is FK'ed
> to their profile. Also, then once they verify an email the boolean there
> is flipped to true.
>
> The next step to me at least is to then build a form from a modelform of
> the above and then render this in a view so the form:
>
> classAthleteProfileEmailUpdateForm(ModelForm):
>
> athleteemail = forms.EmailField(label=(u'Athlete Email Address:'))
>
>
> classMeta:
>
> model = AthleteEmail
>
> exclude = ('athlete', 'verified',)
>
> fields = ['email',]
>
>
> At this point I'm not sure though, let me try to explain. For example on
> my profile module:
>
> # Athlete User
>
> classAthlete(models.Model):
>
> athleteuser = models.OneToOneField(User)
>
> athleteavatar = models.ImageField("Profile Pic",
> upload_to="images/", blank=True, null=True,
> default='images/default/no-img.jpg')
>
> athletebirthday = models.DateField(blank=True, null=True)
>
> athleteurl = models.CharField(max_length=30, unique=True,
> blank=True) # Must limit to a-z && A-Z && and 0-9 chars,
> validators=[validate_slug]
>
> athletelanguage = models.CharField(max_length=15, blank=True)
>
> athletecommunities = models.ManyToManyField('communities.Community',
> blank=True, null=True)
>
> athletecolleges = models.ManyToManyField('colleges.College',
> blank=True, null=True)
>
> athletetwitterscreenname = models.CharField(max_length=30, blank=True)
>
> isVerified = models.BooleanField(default=False)
>
>
>
> User.profile = property(lambdau:
> Athlete.objects.get_or_create(athleteuser=u)[0])
>
>
> You can see this line: User.profile = property(lambda u:
> Athlete.objects.get_or_create(athleteuser=u)[0])
>
> then the form:
>
> # Athlete Update Profile Form
>
> classAthleteProfileUpdateForm(ModelForm):
>
> athleteavatar = forms.ImageField(label=(u'Athlete Avatar:'))
>
> athletebirthday = forms.CharField(label=(u'Athlete Birthday:'))
>
> athleteurl = forms.CharField(label=(u'Athlete Url:'))
>
> #athletecommunities = forms.MultipleChoiceField(label=(u'Athlete
> Communities:'), widget=forms.CheckboxSelectMultiple, required=False,
> choices=ATHLETECOMMUNITIESCHOICES)
>
>
>
> classMeta:
>
> model = Athlete
>
> exclude = ('athleteuser',)
>
> fields = ['athleteavatar', 'athletebirthday', 'athleteurl',
> 'athletecommunities']
>
>
> which then allows me in a view to:
>
> athleteprofile = AthleteProfileUpdateForm(instance = profile)
>
> thereby displaying a form with the already submitted contents in the
> form. However, I'm not sure how to do this with my current situation. I
> would assume a similar approach so basically collecting all the email
> objects and more specifically the email fields within that object that
> relates to the current or logged in user profile and then for looping
> over those items in a form. To me that would be the way that then I
> could dynamically show them all emails they have and allow them to edit
> them. I believe if I could implement this I could figure out how to do
> the rest that I need.
>
> Do you have any ideas?
>
> Thanks so much!
>
> JJ
>
>
> --
> 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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/46257514-13d8-4a7e-ad34-2595d102fe7d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/46257514-13d8-4a7e-ad34-2595d102fe7d%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/547D36F7.3080007%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment