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

ace.js and markdown.js errors with django.contrib.staticfiles.storage.ManifestStaticFilesStorage #197

Closed
sodrew opened this issue Feb 2, 2023 · 2 comments

Comments

@sodrew
Copy link

sodrew commented Feb 2, 2023

This was mentioned in #55, but without real instructions to reproduce.

Details

OS (Operating System) version: Windows 11
Browser and browser version: MS Edge 108.0.1462.76 (Official build) (64-bit)
Django version: 3.2.16 (my webhost won't upgrade to 4.x)
Martor version & theme: 1.6.16

Steps to reproduce (some of this is really nitty gritty, but wanted to be clear how barebones this was)

  1. Start with a fresh install of django 3.2.16
virtualenv martortest -p python3
. martortest/bin/activate
pip install Django==3.2.16 martor==1.6.16
cd martortest
django-admin startproject settings
cd settings
./manage.py startapp testapp
mkdir -p testapp/templates
  1. replace the testapp/models.py file:
from django.db import models
from martor.models import MartorField

class MyModel(models.Model):
    brief = MartorField(null=True, blank=True)

  1. replace the testapp/views.py file:
from django.shortcuts import render
from django.forms import ModelForm, Textarea, DateInput

from .models import *

class MyModelForm(ModelForm):

    class Meta:
        model = MyModel
        fields = '__all__'

def test_edit(request):
    form = MyModelForm(request.POST or None,
                       instance=None)

    return render(request, 'template.html', {
        'form': form,
    })

  1. create the testapp/templates/template.html file:
{{ form.media }}

<form action="{% url 'test_edit' %}" method="post">
    {% csrf_token %}
    {{ form.as_p }}
</form>

  1. create the testapp/urls.py file:
from django.contrib import admin
from django.urls import path, include, re_path

from .views import *

urlpatterns = [
    path('', test_edit, name='test_edit'),
]

  1. update the settings/urls.py file
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.views.static import serve

urlpatterns = [
    path('admin/', admin.site.urls),
    path('martor/', include('martor.urls')),
    path('test/', include('testapp.urls')),
    # line below needed so that static files will be served without an external web server when DEBUG is set to false
    re_path(r'^static/(?P<path>.*)$', serve, {
        'document_root': settings.STATIC_ROOT,
        'show_indexes': True,
    }),
]

  1. Set these variables settings/settings.py:
DEBUG=False
ALLOWED_HOSTS = ['localhost']
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATIC_ROOT = 'static'
INSTALLED_APPS += [
    'martor',
    'testapp',
]

  1. run:
./manage.py createsuperuser
./manage.py makemigrations
./manage.py migrate
./manage.py collectstatic
./manage.py runserver
  1. navigate to http://localhost:8000/test/ and view these errors:
  1. View the dom. Instead of seeing:

<script src="http://localhost:8000/static/plugins/js/snippets/markdown.js"></script></head><body>

you see:

<script src="snippets/markdown.js"></script></head><body>

  1. If you comment this line from settings/settings.py, everying loads as expected:
# STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
agusmakmun pushed a commit that referenced this issue Mar 16, 2023
@agusmakmun
Copy link
Owner

Hello @sodrew, thank you for reporting this issue. We have tried to solve this issue by updating the ace & related packages version. And I have tried using your steps to reproduce the issue, and seems now working as expected.

Home Admin
Screen Shot 2023-03-16 at 08 22 12 Screen Shot 2023-03-16 at 08 22 55

Please upgrade your martor version to resolve this issue, and let us know if you still facing this issue.

pip install martor --upgrade

@sodrew
Copy link
Author

sodrew commented Mar 20, 2023

Many thanks @agusmakmun. Also validated on my end.

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

No branches or pull requests

2 participants