Questions tagged as 'django-models'

1
answer

Render multiple forms and validate them in a single template in DJANGO

I tried to render 3 forms with Class-based views in a single template but I did not succeed, so I decided to do something like this with a method: def formTortas(request): .... where I call my 3 forms defended in Forms.py in this way,...
asked by 06.04.2017 / 17:59
2
answers

How to solve this query set? [duplicate]

I have a problem where I want to subtract two fields and then update a record, which would be cantidad - stock , and the latter would be the modified one, here the model: models.py: class Pedido(models.Model): especialidad = m...
asked by 13.02.2017 / 14:15
2
answers

Consult several Django models

I have these models: class TablaA(models.Model): estado = models.BooleanField() # mas campos... class TablaB(models.Model): tabla_a = models.ForeignKey(TablaA) estado = models.BooleanField() # mas campos... class TablaC(m...
asked by 17.01.2017 / 00:14
2
answers

filter to get the contents of a Django list?

I hope it is not a little trivial my question I have the following models. class ModelA(models.Model): tipo= UCharField(max_length=20, null=True, blank=True) class ModelB(models.Model): model_a= models.ForeignKey(ModelA, null=False...
asked by 11.10.2016 / 21:21
1
answer

Performing migrations in Django - django.db.utils.IntegrityError: null values

I am adding the following attribute type choice to my model class User(AbstractUser): GENDER_MALE = 'M' GENDER_FEMALE = 'F' GENDER_OTHER = 'O' GENDER_CHOICES = ( (GENDER_MALE, u'male'), (GENDER_FEMALE, u'...
asked by 16.01.2016 / 22:35
3
answers

Consultation of two Models in Django

I have these two models: class Pacientes(models.Model): nombres = models.CharField(max_length=50) apellidos = models.CharField(max_length=50) numero_identificacion = models.CharField(max_length=10) fecha_nacimiento = models.DateField(blank=Fal...
asked by 05.07.2018 / 20:03
1
answer

How to use Django with an existing database in MySQL?

I have an application in Django 2.0 and as a database engine I use MySQL. I have a problem because the database was previously created and already has records, my idea is to use this same database for the application I'm creating. Use the com...
asked by 09.04.2018 / 17:00
1
answer

Access the Django database from a non-Django script

When I try to access the database that Django automatically creates from the interpreter, or from a script that Django has not created on its own, I receive an error. Code where I try to import the User model of the application called ap...
asked by 25.08.2017 / 16:24
1
answer

Restrict access by url

In my application I have the user model that extends AbstractUser and I have added two boolean fields, my question is, how can I make the user not enter certain views by url depending on whether it is validator or is a digitizer? So far I have o...
asked by 25.07.2017 / 00:28
2
answers

Register a user from a form in Django

Hi, I have a model that inherits from AbstractUser: Models.py class Usuario(AbstractUser,models.Model): dni=models.CharField( verbose_name="DNI", max_length=9, blank=False, ) clave = models.CharField(...
asked by 14.02.2017 / 10:27