मैं django-userena
का उपयोग कर रहा हूं। मेरे पास UserProfile
नामक एक मॉडल है। मैंने साइनअप फॉर्म में अतिरिक्त फ़ील्ड जोड़े हैं। और ये फ़ील्ड सही तरीके से दिखाई दे रहे हैं लेकिन डेटा सहेजा नहीं गया है। मैं कुछ फ़ील्ड डेटा को किसी अन्य मॉडल (Business
) में भी सहेजना चाहता हूं। उदाहरण के लिए मेरे पास दो फ़ील्ड हैं जैसे contact
और business
। मैं चाहता हूं कि संपर्क क्षेत्र UserProfile
पर जायेगा मॉडल और business
फ़ील्ड Business Model
पर जाएगा। कोई सुराग? धन्यवादdjango-userena रूपों को अतिरिक्त फ़ील्ड जोड़ने
यहाँ मेरी कोड
class SignupFormExtra(SignupForm):
address = forms.CharField(label=_(u'Address'),max_length=30,required=False)
contact = forms.CharField(label=_(u'Contact'),max_length=30,required=False)
business = forms.CharField(label=_(u'Business Name'),max_length=30,required=False)
def save(self):
"""
Override the save method to save the first and last name to the user
field.
"""
user_profile = super(SignupFormExtra, self).save(commit=False)
user_profile.address = self.cleaned_data['address']
user_profile.contact = self.cleaned_data['contact']
user_profile.business = self.cleaned_data['business']
user_profile.save()
return user_profile
अद्यतन है: मैं एक उपयोगकर्ता उदाहरण पर उन मूल्यों के संचय कर रहा हूँ ... मैं पैर की अंगुली चाहते प्रोफ़ाइल मॉडल पर उन्हें भंडारण - एक उदाहरण है कि उपयोगकर्ता के लिए बाध्य कर रहा है
आप इसे की कोशिश की है करता है? – Ahsan