Quera Final Project
- Start commit with [add] ,[modify], [fix]
- Comment
- Description (Optional)
[Add] Comment
Description
- main → for ci/cd
- hotfix -- for fix bug in main branch
- release → for release tag
- develop → second main branch, all below branch merge from this branch
- feature → for each feature
- feature/feature_name
- feature/feautre_name2
- bugfix → for each bug in develop branch
- bugfix/bug_name
- bugfix/bug_name2
- Start new branch, then Sync branch with
develop
branch - Commit and push code every day
- When finishing the task and pushed to origin then
pull request
todevelop
branch - Review
pull request
merge todevelop
branch If Task finished and~develop~
branch not sync, then merge~develop~
into the in progress, and fix the conflict.
from django.contrib.auth.models import AbstractUser, Aliuser, FUser
--->
from django.contrib.auth import models as user_models
class User(user_models.AbstractUser)
from package_name import forms as package_name_forms
from package_name import models as package_name_models
from package_name import views as package_name_views
from package_name import serializers as package_name_serializers
- add urls to each app and include urls
project file
package_name/urls.py
urlpatterns = [
path(....,view,name=...),
path(....,view,name=...),
]
project_name/urls.py
urlpatterns = [
path(....,include,name=...),
path(....,include,name=...),
]
ObjectManager
- all queries in object manager
class QuestionManager(models.Manager):
def get_x_by_y(self, user):
return self.filter(user=user)
class Question(models.Model):
varibales
objects = QuestionManager()
@propery
other functions
ForeignKey
OneToOneField
models.ForeignKey('package_name.model',)
models.OneToOneField('package.model',)
on_delete=models.PROTECT
verbose_name
: createvaraible_name.py
file
# User
USERNAME = 'نام کاربری'
FIRST_NAME = 'نام'
LAST_NAME = 'نام خانوادگی'
# Answer field
ANSWER_USER = 'کاربر ایجاد کننده'
UPVOTERS = 'نظر مثبت'
- Each class, function → doc string
class Answer(models.Model):
"""
توضیح برای کلاس
"""