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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:47:13+00:00 2026-05-13T13:47:13+00:00

Greetings I am hacking Django and trying to test something such as: Like woot.com

  • 0

Greetings
I am hacking Django and trying to test something such as:

Like woot.com , I want to sell “an item per day”, so only one item will be available for that day (say the default http://www.mysite.com will be redirected to that item),

Assume my urls for calling these items will be such: www.mysite.com/item/<number>

my model for item:

class Item(models.Model):
        item_name = models.CharField(max_length=30)
        price = models.FloatField()
        content = models.TextField() #keeps all the html content
        start_time = models.DateTimeField()
        end_time = models.DateTimeField()

And my view for rendering this:

def results(request, item_id):
    item = get_object_or_404(Item, pk=item_id)
 now = datetime.now()

    if item.start_time > now:
     #render and return some "not started yet" error templete
 elif item.end_time < now:
     #render and return some "item selling ended" error templete
 else:
     # render the real templete for selling this item

What would be the efficient and clever model & templete for achieving this ?

  • 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-13T13:47:13+00:00Added an answer on May 13, 2026 at 1:47 pm

    It seems you’ve got the basics figured out, so I’m assuming you’re asking for polishing suggestions… A few ideas in this vein:

    1. I think I’d have a separate URL like /items/today/ for this, or perhaps just /today/.

    2. You’ll want to use the date components of datime.datetime.now() only. The whole thing is an object containing the current time specified to a microsecond’s precision.

    3. How about using a single base template for all three cases and inheriting from it to change a block containing either the button to click on when buying, the price etc., or a note saying that the item is not being sold yet / any more. Then people can still use the numbered URLs when saying things like See what I bought yesterday, you have to go to that site in an e-mail. 😉

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

Sidebar

Related Questions

Greetings, I am trying to learn pointers in C, I simply want my addtwo
Greetings fellow earthlings, I am trying to customize a popup box. I don't want
Greetings everyone and thank you for checking out my post. I am trying to
Greetings, Trying to sort through the best way to provide access to my Entity
Greetings! I'm trying to have a UIWebView controlled from generated events. Is there a
Greetings, With javascript, I am trying to make a very easy animation, an image
Greetings Friends, I am trying to overlay the simple 2D game I am developing
Greetings Stack Overflow community. I'm trying to make a function that can pop all
Greetings! I am trying to find a way in Java to programmatically enable/disable a
Greetings! I am trying to find a way in Java to programmatically enable/disable a

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.