text: import json
  from django.contrib.auth.mixins import LoginRequiredMixin
  from django.contrib import messages
  from django.contrib.messages.views import SuccessMessageMixin
  from django.http import JsonResponse
  from django.urls import reverse_lazy
  from django.views.generic import (
      ListView,
      DetailView,
      CreateView,
      UpdateView,
      DeleteView,
  )
  
  from .models import Entry
  
  
  class LockedView(LoginRequiredMixin):
      login_url = "admin:login"
  
  
  class EntryListView(LockedView, ListView):
      model = Entry
      queryset = Entry.objects.all().order_by("-date_created")
  
  
  class EntryDetailView(LockedView, DetailView):
      model = Entry
  
  
  class EntryCreateView(LockedView, SuccessMessageMixin, CreateView):
      model = Entry
      fields = ["title", "content"]
      success_url = reverse_lazy("entry-list")
      success_message = "Your new entry was created!"
  
  
  class EntryUpdateView(LockedView, SuccessMessageMixin, UpdateView):
      model = Entry
      fields = ["title", "content"]
      success_message = "Your entry was updated!"
  
      def get_success_url(self):
          return reverse_lazy("entry-detail", kwargs={"pk": self.object.pk})
  
  
  class EntryDeleteView(LockedView, SuccessMessageMixin, DeleteView):
      model = Entry
      success_url = reverse_lazy("entry-list")
      success_message = "Your entry was deleted!"
  
      def delete(self, request, *args, **kwargs):
          messages.success(self.request, self.success_message)
          return super().delete(request, *args, **kwargs)
  
  
  
  def view_returns_json(request):
      entry_count = Entry.objects.count()
      data = {
          "entry_count": entry_count
      }
      return JsonResponse(data)
  
  
  def ajax_create_entry(request):
      data = {}
      if request.headers.get("X-Requested-With") == "XMLHttpRequest":
          data_from_post = request.POST['zip']
          print(data_from_post)
          data = {
              'my_data': data_from_post, 
          }
      return JsonResponse(data)