Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working if (Memcached) Cache offline #43

Open
pyMan opened this issue Apr 13, 2021 · 1 comment
Open

Not working if (Memcached) Cache offline #43

pyMan opened this issue Apr 13, 2021 · 1 comment

Comments

@pyMan
Copy link

pyMan commented Apr 13, 2021

Hi.

Python 3.8.x

django 2.2.x
django_dynamic_models 0.3.0

I set settings.CACHE to use memcached. If the memcached service is offline for any reason, simplest things like creating e FieldSchema fail. As soon as I start the memcached service, things work.

I do not understand exactly how the missing cache backend can affect things. I see this library makes use of cache, but it should be just for performance reason.

from dynamic_models.models import ModelSchema, FieldSchema

car_schema = ModelSchema.objects.create(name='Car')
car_model_field = FieldSchema.objects.create(model_schema=car_schema, name='test', data_type='character')  ### raise error

Traceback

Traceback (most recent call last):
  File ".\test.py", line 31, in <module>
    FieldSchema.objects.create(model_schema = model_schema, name = "test", data_type = 'character')
  File "C:\Users\.....\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\.....\lib\site-packages\django\db\models\query.py", line 422, in create
    obj.save(force_insert=True, using=self.db)
  File "C:\Users\.....\lib\site-packages\dynamic_models\models.py", line 95, in save
    self._schema_editor.update_column(model, field)
  File "C:\Users\.....\lib\site-packages\dynamic_models\schema.py", line 39, in update_column
    self.add_column(model, new_field)
  File "C:\Users\.....\lib\site-packages\dynamic_models\schema.py", line 44, in add_column
    editor.add_field(model, field)
  File "C:\Users\.....\lib\site-packages\sql_server\pyodbc\schema.py", line 635, in add_field
    if field.many_to_many and field.remote_field.through._meta.auto_created:
AttributeError: 'NoneType' object has no attribute 'many_to_many'

Thanks for help

@rvinzent
Copy link
Owner

The caching has been buggy in the past and needs to be removed / reworked 🙂

That was the last thing I wanted to do before the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants