A model field that can be edited without needing a form.
Project description
What is django_ief?
It is a field for django database models which you don't need any extra forms to edit nor save.
How to use it?
First, install the application and add the urls.
# settings.py
installed_apps = [
...,
'django_ief',
...,
]
# urls.py
urlpatterns = [
path('', include('django_ief.urls')),
# others
]
Then just use it as a field.
from django.db import models
from django_ief.fields import InlineEditableField
def permission_function(request):
return get_perm_from_request(request)
class BlogPost(models.Model):
content = InlineEditableField(
can_edit=permission_function,
text_field_kwargs={**kwargs_for_text_field},
image_field_kwargs={**kwargs_for_image_field}
)
The above creates an additional model to hold its images which looks like this:
class BlogPost_Images(models.Model):
owner = models.ForeignKey(BlogPost, on_delete=models.CASCADE)
image = models.ImageField(**kwargs_for_image_field)
which you can access with
BlogPost.image_model
and creates a text field in the original model which looks like:
class BlogPost(models.Model):
content = InlineEditableField(...)
content_text = models.TextField(**kwargs_for_text_field)
If you want you may interact with those underlying fields and models but you don't need to,
all you need to do is to use one attribute of the InlineEditableField
in your templates, rendered
.
<!-- you need to add the actual editor static for it to work -->
<script src="{% static 'django_ief/ckeditor.js' %}"></script>
<!-- it is just a single file, you now can use any number of fields with the .rendered attribute on the page -->
{{ obj.content.rendered }}
And that's it, everything else is automatically taken care of.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django_ief-0.1.2.tar.gz
.
File metadata
- Download URL: django_ief-0.1.2.tar.gz
- Upload date:
- Size: 149.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c265e26c35a4e012d6e4e8c5ed6ec6bdd9c9f18a110f87712a1c9d0dc1076e9d |
|
MD5 | db2afddf692f34f9429a8d85ab8d59e6 |
|
BLAKE2b-256 | c43c0aa7b65f7f08be229853b1a1970eed025ce9de7ef9dd912ac58336251d81 |