Site icon JnPnote

Following Django Tutorial (CRM)-Part9

This post is for myself to remember how to build Django project.
I did follow the tutorial from the JustDjango Learn website free tutorial.
And this is the fourth tutorial named Getting Started With Django.
I am not going over all the details and descriptions for each part. There are good explanations on video of the JustDjango Learn. So, visit their site and try their tutorials if you need more details. Also, the orders of this post and their video might be different because I put things first what I think should come first.

I am doing this on Windows 10 with just Windows PowerShell. Not using virtual machines at all.

1. built-in authentication source code provided by django

2. create login

{% extends 'base.html' %}

{% block content %}

<form method="post">
	{% csrf_token %}
	{{ form.as_p }}
	<button type="submit">Login</button>
</form>

{% endblock content %}
LOGIN_REDIRECT_URL = "/leads"

3. create logout

4. Create Signup

class SignupView(generic.CreateView):
	template_name = "registration/signup.html"
	form_class = UserCreationForm

	def get_success_url(self):
		return reverse("login")

5. tests

from django.test import TestCase
from django.shortcuts import reverse

# Create your tests here.

class LandingPageTest(TestCase):

	def test_get(self):
		response = self.client.get(reverse("landing-page"))
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, "landing.html")

done for this post

Exit mobile version