django

django 1.3 UserProfile matching query does not exist

怎甘沉沦 提交于 2021-02-18 07:07:23
问题 I have a small problem with User model, the model looks like this: #! -*- coding: utf-8 -*- from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): url = models.URLField(max_length = 70, blank = True, verbose_name = 'WWW') home_address = models.TextField(blank = True, verbose_name = 'Home Adress') user = models.ForeignKey(User, blank = True, unique = True) def __unicode__(self): return '%s' %(self.user) When I open a django-shell and first

django 1.3 UserProfile matching query does not exist

流过昼夜 提交于 2021-02-18 07:06:32
问题 I have a small problem with User model, the model looks like this: #! -*- coding: utf-8 -*- from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): url = models.URLField(max_length = 70, blank = True, verbose_name = 'WWW') home_address = models.TextField(blank = True, verbose_name = 'Home Adress') user = models.ForeignKey(User, blank = True, unique = True) def __unicode__(self): return '%s' %(self.user) When I open a django-shell and first

Celery Gevent Pool - ConcurrentObjectUseError

▼魔方 西西 提交于 2021-02-18 07:06:09
问题 I have a celery worker that is using the gevent pool which does HTTP requests and adds another celery task with page source. I'm using Django, RabbitMQ as a broker, Redis as a celery result backend, Celery 4.1.0. The task has ignore_result=True but I'm getting this error pretty often ConcurrentObjectUseError: This socket is already used by another greenlet: <bound method Waiter.switch of <gevent.hub.Waiter...> I see it is related to the Redis connection. I can't figure out how to solve this.

Celery Gevent Pool - ConcurrentObjectUseError

我是研究僧i 提交于 2021-02-18 07:04:51
问题 I have a celery worker that is using the gevent pool which does HTTP requests and adds another celery task with page source. I'm using Django, RabbitMQ as a broker, Redis as a celery result backend, Celery 4.1.0. The task has ignore_result=True but I'm getting this error pretty often ConcurrentObjectUseError: This socket is already used by another greenlet: <bound method Waiter.switch of <gevent.hub.Waiter...> I see it is related to the Redis connection. I can't figure out how to solve this.

Celery Gevent Pool - ConcurrentObjectUseError

女生的网名这么多〃 提交于 2021-02-18 07:04:28
问题 I have a celery worker that is using the gevent pool which does HTTP requests and adds another celery task with page source. I'm using Django, RabbitMQ as a broker, Redis as a celery result backend, Celery 4.1.0. The task has ignore_result=True but I'm getting this error pretty often ConcurrentObjectUseError: This socket is already used by another greenlet: <bound method Waiter.switch of <gevent.hub.Waiter...> I see it is related to the Redis connection. I can't figure out how to solve this.

Select values which not in another table with Django

我只是一个虾纸丫 提交于 2021-02-18 06:14:33
问题 How this SQL query can be translated to Django ORM statement? SELECT field1, field2, field3 FROM table1 WHERE field1 NOT IN (SELECT 2_field1 FROM table2); Kindly help! :) ps table1 and table2 not bounded with ForeignKey or ManyToMany 回答1: Using two QuerySets, as shown in the docs. inner_qs = table2.objects.all() results = table1.objects.exclude(field1__in=inner_qs) 来源: https://stackoverflow.com/questions/14105660/select-values-which-not-in-another-table-with-django

Select values which not in another table with Django

僤鯓⒐⒋嵵緔 提交于 2021-02-18 06:14:17
问题 How this SQL query can be translated to Django ORM statement? SELECT field1, field2, field3 FROM table1 WHERE field1 NOT IN (SELECT 2_field1 FROM table2); Kindly help! :) ps table1 and table2 not bounded with ForeignKey or ManyToMany 回答1: Using two QuerySets, as shown in the docs. inner_qs = table2.objects.all() results = table1.objects.exclude(field1__in=inner_qs) 来源: https://stackoverflow.com/questions/14105660/select-values-which-not-in-another-table-with-django

Posting a foreign key relationship in Django Rest Framework

霸气de小男生 提交于 2021-02-18 05:23:39
问题 In my models , I have the following classes: class Topic(models.Model): name = models.CharField(max_length=25, unique=True) class Content(models.Model): title = models.CharField(max_length=255) body = models.TextField() topic = models.ForeignKey(Topic, blank=True, null=True) My serializers is like this: class TopicSerializer(serializers.ModelSerializer): class Meta: model = Topic fields = ('name') class ContentSerializer(serializers.ModelSerializer): topic = TopicSerializer(read_only=True)

How to debug “could not receive data from client: Connection reset by peer”

非 Y 不嫁゛ 提交于 2021-02-18 05:12:25
问题 I'm running a django-celery application on Ubuntu-12.04. When I run a celery task from my web interface, I get the following error, taken form postgresql-9.3 logfile (maximum level of log): 2013-11-12 13:57:01 GMT tss_usr 8113 LOG: could not receive data from client: Connection reset by peer tss_usr is the postgresql user of the django application database and (in this example) 8113 is the pid of the process who killed the connection, I guess. Have you got any idea on why this happens or at

How to debug “could not receive data from client: Connection reset by peer”

你。 提交于 2021-02-18 05:11:59
问题 I'm running a django-celery application on Ubuntu-12.04. When I run a celery task from my web interface, I get the following error, taken form postgresql-9.3 logfile (maximum level of log): 2013-11-12 13:57:01 GMT tss_usr 8113 LOG: could not receive data from client: Connection reset by peer tss_usr is the postgresql user of the django application database and (in this example) 8113 is the pid of the process who killed the connection, I guess. Have you got any idea on why this happens or at