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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:31:13+00:00 2026-05-28T19:31:13+00:00

I faced the error when I tried to capture the POST data from a

  • 0

I faced the error when I tried to capture the POST data from a form. Weird, because the same algorithm works with another django app model.

The models:

class Item(models.Model):
    code = models.CharField(max_length=200, unique=True)
    barcode = models.CharField(max_length=300)
    desc = models.CharField('Description',max_length=500)
    reg_date = models.DateField('registered date')
    registrar = models.CharField(max_length=100)
    def __unicode__(self):
       return self.code + ' : ' + self.desc

class ItemInfo(models.Model):
    model = models.ForeignKey(Item)
    supplier = models.ForeignKey(Supplier)
    stock_on_hand = models.IntegerField()
    stock_on_order = models.IntegerField()
    cost = models.IntegerField()
    price = models.IntegerField()
    unit = models.CharField(max_length=100)
    lead_time = models.IntegerField()

    def __unicode__(self):
        return Item.code + ' : ' + supplier

class ItemForm(ModelForm):
     class Meta:
         model = Item

class ItemInfoForm(ModelForm):
     class Meta:
        model = ItemInfo
        exclude = ('model')

And the views.py function for non-working (Item) is like this:

def register(request):
    csrf_context = RequestContext(request)
    current_user = User
    if request.user.is_authenticated():
        if request.POST:
            item = Item()
            item_info = ItemInfo()

            header_form == ItemForm(data=request.POST,instance=item)
            details_form == ItemInfoForm(data=request.POST, instance=item_info)

            if header_form.is_valid():
                 header = header_form.save()

                if details_form.is_valid():
                    details = details_form.save(commit=False)
                    details.supplier = header
                    details.save()
                    return HttpResponseRedirect('/item/')
               else:
                    return render_to_response('error/denied_data_entry.html')
         else:
             header_form = ItemForm()
             details_form = ItemInfoForm()
         return render_to_response('item/register.html',{'header_form' : header_form, 'details_form' : details_form}, csrf_context)
    else:
         return render_to_response('error/requires_login.html', csrf_context)

The working views.py function for another working (Supplier) model is here:

def register(request):
    csrf_context = RequestContext(request)
    current_user = User    
    if request.user.is_authenticated():
        if request.POST:
             supplier = Supplier()
             supplier_info = SupplierInfo()

             header_form = SupplierForm(data=request.POST, instance=supplier)
             details_form = SupplierInfoForm(data=request.POST, instance=supplier_info)

             if header_form.is_valid():
                 header = header_form.save()

                 if details_form.is_valid():
                     details = details_form.save(commit=False)
                     details.model = header
                     details.save()
                     return HttpResponseRedirect('/supplier/')
                 else:
                     return render_to_response('error/denied_data_entry.html')
             else:
                 return render_to_response('error/denied_data_entry.html')
         else:  
             header_form = SupplierForm()
             details_form = SupplierInfoForm()
             return render_to_response('supplier/register.html', {'header_form' : header_form, 'details_form' : details_form}, csrf_context)
    else:
        return render_to_response('error/requires_login.html', csrf_context)  

The traceback page shows that the POST did pass some variable. Help me please, I cant figure it out why it works on Supplier, but not Item.

P/S: Sorry for the indentation.

  • 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-28T19:31:14+00:00Added an answer on May 28, 2026 at 7:31 pm

    The problem is here:

    # ...
    header_form == ItemForm(data=request.POST,instance=item)
    details_form == ItemInfoForm(data=request.POST, instance=item_info)
    

    You’re not assigning, you’re comparing.

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

Sidebar

Related Questions

I also got this same problem from last day. i tried 2-3 time to
I am trying to load twitter link in UIWebview.I have faced NSURLErrorDomain error The
Good morning! I need to move data from Oracle 8i(Enterprise Edition Release 8.1.6.0.0) to
Today I faced an error due to which my Android application is getting by
I got this error when I tried to access my development site via http://localhost/home/index.html
I´ve tried deploy an application on Weblogic 9.2.1 and I´ve received this error: org.richfaces.component.html.HtmlSubTable
I have this code just to send data from already loaded jqGrid: jQuery(#bedata).click(function(){ //Function
I tried to upload my test gwt app but I've just faced a quite
Everyone (at least everyone who uses a compiled language) has faced compilation errors but
Faced with the challenge of a new application with which you had free reign

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.