django

Django edit user profile

泪湿孤枕 提交于 2021-02-17 09:01:31
问题 I'm trying to create an "Edit Profile" form in the fronted. What happens is that my form(i'm not 100% sure) tries to create a user instead of finding the current user and update his profile. So I think that's the issue. Checked many questions here but none was clear enough. The fields I'm trying to edit are email, first name and last name. (Also I would like to add uda forms.py class UpdateProfile(forms.ModelForm): username = forms.CharField(required=True) email = forms.EmailField(required

ModuleNotFoundError and ImportError even beeing right

喜你入骨 提交于 2021-02-17 07:10:45
问题 Hello, thanks for your time. i'm trying to import models on seeders.py. Can someone please tell me what am i doing wrong, i've done this a hundred times and tried every single way: from winners.models import Player or from ..models import Player models.py: from django.db import models class Player (models.Model): name = models.CharField(max_length=100) sex = models.CharField(max_length=9, choices=sex_choices) age = models.PositiveIntegerField() height = models.DecimalField(max_digits=3,

DRF SimpleJWT remove password and add date field

北慕城南 提交于 2021-02-17 07:10:39
问题 I created a custom user model extending from AbstractBaseUser where the only data I'm getting from the user is a userID, user (the username field) and date (required and in the format dd-mm-yyyy ) and the creation of the user works fine as you can see from the DB in the next image Used password = None and last_login = None to refer i didn't want password and last_login tables. Then, created a view where only authenticated users can access. To handle the authentication, used simpleJWT. In urls

DRF SimpleJWT remove password and add date field

会有一股神秘感。 提交于 2021-02-17 07:10:08
问题 I created a custom user model extending from AbstractBaseUser where the only data I'm getting from the user is a userID, user (the username field) and date (required and in the format dd-mm-yyyy ) and the creation of the user works fine as you can see from the DB in the next image Used password = None and last_login = None to refer i didn't want password and last_login tables. Then, created a view where only authenticated users can access. To handle the authentication, used simpleJWT. In urls

DRF SimpleJWT remove password and add date field

强颜欢笑 提交于 2021-02-17 07:10:05
问题 I created a custom user model extending from AbstractBaseUser where the only data I'm getting from the user is a userID, user (the username field) and date (required and in the format dd-mm-yyyy ) and the creation of the user works fine as you can see from the DB in the next image Used password = None and last_login = None to refer i didn't want password and last_login tables. Then, created a view where only authenticated users can access. To handle the authentication, used simpleJWT. In urls

ModuleNotFoundError and ImportError even beeing right

六眼飞鱼酱① 提交于 2021-02-17 07:09:41
问题 Hello, thanks for your time. i'm trying to import models on seeders.py. Can someone please tell me what am i doing wrong, i've done this a hundred times and tried every single way: from winners.models import Player or from ..models import Player models.py: from django.db import models class Player (models.Model): name = models.CharField(max_length=100) sex = models.CharField(max_length=9, choices=sex_choices) age = models.PositiveIntegerField() height = models.DecimalField(max_digits=3,

Flask/Django converting files [closed]

泄露秘密 提交于 2021-02-17 07:06:28
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 days ago . Improve this question I'm trying to build a little converter website. pdf to docx, images to pdf, csv to excel etc... I really want to use node as my static files host server. But as I know node doesn't have that cool modules to handle such convertations. I think of using another server

Flask/Django converting files [closed]

你离开我真会死。 提交于 2021-02-17 07:05:03
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 days ago . Improve this question I'm trying to build a little converter website. pdf to docx, images to pdf, csv to excel etc... I really want to use node as my static files host server. But as I know node doesn't have that cool modules to handle such convertations. I think of using another server

How to prevent usernames from containing @/./+/-/_.?

不打扰是莪最后的温柔 提交于 2021-02-17 07:00:07
问题 I'm using django-allauth, and for some reason the username default allows: "letters, digits and @/./+/-/_." How can I ensure usernames are strictly alphanumeric (without @/./+/-/_. )? I'm already using this clean_username() validator which currently works: class UsernameMaxAdapter(DefaultAccountAdapter): def clean_username(self, username): exclude = ['@', '/', '.', '+', '-', '/', '_', ','] if len(username) > 20: raise ValidationError("Username can't be over 20 characters") for i in exclude:

middleware updates request.user, but request.user becomes AnonymousUser in view

元气小坏坏 提交于 2021-02-17 06:38:48
问题 I wrote a simple JWT middleware to get user from the JWT. The method get_user_from_jwt returns a User object. # app.middlewares.py class JwtMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): self.process_request(request) return self.get_response(request) def process_request(self, request): request.user = self.get_user_from_jwt(request.headers) def get_user_pk_from_jwt(self, auth_header: str) -> int: _, token = auth_header.split(' ')