Site icon JnPnote

Following Django Tutorial (CRM)-Part8

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. Class based views

2. change functions to class

class LandingPageView(generic.TemplateView):
	template_name = "landing.html"

class LeadListView(generic.ListView):
	template_name = "lead_list.html"
	queryset = Lead.objects.all()
	context_object_name = "leads"

class LeadDetailView(generic.DetailView):
	template_name = "lead_detail.html"
	queryset = Lead.objects.all()
	context_object_name = "lead"

class LeadCreateView(generic.CreateView):
	template_name = "lead_create.html"
	form_class = LeadModelForm

	def  get_success_url(self):
		return reverse("leads:lead-list")

class LeadUpdateView(generic.UpdateView):
	template_name = "lead_update.html"
	queryset = Lead.objects.all()
	form_class = LeadModelForm

	def  get_success_url(self):
		return reverse("leads:lead-list")

class LeadDeleteView(generic.DeleteView):
	template_name = "lead_delete.html"
	queryset = Lead.objects.all()

	def  get_success_url(self):
		return reverse("leads:lead-list")
{% extends "base.html" %}

{% block content %}
	<a href="{% url 'leads:lead-list' %}">Go back to leads</a>
	<hr />
	<h1>Are you sure you want to delete this lead?</h1>
	<form method="post">
		{% csrf_token %}
		{{ form.as_p }}
		<button type="submit">Submit</button>
	</form>
{% endblock content %}

3. Staticfiles

4. apply static files

5. sending emails

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

done for this post

Exit mobile version