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

  • Home
  • SEARCH
  • 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 7414079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:00:05+00:00 2026-05-29T07:00:05+00:00

this is my model : class Member(models.Model): profile = models.OneToOneField(Profile, editable=False, null=True) title =

  • 0

this is my model :

class Member(models.Model):
    profile = models.OneToOneField(Profile, editable=False, null=True)
    title = models.CharField(max_length=4, choices=TITLE_TYPES, null=True)
    name = models.CharField(max_length=100, null=True, verbose_name='Name') 
    lastname = models.CharField(max_length=100, null=True, verbose_name='LastName') 
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, null=True, verbose_name='Gender') 
    dob = models.DateField('dob')
    redressno = models.CharField(max_length=100, null=True, verbose_name='RedressNo') 

this is my form

class MemberForm(ModelForm):
  dob = forms.DateField(required=False, input_formats=('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y'))
  class Meta:
    model = Member
    exclude = ('profile',)    

this is my view :

     members = Member.objects.filter(profile=profiles)
data1 = serializers.serialize( "python", members)
        print data1[0]['fields']
        memarr=[] 
        for index, a in enumerate(data1):
          memarr.append(a['fields'])
        print memarr
        MemberFormSet = formset_factory(MemberForm, formset=BaseFormSet)    
        member_formset = MemberFormSet(initial=memarr)
        #here setting intial array of mem 
        mdata['form-TOTAL_FORMS']=u'2'
        mdata['form-INITIAL_FORMS']=u'0'
        mdata['form-MAX_NUM_FORMS']=u''

        member_formset = MemberFormSet(mdata)

        memberform = MemberForm(mdata)

    c = {'form': form, 'memberform': memberform, 'member_formset': member_formset}
    c.update(csrf(request))
    return render_to_response('edit_profile.html', c, RequestContext(request))

m passing the initial data but still the initial data is not being shown in the form?

  • 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-29T07:00:06+00:00Added an answer on May 29, 2026 at 7:00 am

    Here’s your problem:

    member_formset = MemberFormSet(initial=memarr)
    ...
    member_formset = MemberFormSet(mdata)
    

    You’re setting the initial data on one FormSet instance, and then throwing away that instance with the initial data and overwriting with another new FormSet instance.

    You can simplify your view to this:

    # If you are not using csrf middleware, use this decorator instead of ghetto magic
    @csrf_protect
    @render_to('edit_profile.html') # handy decorator from django-annoying
    def profile_members_edit(request.profile):
    
        members = Member.objects.filter(profile=profiles)
    
        # iterate over the ValuesQuerySet gives a list of dicts for initial data
        member_data = list(members.values())
    
        # setting extra=<> and max_num=<> is easier than setting internal form data
        MemberFormSet = formset_factory(MemberForm, formset=BaseFormSet, extra=2)
    
        member_formset = MemberFormSet(initial=member_data)
    
        return {'member_formset': member_formset }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my model: class Position(models.Model): map = models.ForeignKey(Map,primary_key=True) #members=models.CharField(max_length=200) LatLng = models.CharField(max_length=40000) infowindow
I have this model in django: class JournalsGeneral(models.Model): jid = models.AutoField(primary_key=True) code = models.CharField(Code,
I have the following Model: class Group(models.Model): member = models.ManyToManyField(Player, through='GroupMember') name = models.CharField(max_length=20,
My model class Member(models.Model): dob = models.DateField('dob') form class MemberForm(ModelForm): dob = forms.DateField(required=False, input_formats='%Y-%m-%d')
In my application I have a model that looks like this: class Talk(models.Model): title
I have a model class like this: class Note(models.Model): author = models.ForeignKey(User, related_name='notes') content
This is just an example, but given the following model: class Foo(models.model): bar =
Suppose my model is this: class Ego(models.Model): event = models.ForeignKey(Event) user = models.ForeignKey(User) As
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
I have a class Similar to this public class Model { public TimeSpan Time1

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.