django-models

ManyToMany Relationships. Returning fields in def __str__ method

爱⌒轻易说出口 提交于 2021-01-27 19:17:24
问题 I have two models: AffectedSegment model class AffectedSegment(models.Model): SEGMENTO_ESCAPULA = 'Escápula' SEGMENTO_HOMBRO = 'Hombro' SEGMENTO_CODO = 'Codo' SEGMENTO_ANTEBRAZO = 'Antebrazo' SEGMENTO_CARPO_MUNECA = 'Carpo/Muñeca' SEGMENTO_MANO = 'Mano' SEGMENT_CHOICES = ( (SEGMENTO_ESCAPULA, u'Escápula'), (SEGMENTO_HOMBRO, u'Hombro'), (SEGMENTO_CODO, u'Codo'), (SEGMENTO_ANTEBRAZO, u'Antebrazo'), (SEGMENTO_CARPO_MUNECA, u'Carpo/Muñeca'), (SEGMENTO_MANO, u'Mano'), ) affected_segment = models

sending mail in django - issue with gmail smtp

我们两清 提交于 2021-01-27 18:43:36
问题 I own a simple portfolio website @ www.manojmj.com I have a contact form on the site where users can fill a form and send it to me via email Right now, I have configured my Gmail account for sending mails via django. I know the from address in the mail will be replaced by my own address as given in settings.py if I use gmail as my provider and there is no way around this. I am ok with this, but the real issue is that, while I'm running my project on localhost, the emails are being sent just

Using json model field with django graphene

帅比萌擦擦* 提交于 2021-01-27 18:04:01
问题 I'm working with graphql endpoint for my project. One of models has textfield which contains some json. If i request list of my entities via graphql, I'm getting this json like a string. How to reach ability to use it in graphql as nested structure with ability of filtering, choosing some properties etc. class SysObjects(models.Model): id = models.BigAutoField(primary_key=True) user_id = models.BigIntegerField() type_id = models.PositiveIntegerField(blank=True, null=True) # status = models

Using json model field with django graphene

陌路散爱 提交于 2021-01-27 17:19:43
问题 I'm working with graphql endpoint for my project. One of models has textfield which contains some json. If i request list of my entities via graphql, I'm getting this json like a string. How to reach ability to use it in graphql as nested structure with ability of filtering, choosing some properties etc. class SysObjects(models.Model): id = models.BigAutoField(primary_key=True) user_id = models.BigIntegerField() type_id = models.PositiveIntegerField(blank=True, null=True) # status = models

How to request GET parameters in templates for a list of files?(Django Zip File Download Issue)

爱⌒轻易说出口 提交于 2021-01-27 16:37:24
问题 I want to download all the single or multiple files created by the function by zipping them. The problem is with templates. Please suggest properly to pass the GET parameters for a list of files I got an error : FileNotFoundError at /test/ [Errno 2] No such file or directory: '[' This is the error for improperly placing the query string that is referring to the list of files. My views are as follows: def submit(request): def file_conversion(input_file,output_file_pattern,chunk_size): output

Django save default value in Proxy Model

瘦欲@ 提交于 2021-01-27 14:32:57
问题 Different proxy models should be different in type. If I query those models I the right ones. I am trying to save a default type field in a proxy model. I don't want to set it everytime in the view. This does not work. The type field is always "TYPE1". models.py: class MyModel(models.Model): class ModelType(models.TextChoices): TYPE1 = 'TYPE1', _('TYPE1') TYPE2 = 'TYPE2', _('TYPE2') type = models.CharField(max_length=100, choices=ModelType.choices, default='TYPE1') class Type2Manager(models

ValueError: invalid literal for int() with base 10:

拜拜、爱过 提交于 2021-01-27 13:14:59
问题 i am getting this value error, when i try to insert some data to django model. My python script is : from task.employeeDetails.models import EmployeeDetails def dumpdata(): userName = "John" designation = 'Software Engineer' employeeID = 2312 contactNumber = 9495321257 project = 'AOL' dateOfJoin = '2009-10-10' EmployeeDetails(userName,designation,employeeID,contactNumber,project,dateOfJoin).save() dumpdata() My models.py is class EmployeeDetails(models.Model): userName = models.CharField(max

Django ORM raw delete query not deleting records

混江龙づ霸主 提交于 2021-01-27 12:55:02
问题 I am using raw_sql queries for my convenience for keeping my database minimal I am deleting extra records. By this query #d is from a loop and has values res=MyModel.objects.raw("DELETE FROM mydb_mymodel WHERE mydb_mymodel.s_type = '%s' and mydb_mymodel.barcode = '%s' and mydb_mymodel.shopcode = '%s' and mydb_mymodel.date = '%s'" ,[d.s_type,d.barcode,d.shopcode,d.date]) It is not deleting records in database but when I do res.query and run it from postgres console it works! Yes I can use

Multiselect dropdown/list in django admin panel only

两盒软妹~` 提交于 2021-01-27 12:45:05
问题 django model choice option as a multi select box Django Multiple Choice Field / Checkbox Select Multiple Django: How can i create a multiple select form? I'm trying to add a multiselect field in existing django model. I went through these three SOF threads and some other blogs but I didn't find required solution. everyone is using modelForms. I want this in purely in default django admin panel (same as choice field). this field is not going to be used in front-end/any kind of form. purely for

Multiselect dropdown/list in django admin panel only

Deadly 提交于 2021-01-27 12:41:26
问题 django model choice option as a multi select box Django Multiple Choice Field / Checkbox Select Multiple Django: How can i create a multiple select form? I'm trying to add a multiselect field in existing django model. I went through these three SOF threads and some other blogs but I didn't find required solution. everyone is using modelForms. I want this in purely in default django admin panel (same as choice field). this field is not going to be used in front-end/any kind of form. purely for