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 3305730
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:12:15+00:00 2026-05-17T21:12:15+00:00

I have an edit page for my object. Because I’ve divided data in two

  • 0

I have an edit page for my object. Because I’ve divided data in two tabs, I’m using jquery-ui. On the first tab (#core_data) I’m loading object’s main data. Form is submited via Ajax :

<form method="post" class="object_form" id="event-core-form" action="{% url edit_event_data event.id %}" enctype="multipart/form-data">
    {{ form.as_p }}
    <p>
        <input class="object-submit" id="event-data-save" type="submit" value="Save data">
    </p>
</form>

js:

$("#event-data-save").livequery("click", function() {
    $("#event-core-form").ajaxSubmit({
        "success": function(data) {
            data = JSON.parse(data)
            $("#core-data").html(data["form"]);               
        }
    });
    return false;
})

and a function is run, and my debug says that it is instantly called 2 times :

def edit_event_data(request, event_id,):
    template_name="management/core_event.html" 
    event = get_object_or_404(Event, pk=event_id)
    form = EventForm(instance=event, data=request.POST)

    if form.is_valid():
        form.save()
        form = EventForm(instance=event)

    form_html = render_to_string(template_name, RequestContext(request, {
        "event" : event,
        "form" : form,
    }))

    result = simplejson.dumps({
        "form": form_html,
        "message": "Data saved."
    }, cls=LazyEncoder)

    return HttpResponse(result, mimetype='application/javascript')

What more, after successfully submitting hitting save once again gives me a raw form rendered :/ Here’s the form I’m using. I think that this may be the reason for my problems:

class EventForm(forms.ModelForm):   
    def __init__(self, *args, **kwargs):
        logging.debug("form - init")
        super(EventForm, self).__init__(*args, **kwargs)

    (...)

    def save(self, *args, **kwargs):   
        (...)

        logging.debug("form - save")
        post = super(EventForm, self).save(*args, **kwargs)
        post.save()

Since in my debug I can see I think too many __init__'s

2010-10-28 23:35:08,210 DEBUG form - init
2010-10-28 23:35:34,065 DEBUG form - init
2010-10-28 23:35:34,068 DEBUG form - save
2010-10-28 23:35:34,073 DEBUG form - init
2010-10-28 23:35:34,258 DEBUG form - init
2010-10-28 23:35:34,262 DEBUG form - save
2010-10-28 23:35:34,270 DEBUG form - init

Can anyone help ?


EDIT:

After removing jquery-ui still the same. Removing livequery also gives no results.

  • 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-17T21:12:16+00:00Added an answer on May 17, 2026 at 9:12 pm

    Why are you instantiating a new form after you save the original one?

    if form.is_valid():
        form.save()
        # what's the point of the next line?
        form = EventForm(instance=event)
    

    This is almost certainly the cause of your duplicated __init__ call. Why are you doing it? You already have a form.

    Also, you’ve forgotten to stop the click action from completing within your JS.

    $("#event-data-save").livequery("click", function(e) {
        e.preventDefault();
        ...
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form on a page where the user has inputs to edit
EDIT: I also have access to ESXLT functions. I have two node sets of
I have recently been working with Python using Komodo Edit and other simpler editors
Edit: I have solved this by myself. See my answer below I have set
EDIT: I have submitted a bug report and Microsoft have acknowledge that it is
EDIT: I have added Slug column to address performance issues on specific record selection.
What are extension methods in .NET? EDIT: I have posted a follow up question
have downloaded Orca to edit an MSI file. I want to remove some banner
I have found a few libraries to edit MP3 tags (UltraID3Lib is great) but
I have a compiled swf file and a I can't edit it , 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.