model

Django – Python: 'int' object has no attribute 'get'

Django – Python: 'int' object has no attribute 'get' Question: I am setting up a Django project to allow tickets to be sold for various theatre dates with a price for adults and a price for children. I have created a models.py and ticket_details.html. I am unfortunately receiving the following error: ‘int’ object has no …

Total answers: 1

Django — concatenate filter on a many_to_many relation create unexpected join

Django — concatenate filter on a many_to_many relation create unexpected join Question: class ProductionOrderProductionOrderStatus(sf_models.BaseModel): production_order = models.ForeignKey(ProductionOrder, on_delete=models.CASCADE) production_order_status = models.ForeignKey(ProductionOrderStatus, on_delete=models.CASCADE) class ProductionOrderStatus(sf_models.BaseModel): status = models.IntegerField(null=False) begin_datetime = models.DateTimeField(default=timezone.now) end_datetime = models.DateTimeField(null=True, blank=True) class ProductionOrder(sf_models.BaseModel): statuses = models.ManyToManyField(ProductionOrderStatus, through=’ProductionOrderProductionOrderStatus’, related_name=’production_orders’) if i concatenate 2 filter like this -> ProductionOrder.objects.filter(statuses__status=2).filter(statuses__end_datetime=None) i get this sql: ‘SELECT …

Total answers: 1

How to access ForeignKey properties from models.py in django

How to access ForeignKey properties from models.py in django Question: I want to access a property of another model from a model via ForeignKey. For example, if invoice_details is a ForeignKey to InvoiceMaster, then I want invoice_details to store the value of InvoiceMaster‘s invoice_number, instead of the primary key. How can I achieve this? I …

Total answers: 2

Django: html submit form that is unique for each element in a list

Django: html submit form that is unique for each element in a list Question: In a template of my project, I am using a for loop to iterate over each object in a model. Each object needs a button next to it that will delete THAT object from the model. So each button needs to …

Total answers: 1

Integrating and fitting coupled ODE's for SIR modelling

Integrating and fitting coupled ODE's for SIR modelling Question: In this case, there are 3 ODE’s that describe a SIR model. The issue comes in I want to calculate which beta and gamma values are the best to fit onto the datapoints from the x_axis and y_axisvalues. The method I’m currently using is to integrate …

Total answers: 2

When I do "makemigrations" I get do "makemigrations"

When I do "makemigrations" I get do "makemigrations" Question: I removed all migration files from my django project and now when i want to re-create i get this ./manage.py makemigrations INFO: AXES: BEGIN LOG :: [axes.apps] 2022-09-15 16:51:59,923 – /home/mixnosha/work_MVD/MVD_LTP/MVD_LTP-ltp/venv/lib/python3.10/site- packages/axes/apps.py:33 INFO: AXES: Using django-axes version 5.31.0 :: [axes.apps] 2022-09-15 16:51:59,926 – /home/mixnosha/work_MVD/MVD_LTP/MVD_LTP-ltp/venv/lib/python3.10/site- packages/axes/apps.py:34 INFO: …

Total answers: 1

Django python – how do add new record every time I update the screen? instead it updates the existing record.?

Django python – how do add new record every time I update the screen? instead it updates the existing record.? Question: How do add new record every time I update the screen? instead it updates the existing record.? Here are the models. class Dealer(models.Model): city = models.CharField(‘City’, max_length=30, blank=True, null=True) contact_name = models.CharField(‘Contact name’, max_length=250, …

Total answers: 1

how to make models for user auth(use abstract user) for login and signup using django?

how to make models for user auth(use abstract user) for login and signup using django? Question: how to make models for user auth(use abstract user) for login and signup using Django? I want to make login OTP based for ecommerse website. from django.db import models class User(models.Model): first_name = models.CharField(max_length=40) last_name = models.CharField(max_length=40) mobile = …

Total answers: 2

I use pytorch to train a model to classify iris, but my acc was about 0.4

I use pytorch to train a model to classify iris, but my acc was about 0.4 Question: I have tried many improvements like increasing epochs, using better loss functions and optimizers, deepening the network and shuffling the dataset, etc, but still to no avail. This problem has been bothering me for a long time, thanks …

Total answers: 1