Aristotle-Metadata-Enterprises / django-garnett

Django Garnett is a field level translation library that allows you to store strings in multiple languages for fields in Django - with minimal changes to your models and without having to rewrite your code.
https://django-garnett.herokuapp.com/
BSD 3-Clause "New" or "Revised" License
81 stars 3 forks source link

Doesn't work with Django 4 #68

Open ntoll opened 2 years ago

ntoll commented 2 years ago

Found this via HN and looks like something I could use for a current project.

However, requirements are hard pinned to specific versions, including not-the-latest version of Django.

Could you perhaps be more forgiving and/or specify minimum versions for the required dependencies?

Thanks - especially those of us who have to use Django4. ;-)

ntoll commented 2 years ago

Here's what a Django 4 user sees from within an existing virtual environment:

$ pip install django-garnett
Collecting django-garnett
  Using cached django_garnett-0.4.7-py3-none-any.whl (27 kB)
Collecting django<3.2.0,>=3.1.0
  Using cached Django-3.1.14-py3-none-any.whl (7.8 MB)
Collecting language-data<1.1.0,>=1.0.1
  Using cached language_data-1.0.1-py3-none-any.whl
Collecting langcodes<3.4.0,>=3.3.0
  Using cached langcodes-3.3.0-py3-none-any.whl (181 kB)
Requirement already satisfied: asgiref<4,>=3.2.10 in /home/ntoll/.virtualenvs/codegrades/lib/python3.9/site-packages (from django<3.2.0,>=3.1.0->django-garnett) (3.5.0)
Requirement already satisfied: pytz in /home/ntoll/.virtualenvs/codegrades/lib/python3.9/site-packages (from django<3.2.0,>=3.1.0->django-garnett) (2021.3)
Requirement already satisfied: sqlparse>=0.2.2 in /home/ntoll/.virtualenvs/codegrades/lib/python3.9/site-packages (from django<3.2.0,>=3.1.0->django-garnett) (0.4.2)
Collecting marisa-trie
  Using cached marisa_trie-0.7.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.3 MB)
Requirement already satisfied: setuptools in /home/ntoll/.virtualenvs/codegrades/lib/python3.9/site-packages (from marisa-trie->language-data<1.1.0,>=1.0.1->django-garnett) (60.6.0)
Installing collected packages: marisa-trie, language-data, langcodes, django, django-garnett
  Attempting uninstall: django
    Found existing installation: Django 4.0.2
    Uninstalling Django-4.0.2:
      Successfully uninstalled Django-4.0.2
Successfully installed django-3.1.14 django-garnett-0.4.7 langcodes-3.3.0 language-data-1.0.1 marisa-trie-0.7.7
LegoStormtroopr commented 2 years ago

Hmm - we're about to do out own shift to Django 4, so let me see what we can do.

vvarp commented 2 years ago

Same applies to Django 3.2 - in order to use django-garnett I had to vendorize it, as installing via poetry/pip was always downgrading Django to 3.1

LegoStormtroopr commented 2 years ago

So I've had a look:

ZipBrandon commented 2 years ago

@vvarp How's it doing on Django 4 when vendorizing? I cut a fork and am about to duplicate the same effort.

ZipBrandon commented 2 years ago

I'm still progressing on this. I updated a few dependencies in my fork. I see that Django 4 removed the KeyTransform and KeyTextTransform from jsonb fields, but I added into the package. I have no understanding of what it was doing for django-garnett yet. I think I'm up-and-running but trying to find my language switcher in my admin so I can test that as well.

https://github.com/ZipDeal-LLC/django-garnett/commit/e60d02818351275cb1d721474ebd40a77819675b

LegoStormtroopr commented 2 years ago

That is a lot of vendoring in of code that Django removed.

Let me see what we can do through the ORM to make that happen.

ZipBrandon commented 2 years ago

@LegoStormtroopr I appreciate it. FWIW I use it via my fork's hack at the moment and it works splendidly. It obviously isn't the ideal way to execute it but I appreciate you open sourcing your approach to this!

angvp commented 2 years ago

Hey @ZipBrandon I tried to use your fork, but I'm having no luck with a project that is already in django 4 and using garnett for the first time (when creating the migrations)

ZipBrandon commented 2 years ago

@angvp Did you do this? https://github.com/Aristotle-Metadata-Enterprises/django-garnett#data-migrations. That got me the first time. The trick is in the step_1_safe_encode_content and the step_2_safe_prepare_translations

angvp commented 2 years ago

I did indeed and didn't help in my case

ZipBrandon commented 2 years ago

@angvp I have recently had to apply it to another migration and my fork does not work either. It's a shame that django-garnett has not been officially updated at this point and feels as if abandoned.

LegoStormtroopr commented 2 years ago

@ZipBrandon its not abandoned. It's stable and suitable for our commercial purposes. We are doing internal releasing using Garnett and will be upgrading it to support Django 4 within our roadmap.

As others have pointed out, they have been able to fork and update it for their own projects - within the ethos of FOSS.

If PRs are opened we will review them to see if they are suitable and meet with our requirements as maintainers.

If there is specific development you'd like to see done, you are welcome to reach out and discuss a commercial support option.

angvp commented 2 years ago

Hey there @LegoStormtroopr and Aristotle-Metadata-Enterprises really thanks for this project, @ZipBrandon we ended up forking and picking a different solution (not going to do publicity about it here as this is not the space for that), and while this is a great project it didn't suit our needs, and while I share your "pain" @LegoStormtroopr is right, in my case, I tried several forks of this, and made it run partially, but it was too much work to do while I was building a proof of concept, I gave it a good 2 or 3 days of updating code and stuff to make it work, I'm happy to open a PR here eventually with some of those changes if they are worth for anyone.