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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:28:10+00:00 2026-05-17T16:28:10+00:00

Is it possible to output a ModelForm using a class method; for example: def

  • 0

Is it possible to output a ModelForm using a class method; for example:

def edit_form(self, *args, **kwargs):
    from smf.node.forms import MediaBaseForm
    return MediaBaseForm(instance=self)

(MediaBaseForm is a ModelForm subclass for model Media), and then in the view:

form = node.edit_form()
(node contains the instance)

This code executes without raising errors; however, when viewing the page, no form fields are generated when I try to render each field separatly. The form does display when I use {{ formset }} but not using {% for form in formset.forms %}} ..etc. {% endfor %} –>

I need this:

{{ formset.management_form }}
    {% for form in formset.forms %}

        {{ form.id }}
        <div id="form_title">Title: {{ form.title }}</div>
        <p>Description:</p> {{ form.description }}
        <p>Comment settings:</p> {{ form.comment }}
        <p>Promoted to frontpage:</p> {{ form.promote }}
        <p>Sticky:</p> {{ form.sticky }}
        <p>Ready for Publishing:</p> {{ form.status }}
    {% endfor %}

instead of this:

{{ formset }}    

Is it not possible to call a form this way or am i doing something wrong?

Complete view:

def node_edit(request, nid):
        #Build the standard node form
        node = node_load(nid)
        obj = node_get_model(node.type, True)
        #modelFormset = modelformset_factory(obj, max_num=1)
        form = node.edit_form()

    if request.method == 'POST': # If the form has been submitted...
        #form = modelFormset(request.POST, request.FILES)
        form = node.edit_form()
        if form.is_valid():
            instances = form.save(commit=False)
            for instance in instances:
                instance.save()
            node_post_process(node, request, obj)

            if 'save_edit' in request.POST:
                id = int(nid)
                return HttpResponseRedirect('/edit/%i' %(id))
            if 'save' in request.POST:
                #id = node_callback_value.Node_ptr
                id = int(nid)
                return HttpResponseRedirect('/content/%i' %(id))
            if 'savenew' in request.POST:
                return HttpResponseRedirect('/content/add/%s' %(node.type))                
    else:
        output = {}
        #form = modelFormset(queryset=obj.objects.filter(node_ptr=nid))
        form = node.edit_form(instance=node)
    output = {
    'formset': form,
    'node': node,
    }
    try:
        return render_to_response('node/forms/%s.edit.html' %(node.type), output)
    except TemplateDoesNotExist:
        return render_to_response('node/forms/default.form.html', {
            'formset': 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-17T16:28:11+00:00Added an answer on May 17, 2026 at 4:28 pm

    I can’t understand what you’re trying to do. There are a number of problems with your approach, though.

    Firstly, there’s no way of passing the POSTed values to the form instantiation. As a result, form.is_valid() will always be False.

    Secondly, the result of node.edit_form() appears to be a single form, not a formset. So I don’t know why you are passing it to the template context as formset and trying to iterate through formset.forms.

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

Sidebar

Related Questions

Is it possible to output specific JSON data (exported from Firefox bookmarks) using PHP.
Is it possible to capture Python interpreter's output from a Python script? Is it
Is it possible using StAX (specifically woodstox) to format the output xml with newlines
I've heard it's possible to output content from an iPad app to an external
Is it possible to redirect all of the output of a Bourne shell script
Is it possible for a stand alone executable to generate a report and output
I was just wondering if it is possible to capture the output of a
I'd like to know if it is possible to redirect StreamWriter output to a
Is it possible to make django's (v1.2) URLField output an HTML5 input tag where
I create a form based on a model , like seen below: class ContactSelectionForm(forms.ModelForm):

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.