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

class AthleteEmail(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:

class AthleteProfileEmailUpdateForm(ModelForm):

    athleteemail = forms.EmailField(label=(u'Athlete Email Address:'))


class Meta:

    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

class Athlete(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(lambda u: 
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

class AthleteProfileUpdateForm(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)

    

    class Meta:

        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+unsubscr...@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/46257514-13d8-4a7e-ad34-2595d102fe7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to