Skip to main content

Posts

Showing posts from September, 2020

Custom template doesn't show up Password change html in django....

  from django . contrib import admin from django . urls import path , include from django . views . generic . base import TemplateView from django . contrib . auth . views import PasswordResetView , PasswordResetDoneView , PasswordResetConfirmView , PasswordResetCompleteView urlpatterns = [ path ( 'admin/' , admin . site . urls ), #127.0.0.1:8000 path ( '' , include ( 'blog.urls' )), path ( 'accounts/' , include ( 'django.contrib.auth.urls' )), path ( '' , TemplateView . as_view ( template_name = 'home.html' ), name = 'home' ), path ( 'accounts/password/reset/' , PasswordResetView . as_view ( template_name = 'registration/password_reset_form.html' ), name = 'password_reset' ), path ( 'accounts/password/reset/' , PasswordResetDoneView . as_view ( template_name = 'registration/password_reset_done.html' ), name = 'password_...

Deploy django project on heroku

 check heroku ------------------------------------- heroku --version ---------------------------------------- In django project  $ pip3 install gunicorn $ pip install django-heroku $ pip install  python-decouple then, $ touch Procfile  edit this procfile -------------------------------------------------- web: gunicorn sample.wsgi sample means very first project wsgi.py file $ pip freeze > requirements.txt ---------------------------------------------------- import those things in settings.py file  --------------------- import django_heroku import dj_database_url from decouple import config Add middleware ' whitenoise.middleware.WhiteNoiseMiddleware ',  --------------------------------------------------  bottom of settings.py file   STATICFILES_STORAGE = ' whitenoise.storage.CompressedManifestStaticFilesStorage ' ---------------------------- then, django_heroku . settings ( locals ())   push github ------------- login heroku  $he...

Connect POSTgreSQL with Django

  First install all necessary step  $ sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib Second $ sudo su - postgres $ psql Create User name with password  $ CREATE USER user_name WITH PASSWORD ' password ';   Create New Database $ CREATE DATABASE database_name WITH OWNER user_name ; Give permission  $ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user_name ; Update settings.py  DATABASES = { ' default ' : { ' ENGINE ' : ' django.db.backends.postgresql_psycopg2 ' , ' NAME ' : 'database_name ' , ' USER ' : ' user_name ' , ' PASSWORD ' : ' password' , ' HOST ' : ' localhost ' , ' PORT ' : ' 5432 ' , } }  Then, python3 manage.py migrate and finally create super user python3 man age.py createsuperuser

GitHub Push (exact method)

  Open Terminal . Change the current working directory to your local project. Initialize the local directory as a Git repository. $ git init Add the files in your new local repository. This stages them for the first commit. $ git add . # Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE '. Commit the files that you've staged in your local repository. $ git commit -m "First commit" # Commits the tracked changes and prepares them to be pushed to a remote repo   Update Git ------------------ $ git remote add upstream https://github.com/siumhossain/Personal-Blog.git $ git pull upstream master $ git status $ git push origin master 😤 Ignore sensitive information. $touch .gitignore and add file or folder name for ignore those from uploading those file in repo  

Admin-django (customize)

  from django . contrib import admin from . models import Category , Product # Register your models here. class CategoryAdmin ( admin . ModelAdmin ): list_display = [ ' name ' , ' slug ' ] prepopulated_fields = { ' slug ' :( ' name ' ,)} admin . site . register ( Category , CategoryAdmin ) class ProductAdmin ( admin . ModelAdmin ): list_display = [ ' name ' , ' slug ' , ' price ' , ' created ' , ' updated ' ]   #listing list_filter = [ ' created ' , ' updated ' ] list_editable = [ ' price ' ] #editable prepopulated_fields = { ' slug ' :( ' name ' ,)} admin . site . register ( Product , ProductAdmin )