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

[PROD] Image upload difficulty on Admin pages #2077

Closed
szabozoltan69 opened this issue Mar 20, 2024 · 3 comments · Fixed by #2078
Closed

[PROD] Image upload difficulty on Admin pages #2077

szabozoltan69 opened this issue Mar 20, 2024 · 3 comments · Fixed by #2078
Assignees

Comments

@szabozoltan69
Copy link
Contributor

Issue

On the Admin page, at countries or regions there are snippets.
Near the snippets there is an option for image upload, but if we try to use it, gives an Error 500.
(There are similar snippets and image upload option for events (emergencies) also, but it works fine.)
In Sentry you can also find this item, id=1648.
Somehow the revisions, the translations, the encoding can be related.

@szabozoltan69
Copy link
Contributor Author

@batpad @thenav56

@szabozoltan69
Copy link
Contributor Author

szabozoltan69 commented Mar 21, 2024

Somehow the country snippet object has no name in /usr/local/lib/python3.8/site-packages/reversion/revisions.py:185:

(Pdb) p content_type
<ContentType: api | country snippet>
(Pdb) pp vars(obj)
{'_mt_disable': False,
 '_state': <django.db.models.base.ModelState object at 0x7f673a02c670>,
 'country_id': 16,
 'id': 102,
 'image': 'countries/2024/03/21/BEE_logo_PERNpnp.jpg',
 'position': 3,
 'snippet': None,
 'snippet_ar': None,
 'snippet_en': None,
 'snippet_es': None,
 'snippet_fr': None,
 'translation_module_original_language': 'en',
 'translation_module_skip_auto_translation': False,
 'visibility': 3}
(Pdb) p obj
(nothing)

@szabozoltan69
Copy link
Contributor Author

szabozoltan69 commented Mar 21, 2024

Solution found.
In case of "no HTML snippet part" (only image) no name can be added by Django.
So instead of

    def __str__(self):
        return self.snippet

We should use:

    def __str__(self):
        return self.snippet or self.image.url

Or something similar as at event snippet:

    def __str__(self):
        return self.snippet if self.snippet else ''

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

Successfully merging a pull request may close this issue.

1 participant