django-database

CommandError: You appear not to have the 'psql' program installed or on your path

对着背影说爱祢 提交于 2021-02-07 20:45:24
问题 I'm using Windows, no virtualenv. I have psycopg2 installed with Pip, and the latest version of PostgreSQL installed as well. When I run ./ manage.py dbshell , I get the following error: CommandError: You appear not to have the 'psql' program installed or on your path. When I run ./ manage.py dbshell psql , I get this: usage: manage.py dbshell [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--database DATABASE] manage.py dbshell:

CommandError: You appear not to have the 'psql' program installed or on your path

浪子不回头ぞ 提交于 2021-02-07 20:43:25
问题 I'm using Windows, no virtualenv. I have psycopg2 installed with Pip, and the latest version of PostgreSQL installed as well. When I run ./ manage.py dbshell , I get the following error: CommandError: You appear not to have the 'psql' program installed or on your path. When I run ./ manage.py dbshell psql , I get this: usage: manage.py dbshell [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--database DATABASE] manage.py dbshell:

Django Mass Update/Insert Performance

半腔热情 提交于 2021-01-02 09:06:16
问题 I'm receiving financial data for approximately 5000 instruments every 5 seconds, and need to update the respective entries in the database. The model looks as follows: class Market(models.Model): market = models.CharField(max_length=200) exchange = models.ForeignKey(Exchange,on_delete=models.CASCADE) ask = models.FloatField() bid = models.FloatField() lastUpdate = models.DateTimeField(default = timezone.now) What needs to happen is the following: After new financial data is received, check if

Django makemigrations AttributeError: 'str' object has no attribute '_meta'

梦想的初衷 提交于 2020-05-28 18:12:10
问题 I was playing with the django framework and I ran into an issue running the makemigration command. Here is a copy of the model and the stack trace it produces. I have seen a couple of posts with the same error but none has led me to resolve my problem here. I am working with django 1.9.4 from django.db import models import os, uuid # Create your models here. def video_directory_path(instance, folder): return os.path.join('video', str(instance.person.id), str(instance.video_id)) def photo

How to count the number of rows in a database table in Django

瘦欲@ 提交于 2020-04-06 02:10:38
问题 I have database created by Django model, where status and id and username are the fields of the table Messages . I need to count the number of rows where status value= 0 for a particular username . This is my incomplete code: Message_me = Messages.objects.get(username='myname') 回答1: Try this code: Message_me = Messages.objects.filter(username='myname', status=0).count() 回答2: You can either use Python's len() or use the count() method on any queryset depending on your requirements. Also note,

How to count the number of rows in a database table in Django

笑着哭i 提交于 2020-04-06 02:10:07
问题 I have database created by Django model, where status and id and username are the fields of the table Messages . I need to count the number of rows where status value= 0 for a particular username . This is my incomplete code: Message_me = Messages.objects.get(username='myname') 回答1: Try this code: Message_me = Messages.objects.filter(username='myname', status=0).count() 回答2: You can either use Python's len() or use the count() method on any queryset depending on your requirements. Also note,

Django __in lowercase

北慕城南 提交于 2020-01-10 04:26:05
问题 I'm using django-taggit, which handles the attachment of tags to arbitrary content types. I imported a large tag list, which contains many uppercase words, as well as lowercase words. Now, I' trying to get objects of another class containing a set of tags, but I want to compare case insensitively. When I do this: Media.objects.filter(tags__name__in=['tag1', 'tag2']) objects containing e.g. the tag "Tag1" are not found, only those ones with "tag1" or "tag2". Is there any possibility in the

How to make Django work with unsupported MySQL drivers such as gevent-mysql or Concurrence's MySQL driver?

╄→гoц情女王★ 提交于 2020-01-09 12:37:12
问题 I'm interested in running Django on an async framework like Concurrence or gevent. Both frameworks come with its own async MySQL driver. Problem is Django only officially supports MySQLdb. What do I need to do to make Django work with the MySQL drivers that come with gevent or Concurrence? Is there a step-by-step guide somewhere that I can follow? Is this a major undertaking? Thanks. 回答1: three cheers for @traviscline's suggestion to go with pymysql. his suggestion was based on this post from