I am building a brand new website with Django cms and I'm using aldryn_bootstrap3
.
When I create a link/button my site seems broken. I get:
File "c:\newCMS\venv37\lib\site-packages\aldryn_bootstrap3\model_fields.py", line 172, in get_link_url
if ref_page.site_id != getattr(cms_page, 'site_id', None):
AttributeError: 'Page' object has no attribute 'site_id'
I tried to install the multisite module (I've seen in the forum that it worked for other people...)
Then, the configuration in my seetings.py
is:
from multisite import SiteID
SITE_ID = SiteID(default=1)
Environment:
Request Method: GET
Request URL: http://localhost:8000/es/?edit&language=es
Django Version: 1.11.22
Python Version: 3.7.3
Installed Applications:
...
'django.contrib.sites',
'aldryn_bootstrap3',
'multisite',
'djangocms_multisite',
'MyCMS']
Error during template rendering:
In template c:\newCMS\venv37\lib\site-packages\aldryn_bootstrap3\templates\aldryn_bootstrap3\plugins\button.html, error at line 2
Traceback:
File "c:\newCMS\venv37\lib\site-packages\aldryn_bootstrap3\model_fields.py" in get_link_url
172. if ref_page.site_id != getattr(cms_page, 'site_id', None):
Exception Type: AttributeError at /es/
Exception Value: 'Page' object has no attribute 'site_id'
Edit this file and comment lines 172/173/174 (in your case)
$ c:\\newCMS\\venv37\\lib\\site-packages\\aldryn_bootstrap3\\model_fields.py
#if ref_page.site_id != getattr(self.page, 'site_id', None):
#ref_site = Site.objects._get_site_by_id(ref_page.site_id)
#link = '//{}{}'.format(ref_site.domain, link)
Then return to the GUI and delete the 'Link-button' that caused the problem
Open the file 'model_fields.py' again and uncomment the 3 lines. Then restart your instance
$ c:\\newCMS\\venv37\\lib\\site-packages\\aldryn_bootstrap3\\model_fields.py
if ref_page.site_id != getattr(self.page, 'site_id', None):
ref_site = Site.objects._get_site_by_id(ref_page.site_id)
link = '//{}{}'.format(ref_site.domain, link)
!! This is not a definitive solution but it will allow you to make your site operational again
On a ** Debian/Ubuntu ** server, edit and comment this file
$ sudo vim /usr/local/lib/python3.6/site-packages/aldryn_bootstrap3/model_fields.py
--> Raphaël Jonard | Web Performances Accelerator <--
Edit the file: aldryn_bootstrap3/model_fields.py
Replace line 169 which looks like:
if ref_page.site_id != getattr(self.page, 'site_id', None):
with:
if ref_page.node.site_id != getattr(self.page.node, 'site_id', None):
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.