Package: django-ckeditor-link
django-ckeditor-linkBuild status fails sometimes - selenium and iframes and ... sleep. Passes with local tox, believe me.link plugin for ckeditor, based on django modelforms/modeladmin, allowing direct linking to your models, or to whatever your want.Table of contentsInstallationUsage / ExamplesSettingsCompatibilityContributeInstallationTo get the latest stable release from PyPipip install django-ckeditor-linkAddckeditor_linkto yourINSTALLED_APPSINSTALLED_APPS = (
    ...,
    'ckeditor_link',
)ckeditor_link does not need it's own database tables, so no need to migrate.If you want an out of the box solution for linking, you can addckeditor_link.link_modelto yourINSTALLED_APPS. Warning, EXPERIMENTAL feature.Usage / ExamplesHave a look atckeditor_link/tests/test_app/settings_test.pyfor a complete example.Following steps are needed.Define a link model. Proposed way: Create an abstract base model, that you can extend from for example when
having a teaser model. And a CKLink model, whose purpose is only to provide a modelform and validation. No data is
ever written to that table, if used with DjangoLinkAdmin.# your_app/models.py@python_2_unicode_compatibleclassLinkModelBase(models.Model):target=models.CharField(max_length=255,blank=True,default='',)external_url=models.CharField(max_length=255,blank=True,default='',)email=models.EmailField(blank=True,default='',)testmodel=models.ForeignKey(TestModel,null=True,default=None,blank=True)classMeta:abstract=Truedef__str__(self):# do it betterreturn"LINK!%s"%self.targetdefget_link(self):# return link value, based on fields.return"http://www.dynamic.com"classLinkModel(LinkModelBase):passclassTeaser(LinkModelBase):image=models.ImageField()title=models.CharField()text=models.TextField()For your convinience, we provide a basic abstract link model, and a django-cms / django-filer compatible version, underckeditor_link.link_model.models. They are namedLinkBaseandCMSFilerLinkBase, and thought to inherit from. To use them, you would need
to addckeditor_link.link_modeltoINSTALLED_APPSin your settings. To use the cms / filer version, you'll need to setCKEDITOR_LINK_USE_CMS_FILERto True in your settings.
You can provide your own LINK_TYPE_CHOICES, if you add some more fields, withsettings.CKEDITOR_LINK_TYPE_CHOICES.Register your model with DjangoLinkAdmin.# your_app/admin.py...fromckeditor_link.adminimportDjangoLinkAdminclassLinkModelAdmin(DjangoLinkAdmin):passadmin.site.register(LinkModel,LinkModelAdmin)Configure your django-ckeditor (or whatever ck you use).# config for django-ckeditorCKEDITOR_LINK_MODEL='my_app.models.LinkModel'CKEDITOR_LINK_IFRAME_URL=reverse_lazy('admin:my_app_linkmodel_add')CKEDITOR_LINK_VERIFY_URL=reverse_lazy('admin:my_app_linkmodel_verify')CKEDITOR_CONFIGS={'default':{'djangolinkIframeURL':CKEDITOR_LINK_IFRAME_URL,'djangolinkVerifyURL':CKEDITOR_LINK_VERIFY_URL,'djangolinkFallbackField':'external','extraPlugins':','.join([# your extra plugins here'djangolink',]),'toolbar':'Custom','toolbar_Custom':[['Bold','Underline'],['DjangoLink','Unlink'],]}}If you have existing content with normal<a href="">style links, you can migrate them into ckeditor-link mode:
In the ckeditor configs, specify your model field asdjangolinkFallbackField(see above), existing href values will
show up in that field (and stay there).In your template, use the django-ckeditor-link templatetag. This addslxmlandcssselectas dependencies - you
must install those yourself.{%loadckeditor_link_tags%}{%object.html_field|ckeditor_link_add_link%}If your linkmodel has a multi widget (as the django-cms's PageField), you can use theCKEDITOR_LINK_ATTR_MODIFIERSsetting, to modify attributes as you like. Example:```
# a default, working with the provided contrib link_model and django-cms
CKEDITOR_LINK_ATTR_MODIFIERS = getattr(
    settings,
    'CKEDITOR_LINK_ATTR_MODIFIERS', {
        'cms_page': '{cms_page_2}'
    }
)
```The actual value ofcms_pagewill be formatted with the  pythonformat(**kwargs)function, where kwargs are the link's
data attributes and it's values (withoutdata-).SettingsCKEDITOR_LINK_MODEL (default:None)# needed when using the ckeditor_link_add_links template filter, otherwise not
CKEDITOR_LINK_MODEL = 'my_app.models.LinkModel'CKEDITOR_LINK_USE_CMS_FILER (default:Trueif django-cms and django-filer in INSTALLED_APPS)# when using the ckeditor_link.link_model app, enable cms and filer integrationCKEDITOR_LINK_MODEL_USE_FILER_ADDONS (default:False)# when using filer integration, use django-filer-addons.filer_gui admin fieldCKEDITOR_LINK_ATTR_MODIFIERS (default:{'cms_page': '{cms_page_2}'})# needed when using the ckeditor_link_add_links template filter
# used to combine multi widgets values, to be in a valid form. 
# django-cms own "PageField" needs this
CKEDITOR_LINK_ATTR_MODIFIERS = {
    'multi_widget_field': '{multi_widget_field_1}--{multi_widget_field_whatever}'
    'cms_page': '{cms_page_2}'
}Django CompatibilityPlease refer to the CHANGELOG.txt for current supported django versions.ContributeFork and code. Quickstart:pipinstall-rtest_requirements.txt./manage.pymigrate# create local sqlite db./manage.pycreatesuperuser# you want that./manage.pyloaddatatest_app# same data that is used for running tests./manage.pyrunserver# goto localhost:8000/admin/ or localhost:8000/testmodel/2/TestingEither runtoxfor complete tests, or `python manage.py testgeckodriver installvisithttps://github.com/mozilla/geckodriver/releasesdownload the latest version of "geckodriver-vX.XX.X-linux64.tar.gz"unarchive the tarball (tar -xvzf geckodriver-vX.XX.X-linux64.tar.gz)give executable permissions to geckodriver (chmod +x geckodriver)move the geckodriver binary to /usr/local/bin or any location on your system PATH.