Django Note Taking App With Source Code
The Django Note Taking App is developed using Python Django, HTML,CSS and JavaScript, This Django Notes A simple web application created with Django, a Python-based web framework, for taking notes.
A Django Notes App users should be able to see or modify other users’ posts (in case this application gets deployed on a web server), this Django Note app can be easily converted between a blog and a note-taking app.
This Note App In Django also includes a downloadable Project With Source Code for free, just find the downloadable source code below and click to start downloading.
Watch the video here to see the full running Django Note Taking App with source code
To start creating a Django Note Taking App, makes sure that you have PyCharm Professional IDE or any platform of django and its requirements Installed in your computer.
Reminders
To perform this python django project make sure that you have knowledge in the following:
- CSS
- HTML
- Javascript
- Database Management
Features Of This Django Note Taking App
- Create Note
- Read Note
- Update Note
- Delete Note
- User Login/Logout
- User Registration
In This Django Note Taking App Consist Of The Following Method:
- django_project – In this method Which is the main method of the app.
- blog – In this method which is the main feature of the app.
- media – In this method which you can found all the media that being upload in this app.
- users – In this method which is the users that manage the app.
Steps on how to create a Django Note Taking App With Source Code
Django Note Taking App With Source Code
- Step 1: Open file.
First , open “pycharm professional” after that click “file” and click “new project“.
- Step 2: Choose Django.
Second, after click “new project“, choose “Django” and click.
- Step 3: Select file location.
Third, select a file location wherever you want.
- Step 4: Create application name.
Fourth, name your application.
- Step 5: Click create.
Fifth, finish creating project by clicking “create” button.
- Step 6: Start of coding.
you are free to copy the following codes below in the given modules and method required.
The List Of Module Given Below Are Under The “Blog” Method
- The Code Given Below Is For The “views.py” Module – you can add the following code below into your “views.py” under the “Blog” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
from django.shortcuts import render from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.contrib.auth.models import User from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView from .models import Post from django.http import HttpResponseRedirect from django.urls import reverse from django.views import generic from .forms import CreateViewForm, UpdateViewForm # enabling case-insensitive search in MySQL databases from django.db.models import Q, TextField from django.db.models.functions import Lower TextField.register_lookup(Lower, "lower") # if users are allowed to view anyone's posts, not only theirs, then leave this and the next class uncommented class PostListView(LoginRequiredMixin, ListView): model = Post template_name = 'blog/home.html' context_object_name = 'posts' # the name of a context variable with the queryset results ordering = ['-date_posted'] paginate_by = 20 # modifying the function for returning posts def get_queryset(self): # if there is a search query in the URL parameter, then use it to filter the results search_query = self.request.GET.get('search', '') # using Q for case-insensitive search in a MySQL database queryset = Post.objects.filter(Q(content__lower__contains=search_query)).order_by('-date_posted') return queryset class PostDetailView(LoginRequiredMixin, DetailView): model = Post # if users are allowed to view only their own posts, not anyone else's, then leave this and the next class uncommented # class PostListView(LoginRequiredMixin, ListView): # model = Post # template_name = 'blog/home.html' # context_object_name = 'posts' # the name of a context variable with the queryset results # ordering = ['-date_posted'] # paginate_by = 20 # # # modifying the function for returning posts # def get_queryset(self): # # if there is a search query in the URL parameter, then use it to filter the results # search_query = self.request.GET.get('search', '') # # using Q for case-insensitive search in a MySQL database # # filtering for posts where the user is the author # queryset = Post.objects.filter(Q(content__lower__contains=search_query)).filter(author_id=self.request.user.id).order_by('-date_posted') # return queryset # # class PostDetailView(LoginRequiredMixin, UserPassesTestMixin, DetailView): # model = Post # # def test_func(self): # post = self.get_object() # if self.request.user == post.author: # return True # return False class PostCreateView(LoginRequiredMixin, CreateView): model = Post form_class = CreateViewForm # making the class use an existing form with pre-defined validation rules template_name = 'blog/post_create.html' success_url = '/' def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) # if users are allowed to update or delete anyone's posts, not only theirs, then leave this and the next class uncommented class PostUpdateView(LoginRequiredMixin, UpdateView): model = Post template_name = 'blog/post_update.html' form_class = UpdateViewForm def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) class PostDeleteView(LoginRequiredMixin, DeleteView): model = Post success_url = '/' template_name = 'blog/post_delete.html' # if users are allowed to update or delete only their own posts, then leave this and the next class uncommented # class PostUpdateView(LoginRequiredMixin, UserPassesTestMixin, UpdateView): # model = Post # template_name = 'blog/post_update.html' # form_class = UpdateViewForm # # def form_valid(self, form): # form.instance.author = self.request.user # return super().form_valid(form) # # def test_func(self): # post = self.get_object() # if self.request.user == post.author: # return True # return False # # # class PostDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView): # model = Post # success_url = '/' # template_name = 'blog/post_delete.html' # # def test_func(self): # post = self.get_object() # if self.request.user == post.author: # return True # return False # defining actions when the CSRF error occurs # the reason parameter here is optional and will only be displayed in logs def csrf_failure(request, reason=""): current_page = request.path # iterating through all the pages that contain forms where the user can potentially encounter the CSRF error # and calling respective functions again try: if '/post/new' in current_page: return PostCreateView.as_view()(request) elif '/update' in current_page: return PostUpdateView.as_view()(request) elif '/delete' in current_page: return PostDeleteView.as_view()(request) # redirect to the homepage in any other case, e.g. after login else: return HttpResponseRedirect('/') # if there was any error in calling the respective function, then redirect to the homepage except: return HttpResponseRedirect('/') |
In this module which is the index module of the Blog method.
- The Code Given Below Is For The “urls.py” Module – you can add the following code below into your “urls.py” under the “Blog” method.
1 2 3 4 5 6 7 8 9 10 11 12 |
from django.urls import path from .views import PostListView, PostDetailView, PostCreateView, PostUpdateView, PostDeleteView from . import views urlpatterns = [ path('', PostListView.as_view(), name='blog-home'), path('post/<int:pk>/', PostDetailView.as_view(), name='post-detail'), path('post/new/', PostCreateView.as_view(), name='post-create'), path('post/<int:pk>/update/', PostUpdateView.as_view(), name='post-update'), path('post/<int:pk>/delete/', PostDeleteView.as_view(), name='post-delete'), ] |
In this module which is the URL configuration module under Blog method.
- The Code Given Below Is For The “models.py” Module – you can add the following code below into your “models.py” under the “Blog” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
from django.db import models from django.utils import timezone from django.contrib.auth.models import User from django.urls import reverse from PIL import Image # defining a database table for posts class Post(models.Model): title = models.CharField(max_length=100) content = models.TextField() date_posted = models.DateTimeField(default=timezone.now) # recording the timestamp when a new entry is created author = models.ForeignKey(User, on_delete=models.CASCADE) # ForeignKey defines a "many-to-one relationship" image = models.ImageField(default='',upload_to='images',blank=True,null=True) audio = models.FileField(default='',upload_to='audio',blank=True,null=True) def __str__(self): return self.title # defining a URL for a new entry def get_absolute_url(self): return reverse('post-detail', kwargs={'pk': self.pk}) # model names should be singular, for example, Post, because they represent a single object # fields should be written in lowercase and with underscores # The __str__ method defines a human-readable representation of the model in the Django admin site # CASCADE defines that when a user is deleted, all his/her entries are deleted as well |
In this module which you can found classes to be call under Blog method.
The List Of Module Given Below Are Under The “Users” Method
- The Code Given Below Is For The “views.py” Module – you can add the following code below into your “views.py” under the “Users” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
from django.shortcuts import render from .forms import UserRegisterForm from django.contrib.auth import authenticate, login, logout from django.contrib.auth.views import LoginView from django.http import HttpResponseRedirect def register(request): # if it is a POST request (a registration form is being submitted) if request.method == 'POST': form = UserRegisterForm(request.POST) # if it passes validation: if form.is_valid(): form.save() # automatically authenticate the new user after registration new_user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password1'], ) login(request, new_user) # redirect to the homepage with a success message return HttpResponseRedirect('/?account=success') # if it is a GET request (a registration form is just being loaded) else: form = UserRegisterForm() # if it is a GET request or the form doesn't pass validation, then return the registration form page return render(request, 'users/register.html', {'form': form}) # adding more context to the default 'LoginView' class-based view class LoginLogout(LoginView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context.update({ 'message': 'You have logged out!', 'tag': 'success' }) return context # adding a custom logout function def logout_view(request): # logging the user out logout(request) # calling the 'LoginLogout' that has updated context for the 'LoginView' return LoginLogout.as_view(template_name='users/login.html')(request) |
In this module which is the index module of the Users method.
I have here the list of Best Python Project with Source code free to download for free, I hope this can help you a lot.
Run Quick Virus Scan for secure Download
Run Quick Scan for secure DownloadDownloadable Source Code Below.
Anyway, if you want to level up your programming knowledge, especially python, try this new article I’ve made for you Best Python Projects with source code for Beginners. But If you’re going to focus on web development using Django, you can download here from our list of Best Django Projects with source code based on real-world projects.
How To Run The Django Note Taking App?
Step 1: Extract/unzip the file
Step 2: Go inside the project folder, open cmd and type the following commands to install Django Framework and run the webserver:
1.) pip install -r requirements.txt
2.) python manage.py runserver
Step 3: Finally, open the browser and go to localhost:8000

Summary
The system is built fully in Django Framework in back-end and HTML, CSS in front-end. It has full-featured user interface with all the functionalities
This Article is the way to enhance and develop our skills and logic ideas which is important in practicing the python programming language which is most well known and most usable programming language in many company.
Related article below
- How To Make A Point Of Sale System In Python
- Best Python Projects for Beginners
- Python MySQL Connection: Simple Python Step by Step Guide
- Python PIP Command Set-up / Fix: Step by Step Guide
- Random Password Generator in Python Projects With Source Code 2020
- Python Range Function|Range in Python Explained with Examples 2020
Inquiries
If you have any questions or suggestions about Django Note Taking App, please feel free to leave a comment below.