django-admin-shell icon indicating copy to clipboard operation
django-admin-shell copied to clipboard

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

Open OmerBhatti opened this issue 1 year ago • 2 comments

Issue

Closes: Allow users to save most used snippets

Changes

  • Added a modal to save code snippets
  • Added a dropdown to select saved snippets
  • Double click any code snippet to save it to db

Screenshots

image

OmerBhatti avatar Apr 26 '24 14:04 OmerBhatti

image

djk2 avatar Oct 02 '24 10:10 djk2

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

djk2 avatar Oct 03 '24 06:10 djk2