Print Template error. Frappe is a dict not an object

Hi guys, 

I've been working to create custom Print Template. But by following the code in the example:
frappe.db.get_value("[doctype]", "[name]", "fieldname")
 
It gave me some error:
File "<template>", line 189, in top-level template code
File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py", line 397, in getattr
return getattr(obj, attribute)
UndefinedError: 'dict object' has no attribute 'db'

frappe.get_doc is working fine but the documentation seems unsynced

Thanks


  1. Please be kind and don't send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/710e6a1d-8699-4154-a6aa-d009523bd82f%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

Ok. Frappe.db is not exposed for Jinja. You can add it in jinja.py file under frappe key as "db": frappe.db and send a pull request.

On Monday, September 29, 2014, Nguyen Do Le Bao <na…@gmail.com> wrote:

Hi guys,

I've been working to create custom Print Template. But by following the code in the example:
frappe.db.get_value("[doctype]", "[name]", "fieldname")
It gave me some error:
File "<template>", line 189, in top-level template code
File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py", line 397, in getattr
return getattr(obj, attribute)
UndefinedError: 'dict object' has no attribute 'db'

frappe.get_doc is working fine but the documentation seems unsynced

Thanks


  1. Please be kind and don't send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/710e6a1d-8699-4154-a6aa-d009523bd82f%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.


  1. Please be kind and don't send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CAAQzbF3RFFp-CMCpG%2BL1YNUDkk%3DY%2BKCFOigz1momPdQEx47Pjg%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Actually, Im fine with just changing the documentation.
The get_doc is enough for any other tasks.

On Mon, Sep 29, 2014 at 5:34 PM, Anand Doshi <an...@erpnext.com> wrote:
Ok. Frappe.db is not exposed for Jinja. You can add it in jinja.py file under frappe key as "db": frappe.db and send a pull request.

On Monday, September 29, 2014, Nguyen Do Le Bao <na...@gmail.com> wrote:
Hi guys,

I've been working to create custom Print Template. But by following the code in the example:
frappe.db.get_value("[doctype]", "[name]", "fieldname")
It gave me some error:
File "<template>", line 189, in top-level template code
File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py", line 397, in getattr
return getattr(obj, attribute)
UndefinedError: 'dict object' has no attribute 'db'

frappe.get_doc is working fine but the documentation seems unsynced

Thanks


  1. Please be kind and don't send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/710e6a1d-8699-4154-a6aa-d009523bd82f%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.


  1. Please be kind and don't send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to a topic in the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this topic, visit https://groups.google.com/d/topic/erpnext-developer-forum/cmUf7g8-W9I/unsubscribe.

    To unsubscribe from this group and all its topics, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CAAQzbF3RFFp-CMCpG%2BL1YNUDkk%3DY%2BKCFOigz1momPdQEx47Pjg%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.



  1. Please be kind and don't send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CAMSzgvXTSw_NiSeUaRmCKA3jmP6%2BqZJYuRf85KKxe4is%2Br%2Bd%3DQ%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.
yes, i agree, generally, it isn't good expose db object to ui level.

在 2014年9月29日星期一UTC+8下午5时39分35秒,Nguyen Do Le Bao写道:
Actually, Im fine with just changing the documentation.
The get_doc is enough for any other tasks. 

On Mon, Sep 29, 2014 at 5:34 PM, Anand Doshi <an...@erpnext.com> wrote:
Ok. Frappe.db is not exposed for Jinja. You can add it in jinja.py file under frappe key as "db": frappe.db and send a pull request. 

On Monday, September 29, 2014, Nguyen Do Le Bao <na...@gmail.com> wrote:
Hi guys, 

I've been working to create custom Print Template. But by following the code in the example:
frappe.db.get_value("[doctype]", "[name]", "fieldname")
 
It gave me some error:
File "<template>", line 189, in top-level template code
File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py", line 397, in getattr
return getattr(obj, attribute)
UndefinedError: 'dict object' has no attribute 'db'

frappe.get_doc is working fine but the documentation seems unsynced

Thanks


  1. Please be kind and don’t send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/710e6a1d-8699-4154-a6aa-d009523bd82f%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.


  1. Please be kind and don’t send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to a topic in the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this topic, visit https://groups.google.com/d/topic/erpnext-developer-forum/cmUf7g8-W9I/unsubscribe.

    To unsubscribe from this group and all its topics, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CAAQzbF3RFFp-CMCpG%2BL1YNUDkk%3DY%2BKCFOigz1momPdQEx47Pjg%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.



  1. Please be kind and don't send large attachments
  2. For issues, features requests use https://github.com/frappe/erpnext/issues



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/388ce15b-ea22-4d1a-b50c-fb64041cbac2%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.