Code Monkey home page Code Monkey logo

jet-django's People

Contributors

f1nality avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jet-django's Issues

Importation error in models using Django3

ERROR IN DJANGO 3

from django.utils.encoding import python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding' (/home/raifran/.conda/envs/vaskipedia/lib/python3.7/site-packages/django/utils/encoding.py)

update archive /jet/models.py and replace

old calling

from django.utils.encoding import python_2_unicode_compatible

new calling

try:
from django.utils.encoding import python_2_unicode_compatible
except:
from six import python_2_unicode_compatible # from django3

[Bug] Fields internationalization - Useless field shown + values not displayed

I use django-modeltranslation to add fields internationalization in my models.

I basically configure the following in my models.py:

label = models.CharField(
    help_text="Displayed label",
    max_length=100,
    null=False,
    blank=False,
  )

And end up with the following fields:
label, label_fr, label_en

Jet doesn't seem to understand it very well:
image

It doesn't make much sense to display the generic label field, it's counter-intuitive in such case at best. Here is the field configuration:
image

There is no way to "hide" the field so it cannot be shown at all by default.


Also, and much more of an issue for me, the internationalized fields don't show:

image

But I do have the proper data in the DB:
image

The reason behind the bug seems to be from the API itself, the API doesn't seem to know about the localized fields and only returns the main one. Maybe should I change configure something differently there?
image

Open SQL connection on demand only

Currently, Jet Admin opens a SQL connection immediately on the app start. This is causing issues on high load projects.

For example, I'm running an auto scalable Google Cloud Run project with gunicorn and concurrency set to 2, and with 100 parallel threads hummering my web site, the number of PostgreSQL connections is 300+. Disabling Jet Admin drops down the number of connections to ~100. There is no load coming towards Jet Admin endpoint at all, it just eats up a connection in every thread.

Is it possible to have Jet Admin only open a SQL connection when there's need for it? Such as on a first request to the API?

Unable to connect to Postgres on a custom socket

Currently, there is no way to connect to a Postgres running on a custom socket (e.g. in Google App Engine).

  1. with this Django settings.py (as per Django docs):
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "HOST": "/cloudsql/xyz",
        "NAME": "foo",
    }
}

jet-admin fails:

Connected to database engine "postgresql:///cloudsql/xyz/foo"
...
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL:  database "cloudsql/xyz/foo" does not exist
  1. with this Django settings.py:
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "foo",
        "OPTIONS": {"host": "/cloudsql/xyz"}
    }
}

jet-admin constructs weird URL and ignores the options:

Connected to database engine "postgresql://foo"
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "foo" to address: nodename nor servname provided, or not known
  1. with this Django settings.py:
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "foo",
        "OPTIONS": {"host": "/cloudsql/xyz"}
    }
}

JET_DATABASE_EXTRA = "?host="/cloudsql/xyz"

it still fails to connect:

Connected to database engine "postgresql://foo?host=/cloudsql/xyz"
...
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "foo?host=" to address: nodename nor servname provided, or not known
  1. with this Django settings.py:
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "HOST": "localhost",
        "NAME": "foo",
        "OPTIONS": {"host": "/cloudsql/xyz"}
    }
}

JET_DATABASE_EXTRA = "?host="/cloudsql/xyz"

it's finally constructing a working connection string:

Connected to database engine "postgresql://localhost/foo?host=/cloudsql/xyz"

but, in this case Django wouldn't connect to the database.

error in SQL syntax (django.db.utils.ProgrammingError)

#12
this issue is related to above one. please go through it before reading this below issue.

Scenario:
when i does any CRUD operation of independent table(when i say independent table it means simple table with some columns) then i do not get any error message on console and data gets updated according to the respective CRUD operation BUT when i does Create/Update operation on table with foreign key reference then i get below error logs BUT the data gets updated according to the respective Create/Update operation successfully(this is surprising though).

And when i follow same process as explained above using django admin panel then everything works fine and i do not get error messages at all.

error log:

