Skip to main content

better link dialog for ckeditor

Project description


.. image::

link plugin for ckeditor, based on django modelforms/modeladmin, allowing direct linking to your models, or to whatever your want.


To get the latest stable release from PyPi

.. code-block:: bash

pip install django-ckeditor-link

Add ``ckeditor_link`` to your ``INSTALLED_APPS``

.. code-block:: python


ckeditor_link does not need it's own database tables, so no need to migrate.


Have a look at ``ckeditor_link/tests/test_app/`` for a complete example.

Following steps are needed.

1. Define a link model. Proposed way: Create a 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.

.. code-block:: python

# your_app/

class LinkModelBase(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)

class Meta:
abstract = True

def __str__(self):
# do it better
return "LINK! %s" %

def get_link(self):
# return link value, based on fields.
return ""

class CKLinkModel(LinkModelBase):

2. Register your model with DjangoLinkAdmin.

.. code-block:: python

# your_app/
from ckeditor_link.admin import DjangoLinkAdmin

class CKModelLinkAdmin(DjangoLinkAdmin):
pass, CKModelLinkAdmin)

3. Configure your django-ckeditor (or whatever ck you use).

.. code-block:: python

# config for django-ckeditor

CKEDITOR_LINK_MODEL = 'ckeditor_link.tests.test_app.models.LinkModel'
CKEDITOR_LINK_IFRAME_URL = reverse_lazy('admin:test_app_linkmodel_add')
CKEDITOR_LINK_VERIFY_URL = reverse_lazy('admin:test_app_linkmodel_verify')

'default': {
'extraPlugins': ','.join(
# your extra plugins here
'toolbar': 'Custom',
'toolbar_Custom': [
['Bold', 'Underline'],
['DjangoLink', 'Unlink'],

4. In your template, use the django-ckeditor-link templatetag.

.. code-block:: html

available, undocumented. at your own risk (needs lxml)


Fork and code. Quickstart:

.. code-block:: bash

pip install -r test_requirements.txt
./ migrate # create local sqlite db
./ createsuperuser # you want that
./ loaddata test_app # same data that is used for running tests
./ runserver # goto localhost:8000/admin/ or localhost:8000/testmodel/2/

Either run `tox` for complete tests, or `python test --settings=ckeditor_link.tests.settings_test`

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-ckeditor_link-0.1.0.tar.gz (51.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page