วันอาทิตย์ที่ 31 มกราคม พ.ศ. 2559
django cms #5 Integrating a thied-party application
ในขั้นนี้เราจะทำการขยาย cms ของเราด้วย Third-party application หมายถึง app ที่มีคนอื่นสร้างไว้แล้วให้เรานำมาใช้ต่อใน cms ของเราได้ ในที่นี้คือ app สร้างบทความหรือข่าว Aldryn News & Blogให้เราทำการติดตั้งด้วยคำสั่ง pip install aldryn-newsblog
ถ้าติดตั้งไม่ได้เพราะไม่มี libxml2 ให้ติดตั้งก่อนด้วยคำสั่ง apt-get install libxml2-dev libxslt-dev
ส่วน Django setting
เปิดไฟล์ settings.py ของ cms เราแล้วแก้ไขส่วน INSTALLED_APPS ดังนี้
# you will probably need to add: 'aldryn_apphooks_config', 'aldryn_boilerplates', 'aldryn_categories', 'aldryn_newsblog', 'aldryn_people', 'aldryn_reversion', 'djangocms_text_ckeditor', 'parler', 'sortedm2m', 'taggit', # and you will probably find the following already listed: 'easy_thumbnails', 'filer', 'reversion',
ต่อมาเพิ่มโค้ดเหล่านี้เข้าไปใน settings.py (ไฟล์เดิม)
THUMBNAIL_PROCESSORS = ( 'easy_thumbnails.processors.colorspace', 'easy_thumbnails.processors.autocrop', # 'easy_thumbnails.processors.scale_and_crop', # disable this one 'filer.thumbnail_processors.scale_and_crop_with_subject_location', 'easy_thumbnails.processors.filters', ) ALDRYN_BOILERPLATE_NAME='bootstrap3' STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ]
สำหรับส่วนต่อไปนี้เราจะเพิ่มส่วน Template ในไฟล์เดิม ใช้เฉพาะใน django1.8
TEMPLATES = [ { # ... 'OPTIONS': { 'context_processors': [ # ... 'aldryn_boilerplates.context_processors.boilerplate', ], 'loaders': [ # ... 'aldryn_boilerplates.template_loaders.AppDirectoriesLoader', ], }, }, ]
เสร็จแล้วใช้ Terminal รันคำสั่ง python manage.py migrate แล้วเปิด server อีกครั้ง
ต่อมาให้เราสร้าง page ใหม่ชื่อ news แล้วปรับ advanced setting ดังรูปด้านล่างนี้
เสร็จแล้วจะได้หน้าแบบนี้ คือหน้าที่ยังไม่มีบทความอะไรเลย
ขั้นนี้เราจะสร้างบทความด้วยการเลือกเมนู Default NewsBlog คลิกที่ Add new article...
กรอกข้อมูลของบทความ เสร็จแล้วให้คลิก save
บทความที่เราสร้างปรากฏขึ้นมา
สมัครสมาชิก:
ส่งความคิดเห็น
(
Atom
)





ไม่มีความคิดเห็น :
แสดงความคิดเห็น