Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

time zone "Eastern Standard Time" not recognized

I keep getting this error:

time zone "Eastern Standard Time" not recognized

here is the code:

def get_context_data(self, **kwargs):
    # Call the base implementation first to get a context
    context = super(IndexView, self).get_context_data(**kwargs)
    """Return the last five published posts."""
    context['latest_post_list'] = Post.objects.order_by('-pub_date')[:5]
    context['archives'] = Post.objects.datetimes('pub_date', 'month', order='DESC')     
    return context;

In my template:

{% for archive in archives %}
    <li><a href="#">{{ archive.month }} {{ archive.year }}</a></li>
{% endfor %}

And in my settings:

TIME_ZONE = 'America/Montreal'

What I would like to do is get some kind of an archive system going. Where it is possible to get the different months and years there was any posts.

Environment:


Request Method: GET
Request URL: http://localhost:8000/blog/

Django Version: 1.6.1
Python Version: 3.3.3
Installed Applications:
('django_admin_bootstrapped.bootstrap3',
 'django_admin_bootstrapped',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'localflavor',
 'reversion',
 'autoslug',
 'blog',
 'acpkinballmanageleague',
 'acpkinballmanageteams',
 'acpkinballmanageevents',
 'acpkinballmanagemembers')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Template error:
In template C:\Users\Ara\Documents\Sites\kinball\blog\templates\posts\index.html, error at line 55
   time zone "Eastern Standard Time" not recognized

   45 :                     <nav class="tags">


   46 :                         


   47 :                     </nav>


   48 :                 </div>


   49 : 


   50 :                 <!-- Archives -->


   51 :                 <nav class="widget">


   52 :                     <h4>Archives</h4>


   53 :                     {% if latest_post_list %}


   54 :                         <ul class="categories">


   55 :                              {% for archive in archives %} 


   56 :                                 <li><a href="#">{{ archive.month }} {{ archive.year }}</a></li>


   57 :                             {% endfor %}


   58 :                         </ul>


   59 :                     {% endif %}


   60 :                 </nav>


   61 : 


   62 :                 <!-- Tweets-->


   63 :                 <div class="widget">


   64 :                     <h4>Twitter</h4>


   65 :                     <ul id="twitter-blog"></ul>


Traceback:
File "C:\Python33\lib\site-packages\django\core\handlers\base.py" in get_response
  139.                 response = response.render()
File "C:\Python33\lib\site-packages\django\template\response.py" in render
  105.             self.content = self.rendered_content
File "C:\Python33\lib\site-packages\django\template\response.py" in rendered_content
  82.         content = template.render(context)
File "C:\Python33\lib\site-packages\django\template\base.py" in render
  140.             return self._render(context)
File "C:\Python33\lib\site-packages\django\template\base.py" in _render
  134.         return self.nodelist.render(context)
File "C:\Python33\lib\site-packages\django\template\base.py" in render
  840.                 bit = self.render_node(node, context)
File "C:\Python33\lib\site-packages\django\template\debug.py" in render_node
  78.             return node.render(context)
File "C:\Python33\lib\site-packages\django\template\loader_tags.py" in render
  123.         return compiled_parent._render(context)
File "C:\Python33\lib\site-packages\django\template\base.py" in _render
  134.         return self.nodelist.render(context)
File "C:\Python33\lib\site-packages\django\template\base.py" in render
  840.                 bit = self.render_node(node, context)
File "C:\Python33\lib\site-packages\django\template\debug.py" in render_node
  78.             return node.render(context)
File "C:\Python33\lib\site-packages\django\template\loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "C:\Python33\lib\site-packages\django\template\base.py" in render
  840.                 bit = self.render_node(node, context)
File "C:\Python33\lib\site-packages\django\template\debug.py" in render_node
  78.             return node.render(context)
File "C:\Python33\lib\site-packages\django\template\defaulttags.py" in render
  305.                 return nodelist.render(context)
File "C:\Python33\lib\site-packages\django\template\base.py" in render
  840.                 bit = self.render_node(node, context)
File "C:\Python33\lib\site-packages\django\template\debug.py" in render_node
  78.             return node.render(context)
File "C:\Python33\lib\site-packages\django\template\defaulttags.py" in render
  156.         len_values = len(values)
File "C:\Python33\lib\site-packages\django\db\models\query.py" in __len__
  77.         self._fetch_all()
File "C:\Python33\lib\site-packages\django\db\models\query.py" in _fetch_all
  854.             self._result_cache = list(self.iterator())
File "C:\Python33\lib\site-packages\django\db\models\sql\compiler.py" in results_iter
  1096.         for rows in self.execute_sql(MULTI):
File "C:\Python33\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
  781.         cursor.execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
  69.             return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
  53.                 return self.cursor.execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\utils.py" in __exit__
  99.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Python33\lib\site-packages\django\utils\six.py" in reraise
  490.             raise value.with_traceback(tb)
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
  53.                 return self.cursor.execute(sql, params)

Exception Type: DataError at /blog/
Exception Value: time zone "Eastern Standard Time" not recognized
like image 643
Ara Sivaneswaran Avatar asked Jan 05 '14 18:01

Ara Sivaneswaran


1 Answers

Installed pytz and the error went away:

pip install pytz

This may be a Windows only issue, see the note https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TIME_ZONE.

like image 105
frmdstryr Avatar answered Oct 13 '22 22:10

frmdstryr