Python
-
-
-
[Django] string 혹은 bytes 를 content file로 managing 해주자Python/Django 2021. 12. 18. 14:31
https://docs.djangoproject.com/en/4.0/ref/files/file/ The File object | Django documentation | Django Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate docs.djangoproject.com
-
[Python] IntegrityError: NOT NULL constraint failed: users_user.usernamePython/Django 2021. 12. 18. 00:12
if username is not None: name = profile_json.get("name", None) # 이부분 email = profile_json.get("email", None) bio = profile_json.get("bio", None) try: user = users_models.User.objects.get(email=email) if user.login_method != users_models.User.LOGIN_GITHUB: raise GithubException() except users_models.User.DoesNotExist: user = users_models.User.objects.create( email=email, first_name=name, # 이부분 us..
-
[Python] dotenv 사용하기Python 2021. 12. 16. 19:12
1. download package 2. write code inside manage.py 3. make .env dir on top 4. get value as : os.environ.get("{var name in .env file}") # .env MAILGUN_USERNAME = 'xx' MAILGUN_PASSWORD = 'xx' pip install django-env or pipenv install django-env # manage.py import dotenv if __name__ == "__main__": dotenv.read_dotenv() main() # settings.py EMAIL_HOST_USER = os.environ.get("MAILGUN_USERNAME") EMAIL_HO..
-
[Python] Django 비밀번호 암호화해서 저장하기 set_passwordPython/Django 2021. 12. 16. 18:24
# user.forms.SignUpForm def save(self, commit): username = self.cleaned_data.get("email") password = self.cleaned_data.get("password") user = super().save(commit=False) user.username = username user.set_password(password) user.save() https://docs.djangoproject.com/en/4.0/ref/contrib/auth/ django.contrib.auth | Django documentation | Django Django The web framework for perfectionists with deadlin..