djk2 / django-admin-shell

Django/Python shell for django admin site.
MIT License
77 stars 11 forks source link

feat: added modal to save most used snippets and pre-fill the code editor #10

Open OmerBhatti opened 5 months ago

OmerBhatti commented 5 months ago

Issue

Closes: Allow users to save most used snippets

Changes

Screenshots

image
djk2 commented 1 week ago

image

djk2 commented 1 week ago

Please look on CI/CD actions, there is a error: django.urls.exceptions.NoReverseMatch: Reverse for 'admin_shell_savedsnippet_add' not found. 'admin_shell_savedsnippet_add' is not a valid view function or pattern name.

Problem is related to this part of template:

{% url 'admin:admin_shell_savedsnippet_add' %}

Unfortunately it not working in Django <= 3.1

This is corrent for 4.2 {% url 'admin:admin_shell_savedsnippet_add' %}

This form is proper for older versions: {% url 'admin:django_admin_shell_savedsnippet_add' %}

I suggest to calculate URL on view level, for example in method

def get_saved_snipets_admin_url(self):
      if django.VERSION < (4, 0):
           reutrn reverse('....)
      else: 
          return reverse('....)

and pass url in context

To check compatible of your code, you can launch tox command locally to tests application code for all supported versions django and python