Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3484570
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:48:12+00:00 2026-05-18T10:48:12+00:00

I wanted to create a edit form with the help of ModelForm. and my

  • 0

I wanted to create a edit form with the help of ModelForm.

and my models contain a Generic relation b/w classes, so if any one could suggest me the view and a bit of template for the purpose I would be very thankful, as I am new to the language.

My models look like:-

 class Employee(Person):
     nickname = models.CharField(_('nickname'), max_length=25, null=True,
         blank=True)
     blood_type = models.CharField(_('blood group'), max_length=3, null=True,
         blank=True, choices=BLOOD_TYPE_CHOICES)
     marital_status = models.CharField(_('marital status'), max_length=1,
         null=True, blank=True, choices=MARITAL_STATUS_CHOICES)
     nationality = CountryField(_('nationality'), default='IN', null=True,
         blank=True)
     about = models.TextField(_('about'), blank=True, null=True)
     dependent = models.ManyToManyField(Dependent,
         through='DependentRelationship')
     pan_card_number = models.CharField(_('PAN card number'), max_length=50,
         blank=True, null=True)
     policy_number = models.CharField(_('policy number'), max_length=50,
         null=True, blank=True)
     # code specific details
     user = models.OneToOneField(User, blank=True, null=True,
         verbose_name=_('user'))

 class Person(models.Model):
      """Person model""" 
      title = models.CharField(_('title'), max_length=20, null=True, blank=True)
      first_name = models.CharField(_('first name'), max_length=100)
      middle_name = models.CharField(_('middle name'), max_length=100, null=True,
          blank=True)
      last_name = models.CharField(_('last name'), max_length=100, null=True,
          blank=True)
      suffix = models.CharField(_('suffix'), max_length=20, null=True,
          blank=True)
      slug = models.SlugField(_('slug'), max_length=50, unique=True)


class PhoneNumber(models.Model) :
     phone_number = generic.GenericRelation('PhoneNumber')
     email_address = generic.GenericRelation('EmailAddress')
     address = generic.GenericRelation('Address')

     date_of_birth = models.DateField(_('date of birth'), null=True, blank=True)
     gender = models.CharField(_('gender'), max_length=1, null=True,
         blank=True, choices=GENDER_CHOICES)

     content_type = models.ForeignKey(ContentType,

If anyone could suggest me a link or so. it would be a great help……..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:48:12+00:00Added an answer on May 18, 2026 at 10:48 am

    posting the solution I found out. After taking a look at the source of Generic_inlineformset_factory.

    I made my view as:-

    def edit_contact(request):
         c={}
         profile = request.user.get_profile()
         EmployeeFormSet = generic_inlineformset_factory(PhoneNumber,extra=0,can_delete=False)
         EmployeeFormSet1=generic_inlineformset_factory(EmailAddress,extra=0,can_delete=False)
         EmployeeFormSet2 = generic_inlineformset_factory(Address, extra = 0, can_delete=False)
         if request.method == "POST":
            p_formset = EmployeeFormSet(data=request.POST, instance = profile),
            e_formset = EmployeeFormSet1(data=request.POST, instance = profile),
            a_formset = EmployeeFormSet2(data=request.POST, instance = profile),
            for e in p_formset:
               if e.is_valid():
                 e.save()
             for e in e_formset:
               if e.is_valid():
                  e.save()
             for e in a_formset:
               if e.is_valid():
                  e.save()
             return HttpResponseRedirect('/forms/sucess-edit/')
          else:
              p_formset = EmployeeFormSet(instance = profile),
              e_formset = EmployeeFormSet1(instance = profile),
              a_formset = EmployeeFormSet2(instance = profile),
          c.update({'p_formset': p_formset, 'e_formset': e_formset,'a_formset': a_formset})
          return  render_to_response('forms/edit_contact.html',c,
                                        context_instance=RequestContext(request))
    

    This worked successfully, I think it would be a good help if any one is using the Generic Relation in their model, and want to create a form for editing that information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to create smth similar to this one Kansas county map where user
I wanted to create one js file which includes every js files to attach
I have create and edit screens for a entity. They only differ by one
I wanted to create bidirectional one to one relationship with shared primary key. As
I wanted to create a new property on a table in my model.. Basically
I wanted to create a control with a TextBox and to bind TextBox.Text property
I wanted to create a very simple method that switches between views in a
I wanted to create a page with a simple button which runs away from
I wanted to create some subdirectories inside my blob. But it is not working
I wanted to create jquery plugin & started off creating a sample jquery plugin...But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.