Closed aszubarev closed 5 years ago
Please, check calendar icon on "edit page", like /admin/APP_NAME/MODEL_NAME/ID/change/
:
are they displayed?
Yes, I checked it on user admin page
i compared html on "edit page" and on filter
I could not reproduce the error. The following code probably does not work correctly. You are using custom Admin/Form classes?
I deleted the cache from the browser and it all worked!
What did you do before that? Update django 2.0 -> 2.1? switch venv?
Yes. If you use django == 2.0.9, then everything works stably. When using version 2.1.2, the icon is displayed only if the page is reloaded without a cache. However, with a simple reboot, the icon is not displayed again. All these actions are carried out in the docker container, static files are given Nginx after the "collectstatic" command. If you run a project from IDEA in debug mode, then even with version 2.1.2 everything works stably.
Added class Media. It worked for me. Now, when i just reload the page the icon is always displayed
class ScheduleAdmin(admin.ModelAdmin):
list_filter = [
('reception_start', DateRangeFilter)
]
class Media:
js = DateRangeFilter.get_js()
Error in JS console?
Run with docker:
FROM python:3.6
RUN apt-get update && apt-get install -y \
nginx \
sqlite3 \
gettext \
--no-install-recommends && rm -rf /var/lib/apt/lists/*
COPY etc/nginx-app.conf /etc/nginx/sites-available/default
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
RUN python manage.py collectstatic --noinput
EXPOSE 80
CMD ["sh", "-c", "service nginx start && python manage.py runserver --nostatic"]
server {
listen 80;
server_name host.com;
location / {
try_files $uri $uri/index.html @backend;
root /usr/src/front;
}
location ^~ /static/ {
alias /usr/src/static/;
}
location ^~ /data/ {
alias /usr/src/data/;
}
location @backend {
proxy_pass http://localhost:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
docker build -t foo . && docker run --name="bar" --rm -it -p 9000:80 foo
With cache / out cache - works (((
OK. I think the problem is somewhere in my code. but it is very strange. I solved this problem by adding the Media class and I like this solution. I suggest to close the issue
Here the reason why we refused this solution.
Thank. I will not close the issue, because the problem is serious, but need more information
@ZubAnt please,
$(".datetimeshortcuts").remove();
DateTimeShortcuts.init();
If possible, paste the following code into 105-106 lines
i am install from here https://github.com/ZubAnt/django-admin-rangefilter/commit/99a46070ed5e9b333353d55af55f7955c77add7c
Uncaught TypeError: $ is not a function
at HTMLDocument.<anonymous> ((index):277)
at l (jquery.min.js:2)
at c (jquery.min.js:2)
Ok, big thx!
Oh, i know is code not best, this can help.
Replace block here to:
django.jQuery('document').ready(function () {
if (!('DateTimeShortcuts' in window)) {
django.jQuery.when(
{% for m in spec.form.js %}
django.jQuery.getScript('{{m}}'),
{% endfor %}
django.jQuery.Deferred(function( deferred ){
django.jQuery( deferred.resolve );
})
).done(function(){
django.jQuery('.datetimeshortcuts').remove();
DateTimeShortcuts.init();
});
}
});
If you encounter the same problem please comment here
is not resolved.
Django 2.1.4
django-admin-rangefilter 0.3.10
calendar.js
DateTimeShortcuts.js
is not loaded.
Try ignore DJANGO_RANGEFILTER_ADMIN_JS_SET
always get_js()
https://github.com/silentsokolov/django-admin-rangefilter/blob/master/rangefilter/filter.py#L110
class DatetimeRangeFilter(DateTimeRangeFilter):
def get_form(self, request):
form_class = super().get_form(request)
form_class.js = super().get_js()
return form_class
Now it worked for me.
Please, show admin.py
. You use default admin.ModelAdmin
without overrides?
I overrides change_list
method in admin.ModelAdmin
Now without overrides is worked.
Hi,
I have the same problem with the overriding change_list template.
If I override change_list template date range component stop working and here is the error from console:
try reimport jQuery.js
Did not work. Here is my template:
{% extends "admin/change_list.html" %}
{% load staticfiles %}
{% block extrahead %}
<script src="https://code.highcharts.com/highcharts.src.js"></script>
<script>
window.onload = function () {
console.log("[+] Window onLoad!")
Highcharts.chart("chart", {{chart|safe}});
}
</script>
{% endblock %}
{% block content %}
{{ block.super }}
{% endblock %}
jQuery
!= django.query
, try import init.js
Tried to load jquery and jquery.ini like:
{% block extrahead %}
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
<script src="https://code.highcharts.com/highcharts.src.js"></script>
<script>
window.onload = function () {
console.log("[+] Window onLoad!")
Highcharts.chart("chart", {{chart|safe}});
}
</script>
{% endblock %}
Now getting this error:
Django==2.2.12 django-admin-rangefilter==0.6.1
admin.py:
from rangefilter.filter import DateRangeFilter, DateTimeRangeFilter
from .models import Event
@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
list_filter = (
('date', DateRangeFilter), ('date', DateTimeRangeFilter),
)
@VictorIsra Hello, Grapelli != Django. We dont support it.
Hello! oh, too bad. Do you have any perspective of adding Grapelli support? this project is pretty similar and works on Grapelli, but it has an unusual alphabet:
Hello! oh, too bad. Do you have any perspective of adding Grapelli support?
I dont think so. ...
PR welcome!
calendar icon is not displayed in admin panel for DateRangeFilter and DateTimeRangeFilter
django==2.1.2 django-admin-rangefilter==0.3.8