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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:19:39+00:00 2026-06-02T17:19:39+00:00

View def editor(request): form = SessionForm(initial={ ‘end_time’: datetime.datetime.now(), }) if request.method == ‘POST’: form

  • 0

View

def editor(request):
    form = SessionForm(initial={
        'end_time': datetime.datetime.now(),
    })

    if request.method == 'POST':
        form = SessionForm(request.POST)
        if form.is_valid():
            form.save()

    return render_to_response('planner/editor.html',
        {'form': form}, context_instance=RequestContext(request),)

This view displays the form and re-displays it on error, so there are 2 cases:

  1. initialized
  2. on error

In the template, I’m trying to display the field end_time with a date filter

Test 1

  <div>End value: {{ form.end_time.value }}</div>
  <div>End value filtered: {{ form.end_time.value|date:"Y-m-d" }}</div>

Case 1 (initialized)

End value: 2012-04-23 12:30:00
End value filtered: 2012-04-23

Case 2 (on error)

End value: 2012-04-23 12:30:00
End value filtered:

Test 2

Now let’s try to remove the .value of end_time

  <div>End value: {{ form.end_time.value }}</div>
  <div>End value filtered: {{ form.end_time|date:"Y-m-d" }}</div>

Case 1 (initialized)

End value: 2012-04-23 12:30:00
End value filtered:

Case 2 (on error)

End value: 2012-04-23 12:30:00
End value filtered: 2012-04-23

As you can see it’s doing the inverse.
How can this be explained ?

  • 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-02T17:19:40+00:00Added an answer on June 2, 2026 at 5:19 pm

    Using

    {{ form.instance.end_time|date:"Y-m-d" }}
    

    Instead of

    {{ form.end_time|date:"Y-m-d" }}
    

    Seems to works in both cases

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

Sidebar

Related Questions

I have the following logic in my view: def view_function(request): if request.method == 'POST':
Given the following view : def comments(request): comments_list = Thing.objects.filter(thing_type=2) #Thing model extends MPTTModel
I tried to read a file in a view like this: def foo(request): f
I have a view in a Django 1.4 project: def index(request): print reverse('menus_index') latest_menu_list
Here's my view: def rsvp_list(request, id, template=rsvp/rsvp_list.html): rsvp = RSVP.objects.get(id=id) return render_to_response(template, { 'attendees':
I have the following code in a view: def controller_details(request, object_id): controller = Controller.objects.get(pk=object_id)
Model: http://dpaste.com/96349/ View: def game_list(request): return render_to_response('games/game_list.html', { 'object_list': GameList.objects.published.all().order_by('position')}) Template: AttributeError at /games/
In my view: def delete_payment(request, id): thePayment = Payment.objects.filter(id=id) thePayment.delete() return HttpResponseRedirect('/invoices/open/') In my
when i change the homepage view: def home(request): return render_to_response('homepage.html') to def home(request): return
My view : def SeekDeals(request , reply_id): reply = SeekReply.objects.get(pk = reply_id) obj =

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.