<commit_before>from django.shortcuts import render_to_response
from models import Animal
from django.views.generic import DetailView
from django.http import Http404
from django.db.models import F
from django.template import RequestContext
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from forms import AnimalFilter

def home(request):
    animals_list = Animal.objects.all().order_by("-views")[:5]
    paginator = Paginator(animals_list, 6)
    page = request.GET.get('page')
    try:
        animals = paginator.page(page)
    except PageNotAnInteger:
        animals = paginator.page(1)
    except EmptyPage:
        animals = paginator.page(paginator.num_pages)
    return render_to_response('animalia/home.html', {'popular': animals, 'home_active': 'active'}, RequestContext(request))

def animal_list(request):
    animals = Animal.objects.filter(name__icontains=request.GET.get('name', ''), species__genus__family__name__icontains=request.GET.get('family', ''))
    return render_to_response('animalia/animal_list.html', {'animals': animals, 'catalogue_active': 'active',})

class AnimalDetail(DetailView):
    model = Animal
    template_name = 'animalia/animal_detail.html'
    def get_object(self, queryset=None):
        pk = self.kwargs.get(self.pk_url_kwarg, None)
        try:
            Animal.objects.filter(pk=pk).update(views=F('views')+1)
            return Animal.objects.get(pk=pk)
        except Animal.DoesNotExist:
            raise Http404<commit_msg>added description to search<commit_after>from django.shortcuts import render_to_response
from models import Animal
from django.views.generic import DetailView
from django.http import Http404
from django.db.models import F
from django.template import RequestContext
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from forms import AnimalFilter

def home(request):
    animals_list = Animal.objects.all().order_by("-views")[:5]
    paginator = Paginator(animals_list, 6)
    page = request.GET.get('page')
    try:
        animals = paginator.page(page)
    except PageNotAnInteger:
        animals = paginator.page(1)
    except EmptyPage:
        animals = paginator.page(paginator.num_pages)
    return render_to_response('animalia/home.html', {'popular': animals, 'home_active': 'active'}, RequestContext(request))

def animal_list(request):
    animals = Animal.objects.filter(name__icontains=request.GET.get('name', ''), description__icontains=request.GET.get('name', ''), species__genus__family__name__icontains=request.GET.get('family', ''))
    return render_to_response('animalia/animal_list.html', {'animals': animals, 'catalogue_active': 'active',})

class AnimalDetail(DetailView):
    model = Animal
    template_name = 'animalia/animal_detail.html'
    def get_object(self, queryset=None):
        pk = self.kwargs.get(self.pk_url_kwarg, None)
        try:
            Animal.objects.filter(pk=pk).update(views=F('views')+1)
            return Animal.objects.get(pk=pk)
        except Animal.DoesNotExist:
            raise Http404
{'fraction_non_alphanumeric': 0.11418347430058555, 'fraction_numerical': 0.006506180871828237, 'mean_word_length': 4.452127659574468, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3728148', 'n_tokens_mistral': 938, 'n_tokens_neox': 901, 'n_words': 187}