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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:02:21+00:00 2026-05-19T09:02:21+00:00

another django question. I have a edit form like this. Look at current_status in

  • 0

another django question. I have a edit form like this. Look at current_status in the code.

It has been updated:

def edit_item(request, client_id = 0, item_id = 0):
    client = None
    item = None
    status = None
    contact = None
    status_id = request.POST.get('status_id', None)
    contact_id = request.POST.get('contact_id', None)
    save_item = request.POST.get('save_item', None)
    save_status = request.POST.get('save_status', None)
    try:
        client = models.Client.objects.get(pk = client_id)
        item = models.StorageItem.objects.get(pk = item_id)
    except:
        return HttpResponseNotFound()
    try:
        status = models.Status.objects.get(pk = status_id)
        contact = models.Contact.objects.get(pk = contact_id)
    except:
        pass
    if request.method == 'POST':
        form = forms.ItemForm(request.POST, instance = item)
        if form.is_valid() and save_item is not None:
            form.save(True)
            request.user.message_set.create(message = "Item {0} has been updated successfully.".format(item.tiptop_id))
            return HttpResponse("<script language=\"javascript\" type=\"text/javascript\">window.opener.location = window.opener.location; window.close();</script>")

        if status is not None and contact is not None and save_status is not None:
            current_status = models.ItemStatusHistory(item = item, contact = contact, status = status,
                                                          user = request.user)
            item.current_item_status_date = date.today()
            item.save()
            current_status.save()
            request.user.message_set.create(message = "Item status has been updated successfully.")
    else:
        form = forms.ItemForm(instance = item)
        title = str(client) + ' : Edit Item'
    status_list = models.Status.objects.all()
    return render_to_response('edit_item.html', {'form':form, 'title':title, 'status_list':status_list, 'item':item}, context_instance = RequestContext(request))

current_status save’s the latest date of when the form is edited. What I ALSO want to do is to save this value into this models field.

  class StorageItem(models.Model):
       current_item_status_date = models.DateField()
  • 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-19T09:02:22+00:00Added an answer on May 19, 2026 at 9:02 am

    Is ItemForm a ModelForm (see Django Model Forms)?

    If so form.save() will return a model instance. Then you can edit its fields if you need to. For example.

    my_obj = form.save()
    my_obj.current_item_status_date = datetime.date.today()
    my_obj.save()
    

    If not, then simply create a new instance of your model and save the field value.

    my_obj = StorageItem(current_item_status_date=datetime.date.today())
    my_obj.save()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the header of a selected tab-item of a tab-control and
There doesn't seem to be any tried and true set of best practices to
I am using a 3rd-party rotator object, which is providing a smooth, random rotation

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.