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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:42:09+00:00 2026-06-17T08:42:09+00:00

Another weird behavior i encountered and not really sure why it happens… I won’t

  • 0

Another weird behavior i encountered and not really sure why it happens…

I won’t completely write what i am doing, basically i have one view for 2 cases: default case when search takes today date by default if nothing is specified , and second is where i specify what date i want to see and get a query …

So here is urls.py:

    url(r'^$', index),
    url(r'^(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<change>prev|next)/$', index),

And here is views.py:

def index(request, month = date.today().month, day = date.today().day, change=None):
    # apply next / previous change
    if change in ("next", "prev"):
        now, mdelta = date(date.today().year, int(month), int(day)), timedelta(days=1)
        if change == "next":   mod = mdelta
        elif change == "prev": mod = -mdelta

        month, day = (now+mod).timetuple()[1:3]

    someData= SomeModel.objects.filter(
        date__exact = date(date.today().year, int(month), int(day))
    )

    return render_to_response('someapp_index.html',RequestContext(request,{'next':request.path, 'someData':someData, 'month': month, 'day':day}))

The thing which occurs is that for some reason when 24 hours pass and next day comes, someData does not update to next day. So for example if today is 15 and 24 hours pass, and already is 16 , then you expect on refresh that someData will filtered by 16 of January but instea it is still filtered by 15 because month and day stays the same from the moment i started or restarted uwsgi server…. ?!?!?!?!?

I tried putting those date.today().dat/month as variables passed in url file , and it had absolutely the same effect ….

Am i the only one with this problem , and it should not occur , or it should behave like this and you can’t put date.today() objects ?

  • 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-17T08:42:10+00:00Added an answer on June 17, 2026 at 8:42 am
    def index(request, month = date.today().month, day = date.today().day, change=None):
                                    ^^^^^^ called upon init   ^^^^^^ 
    

    Yes, your month/day values are initialized on server init.

    Set them to None if you want defaults, and call date.today() in your view if they are None.

    Passing date.today() as an argument to a function will force it to be evaluated. It is the same as passing the function one specific value.

    Change to

    def index(request, month=None, day=None, change=None):
          if month is None:
              month = date.today().month
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a really weird issue I'm having and I'm not really sure what
I have another weird problem which I have not been able to solve in
I encountered following weird behavior yesterday. It seems a compiler bug to me or
I`m really confused here about this weird behavior! The thing is, I have a
I have noticed some weird behavior when sourcing another script within my shell script.
I have another Richfaces question which may seem rather weird. I am developing a
I have a weird behavior in my GUI code. If the user produces a
I'm troubleshooting some weird behavior of a threaded application and have stumbled upon a
There's a weird behavior where I use a post and then make a redirect
I'm working with Fragments for the first time and running into a weird behavior.

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.