Questions tagged [django-model-field]

112 questions
0
votes
2 answers

How to raise ValidationError in Django model if email exist

I am trying to raise ValidationError through validators.py or def clean(self) on an email field in the Django model to know if an email exists in the DB. Below is a brief of my model: class Profile(models.Model) ... email =…
phagyrhe
  • 167
  • 1
  • 14
0
votes
1 answer

Django.admin - How to make a Modelfield disable if other field is == False

I'm new to Django, and I'm developing a website in which I need to automate the creation of new pages through Django admin platform. So the idea is to create a new tab on the main menu of the site if a display parameters is set to True. However I…
0
votes
0 answers

Django imeplement custom model field without migration

I'm trying to implement custom field in my model following the docs, My model is as follow: class User(AbstractUser): uid = models.CharField( "uid", max_length=255, null=True, blank=True) phone_number = models.CharField( …
Linh Nguyen
  • 3,452
  • 4
  • 23
  • 67
0
votes
1 answer

How do I call an API from a Django Model based on one field

I want to populate a number of fields based on the website field below. I send the website as a parameter to the API and it returns a number of values in JSON. I then want to send it and store it in the model for that instance. class…
Dellaa
  • 3
  • 3
0
votes
1 answer

What is the meaning of "Model.delete() isn't called on related models" in Django Doc

I was reading Django's article on model fields and models.CASCADE. I don't understand this phrase: Model.delete() isn’t called on related models models.CASCADE means that related objects to delete when the target object deleted ,so what is the…
rahnama7m
  • 865
  • 10
  • 38
0
votes
2 answers

I'm trying to add a dynamic queryset to a model-form/formset field from a url kwarg , no luck so far

Edit: It appears that the problem I'm experiencing is directly related to the formset_factory() call. For some reason or other, I have been unable to access the kwargs from the view if I pass the form through the function. I'm building a web app…
0
votes
1 answer

Django Custom Setting Size Attribute on Model Form Not Working

I am trying to specify the length in characters on a model field. I cannot get it to render on the page and drop in the size attribute to the input field. The basic form looks like: class QuestionForm(ModelForm): question =…
OptimusPrime
  • 777
  • 16
  • 25
0
votes
2 answers

'Calculate' variables as fields in the Django model

I have a simple model: class Atividade(models.Model): valor_brl = models.DecimalField(max_digits=14, decimal_places=2) dolar_ref = models.DecimalField(max_digits=14, decimal_places=2) valor_usd = models.DecimalField(max_digits=14,…
vcruvinelr
  • 126
  • 8
0
votes
1 answer

ModuleNotFoundError: No module named 'oscar.app' in Django Oscar

I just installed Oscar module for my website and all tables are stored in database, but now i am using this module on my urls.py file but it's giving me an error ModuleNotFoundError: No module named 'oscar.app' Please help me to solve this…
0
votes
1 answer

Can I create a related Django field between two models with a shared foreign key value?

I have two models: class Foo(Model): special_id = IntegerField(primary_key=True) class FooDetail(Model): special_id = IntegerField(primary_key=True) special_id comes from an outside source -- it's a foreign key into another database. …
rrauenza
  • 6,285
  • 4
  • 32
  • 57
0
votes
1 answer

Django Auto add id field in database i don't want it

Django auto add id field in database i don't want to add id field in my database please help fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
user10989738
  • 81
  • 1
  • 11
0
votes
0 answers

Where do custom model fields get converted to their db_type?

I'm a bit confused here. I wrote a custom model field called PriceField that returns an instance of my class Price from its from_db_value and to_python methods, which both convert from strings to instances of Price. My db_type method returns…
Michael Hoffmann
  • 2,411
  • 2
  • 24
  • 42
0
votes
1 answer

Django - right way to join not-django tables

I have old cms database, structure isn't perfect and it can't be modified but i need to query using django TABLE posts (post_id) TABLE posts_text (post_id, post_text) TABLE episode (id, season_id, …
pyAndy
  • 25
  • 5
0
votes
1 answer

Django 2 - quieres in HTML

I am creating a program to list all main locations for a selected engagement. I have two models: Engagement and MainLocation. Engagement is a foreign key in the MainLocation model. The main location model looks like this: class…
tootall
  • 13
  • 1
  • 7
0
votes
1 answer

Saving the ModelForm containing ForeignKey field referenced to another Model in Postgresql database table

Below are my Models class Seminar(models.Model): seminarID = models.AutoField(primary_key=True) presenter_name = models.CharField(max_length=200) location_name = models.TextField() seminar_DT =…