Skip to content
Advertisement

Tag: django

Django Model method that uses data from the model

I want to generate unique codes (e.g. “DXGH”) and save it as a field in one of my models. The problem I have is that I do not know how to check against previously generated codes whenever a new object is created. Currently my models.py looks something like this: Ideally I would set the default value of room_code to code_gen_unique,

django charfield not showing in admin panel

i create a model in django and register it in admin.py when i go to admin panel it shows the model but when i want to create object it doesn’t show the charfields and i can just create the oject without any details this is my codes below view.py model.py stting.py admin.py this screenshot is from my admin panel >

Python: Run a code after return something

This is an ApiView from my django project: As you see, if client.is_busy is not True, I’m making it True in here. But in this situation, I need to client.is_busy = False after 30 seconds. If I do it under client.save() code, it delays to response. How can I do it? Answer You should consider using timer objects here. e.g.

django pytest how to test a view with argument(id)

i have a question regarding using pytest. These are my very 1st tests. I have 2 views which i want to test (simplest possible way). Views: Here are my tests: Urls: 1st test (menu view) is working properly 2nd test (cuisine details view) shows error I know i should probably put somethere ID argument but tried few options and havent

Advertisement