Comments (3)
@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.
@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.
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)
- CKEditor + Calendar issue in New Django Jet HOT 3
- [Bug] No support for non-number ID fields HOT 4
- editable option not working in case of table with foreign key reference
- error in SQL syntax (django.db.utils.ProgrammingError)
- CKEDITOR field - Not working as HTML option setting configuration
- Link Models to Dashboard
- Support Django-Money or Allow for Custom Serialisers
- Only the "default" database models are exposed
- Unable to connect to Postgres on a custom socket HOT 2
- Versions diff
- Open SQL connection on demand only
- Not working on Django 3.0.7
- AttributeError: 'str' object has no attribute '_meta'
- Importation error in models using Django3 HOT 1
- Jet bridge confusion
- Error When Deploying Django App with Version 5.1
- [Bug] PATCH - GenericForeignKey relationship fails with "django.core.exceptions.FieldDoesNotExist: StudentSolution has no field named 'object_id'" HOT 4
- [Feature] Display GenericRelation
- not able to Navigate by page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jet-django.