django-localized-fields | Implementation of localized model fields | Internationalization library

 by   SectorLabs Python Version: 6.8b4 License: MIT

kandi X-RAY | django-localized-fields Summary

kandi X-RAY | django-localized-fields Summary

django-localized-fields is a Python library typically used in Utilities, Internationalization applications. django-localized-fields has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can install using 'pip install django-localized-fields' or download it from GitHub, PyPI.

2.0, 2.1, 2.2, 3.0, 3.1. 3.6, 3.7, 3.8, 3.9. django-localized-fields is an implementation of a field class for Django models that allows the field's value to be set in multiple languages. It does this by utilizing the hstore type (PostgreSQL specific), which is available as models.HStoreField since Django 1.10. :warning: This README is for v6. See the v5.x branch for v5.x.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              django-localized-fields has a low active ecosystem.
              It has 62 star(s) with 13 fork(s). There are 37 watchers for this library.
              There were 1 major release(s) in the last 6 months.
              There are 4 open issues and 31 have been closed. On average issues are closed in 78 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of django-localized-fields is 6.8b4

            kandi-Quality Quality

              django-localized-fields has 0 bugs and 0 code smells.

            kandi-Security Security

              django-localized-fields has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              django-localized-fields code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              django-localized-fields is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              django-localized-fields releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              It has 2784 lines of code, 224 functions and 52 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed django-localized-fields and discovered the below as its top functions. This is intended to give you an instant insight into django-localized-fields implemented functionality, and help decide if they suit your requirements.
            • Validate and set the slug
            • Returns a tuple of values and their values
            • Resolve an object property
            • Gets the value
            • Set a language value
            • Gets the value from the given field
            • Prepare the value
            • Validate that the value is not None
            • Checks if value is empty
            • Creates a slug
            • Make a unique slug
            • Converts the value to the corresponding value
            • Convert a localized value to a LocalizedIntegerValue
            • Convert the value to the native value
            • Convert a local value to a LocalizedFloatValue
            • Prepare the value of the attribute
            • Prepare value for the column
            • Prepare the value for saving
            • Create a new custom command
            • Return the locale of the current object
            Get all kandi verified functions for this library.

            django-localized-fields Key Features

            No Key Features are available at this moment for django-localized-fields.

            django-localized-fields Examples and Code Snippets

            No Code Snippets are available at this moment for django-localized-fields.

            Community Discussions

            Trending Discussions on django-localized-fields

            QUESTION

            Maintain uniqueness on django-localized-fields
            Asked 2020-Jan-14 at 13:54

            I'm trying to avoid having duplicate localized items stored in a Django-rest-framework app, django-localalized-fields package with a PostgreSQL database I can't find any way to make this work.

            (https://pypi.org/project/django-localized-fields/)

            I've tried writing custom duplicate detection logic in the Serializer, which works for create, but for update the localized fields become null (they are required fields, so I receive a not null constraint error). It seems to be django-localized-fields utility which is causing this problem.

            The serializer runs correctly (create/update) when I'm not overriding create/update in the serializer by defining them separately.

            I've also tried adding unique options to the database in the model, which does not work - duplicates are still created. Using the standard unique methods, or the method in the django-localized-fields documentation (uniqueness=['en', 'ro']).

            I've also tried the UniqueTogetherValidator in Django, which also doesn't seem to support HStore/localizedfields.

            I'd appreciate some help in tracking down either how to fix the update in the serializer or place a unique constraint in the database. Since django-localized-fields uses hstore in PostgreSQL it must be a common enough problem for applications using hstore to maintain uniqueness.

            For those who aren't familiar, Hstore stores items as key/value pairs within a database. Here's an example of how django-localized-fields stores language data within the database:

            "en"=>"english word!", "es"=>"", "fr"=>"", "frqc"=>"", "fr-ca"=>""

            ...

            ANSWER

            Answered 2020-Jan-14 at 13:54

            django-localized-fields constraint unique values only per the same language. If you want to achieve that values in a row don't collide with values in another row, you have to validate them on Django and database level.

            Validation in Django

            In Django you can create custom function validate_hstore_uniqueness, which is called everytime is model validated.

            Source https://stackoverflow.com/questions/57104470

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install django-localized-fields

            Create a virtual environment:.
            Clone the repository: λ git clone https://github.com/SectorLabs/django-localized-fields.git
            Create a virtual environment: λ cd django-localized-fields λ virtualenv env λ source env/bin/activate
            Create a postgres user for use in tests (skip if your default user is a postgres superuser): λ createuser --superuser psqlextra --pwprompt λ export DATABASE_URL=postgres://localized_fields:<password>@localhost/localized_fields Hint: if you're using virtualenvwrapper, you might find it beneficial to put the export line in $VIRTUAL_ENV/bin/postactivate so that it's always available when using this virtualenv.
            Install the development/test dependencies: λ pip install ".[test]" ".[analysis]"
            Run the tests: λ tox
            Auto-format code, sort imports and auto-fix linting errors: λ python setup.py fix

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install django-localized-fields

          • CLONE
          • HTTPS

            https://github.com/SectorLabs/django-localized-fields.git

          • CLI

            gh repo clone SectorLabs/django-localized-fields

          • sshUrl

            git@github.com:SectorLabs/django-localized-fields.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Internationalization Libraries

            formatjs

            by formatjs

            react-i18next

            by i18next

            version

            by sebastianbergmann

            globalize

            by globalizejs

            angular-translate

            by angular-translate

            Try Top Libraries by SectorLabs

            django-postgres-extra

            by SectorLabsPython

            celery-cloudwatch

            by SectorLabsPython

            keycloak-mock

            by SectorLabsTypeScript