Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 4 support #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ a filer File or anything custom like a News model.

<img src="https://github.com/dreipol/linkit/raw/master/doc/linkit.gif"/>

## Installation
## Installation
Install the latest version with pip and add `linkit` to your `INSTALLED_APPS` - and you're good to go.

$ pip install LinkIt

## Usage
## Usage
You're now able to use the new `LinkField` on any of your models:

```python
Expand All @@ -22,21 +22,21 @@ class Foo(Model):
link = LinkField(types=['page', 'file', 'input']) # <-- Yay!
```

If you register this model in django admin you'll get a dropdown field where yru can choose between cms pages, filer files or just a plain input field.
Your model is now able to link to any of these entities with one single field.
If you register this model in django admin you'll get a dropdown field where yru can choose between cms pages, filer files or just a plain input field.
Your model is now able to link to any of these entities with one single field.

In a template you could use this link field like this:
````html
<a href="{{ instance.link.href }}" target="{{ instance.link.target }}">{{ instance.link.label }}</a>
````

## Configuration
The `LinkField` takes some options which will define how the rendered widget looks and what options the content editor has:

- `types: list = None` Defines which link types are allowed (see more bellow in the section «Types»)
- `allow_target: bool = False` If set to true, the widget renders a checkbox so the editor can choose the `_target` of the link
- `types: list = None` Defines which link types are allowed (see more bellow in the section «Types»)
- `allow_target: bool = False` If set to true, the widget renders a checkbox so the editor can choose the `_target` of the link
- `allow_label: bool = True` Renders an additonal input field so a custom label can be set
- `allow_no_follow: bool = False` If set to true, the widget renders a checkbox so the editor can choose the `rel="nofollow"` for the link
- `allow_no_follow: bool = False` If set to true, the widget renders a checkbox so the editor can choose the `rel="nofollow"` for the link

## Types
Out of the Box LinkIt ships with three types: input, file, page. The `LinkType` base class makes it easy to implement your own link type, whatever
Expand All @@ -59,7 +59,7 @@ class NewsLinkType(ModelLinkType):

````python
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class ContentConfig(AppConfig):
Expand Down
2 changes: 1 addition & 1 deletion linkit/types/file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from filer.fields.file import AdminFileFormField
from filer.models import File

Expand Down
2 changes: 1 addition & 1 deletion linkit/types/input.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from django.forms import CharField
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from linkit.types.contracts import LinkType, TypeForm

Expand Down
2 changes: 1 addition & 1 deletion linkit/types/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from cms.forms.fields import PageSelectFormField
from cms.models import Page
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from linkit.types.contracts import LinkType, TypeForm

Expand Down