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

data_collector changes for django >= 1.7 #1556

Closed
MFlyer opened this issue Nov 30, 2016 · 0 comments
Closed

data_collector changes for django >= 1.7 #1556

MFlyer opened this issue Nov 30, 2016 · 0 comments
Assignees
Labels
Milestone

Comments

@MFlyer
Copy link
Member

MFlyer commented Nov 30, 2016

Hi @schakrava , need your help / confirmation for upcoming PR:

While checking Pincard manager after Django update got this while trying to create a new pincard (credit card symbol on users page clicked):

Traceback (most recent call last):
  File "/opt/build/eggs/gevent-1.1.2-py2.7-linux-x86_64.egg/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/opt/build/src/rockstor/smart_manager/data_collector.py", line 96, in create_pincard
    new_pincard = save_pincard(uid)
  File "/opt/build/src/rockstor/system/pinmanager.py", line 171, in save_pincard
    flush_pincard(uid)
  File "/opt/build/src/rockstor/system/pinmanager.py", line 163, in flush_pincard
    Pincard.objects.filter(user=int(uid)).delete()
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/query.py", line 536, in delete
    collector.collect(del_query)
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/deletion.py", line 193, in collect
    if self.can_fast_delete(objs):
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/deletion.py", line 155, in can_fast_delete
    for related in get_candidate_relations_to_delete(opts):
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/deletion.py", line 62, in get_candidate_relations_to_delete
    opts.get_fields(include_hidden=True) for opts in candidate_models
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/deletion.py", line 62, in <genexpr>
    opts.get_fields(include_hidden=True) for opts in candidate_models
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/options.py", line 740, in get_fields
    return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/options.py", line 802, in _get_fields
    all_fields = self._relation_tree
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/utils/functional.py", line 59, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/options.py", line 709, in _relation_tree
    return self._populate_directed_relation_graph()
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/db/models/options.py", line 681, in _populate_directed_relation_graph
    all_models = self.apps.get_models(include_auto_created=True)
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/utils/lru_cache.py", line 101, in wrapper
    result = user_function(*args, **kwds)
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/apps/registry.py", line 168, in get_models
    self.check_models_ready()
  File "/opt/build/eggs/Django-1.8.16-py2.7.egg/django/apps/registry.py", line 131, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
AppRegistryNotReady: Models aren't loaded yet.
<Greenlet at 0x22e8cd0: create_pincard(u'11201')> failed with AppRegistryNotReady

Googling found that it's related to Django >=1.7 and solved over system.pinmanager this with:

import django
django.setup()

Pinmanager code inside data_collector (remember data_collector is supervisord, not on our wsgi) relies on system.pinmanager that loads Django User model (from django.contrib.auth.models import User as DjangoUser), but django.setup() now seems to be required

Can you confirm this being ok? :)

Meanwhile, having PR
M.

schakrava added a commit that referenced this issue Dec 4, 2016
@schakrava schakrava added the bug label Dec 4, 2016
@schakrava schakrava added this to the Pinnacles milestone Dec 4, 2016
@schakrava schakrava changed the title [Bug] Upgrading to Django >= 1.7 requires enabling Django on data_collector data_collector changes for django >= 1.7 Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants