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 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 have three TS variables resembling something like the following: data <- read.csv(...)
Greetings, I'm trying to find a way to 'unbind' a socket from a particular
Greetings, I'm trying to find either a free .NET library or a command-line executable
Greetings all, I'm trying to localize a .NET/C# project. I'm using string resource files
Greetings! I am trying to check directory write-permissions from within a Windows MFC/ATL program
Greetings, creating my first MVVM based WPF app and trying to figure out why
Greetings, I want to import MS Access 2007 table to SQL 2005. I followed
Greetings, I am trying to code a solution for an order form pricing calculator
Greetings, I'm uploading an image to my server using the following code: http://cocoadev.com/index.pl?HTTPFileUploadSample However,
Greetings, I am trying to run an SQL Script uploaded using Application Express (APEX),

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.