0% found this document useful (0 votes)
39 views

Test

This document contains information about setting up a Django project including creating apps, models, templates, urls, authentication, and using git for version control. It discusses initializing a Django project, creating apps, making migrations, setting up the admin interface, working with models and databases, user registration, login/logout, and adding a user profile. It also provides commands for using git to add, commit, push, pull and manage branches when working on a Django project.

Uploaded by

sudam swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Test

This document contains information about setting up a Django project including creating apps, models, templates, urls, authentication, and using git for version control. It discusses initializing a Django project, creating apps, making migrations, setting up the admin interface, working with models and databases, user registration, login/logout, and adding a user profile. It also provides commands for using git to add, commit, push, pull and manage branches when working on a Django project.

Uploaded by

sudam swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

pip install flask-bcrypt

from flask_bcrypt import Bcrypt


bcrypt = Bcrypt()
bcrypt.generate_password_hash('testing').decode('utf-8')
hashed_pass = bcrypt.generate_password_hash('testing').decode('utf-8')
bcrypt.check_password_hash(hashed_pass, 'testing') -->> True
db.create_all()

-----------------------------------------------------------------------------------
-----------------
Django project--Starter
1.django-admin startroject (ProjectName)-->Create Project
2.python manage.py runserver--> for running Server
3.python manage.py startapp (AppName)-->Create App
4.blog(app)-->templates-->blog(sameNameasApp)-->config in Project settings.py to
detect appTemplates
5.blog(app)-->static-->blog(sameNameasApp)-->
6*.template routes uses "url" {% url 'name of urlpattern ' %}tag and name of url/
flask uses {{ url_for(function)}}

---------------------
Django project--Admin
1.python manage.py makemigrations-->detects the chanages user Models
2.python manage.py migrate--> In order to apply changes
3.python manage.py createsuperuser
---------------------
Django project--Database
1.from django.contrib.auth.models import User---> Default User class
2. Django-->User.objects.all()------Flask-->User.query.all()
filter(username='')-----------------filter_by(username='')
3.to Get all Post of a pertiular user django gives the below query:-
--user.post_set.all()
-user -- User.objects.first()--> any User class obj
-modelname_set-- model to be queried
--user.post_set.create()--> Create a new post for the user
4.Dateformating
Django--post.date_posted|date:"F d Y"
Flask--post.date_posted.strftime("%B %d %Y")

---------------------
Django project--User Registration
1.Create users app
2.Add it to project settings
3.Created register views
4.Default form django.contrib.auth.forms import UserCreationForm
5.To get additional data on form need to Create new Form and Inherit
UserCreationForm
6.pip install django-crispy-forms
7.Add crispy_forms to settings.py
-----CRISPY_TEMPLATE_PACK = 'bootstrap4'

---------------------
Django project--Login/Logout
1.LOGIN_REDIRECT_URL = 'blog-home' LOGIN_URL = 'login'
2.from users import views as user_views
3. path('login/',
auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
path('logout/',
auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
---------------------
Django project--UserProfile/Picture
1.Create a Profile Model extended from User
2.OneToOneField(User, ondelete='...')
3.

-----------------------------------------------------------------------------------
-----------------------
git add -A -------------------------------------------------> Add all modified
files to Staging

git branch <branch-name>------------------------------------> Creating a new Branch

git branch--------------------------------------------------> Checking all the


branches

git checkout <branch-name>----------------------------------> Moving from master to


branch

git status--------------------------------------------------> check all files in


staging

git commit -m "adding templates with css"-------------------> Commiting changes to


the branch

git log-----------------------------------------------------> Check the logs for


commits

git pull origin master--------------------------------------> Pull latest source


from git

git push -u origin <branch-name>----------------------------> Push changes to


branch in remote repository

git branch -a-----------------------------------------------> Check branch status

git checkout master

git pull origin master

git branch --merged

git merge templates-01

git push -u origin <branch-name>

%config Completer.use_jedi = False

You might also like