Skip to main content

django-splint-kovs

PyPI - Python Version PyPI - License PyPI

django-splint-kovs is a tool for projects with django framework, here you will find some basic settings for your models, views, serializers and adminitrators. This package assumes you have already started a project with django framework, otherwise see Getting started with Django

How to install?

pip install django-splint-kovs

Features

  • SplintViewSet (Splint version of DRF GenericViewSet):

  • SplintModelViewSet (Splint version of DRF ModelViewSet)

    This a simple class to django views, you can use it by simply inheriting it in your views.

    class StudentViewSet(SplintViewSet, ...):
    

    with this you have set some custom attributes to the class, for example:

    class StudentViewSet(SplintViewSet, ...):
      serializer_class = StudentSerializer # serializer default
      # Custom serializers
      read_serializer_class = StudentRetrieveSerializer # serializer to retrieve action
      list_serializer_class = StudentListSerializer # serializer to list action 
      write_serializer_class = StudentWriteSerializer # serializer to create, destroy and update actions
    
  • SplintModel:

    This class is an example base model, it contains some generic attributes that can be very useful, such as fields that save the creation, update and deletion date of records. With that, we don't need to worry about creating these fields manually for each of our models.

    Another utility:

    • Overriding of the delete method to ensure that objects are not completely deleted.
    • Saves original value model fields with pattern __original_{field_name} in local cache before any actions (save, deleted) as also signals flow.
    • Log activity to every action in the system

    Usage:

    class StudentModel(SplintModel):
      name: ..
    
    Student.objects.create(name='first student')
    # Student fields
    {
      id: 1,
      name: 'first student',
      created_at: <DateTime>,
      updated_at: <DateTime>,
      _deleted: False,
      _deleted_at: <Datetime>
    }
    
    students = Student.objects.all()
    students.delete() # this objects has not been deleted completely, it will only be invisible to objects manage default.
    
    s_with_deleted = Student.objects_with_deleted.filter(_deleted=True) # list of "deleted" students.
    
    
  • SplintImageField:

    This class provide image width, height (at least one dim) and quality to resize image using PIL. Vertical crop images will be applied before resizing the image, you can use it by simply seting in your models fields.

    class StudentModel(SplintModel):
      profile_picture = SplintImageField('Profile picture', upload_to='student', width=120, ...)
      ...
    
  • splint_cached_property:

    This class a sample decorator for saves properties values in cache services, for details on how to configure access to topics cache in django docs https://docs.djangoproject.com/en/4.0/topics/cache/

    class StudentModel(SplintModel):
    ...
    
    def studentgroups_actives__cache_key(self):
      return sha224(f'{self.id}'.encode()).hexdigest()
    
    @splint_cached_property
    def studentgroups_actives(self):
      ...
    
    

    by default this class will look for a function with pattenr {property_name}__cache_key that returns a text representing a key, this key will be used to retrieve the value later.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Metadata

Release files for django-splint-kovs 0.0.63

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-splint-kovs 0.0.63
File Size Uploaded Provenance Actions
django_splint_kovs-0.0.63.tar.gz 16.8 kB Without provenance Details for django_splint_kovs-0.0.63.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-splint-kovs 0.0.63
File Interpreter ABI Platform Actions
django_splint_kovs-0.0.63-py3-none-any.whl Python 3 none any Details for django_splint_kovs-0.0.63-py3-none-any.whl

Total release size: 35.9 kB

Release files / django_splint_kovs-0.0.63.tar.gz

Download URL django_splint_kovs-0.0.63.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
52444e37cb6ec36a6c75096bd3ff9c268459305854695f2cda14d10bae02853f
BLAKE2b-256 checksum
How to use checksums
63ad2ab64b060ce3d7bc9e0cd344e30290f46a5e9fd2f60cd32a3fbbb28092af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / django_splint_kovs-0.0.63-py3-none-any.whl

Download URL django_splint_kovs-0.0.63-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ad27ed8f166a7d8d356729b2ee8786e6fa0d21cba23929f6e16886c2f0474a6
BLAKE2b-256 checksum
How to use checksums
3743c98f2555c8a85e20fb786a7b8756eb9a278837afc1178d5adf10842aedae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Security for django-splint-kovs 0.0.63

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.63 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page