Relative Content

Tag Archive for python-3.xdjango

Django DateField persistence

I have a model / Form / view for a request that works well, but when I want to update a request all the fields are loaded except the due_date field (with a date widget) witch remains empty. If I don’t pay attention I validate and the due_date become None. I would like it to load the date that was saved during creation by default and then I modify it or not. Here is the code.

Raw input being recorded but data is not saving throwing “this field is required” error

For context, I’ve essentially got a form whereby the user fills in job details and can choose who was on the job from an existing list of workers and input their hours, rates, and total wages. I’ve implemented a script so the user can ‘add’ more workers to the form. The main issue is that the data is not saving specifically for the hours and rates field even though the wages field is, so I cannot submit the whole form. Given the JS is client-side it is more likely a django problem, I’ve tested it anyway by getting rid of my script.

Testing concurrency ability of a Django app

Let’s suppose I have a Django app named MyApp in which I have a Django model called MyModel. This model has a method called process. The database is Postgresql so it allows concurrent queries.

Django: models.Model.objects.filter(pk) return nothing

I started learn Django framework.
Following the official tutorial I have model Question that is derived from django.db.models.Model
After all migrations, In views.py I created function called detail that is supposed to show me question by quest_id here is the code