<filename>boards/views.py
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.models import User
from boards.forms import NewTopicForm
from boards.models import Board, Topic, Post

def home(request):
	context = {}
	boards = Board.objects.all()
	context["boards"] = boards
	return render(request, 'home.html', context)

def board_topics(request, pk):
	board = get_object_or_404(Board, pk=pk)
	return render(request, 'topics.html', {'board':board})

def new_topic(request, pk):
	board = get_object_or_404(Board, pk=pk)
	user = User.objects.first()
	if request.method == "POST":
		form = NewTopicForm(request.POST)
		if form.is_valid():
			topic = form.save(commit=False)
			topic.board = board
			topic.starter = user
			topic.save()
			post = Post.objects.create(
				message=form.cleaned_data.get('message'),
				topic=topic,
				created_by=user
			)
			return redirect('board_topics', pk=board.pk)
	else:
		form = NewTopicForm()
	return render(request, 'new_topic.html', {'board':board, 'form':form})	
<filename>boards/views.py
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.models import User
from boards.forms import NewTopicForm
from boards.models import Board, Topic, Post

def home(request):
	context = {}
	boards = Board.objects.all()
	context["boards"] = boards
	return render(request, 'home.html', context)

def board_topics(request, pk):
	board = get_object_or_404(Board, pk=pk)
	return render(request, 'topics.html', {'board':board})

def new_topic(request, pk):
	board = get_object_or_404(Board, pk=pk)
	user = User.objects.first()
	if request.method == "POST":
		form = NewTopicForm(request.POST)
		if form.is_valid():
			topic = form.save(commit=False)
			topic.board = board
			topic.starter = user
			topic.save()
			post = Post.objects.create(
				message=form.cleaned_data.get('message'),
				topic=topic,
				created_by=user
			)
			return redirect('board_topics', pk=board.pk)
	else:
		form = NewTopicForm()
	return render(request, 'new_topic.html', {'board':board, 'form':form})	