2009-06-26 12 views
19

"लोड" के रूप में खोज के लिए अभी तक बहुत सामान्य है:Django: "लोड" क्या करता है (एक टेम्पलेट फ़ाइल में)?

  1. "लोड" का उद्देश्य क्या है और क्या यह इस विशेष मामले में क्या करता है? - एक टेम्पलेट फ़ाइल, base_weblog.html में,

    {% load weblog %}{% render_month_links %}

  2. कुछ नामकरण अपना काम करने में "लोड" के लिए आदेश में इस्तेमाल किया सम्मेलनों हैं? जैसे फ़ोल्डर और/या फ़ाइलों के नाम और/या कक्षा के नाम?

  3. "लोड" के लिए प्रलेखन कहां है और क्या आप विस्तृत कर सकते हैं?


विवरण:

उदाहरण http://www.djangoproject.com/ के लिए स्रोत से है - प्रत्यक्ष डाउनलोड यूआरएल http://shrinkster.com/17g8 के माध्यम से है।

आंशिक फ़ोल्डर संरचना (कोई फाइल एक्सटेंशन के साथ आइटम फ़ोल्डर हैं):

django_website 

    apps 
    accounts 
    aggregator 
    blog 
     urls.py 
     models.py 
     class Entry(models.Model) 

     templatetags 
     weblog.py 
    contact 
    docs 

    templates 
    base_weblog.html 

    aggregator 
    blog 
     entry_archive.html 
     entry_archive_year.html 
     month_links_snippet.html 
     entry_archive_month.html 
     entry_detail.html 
     entry_snippet.html 
     entry_archive_day.html 
    comments 
    contact 
    docs 
    feeds 
    flatfiles 
    flatpages 
    registration 
+1

सुनिश्चित करें कि blog.templatetags settings.py में आपके INSTALLED_APPS tuple में है। उसने मेरे लिए इसे हल कर दिया। – cheenbabes

+0

custom_filter.py फ़ाइल से लोड डेटा – shadow0359

उत्तर

3

"लोड" (टेम्पलेट फ़ाइल django_website/templates/base_weblog.html में) के बाद "वेबलॉग" फ़ोल्डर django_website/apps/blog/templatetags में weblog.py दायर करने के लिए संदर्भित करता है। फ़ोल्डर templatetags को बिल्कुल नामित किया जाना चाहिए और इसमें __init__.py (प्रश्न 2) नाम की एक फ़ाइल होनी चाहिए।

"लोड" इस मामले में टेम्पलेट्स, django_website\templates\base_weblog.html में उपयोग के लिए उपलब्ध कस्टम टेम्पलेट टैग (render_latest_blog_entries और render_month_links) बनाता है। "लोड" एक सुरक्षा और प्रदर्शन समारोह है।

11

load:

लोड एक कस्टम टेम्पलेट टैग सेट।

अधिक जानकारी के लिए Custom tag and filter libraries देखें।

+0

+1 - मुझे इसे हराएं! –

संबंधित मुद्दे