Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute #130

Open
Kizuna-Meraki opened this issue Feb 12, 2024 · 3 comments

Comments

@Kizuna-Meraki
Copy link

After successfully creating, syncing and building 2 groups, I got this when archiving the third group.

tg-archive --build

2024-02-12 19:04:44,734: building site
Traceback (most recent call last):
File "/usr/local/bin/tg-archive", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/tgarchive/init.py", line 161, in main
b.build()
File "/usr/local/lib/python3.10/site-packages/tgarchive/build.py", line 87, in build
self._render_page(messages, month, dayline,
File "/usr/local/lib/python3.10/site-packages/tgarchive/build.py", line 116, in _render_page
html = self.template.render(config=self.config,
File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "", line 90, in top-level template code
File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 485, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2016-12-02'

@Kizuna-Meraki
Copy link
Author

Another group failed during tg-archive --build with the same error message.

tg-archive --build
2024-02-12 20:02:19,652: building site
Traceback (most recent call last):
  File "/usr/local/bin/tg-archive", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/tgarchive/__init__.py", line 161, in main
    b.build()
  File "/usr/local/lib/python3.10/site-packages/tgarchive/build.py", line 87, in build
    self._render_page(messages, month, dayline,
  File "/usr/local/lib/python3.10/site-packages/tgarchive/build.py", line 116, in _render_page
    html = self.template.render(config=self.config,
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 90, in top-level template code
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 485, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2017-09-22'

@VAny6661
Copy link

VAny6661 commented Feb 28, 2024

In db.py (in get_timeline and get_dayline) try change

 cur.execute("""
            SELECT strftime('%Y-%m-%d 00:00:00', date) as "[timestamp]",
            COUNT(*) FROM messages AS count
            GROUP BY strftime('%Y-%m', date) ORDER BY date
        """)

to

cur.execute("""
            SELECT strftime('%Y-%m-%d %H:%M:%S', date) as "[timestamp]",
            COUNT(*) FROM messages AS count
            GROUP BY strftime('%Y-%m', date) ORDER BY date
             """)

or just do not change standart timezone in config.yaml
If not help, you can try answer from this issue

@Pepepy
Copy link

Pepepy commented Oct 18, 2024

Muchas Gracias, esto soluciona completamente el problema.

En db.py (en get_timeline y get_dayline) intente cambiar

 cur.execute("""
            SELECT strftime('%Y-%m-%d 00:00:00', date) as "[timestamp]",
            COUNT(*) FROM messages AS count
            GROUP BY strftime('%Y-%m', date) ORDER BY date
        """)

a

cur.execute("""
            SELECT strftime('%Y-%m-%d %H:%M:%S', date) as "[timestamp]",
            COUNT(*) FROM messages AS count
            GROUP BY strftime('%Y-%m', date) ORDER BY date
             """)

o simplemente no cambie la zona horaria estándar en config.yaml Si no ayuda, puede intentar responder a este problema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants