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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:02:09+00:00 2026-06-13T18:02:09+00:00

Hi I am crating a view for editing a model using model forms. My

  • 0

Hi I am crating a view for editing a model using model forms.

My forms.py looks like:

from user_profile.models import Project
from django.forms import ModelForm


def ProjectForm(ModelForm):
    class Meta:
         model = Project

And my views.py:

from django.shortcuts import render_to_response
from django.template import RequestContext
from user_profile.models import Project
from user_profile.forms import ProjectForm

def EditProject(request, project_id=None):
    """
    This view allows a user to edit details of a project.
    """
    title = u'Unirac - Edit Project'
    project = Project.objects.get(id=4)
    if request.method == 'POST':
        form = ProjectForm(request.POST)
        if form.is_valid():
            # save form
            form.save()
        else:
            return render_to_response('edit_project.html', {
                'title': title,
                'form': form,
            }, RequestContext(request))
    else:
        form = ProjectForm(instance=project)
        return render_to_response('edit_project.html', {
            'title': title,
            'form': form,
        }, RequestContext(request))

But I’m getting a ProjectForm() got an unexpected keyword argument 'instance' error?

I can’t figure out why, as you can pass instance to a model form, can’t you?

Any help would be much appreciated.

  • 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-06-13T18:02:10+00:00Added an answer on June 13, 2026 at 6:02 pm
    def ProjectForm(ModelForm):
    

    Unless this is just a typo when posting it here, there’s your problem.
    You’ve defined a ProjectForm function, not a class.

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

Sidebar

Related Questions

I have a partial view that I use for editing and creating my models.
I currently only have the create view for my Album class: @model MvcApplication1.Models.AlbumViewModel @{
Hi I have a line in my view like: @Html.DropDownListFor(modelItem => item.CheckerId, Model.StaffByArea as
I am creating an Automapper mapping between my AccountEditViewModel (View Model used for editing
Should I use the same controller and view for editing and creating models in
I am creating view models for each screen in my ASP.NET MVC application. I
Is there any possibility of creating a view like the following image? I do
I have a partial view that has something like this <%= Html.DropDownListFor(m => m.SelectedProductName,
I am creating list of checkboxes in partial view by follwoing http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ code and
I'm making a small project to learn Django, and i'm having some problems trying

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.