django-models

Django Uploaded images not displayed in development

徘徊边缘 提交于 2021-02-20 00:40:26
问题 I have defined a model with a 'pic' image field: class Photo(models.Model): title = models.CharField(max_length=100) body = models.TextField() teaser = models.TextField('teaser', blank=True) pic = models.ImageField(upload_to = 'pic_folder/', default = 'pic_folder/None/default.jpg') created=models.DateTimeField(default=datetime.datetime.now) pub_date=models.DateTimeField(default=datetime.datetime.now) categories = models.ManyToManyField(Category, blank=True) likes = models.IntegerField(default

How to set daily update limit for django model(db)?

折月煮酒 提交于 2021-02-19 23:24:48
问题 Hi I'm having one Django web app where My model A contains 1000 records and I want to set a daily update limit for example if users are updating that data by uploading a .xls file then it should count how many records updated and once it is more than 500 then the user should get an Error message(Is there Any easy way to implement this at file processing level). Can Anyone help me how to implement this (Is there an SQLite parameter that I can mention in settings.py) below is my upload code.

How to set daily update limit for django model(db)?

北慕城南 提交于 2021-02-19 23:10:36
问题 Hi I'm having one Django web app where My model A contains 1000 records and I want to set a daily update limit for example if users are updating that data by uploading a .xls file then it should count how many records updated and once it is more than 500 then the user should get an Error message(Is there Any easy way to implement this at file processing level). Can Anyone help me how to implement this (Is there an SQLite parameter that I can mention in settings.py) below is my upload code.

Delete an object automatically after 5 minutes

别来无恙 提交于 2021-02-19 16:05:06
问题 I'm trying to create a function that automatically delete an object after 5 minutes from publication. from django.contrib.gis.db import models from django.utils import timezone import datetime class Event(models.Model): name = models.CharField( max_length=100, ) publishing_date = models.DateTimeField( default=timezone.now, blank=True, ) @property def delete_after_five_minutes(self): time = self.publishing_date + datetime.timedelta(minutes=5) if time > datetime.datetime.now(): e = Event

Delete an object automatically after 5 minutes

旧巷老猫 提交于 2021-02-19 15:55:50
问题 I'm trying to create a function that automatically delete an object after 5 minutes from publication. from django.contrib.gis.db import models from django.utils import timezone import datetime class Event(models.Model): name = models.CharField( max_length=100, ) publishing_date = models.DateTimeField( default=timezone.now, blank=True, ) @property def delete_after_five_minutes(self): time = self.publishing_date + datetime.timedelta(minutes=5) if time > datetime.datetime.now(): e = Event

Django Search query within multiple fields in same data table

不羁岁月 提交于 2021-02-19 08:27:23
问题 This is my models.py file. class CustomerInfo(models.Model): customer_name=models.CharField('Customer Name', max_length=50) customer_mobile_no = models.CharField('Mobile No', null=True, blank=True,max_length=12) customer_price=models.IntegerField('Customer Price') customer_product_warrenty = models.CharField('Product Warrenty',null=True, blank=True,max_length=10) customer_sell_date = models.DateTimeField('date-published', auto_now=True) customer_product_id=models.CharField('Product ID',max

Django Search query within multiple fields in same data table

佐手、 提交于 2021-02-19 08:27:10
问题 This is my models.py file. class CustomerInfo(models.Model): customer_name=models.CharField('Customer Name', max_length=50) customer_mobile_no = models.CharField('Mobile No', null=True, blank=True,max_length=12) customer_price=models.IntegerField('Customer Price') customer_product_warrenty = models.CharField('Product Warrenty',null=True, blank=True,max_length=10) customer_sell_date = models.DateTimeField('date-published', auto_now=True) customer_product_id=models.CharField('Product ID',max

Video Upload and display on a Django Website

痴心易碎 提交于 2021-02-19 07:58:07
问题 I have a model where I upload a video, i want to display the same in the browser but somehow I am not able to. Kindly help me. I made an app with the name deploy, where I am uploading the video and saving it. Kindly tell me where I am doing wrong and what should be done here. I want the video which was uploaded should be displayed on the page and there should be a option for download as well. I shall be extremely thankful for the help. My models.py file: class Video(models.Model): Video

`basename` argument not specified, and could ' \

£可爱£侵袭症+ 提交于 2021-02-19 04:53:10
问题 I am getting the below error again and again.I am trying to solve it from morning but nothing is happening. assert queryset is not None, ' basename argument not specified, and could ' \ AssertionError: basename argument not specified, and could not automatically determine the name from the viewset, as it does not have a .queryset attribute. models.py class Language(models.Model): A = models.CharField(max_length=50) B = models.ForeignKey(User,on_delete=models.CASCADE,null=True) C = models

Django global queryset

邮差的信 提交于 2021-02-19 03:08:58
问题 I would like to have a global variable in my django app that stores resulting list of objects that I later use in some functions and I don't want to evaluate queryset more that once, i do it like this: from app.models import StopWord a = list(StopWord.objects.values_list('word', flat=True)) ... def some_func(): ... (using a variable) ... This seems ok to me but the problem is that syncdb and test command throw an exception: django.db.utils.DatabaseError: (1146, "Table 'app_stopword' doesn't