Django- User Profile Management Django by Ravinder Nath Rajotiya - January 13, 2022January 20, 20220 User Profile Management In the previous tutorial Django-User Login and Logout users able to login and logout. There was no user profile when they login. We need to have a user profile. Default Django view model does not have a feature to add user profile picture, We can do it by extending the user model to add more fields, In this tutorial we’ll learn how to use Django signals to run specific functions after certain actions which can be extremely useful for this type of work. We will extend user profile and create a profile model that will have a one-to-one relationship with the user. One-to-one relationship means that one user can have one profile and one profile will be associated with
Django-User Login and Logout Django by Ravinder Nath Rajotiya - January 11, 2022January 15, 20220 User Login and Logout: In this tutorial we are going to see how to create the authentication system for our Django applications so that the users can login, logout. Also the users need to be logged in, in order to access certain pages. The registration page created in the Django- Admin and Users registration post was used only by admin, but the users were not able to login. So, we have to create a login page for the frontend where users will be able to register, login or logout. Django has lot of functionality taking care for us at the backend. So, we get started with using the default LoginView If you want the users to login and have access to certain
Django- Admin and Users registration Django by Ravinder Nath Rajotiya - January 9, 2022January 10, 20220 Introduction Well, one of the important part of dynamic sites is to create users so that one can have access to the database to enter data, to delete , edit or update the data, to authorize users to have an access to certain data set. Django provide an admin page by default. This can be accessed just by typing admin after the url i.e. localhost:8000/admin and you will see a page as seen below: But you can't do anything here right now. We have to first create super admin who will be responsible for the overall management and users with the roles to have access to certain pages or data. Let us first create a superuser from the command-line. Creating super user Well, If you
Dynamic Links in Django Django by Ravinder Nath Rajotiya - January 5, 2022January 6, 20220 Introduction Let us take an example of the blog post entries on a web page. If there are lot many blog posts, it would become very difficult to scroll up and down to read a post. Instead, it would be much better and aneasier way of accessing the post we could for examle pass the blog id in url e.g. localserver:8000/1 or localserver:8000/4 etc. This will directly take you to bolog id ‘1’ or blog id ‘4’. This is also the case with twitter or facebook etc when people say follow me @name. Since there are huge number f users and username were displayed on the page to select from, it would not be possible for us to querry/serch and access the
blogApp – Forms and database connection Django by Ravinder Nath Rajotiya - January 5, 2022January 5, 20220 blogApp - Forms and database connection In this post we are going to see how to connect forms with database in Django. We explain step by step method. Refer to previous post Simple blogApp in Django This post is extension of Simple blogApp in Django. The following files are created/updated Step-1: Create forms.py and define the fields for table from django import forms from .models import blogPostDb class blogposts(forms.ModelForm): class Meta: model = blogPostDb fields = ['title', 'author', 'contents'] Step-2: Modify the views.py from django.shortcuts import render, redirect from .models import blogPostDb from .forms import blogposts from django.contrib import messages # Create your views here. def home(request): if request.method == 'POST': form = blogposts(request.POST or None) if form.is_valid(): form.save() all_posts=blogPostDb.objects.all() messages.success(request,('Post added.....')) return render(request, 'blog/index.html', {'all_posts': all_posts}) else: all_posts=blogPostDb.objects.all() return render(request, 'blog/index.html', {'all_posts': all_posts}) Step-3: Now modify the home page (index.html) <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> </head> <body> <h1>Welcome home</h1> {% for