แอปพลิเค Django สำหรับการกำหนดส่วนของเว็บไซต์โดยการร้องขอ
การติดตั้ง
& nbsp; 1 เพิ่ม section.context_processors.section เพื่อ TEMPLATE_CONTEXT_PROCESSORS ในแฟ้มตั้งค่าของคุณ:
& nbsp; TEMPLATE_CONTEXT_PROCESSORS = (
& nbsp; "django.contrib.auth.context_processors.auth"
& nbsp; "django.core.context_processors.debug"
& nbsp; "django.core.context_processors.i18n"
& nbsp; "django.core.context_processors.media"
& nbsp; "django.contrib.messages.context_processors.messages"
& nbsp; "section.context_processors.section")
& nbsp; 2 เพิ่มมูลค่าข้อที่การตั้งค่าของคุณในรูปแบบไฟล์:
& nbsp; # Tuple ของพจนานุกรมที่ใช้เพื่อให้ตรงกับชื่อรูปแบบ URL ส่วนเว็บไซต์
& nbsp; # ตัวอย่างเช่น: ({'ชื่อ': '<ชื่อส่วน>', 'matching_pattern_names' ('
& nbsp; ข้อ = (
& nbsp; {'ชื่อ': 'บ้าน', 'matching_pattern_names' ('บ้าน')}
& nbsp;)
การใช้งาน
หากคุณกำลังใช้มุมมองทั่วไปตอนนี้คุณจะมีตัวแปรโดยอัตโนมัติส่วนเพิ่มให้กับบริบทและสามารถใช้ได้ในแบบของคุณ
มิฉะนั้นมีลักษณะที่วัตถุ RequestContext และวิธีการใช้:
http://docs.djangoproject.com/en/dev/ref/templates/api/#id1
Requirements:
- Python
- Django
ความคิดเห็นที่ไม่พบ