model

How to add the name of an uploaded file to a model in django

How to add the name of an uploaded file to a model in django Question: I am learning django. I am stuck with this problem. I have created a form in which a user uploads a text file and selects a gender. The user is also supposed to write the name of the text file …

Total answers: 1

Wagtail Customising User Account Settings Form With One-to-One Model

Wagtail Customising User Account Settings Form With One-to-One Model Question: I have a model in my app called "portal", in portal/models.py: from django.db import models from django.contrib.auth.models import User from django.dispatch import receiver from django.db.models.signals import post_save from wagtail.snippets.models import register_snippet from wagtail.admin.edit_handlers import FieldPanel @register_snippet class StaffRoles(models.Model): role = models.CharField(max_length=154, unique=True, help_text="Create new staff …

Total answers: 1

con't define variable in pydantic init function

con't define variable in pydantic init function Question: i want to define a Base model that inherits from pydantic BaseModel like bellow class BaseDomain(BaseModel): def __init__(self, **kwargs): self.__exceptions = [] def add_error(self, exception: GeneralException): self.__exceptions.append(exception) but i get this error when i use Product model that inherits from BaseDomain ValueError: "Product" object has no field …

Total answers: 4

Classification Model's parameters produce different results

Classification Model's parameters produce different results Question: I’m working on SVC model for classification and I faced different accuracy result in each time I changed the values of the parameters (svc__gamma, svc__kernel and svc__C), I read the documentation of Sklearn but I could not understand what those parameters mean, I have Three questions : What …

Total answers: 1

Is it bad practice to include non-validating methods in a pydantic model?

Is it bad practice to include non-validating methods in a pydantic model? Question: I’m using pydantic 1.3 to validate models for an API I am writing. Is it common/good practice to include arbitrary methods in a class that inherits from pydantic.BaseModel? I need some helper methods associated with the objects and I am trying to …

Total answers: 2

Django "NameError: name 'Album' not defined"

Django "NameError: name 'Album' not defined" Question: I am trying to run see and manipulate a simple django database but the error from the Django Shell is saying one of my models isn’t defined. Most of the questions with errors similar to mine are due to people referencing a model before declaring it. However, I’m …

Total answers: 4

Do Django backward relations add computational overhead?

Do Django backward relations add computational overhead? Question: In Django, you create models and can optionally specify a foreign key on a field class Man: … class Dog: … owner = models.ForeignKey(Man, on_delete=models.SET_NULL) You can then query each Dog for its respective owner or get all dogs for a Man owner = some_dog.owner all_dogs = …

Total answers: 1

Django: access the model meta class value

Django: access the model meta class value Question: I have some model classes defined: class ModelA(models.Model): class Meta: abstract = True class ModelB(ModelA): class Meta: abstract = False So, now I have a class object, I want to check if it is abstract, is there any way to do this? For example, I want something …

Total answers: 2

Django: ImportError: cannot import name 'User'

Django: ImportError: cannot import name 'User' Question: I’m new to django and I’m facing some difficulties in creating a user from the AbstractBaseUser model. Now I’m starting wondering if my user model is not being build in the right way. This is my User model from django.db import models from django.contrib.auth.models import AbstractBaseUser class User(AbstractBaseUser): …

Total answers: 6