[08/Apr/2019 14:17:50] "GET /jet_api/models/layer;merchantaccountbalance/1/ HTTP/1.1" 200 110
Jet view exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY `merchant_account_balance`.`id` DESC) AS __inner__row\n                ' at line 7")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/jet_django/deps/rest_framework/views.py", line 480, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/jet_django/views/model.py", line 194, in get_siblings
    return Response(get_model_siblings(self.model, obj, queryset))
  File "/usr/local/lib/python3.5/dist-packages/jet_django/utils/siblings.py", line 150, in get_model_siblings
    row_number = get_row_number(Model, instance, join_sql, join_args, where_sql, where_args, order_by_sql)
  File "/usr/local/lib/python3.5/dist-packages/jet_django/utils/siblings.py", line 36, in get_row_number
    cursor.execute(query, args)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY `merchant_account_balance`.`id` DESC) AS __inner__row\n                ' at line 7")
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY `merchant_account_balance`.`id` DESC) AS __inner__row\n                ' at line 7")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/jet_django/deps/rest_framework/views.py", line 480, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/jet_django/views/model.py", line 194, in get_siblings
    return Response(get_model_siblings(self.model, obj, queryset))
  File "/usr/local/lib/python3.5/dist-packages/jet_django/utils/siblings.py", line 150, in get_model_siblings
    row_number = get_row_number(Model, instance, join_sql, join_args, where_sql, where_args, order_by_sql)
  File "/usr/local/lib/python3.5/dist-packages/jet_django/utils/siblings.py", line 36, in get_row_number
    cursor.execute(query, args)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.5/dist-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY `merchant_account_balance`.`id` DESC) AS __inner__row\n                ' at line 7")
Internal Server Error: /jet_api/models/layer;merchantaccountbalance/1/get_siblings/

[Feature] Display GenericRelation

I have the following model in models.py

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

The relevant line is

student_solutions = GenericRelation('student_solution.StudentSolution')

In the JET Admin I don't see the relation at all:

image

I don't see it either when trying to customise the interface:

image

I would expect the StudentSolution relationship to be displayed. I guess this connector doesn't have such feature at this time, but it could be handy.

CKEDITOR field - Not working as HTML option setting configuration

When I modify through settings the view, I am not able to upload Media through my CKEDITOR field. This is how my field looks in the model. I tried to choose "HTML". But the option for uploading to amazon through this field is dissapered under the "Advanced tap"

  • body = RichTextUploadingField()

Please fix I love the new admin, really keen to implement this in production!!!

Not to expose SQL queries while passing queries using REST

SQL Queries are exposed while passing payload to https://api-fberry-demo.geex-arts.com/jet_api/sql/. The right way should be to build queries on the go in the backend only. Any specific reason why queries (literally) are passed in payload? Due to this table names in the database are exposed to the world which is a security risk.

CKEditor + Calendar issue in New Django Jet

First all amazing job I love the new UI !! Especialy in dark theme ...

But unfortunately migrating from the old Jet-admin to this.

  • CK-editor widget is not displaying
  • Functions like clickable calendar not functional either..

This makes an issue that migrating might be to long time

I will wait excited for when new updates is available all the best!

Jet view exception
Traceback (most recent call last):
File "/Users/dev/PycharmProjects/MYNORDICROOM19/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/Users/dev/PycharmProjects/MYNORDICROOM19/venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 303, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: near "(": syntax error

[Bug] PATCH - GenericForeignKey relationship fails with "django.core.exceptions.FieldDoesNotExist: StudentSolution has no field named 'object_id'"

I have the following dynamic entity in one of my models:

# Dynamic relationship to either Org, Institution or Campus entities
  generic_owner_content_type = models.ForeignKey(
    ContentType,
    on_delete=models.CASCADE,  # TODO check if good thing
    limit_choices_to=(
      models.Q(app_label='tfp', model='org') |
      models.Q(app_label='tfp', model='institution') |
      models.Q(app_label='tfp', model='campus')
    ),
    # null=True,  # Allow a solution not to belong to any owner,
    # blank=True,
  )
  generic_owner_object_id = models.PositiveIntegerField()
  generic_owner_content_object = fields.GenericForeignKey(
    'generic_owner_content_type',
    'generic_owner_object_id'
  )

When I update the entity through the Jet Admin UI such as:
image

I get the following error on the backend logs:

[1551913953167] Jet view exception
[1551913953167] Traceback (most recent call last):
[1551913953167] File "/var/task/django/db/models/options.py", line 564, in get_field
[1551913953167] return self.fields_map[field_name]
[1551913953167] KeyError: 'object_id'
[1551913953167] During handling of the above exception, another exception occurred:
[1551913953167] Traceback (most recent call last):
[1551913953167] File "/var/task/jet_django/deps/rest_framework/views.py", line 480, in dispatch
[1551913953167] response = handler(request, *args, **kwargs)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/mixins.py", line 84, in partial_update
[1551913953167] return self.update(request, *args, **kwargs)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/mixins.py", line 69, in update
[1551913953167] serializer.is_valid(raise_exception=True)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/serializers.py", line 236, in is_valid
[1551913953167] self._validated_data = self.run_validation(self.initial_data)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/serializers.py", line 434, in run_validation
[1551913953167] value = self.to_internal_value(data)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/serializers.py", line 488, in to_internal_value
[1551913953167] validated_value = field.run_validation(primitive_value)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/fields.py", line 776, in run_validation
[1551913953167] return super(CharField, self).run_validation(data)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/fields.py", line 524, in run_validation
[1551913953167] self.run_validators(value)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/fields.py", line 538, in run_validators
[1551913953167] validator(value)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/validators.py", line 79, in __call__
[1551913953167] queryset = self.filter_queryset(value, queryset)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/validators.py", line 66, in filter_queryset
[1551913953167] return qs_filter(queryset, **filter_kwargs)
[1551913953167] File "/var/task/jet_django/deps/rest_framework/validators.py", line 31, in qs_filter
[1551913953167] return queryset.filter(**kwargs)
[1551913953167] File "/var/task/django/db/models/manager.py", line 82, in manager_method
[1551913953167] return getattr(self.get_queryset(), name)(*args, **kwargs)
[1551913953167] File "/var/task/django/db/models/query.py", line 844, in filter
[1551913953167] return self._filter_or_exclude(False, *args, **kwargs)
[1551913953167] File "/var/task/modeltranslation/manager.py", line 304, in _filter_or_exclude
[1551913953167] new_key = rewrite_lookup_key(self.model, key)
[1551913953167] File "/var/task/modeltranslation/manager.py", line 51, in rewrite_lookup_key
[1551913953167] fields_to_trans_models = get_fields_to_translatable_models(model)
[1551913953167] File "/var/task/modeltranslation/manager.py", line 141, in get_fields_to_translatable_models
[1551913953167] related_model = get_model_from_relation(f)
[1551913953167] File "/var/task/django/contrib/admin/utils.py", line 446, in get_model_from_relation
[1551913953167] return field.get_path_info()[-1].to_opts.model
[1551913953167] File "/var/task/django/contrib/contenttypes/fields.py", line 396, in get_path_info
[1551913953167] object_id_field = opts.get_field(self.object_id_field_name)
[1551913953167] File "/var/task/django/db/models/options.py", line 566, in get_field
[1551913953167] raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))
[1551913953167] django.core.exceptions.FieldDoesNotExist: StudentSolution has no field named 'object_id'
[1551913953167] [ERROR] 2019-03-06T23:12:33.148Z 9a1e71e4-30ce-4e99-94b4-8d6f57257a74 Jet view exception
Traceback (most recent call last):
  File "/var/task/django/db/models/options.py", line 564, in get_field
  return self.fields_map[field_name]
KeyError: 'object_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/task/jet_django/deps/rest_framework/views.py", line 480, in dispatch
  response = handler(request, *args, **kwargs)
  File "/var/task/jet_django/deps/rest_framework/mixins.py", line 84, in partial_update
  return self.update(request, *args, **kwargs)
  File "/var/task/jet_django/deps/rest_framework/mixins.py", line 69, in update
  serializer.is_valid(raise_exception=True)
  File "/var/task/jet_django/deps/rest_framework/serializers.py", line 236, in is_valid
  self._validated_data = self.run_validation(self.initial_data)
  File "/var/task/jet_django/deps/rest_framework/serializers.py", line 434, in run_validation
  value = self.to_internal_value(data)
  File "/var/task/jet_django/deps/rest_framework/serializers.py", line 488, in to_internal_value
  validated_value = field.run_validation(primitive_value)
  File "/var/task/jet_django/deps/rest_framework/fields.py", line 776, in run_validation
  return super(CharField, self).run_validation(data)
  File "/var/task/jet_django/deps/rest_framework/fields.py", line 524, in run_validation
  self.run_validators(value)
  File "/var/task/jet_django/deps/rest_framework/fields.py", line 538, in run_validators
  validator(value)
  File "/var/task/jet_django/deps/rest_framework/validators.py", line 79, in __call__
  queryset = self.filter_queryset(value, queryset)
  File "/var/task/jet_django/deps/rest_framework/validators.py", line 66, in filter_queryset
  return qs_filter(queryset, **filter_kwargs)
  File "/var/task/jet_django/deps/rest_framework/validators.py", line 31, in qs_filter
  return queryset.filter(**kwargs)
  File "/var/task/django/db/models/manager.py", line 82, in manager_method
  return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/var/task/django/db/models/query.py", line 844, in filter
  return self._filter_or_exclude(False, *args, **kwargs)
  File "/var/task/modeltranslation/manager.py", line 304, in _filter_or_exclude
  new_key = rewrite_lookup_key(self.model, key)
  File "/var/task/modeltranslation/manager.py", line 51, in rewrite_lookup_key
  fields_to_trans_models = get_fields_to_translatable_models(model)
  File "/var/task/modeltranslation/manager.py", line 141, in get_fields_to_translatable_models
  related_model = get_model_from_relation(f)
  File "/var/task/django/contrib/admin/utils.py", line 446, in get_model_from_relation
  return field.get_path_info()[-1].to_opts.model
  File "/var/task/django/contrib/contenttypes/fields.py", line 396, in get_path_info
  object_id_field = opts.get_field(self.object_id_field_name)
  File "/var/task/django/db/models/options.py", line 566, in get_field
  raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))
django.core.exceptions.FieldDoesNotExist: StudentSolution has no field named 'object_id'

I do not experience this issue when I use the Django Admin interface.


Solution

Renaming the model fields to the following fixed the issue:

# Dynamic relationship to either Org, Institution or Campus entities
  # XXX https://simpleisbetterthancomplex.com/tutorial/2016/10/13/how-to-use-generic-relations.html
  #  Do not rename "object_id", Jet Admin failed to update field when used a different variable name for some reason
  content_type = models.ForeignKey(
    ContentType,
    on_delete=models.CASCADE,  # TODO check if good thing
    limit_choices_to=(
      models.Q(app_label='tfp', model='org') |
      models.Q(app_label='tfp', model='institution') |
      models.Q(app_label='tfp', model='campus')
    ),
    # null=True,  # Allow a solution not to belong to any owner,
    # blank=True,
  )
  object_id = models.PositiveIntegerField()
  content_object = fields.GenericForeignKey(
    'content_type',
    'object_id'
  )

I guess something is hardcoded on the jet-django package and it doesn't handle custom model variable for dynamic relationships. I only have one in my case so it's not blocking, just annoying, but this should be fixed.

[Bug] No support for non-number ID fields

I use django-hashid for my "id" field in my models.

When running jet-django along with these models I get the following error:

  File "/Users/amit/workspace/project/project-platform/src/project_platform/web/urls.py", line 18, in <module>
    from jet_django.urls import jet_urls
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/urls.py", line 40, in <module>
    jet_urls = init_urls()
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/urls.py", line 21, in init_urls
    jet.register_related_models()
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/admin/jet.py", line 23, in register_related_models
    self.register(item['model'], hidden=True)
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/admin/jet.py", line 9, in register
    self.models.append(JetAdminModelDescription(Model, fields, actions, hidden))
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/admin/model_description.py", line 25, in __init__
    self.filter_class = model_filter_class_factory(Model, self.get_display_model_fields(), self.get_model_relations())
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/filters/model.py", line 164, in model_filter_class_factory
    class FilterSet(django_filters.FilterSet):
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/deps/django_filters/filterset.py", line 71, in __new__
    new_class.base_filters = new_class.get_filters()
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/filters/model.py", line 207, in get_filters
    filters[filter_name] = cls.filter_for_field(field, field_name, lookup_expr)
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/filters/model.py", line 225, in filter_for_field
    field, lookup_type = resolve_field(field, lookup_expr)
  File "/usr/local/lib/python3.7/site-packages/jet_django-0.5.8-py3.7.egg/jet_django/deps/django_filters/utils.py", line 218, in resolve_field
    raise FieldLookupError(model_field, lookup_expr) from e
jet_django.deps.django_filters.exceptions.FieldLookupError: Unsupported lookup 'gt' for field 'app.MyModel.id'.

Seems to be a problem with the id field being a non-integer.

I upgraded my entire project to python 3 just for this dashboard :) Hope we can get this to work !

Thanks!

AttributeError: 'str' object has no attribute '_meta'

so im using django 3.1 and i defined a model with a foreign key relation like this:

class Account(TimeStampedModel):
    corporate = models.ForeignKey('CompanyDetail',on_delete=models.CASCADE,related_name= 'corporate_accounts')
    balance = models.DecimalField(max_digits=20, decimal_places=2)

this throwns an this error when I try to run the project or run migrations:

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/apps.py", line 12, in ready
    conf = JetDjangoConfiguration()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 28, in __init__
    self.models = dict(map(lambda x: (self.model_key(x), self.serialize_model(x)), models))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 28, in <lambda>
    self.models = dict(map(lambda x: (self.model_key(x), self.serialize_model(x)), models))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 185, in serialize_model
    'fields': list(map(lambda field: self.serialize_field(field), fields))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 185, in <lambda>
    'fields': list(map(lambda field: self.serialize_field(field), fields))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 214, in serialize_field
    result['params'] = {'related_model': self.serialize_related_model(field.related_model)}
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 250, in serialize_related_model
    'model': Model._meta.db_table,
AttributeError: 'str' object has no attribute '_meta'

everything works fine when I manually import CompanyDetail. It also works fine when I take out jet_django from my installed apps in settings.py and urls.py file.

Jet bridge confusion

Pip installs jet-django from the jet-bridge repository, right? which is up to date.

This repo hasn't been touched in years.

Suggest something be done to avoid this confusion (eg put a warning on this repo, remove/archive it, etc).

ImportError: cannot import name 'QUERY_TERMS'

Hi,

when I run command python manage.py migrate jet_django,I met an error like blow

ImportError: cannot import name 'QUERY_TERMS' from 'django.db.models.sql.constants' (/Users/hujianxin/.local/share/virtualenvs/v-5bzDOrwr/lib/python3.7/site-packages/django/db/models/sql/constants.py)

python version: 3.7
django version: 2.0.24

Support Django-Money or Allow for Custom Serialisers

I am using a field called "django-money" and when trying to use it with jet-admin throws an exception

decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

This happens because it tries to serialize it as a decimal though it should be serialized as a string

Hello, when I run python manage.py migrate jet_django I get the following error.

Hello, when I run python manage.py migrate jet_django I get the following error.

Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/core/management/init.py", line 224, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/core/management/init.py", line 36, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Users/owner/miniconda3/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 14, in
from django.db.migrations.autodetector import MigrationAutodetector
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 11, in
from django.db.migrations.questioner import MigrationQuestioner
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/db/migrations/questioner.py", line 9, in
from .loader import MigrationLoader
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/db/migrations/loader.py", line 8, in
from django.db.migrations.recorder import MigrationRecorder
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 9, in
class MigrationRecorder:
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 22, in MigrationRecorder
class Migration(models.Model):
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/db/models/base.py", line 87, in new
app_config = apps.get_containing_app_config(module)
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/apps/registry.py", line 249, in get_containing_app_config
self.check_apps_ready()
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/apps/registry.py", line 131, in check_apps_ready
settings.INSTALLED_APPS
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/conf/init.py", line 57, in getattr
self._setup(name)
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/conf/init.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/Users/owner/miniconda3/lib/python3.6/site-packages/django/conf/init.py", line 107, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/owner/miniconda3/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'application'

Originally posted by @datatalking in #1 (comment)

Question regarding Caching

I wonder how can we improve performances using a Cache system.

I'm not familiar with caching in Django, but everywhere I look it's all about views/templates, not about the DB data themselves.

What I'd like to do, is that Jet Django should query my cache first and then fallback on the DB.
I don't know how this is handled by the jet_django package, but I assume it uses the models to query the DB.

What should I configure, so that all read queries go through a cache before hitting the DB?

This may not be related to jet-django, but I'm not sure.

editable option not working in case of table with foreign key reference

i have a some tables in my database and many of them have foreign key reference and others are independent tables. The editable option on independent column is working but it not working in case of table with foreign key reference.
edit1

here above table is independent table and mortality field is non-editable
check below screenshot for more info
edit2

but when i disable editable option for 'remaining' field then also jetadmin allows me to edit the field in create/update operation
refer below screenshots
edit3
edit4

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.