D
D
Dmitry Vyatkin2015-07-31 06:21:55
JavaScript
Dmitry Vyatkin, 2015-07-31 06:21:55

How to turn list values ​​into querystring in Django?

In the view, a list with dates of the format (2015.07.31 (Friday)) is formed and passed to the template, after which it is displayed in a loop - how to turn the list values ​​into a query string of the format (?y=2015&m=7&d=31) and remove "Friday"? Can this be done in the template, otherwise I didn't find a suitable filter for some reason!?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex, 2018-12-28
@VegasChickiChicki

In your code, work with timers is done incorrectly. You seem to assume that when a variable is written, the previous timer is destroyed - but this works differently. What happens is that the functions intro_start and intro_start2 never stop. Each run of lines spawns another "thread" intro_start and intro_start2. Because they change global variables, the move gets faster and faster.
A little fix and it will be ok: https://codepen.io/AlexNetkachov/pen/wRrdOL?editor...

T
tplus, 2015-07-31
@dim137

date¶
Formats a date according to the given format.
Uses a similar format as PHP's date() function ( php.net/date ) with some differences.

https://docs.djangoproject.com/en/1.8/ref/template...
Format the date object in the template to the scheme you need. Using strftime as an example:
>>> d
datetime.date(2015, 1, 1)
>>> d.strftime('?y=%Y&m=%m&d=%d')
'?y=2015&m=01&d=01'
>>>

If the template tag won't let you use characters except for date formatting, can you do it in the view?

V
Vladislav Sklyar, 2015-07-31
@VladSkliar

Look here . Maybe what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question