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

500 error when deleting a profile (whether via command line or admin or via /settings/account/ ) #7884

Closed
owocki opened this issue Nov 16, 2020 · 2 comments · Fixed by #7885

Comments

@owocki
Copy link
Contributor

owocki commented Nov 16, 2020

to reproduce, hit the admin + delete the profile, use settings/account or use the code below

from dashboard.models import Profile
Profile.objects.get(pk=98375).delete()
In [4]: Profile.objects.get(pk=98375).delete()
---------------------------------------------------------------------------
DoesNotExist                              Traceback (most recent call last)
<ipython-input-4-a7b0d4559f33> in <module>()
----> 1 Profile.objects.get(pk=98375).delete()

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/django/db/models/base.py in delete(self, using, keep_parents)
    917         collector = Collector(using=using)
    918         collector.collect([self], keep_parents=keep_parents)
--> 919         return collector.delete()
    920
    921     delete.alters_data = True

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/django/db/models/deletion.py in delete(self)
    316                     for obj in instances:
    317                         signals.post_delete.send(
--> 318                             sender=model, instance=obj, using=self.using
    319                         )
    320

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/django/dispatch/dispatcher.py in send(self, sender, **named)
    173         return [
    174             (receiver, receiver(signal=self, sender=sender, **named))
--> 175             for receiver in self._live_receivers(sender)
    176         ]
    177

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/django/dispatch/dispatcher.py in <listcomp>(.0)
    173         return [
    174             (receiver, receiver(signal=self, sender=sender, **named))
--> 175             for receiver in self._live_receivers(sender)
    176         ]
    177

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/cacheops/query.py in _post_delete(self, sender, instance, **kwargs)
    486         # NOTE: this will behave wrong if someone changed object fields
    487         #       before deletion (why anyone will do that?)
--> 488         invalidate_obj(instance)
    489
    490     def inplace(self):

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/cacheops/invalidation.py in invalidate_obj(obj, using)
     36     """
     37     model = obj.__class__._meta.concrete_model
---> 38     invalidate_dict(model, get_obj_dict(model, obj), using=using)
     39
     40

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/funcy/decorators.py in wrapper(*args, **kwargs)
     36         def wrapper(*args, **kwargs):
     37             call = Call(func, args, kwargs)
---> 38             return deco(call, *dargs, **dkwargs)
     39         return wraps(func)(wrapper)
     40     return _decorator

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/funcy/flow.py in post_processing(call, func)
    161 def post_processing(call, func):
    162     """Post processes decorated function result with func."""
--> 163     return func(call())
    164
    165 collecting = post_processing(list)

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/cacheops/invalidation.py in get_obj_dict(model, obj)
     98 def get_obj_dict(model, obj):
     99     for field in serializable_fields(model):
--> 100         value = getattr(obj, field.attname)
    101         if value is None:
    102             yield field.attname, None

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/django/db/models/query_utils.py in __get__(self, instance, cls)
    133             val = self._check_parent_chain(instance, self.field_name)
    134             if val is None:
--> 135                 instance.refresh_from_db(fields=[self.field_name])
    136                 val = getattr(instance, self.field_name)
    137             data[self.field_name] = val

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/django/db/models/base.py in refresh_from_db(self, using, fields)
    626             db_instance_qs = db_instance_qs.only(*fields)
    627
--> 628         db_instance = db_instance_qs.get()
    629         non_loaded_fields = db_instance.get_deferred_fields()
    630         for field in self._meta.concrete_fields:

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/cacheops/query.py in get(self, *args, **kwargs)
    352             qs = self
    353
--> 354         return qs._no_monkey.get(qs, *args, **kwargs)
    355
    356     def first(self):

~/gitcoin/gitcoin-37/lib/python3.7/site-packages/django/db/models/query.py in get(self, *args, **kwargs)
    406             raise self.model.DoesNotExist(
    407                 "%s matching query does not exist." %
--> 408                 self.model._meta.object_name
    409             )
    410         raise self.model.MultipleObjectsReturned(

DoesNotExist: Profile matching query does not exist.
@owocki
Copy link
Contributor Author

owocki commented Nov 16, 2020

can be fixed with settings fix prob https://github.com/Suor/django-cacheops

or by updating the version number of django cacheops

@owocki owocki changed the title 500 error when deleting a profile (whether via command line or admin) 500 error when deleting a profile (whether via command line or admin or via /settings/account/ ) Nov 16, 2020
@chibie chibie self-assigned this Nov 16, 2020
@developerfred
Copy link
Contributor

developerfred commented Nov 16, 2020

is working in administration update version django-chacheops
Screen Shot 2020-11-16 at 16 12 58

172.18.0.1 - - [16/Nov/2020 16:12:32] "POST /_administrationauth/user/22/delete/ HTTP/1.1" 302 -

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

Successfully merging a pull request may close this issue.

4 participants