python - Django, making a page activate for a fixed time -


Greetings I am hacking the DJ and am trying to do some such tests:

like , I want to sell "one item per day", so only one item will be available that day (say the default www.mysite.com will be redirected to that item),

Calling these items Consider my URL for example: www.mysite.com/item/<number>

My model for the item:

  class items (models.model): Item_name = models.CharField (max_length = 30) price = models.floatfield () Content = models.TextField () # All html content start_time = models.DateTimeField () end_time = models.DateTimeField ()  

and my idea to render it:

  DIF result (request, item_id): item = get_object_or_404 (item, pk = item_id) now = datetime.now () if item .start_time & gt; Now: #Render and some "not yet started" error Temple Elph items .end_time & lt; Now ####################################### It seems that you have understood the basics, so I believe what it is ?   

You are asking to polish suggestions ... some thoughts in this vein:

  1. I think for me / items / today / for this, or maybe just / today / .

  2. You would like to use the date code datime .datetime.now () only The whole object is an object in which microseconds The current time specified for precision.

  3. How to use a single base template for all three cases and to replace it with block, about how to inherit it, either when buying, clicking on price etc. To do this, click on the button, or a note saying that the item is not yet being sold / more then when people are saying that I had bought yesterday, you have to go to that site in an e-mail. ; -)


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -