Skip to main content

All Questions

Tagged with
0 votes
0 answers
18 views

pyotp shows expired otp error even when it's not expired

I am using this library to reset the user's password. This is the block of code that generates the code: async def create_code(db: AsyncSession, user): secret_key = pyotp.random_base32() totp = pyotp....
binbin's user avatar
  • 25
0 votes
1 answer
34 views

Django Rest Framework: validate_username and update methods not called during PUT request

I am working on a Django Rest Framework (DRF) project, where I need to validate a username field and handle custom update logic in a serializer. My model has a username field with unique=True. Here's ...
devKOfori's user avatar
0 votes
2 answers
60 views

How do I get my code to reject invalid input and repeat the prompt? [duplicate]

I need this code to only accept "y" or "n" for the sYesOrNo input. If user enters invalid input, I need it to re-display the sYesOrNo input prompt. It repeats the loop if user ...
RLA's user avatar
  • 9
0 votes
0 answers
67 views

Trouble with change text in tk.Entry on validation

I want to create an entry field for a date. I want the user to be able to type the digits for the month, day, year and have the '/' come up automatically. I thought I would be able to do this with ...
NurseStacey's user avatar
1 vote
1 answer
41 views

Pydantic/Django Ninja use only existing keys (even with None)

having an app in Django Ninja with schemas: class NumericalFilterSchema(Schema): gt: Optional[int] = None lt: Optional[int] = None gte: Optional[int] = None lte: Optional[int] = None ...
Leemosh's user avatar
  • 905
0 votes
1 answer
47 views

Validating input in tkinter

I am very very new to Python (about 2 weeks). I am writing a GUI using tkinter. The interface has 3 frames. In one frame I enter data and use it to do simple calculations. I would like to test for ...
Stephen Webber's user avatar
4 votes
2 answers
159 views

How can I enforce a minimum age constraint and manage related models in Django?

I am working on a Django project where I need to validate a model before saving it, based on values in its related models. I came up with this issue while extracting an app from an project using an ...
Danmaxis's user avatar
  • 1,722
0 votes
0 answers
43 views

problems validating form with a loop for python

I am trying to validate my fields in a more efficient way and I think I am on the right track, but I have a problem with the for loop, the code is as follows First of all I manage all the fields ...
Diego Marin's user avatar
0 votes
1 answer
31 views

Recursive Descent Parser in Python not validating code

I was tasked to write a top-down recursive descent parser for the Puck-24.3 programming language. Task: Language Token Types: Integers are non-empty sequences of digits optionally preceded with ...
DaneShuler's user avatar
0 votes
0 answers
59 views

How can I reduce the complexity of my validations in python

I am trying to lower the complexity of my code and I use Scrutinizer to measure those values. In my code, most of the complexity is due to validations, so how can I improve them? class gestionRegister:...
Diego Marin's user avatar
0 votes
0 answers
170 views

Pydantic: remove discriminated union discriminator value from ValidationError loc field

I am currently using FastAPI for a university project, where it serves as my backend. One of the flows of my application requires me to send a payload from the front-end to the back-end, where one of ...
D. T. I.'s user avatar
2 votes
1 answer
91 views

Save to disk training dataset and validation dataset separately in PyTorch

I want to save train dataset, test dataset, and validation dataset in 3 separate folders. Doing this for training and testing is easy # Get training and testing data all_training_data = getattr(...
Noumeno's user avatar
  • 161
0 votes
1 answer
50 views

tkinter Entry validatecommand and trace_add for a float that allows an empty input and triggers an update function

Input or paste only a float into a tk.Entry, except allowing an empty field, then trigger an action that passes the updated value. This should be generalizable. import tkinter as tk def ...
keysanderaser's user avatar
0 votes
0 answers
81 views

Django max_length validation for BinaryField causes KeyError in translation __init__.py

I have a simple model, something like class Notenbild(models.Model): bild_data = models.BinaryField(max_length=500000, editable=True) In admin.py class BinaryFieldWithUpload(forms.FileField): ...
Alexander Pacha's user avatar
1 vote
0 answers
22 views

Pydantic seperate schema validation from logic/functional validation

Let's say I have this model: class User(BaseModel): name: str email: EmailStr phone_number: str job_title: str company: str salary: int @field_validator('company') ...
Kevin Nammour's user avatar

15 30 50 per page
1
2 3 4 5
140