<commit_before>from django.views.generic.list_detail import object_list, object_detail
from django.shortcuts import render_to_response

from djobs.models import Job, JobCategory, Employer
import datetime

def category_jobs(request, slug):
    category = JobCategory.objects.get(slug=slug)
    jobs = Job.active.filter(category=category)
    
    return object_list(request, 
        queryset=jobs, 
        allow_empty=True, 
        template_name='djobs/category_jobs.html', 
        extra_context={'category': category}
    )
    
def employer_jobs(request, id):
    employer = Employer.objects.get(pk=1)
    jobs = Job.active.filter(employer=employer)
    
    return object_list(request, 
        queryset=jobs, 
        allow_empty=True, 
        template_name='djobs/employer_jobs.html', 
        extra_context={'employer': employer}
    )
    
def job_detail(request, id):
    jobs = Job.active.all()
    
    return object_detail(request, 
        queryset=jobs, 
        object_id=id, 
        template_name='djobs/job_detail.html')<commit_msg>views return 404 when object not found<commit_after>from django.views.generic.list_detail import object_list, object_detail
from django.shortcuts import render_to_response, get_object_or_404

from djobs.models import Job, JobCategory, Employer
import datetime

def category_jobs(request, slug):
    category = get_object_or_404(JobCategory, slug=slug)
    jobs = Job.active.filter(category=category)
    
    return object_list(request, 
        queryset=jobs, 
        allow_empty=True, 
        template_name='djobs/category_jobs.html', 
        extra_context={'category': category}
    )
    
def employer_jobs(request, id):
    employer = get_object_or_404(Employer, pk=id)
    jobs = Job.active.filter(employer=employer)
    
    return object_list(request, 
        queryset=jobs, 
        allow_empty=True, 
        template_name='djobs/employer_jobs.html', 
        extra_context={'employer': employer}
    )
    
def job_detail(request, id):
    jobs = Job.active.all()
    
    return object_detail(request, 
        queryset=jobs, 
        object_id=id, 
        template_name='djobs/job_detail.html')
{'fraction_non_alphanumeric': 0.09376443418013856, 'fraction_numerical': 0.006004618937644342, 'mean_word_length': 3.314741035856574, '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': '2430916', 'n_tokens_mistral': 718, 'n_tokens_neox': 656, 'n_words': 118}