<commit_before>from django.shortcuts import render

# Create your views here.
from tasks.models import Task, TaskForm 
from django.views.generic import ListView, DetailView

class PostsListView(ListView):
    model = Task              

class PostDetailView(DetailView):
    model = Task

def task_new(request):
        form = TaskForm()
        return render(request, 'tasks/task_new.html', {'form': form})

<commit_msg>Update views.py<commit_after>from django.shortcuts import render

# Create your views here.
from tasks.models import Task, TaskForm 
from django.views.generic import ListView, DetailView

class PostsListView(ListView):
    model = Task              

class PostDetailView(DetailView):
    model = Task

def task_new(request):
        form = TaskForm()
        return render(request, 'tasks/task_new.html', {'form': form})

def task_new(request):
        if request.method == "POST":
            form = TaskForm(request.POST)
            if form.is_valid():
                post = form.save(commit=False)
                post.author = request.user
                post.published_date = timezone.now()
                post.save()
                return redirect('tasks.views.task_detail', pk=post.pk)
        else:
            form = TaskForm()
        return render(request,  'tasks/task_new.html', {'form': form})

{'fraction_non_alphanumeric': 0.10187265917602996, 'fraction_numerical': 0.0, 'mean_word_length': 2.601078167115903, 'pattern_counts': {'":': 1, '<': 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': '3775041', 'n_tokens_mistral': 380, 'n_tokens_neox': 366, 'n_words': 98}