Giter Club home page Giter Club logo

Comments (3)

f1nality avatar f1nality commented on September 12, 2024 1

@Vadorequest regarding hiding field, its possible with visual editor as described here:
https://docs.jetadmin.io/manipulate/summary-view

regarding values not shown, i need to investigate it more detailed, which data type is specified for them in JET btw?

from jet-django.

f1nality avatar f1nality commented on September 12, 2024 1

@Vadorequest hello!

managed to investigate this issue: the problem is that django-modeltranslation patches django models so you need to run jet_django only after django-modeltranslation has finished its patching like this in your settings.py:

INSTALLED_APPS = (
...
'modeltranslation',
'jet_django', # after modeltranslation

)

from jet-django.

Vadorequest avatar Vadorequest commented on September 12, 2024

The values (label_fr, label_en) are not shown, because my model doesn't explicitly list them.

Here is my Model:

from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from jsonfield import JSONField


class Org(models.Model):
  name = models.SlugField(
    help_text="Name which references the organisation (unique)",
    max_length=50,
    unique=True,
  )
  label = models.CharField(
    help_text="Displayed label",
    max_length=100,
    null=False,
    blank=False,
  )
  logo = JSONField(
    help_text="Logo (JSON). All fields are required<br />"
              "Structure is likely to evolve and therefore stored as JSON for the sake of simplicity",
    default='',
    null=False,
    blank=False,
  )
  apps = JSONField(
    help_text="Applications configuration (JSON)<br />"
              "Structure is likely to evolve and therefore stored as JSON for the sake of simplicity",
    default='',
    null=False,
    blank=False,
  )
  # Reverse generic relation - XXX See https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#reverse-generic-relations
  student_solutions = GenericRelation('student_solution.StudentSolution')

  class Meta:
    # https://docs.djangoproject.com/en/2.1/ref/models/options/#django.db.models.Options.db_table
    db_table = "tfp_organisations"
    verbose_name = 'Organisation'
    verbose_name_plural = 'Organisations'

    # https://docs.djangoproject.com/en/2.1/ref/models/options/#indexes
    # indexes = [
    #   models.Index(fields=['name', 'name']),
    # ]

  def __str__(self):
    return self.label

As you can see, there is no mention of label_en or label_fr, it's because those fields are added in the model at runtime. But they exist in the DB.

from modeltranslation.translator import translator, TranslationOptions

from tfp_backoffice.apps.org.models import Org


class OrgTranslationOptions(TranslationOptions):
  """
  See https://django-modeltranslation.readthedocs.io/en/latest/registration.html
  """
  fields = ('label',)
  required_languages = ('fr',)  # ex: {'de': ('title', 'text'), 'default': ('title',)}


translator.register(Org, OrgTranslationOptions)

It's a particular edge case, JET maps the model but is not aware of those fields that are added a bit differently, through a register

from jet-django.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.