class CustomClearableFileInput(ClearableFileInput):
***
template_name = 'clearable_file_input.html'
{% if widget.is_initial %}
<span>{{ widget.initial_text }}</span>: <a href="{{ widget.value.url }}">{{ widget.value }}</a>
{% if not widget.required %}
<input type="checkbox" name="{{ widget.checkbox_name }}" id="{{ widget.checkbox_id }}"/>
<label for="{{ widget.checkbox_id }}">{{ widget.clear_checkbox_label }}</label>
{% endif %}
<br/>
<span>{{ widget.input_text }}</span>:
{% endif %}
<input type="{{ widget.type }}" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}/>
Traceback (most recent call last):
File "/srv/envs/Project/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/srv/envs/Project/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/srv/envs/Project/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/srv/envs/Project/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/srv/envs/Project/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "/home/nurzhan/CA/article/views.py", line 106, in get
request=request
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/loader.py", line 68, in render_to_string
return template.render(context, request)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/backends/django.py", line 68, in render
reraise(exc, self.backend)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/backends/django.py", line 89, in reraise
six.reraise(exc.__class__, new, sys.exc_info()[2])
File "/srv/envs/Project/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/backends/django.py", line 66, in render
return self.template.render(context)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/base.py", line 207, in render
return self._render(context)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/base.py", line 993, in render
bits.append(force_text(bit))
File "/srv/envs/Project/lib/python3.6/site-packages/django/utils/encoding.py", line 76, in force_text
s = six.text_type(s)
File "/srv/envs/Project/lib/python3.6/site-packages/django/utils/html.py", line 385, in <lambda>
klass.__str__ = lambda self: mark_safe(klass_str(self))
File "/srv/envs/Project/lib/python3.6/site-packages/django/forms/boundfield.py", line 41, in __str__
return self.as_widget()
File "/srv/envs/Project/lib/python3.6/site-packages/django/forms/boundfield.py", line 120, in as_widget
**kwargs
File "/srv/envs/Project/lib/python3.6/site-packages/django/forms/widgets.py", line 221, in render
return self._render(self.template_name, context, renderer)
File "/srv/envs/Project/lib/python3.6/site-packages/django/forms/widgets.py", line 226, in _render
return mark_safe(renderer.render(template_name, context))
File "/srv/envs/Project/lib/python3.6/site-packages/django/forms/renderers.py", line 31, in render
template = self.get_template(template_name)
File "/srv/envs/Project/lib/python3.6/site-packages/django/forms/renderers.py", line 37, in get_template
return self.engine.get_template(template_name)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/backends/django.py", line 41, in get_template
reraise(exc, self)
File "/srv/envs/Project/lib/python3.6/site-packages/django/template/backends/django.py", line 89, in reraise
six.reraise(exc.__class__, new, sys.exc_info()[2])
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/template/backends/django.py", line 39, in get_template
return Template(self.engine.get_template(template_name), self)
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/template/engine.py", line 162, in get_template
template, origin = self.find_template(template_name)
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/template/engine.py", line 148, in find_template
raise TemplateDoesNotExist(name, tried=tried)
django.template.exceptions.TemplateDoesNotExist: clearable_file_input.html
[24/Aug/2017 11:02:30] "GET /administration/article/47/edit/ HTTP/1.1" 500 25476
url(r'^book/(?P<pk>\d+)/sorting/$',
BookSortingView.as_view(),
name='book_sorting')
$("#books").sortable({
update: function(event, ui) {
var information = $('#books').sortable('serialize');
$.ajax({
url: "???",
type: "post",
data: information
});
},
}).disableSelection();
class BookSortingView(View):
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(BookSortingView, self).dispatch(request, *args, **kwargs)
def post(self, request, pk, *args, **kwargs):
for index, pk in enumerate(request.POST.getlist('book[]')):
book = get_object_or_404(Book, pk=pk)
book.position = index
book.save()
return HttpResponse()
class BookDeleteView(View):
def post(self, request, pk, *args, **kwargs):
data = dict()
book = Book.objects.get(pk=pk)
book.delete()
data['form_is_valid'] = True
context = {
'books': Book.objects.all()
}
data['html_books'] = render_to_string(
'books.html',
context
)
return JsonResponse(data)
def get(self, request, pk, *args, **kwargs):
data = dict()
book = Book.objects.get(pk=pk)
context = {
'book': book
}
data['html_book_delete_form'] = render_to_string(
'delete_book.html',
context,
request=request,
)
return JsonResponse(data)
class BookDeleteView(DeleteView):
model = Book
slug_field = 'pk'
success_url = reverse_lazy('book_list')
{% for book in books %}
<a id="bookDeleteBtn-{{ forloop.counter }}" class="btn btn-primary">Удалить</a>
<div id="bookDeleteModalBox-{{ forloop.counter }}" class="modal fade">
Содержимое модального окна
</div>
{% endfor %}
$("#bookDeleteBtn-???").click(function () {
$.ajax({
beforeSend: function () {
$("#bookDeleteModalBox-???").modal("show");
},
});
});
if book_create_form.is_valid():
new_book = book_create_form.save(commit=False)
new_book.save()
data['html_book_create_form'] = render_to_string('create_book.html', context)
data['html_book_create_form'] = render_to_string('create_book.html', context, request=request)
$(function () {
$("#bookCreateBtn").click(function () {
$.ajax({
beforeSend: function () {
$("#bookCreateModalBox").modal("show");
},
});
});
});
Traceback (most recent call last):
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/srv/envs/kaseAdmPy362/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File ".../views.py", line 26, in post
request
TypeError: unhashable type: 'dict'
url(r'^book/create/$', BookCreateView.as_view(), name='book_create'),
class BookCreateView(View):
def post(self, request):
data = dict()
book_create_form = BookCreateForm(request.POST)
if book_create_form.is_valid():
book_create_form.save()
data['form_is_valid'] = True
books= Book.objects.all()
data['html_books'] = render_to_string('books.html', {
'books': books
})
else:
data['form_is_valid'] = False
context = {'books': books}
data['html_create_book_form'] = render_to_string('create_book.html', {
context,
request
})
return JsonResponse(data)
def get(self, request):
data = dict()
book_create_form = BookCreateForm()
context = {'book_create_form': book_create_form}
data['html_create_book_form'] = render_to_string('create_book.html', {
context,
request
})
return JsonResponse(data)
<div id="books">
{% include 'books.html' %}
</div>
<a id="bookCreateBtn" href="#bookCreateModalBox" class="btn btn-primary" data-toggle="modal">Добавить новую книгу</a>
<div id="bookCreateModalBox" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="{% url 'book_create' %}" class='bookCreateForm'>
{% csrf_token %}
<div class="modal-body">
{{ create_book_form }}
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Создать</button>
</div>
</form>
</div>
</div>
</div>
$(document).ready(function(){
$("#bookCreateBtn").click(function() {
$("#bookCreateModalBox").modal('show');
});
});
$("#bookCreateModalBox").on("submit", "#bookCreateForm", function () {
var form = $(this);
$.ajax({
url: form.attr("action"),
data: form.serialize(),
type: form.attr("method"),
dataType: 'json',
success: function (data) {
if (data.form_is_valid) {
$("#books").html(data.html_books);
}
else {
$("#bookCreateModalBox .modal-body").html(data.html_create_book_form);
}
}
});
return false;
});
urlpatterns = [
url(r'^admin/$', login_required(DashboardView.as_view(), login_url='/admin/login/')),
]
httpd.exe: Syntax error on line 171 of C:/Program Files/Apache2.4/conf/httpd.conf: Cannot load C:/Program Files/Apache2.4/modules/mod_wsgi.so into server: \xcd\xe5 \xed\xe0\xe9\xe4\xe5\xed \xf3\xea\xe0\xe7\xe0\xed\xed\xfb\xe9 \xec\xee\xe4\xf3\xeb\xfc.
.LoadModule wsgi_module modules/mod_wsgi.so
. Как раз после добавления этой записи, Apache перестал запускаться. mog_wsgi скачивал из этого сайта www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
settings.py:
forms.py:
ERROR: