home
join about login
mesclóstico

June 28, 2018, 5:28 p.m.

Trump-Putin summit to unfold in Cold War venue Helsinki on July 16

WASHINGTON/MOSCOW (Reuters) - U.S. President Donald Trump and Russian President Vladimir Putin will hold their first summit on July 16 in Helsinki, a venue famed for its Cold War diplomacy, with nervous U.S. allies in Eu...

492 views origin
Little Planet Soyuz - Eu vi eu viiiii O papai noel tava na sinaleira - Noel Guarany | Sem Fronteira (1975) [Álbum Completo/Full Album] - The Extraordinary Spiral in LL Pegasi - This is how to train a cat :D How I Trained My Cat - Wozniacki passes Barty test in Madrid, Sharapova advances - NASA Awards Contract for Aerospace Systems Modeling, Simulation - amizades - NASA Awards Contract for Continued Operations of its Jet Propulsi - Fallece un exdiputado federal del PRI tiroteado este fin de seman - Dieguito - A Lesma © ℗ MÚSICA AUTORAL Ensaio - At Tranquility Base - Climate change: 'Hothouse Earth' risks even if CO2 emissions slas - casados - Exclusive: North Korea earned $200 million from banned exports, s - Launching to Observe Our Sun - Eclipse solar hoje! - Major League Baseball notebook: Mariners deal for Colome, Span fr - Trump quip about North Korea's Kim sparks outcry on social media - Orion in Red and Blue - Southern California as Seen From Apollo 7 - Guri de Uruguaiana fala sobre hits do Carnaval e exageros no Phot - Cetus Galaxies and Supernova - Slava Ukraini! on Steam - Celebrating 28 Years of the Hubble Space Telescope - Los candidatos se disputan el poderoso voto del magisterio mexica - gliptodonte encontrado en Picada Varela - Federer pummels Bemelmans to move closer to top spot - Tonella - revisão do limpador de parabrisa do fusca - Pipi das Meias Altas Portuguese vol 1 - Austria plans tougher sentences for crimes against women - GLORIA GROOVE - SEDANAPO -  

tutti - social network

Tutti is the simplest social network on internet. Here you can make friends, create communities, sell things, make surveys, comment and share stuff.

Resultado do robô da ialogica de hoje, quer saber como ganhar dinheiro com os robôs da Ialogica? Entre em contato! Http://www.ialogica.com.br

#empreendedorismo #empreendedoris #empreender #empreendedor #precisodedinheiro #dinheiro #invest #investimento #meutrabralho #trabalho #notrabalho #fiqueemcasa #fiquemcasa #dançadocaixão #toemcasa #xocorona #felizdiadasmulheres #tocaosom #carnavanokawai #retratodecarnaval #aquecimento #quebracabeça #raioxdaverdade #cartapara2020 #retrospectiva #meusonhodenatal #retratonatalino #meuoutrolado #blackfriday #bandanachique #reggaenapraia #kwaikpopn #vireizumbi #kwai #rendaextra #ações #família #renda #trabalheemcasa #fiqueemcasa #emcasa #coronavirus #atitude #notrabalho #trabalhoemcasa #trabalho #investimentoimobiliario #invest #consultordeinvestimentos #servico #investimento #investimentos #meuinvestimento #investimentointeligente #investimentofinanceiro #investimentoseguro #mentesbrilhantesinvestimentos #investimentoimobiliario #investimento #investimentos #truquedodinheiroinfinito #desenvolvimentopessoal #dinheiro #finanças #economia #bolsadevalores #bomperfil #compartilhar #vendas #ganhardinheiro
image
Django tips and tricks

As far as I know there is no way for the browser to tell the application what is the user's timezone.
That is a problem when you want to run an international site, mostly when users from different places save time related stuff.
Some people suggest to just ask the user what his timezone is.
I did not want to bother them with that, so I created this little hack.
this involves a context processor and some javascript.

So lets start with the context processor in django.
you start by writing your context_processor.py file
 from django.utils import timezone
def timezone_processor(request):
# look for a cookie that we expect to have the timezone
tz = request.COOKIES.get('local_timezone', None)
if tz:
tz_int = int(tz) # cast to int
# here we decide what will prefix timezone number
# the output of tz_str will be something like:
# Etc/GMT+1, GMT+0, Etc/GMT-2
if tz_int >= 0:
tz_str = 'Etc/GMT+'+tz
else:
tz_str = 'Etc/GMT'+tz
# this forces timezone
timezone.activate(tz_str)
# Now we tell the template that we have a timezone
return {'local_timezone': tz}

For the context processor to work you must declare it in settings.py
 TEMPLATES = [
{
.........
'OPTIONS': {
'context_processors': [
.........
'myapp.context_processors.timezone_processor',
],
},

Ok, so this code just create a timezone string and activates it.
A template context processor returns a dictionary that will be sent to the context of the template when rendering. Here we are returning local_timezone.
But where this cookie come from? Lets go to the template and make this javascript trick.

 <!-- if django already knows timezone we will not run it again -->
{% if not local_timezone %}
<!-- getTimezoneOffset does the trick! -->
<!-- it return minutes so we divide to get hours -->
timezone = new Date().getTimezoneOffset() / 60;
document.cookie = 'local_timezone=" + timezone;
<!-- set a cookie with this value and we are done -->
{% endif %}
*for simplicity I didn't include cookie expires nor half hour timezones like North Korea.

So it's first time the user enters the site. Django doesn't know yet it's timezone.
As local_timezone comes empty, we run this javascript lines, get the timezone offset and save it in a cookie.

Next page the user enters, the context processor will read that cookie and will activate the appropriate timezone.
If you need to activate it the very first time, just make it refresh after setting the cookie.

Well that's it, hope this helps you.
more