Re: drop-in replacement for admin module foreign key relation UI

2016-07-14 Thread muin
when I use this method, I can only use its id, So how can it show related 
model's field which has been defined in __str__

On Tuesday, February 17, 2015 at 3:20:22 PM UTC+8, Jani Tiainen wrote:
>
> On Mon, 16 Feb 2015 15:03:05 -0800 (PST) 
> Jani Kajala > wrote: 
>
> > Hi all, 
> > 
> > I have tons of objects referenced by ForeignKey in Django Admin module 
> UI, 
> > and I would like to replace it with something more optimal, e.g. 
> auto-fill 
> > input box or something. 
> > 
> > My model looks something like this: 
> > 
> > class SoapCall(models.Model): 
> > customer = models.ForeignKey(Customer, null=True, blank=True) 
> > created = models.DateTimeField(default=now) 
> > wsdl = models.CharField(max_length=255) 
> > func = models.CharField(max_length=63) 
> > request = models.TextField() 
> > response = models.TextField() 
> > 
> > Now, this works great, but if I have 10 Customer objects it's not 
> very 
> > nice to generate one huge ... element for every page 
> load. 
> > 
> > There seems to be many possible plugins/implementations for this, but I 
> was 
> > just wondering if anyone would have up-to-date recommendations in this 
> > mailing list. I'm on Python 3.4.2 and Django 1.7.4. 
>
> I would start with built-in implementation, a.k.a. rawid_id_fields <
> https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields>
>  
>
>
>
> -- 
> Jani Tiainen 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d669c0e2-ec77-489e-86dd-6fbb31929f1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 分享一个用python和javascript开发的Django: advanced network website

2016-07-14 Thread muin
我杭州的

On Thursday, July 14, 2016 at 7:31:45 PM UTC+8, Cherry Chen wrote:
>
>
> 
>
> 大家好,我是内地的,想知道这个群里是否有来自中国内地,香港和台湾的朋友。希望大家喜欢我的分享,多多交流。
>
>
> https://www.livecoding.tv/olivierpons/videos/JYpDK-django-advanced-network-website-cogofly-2
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/50c28b7f-1f9c-4787-8f44-8d3fdb755e28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


column "" must appear in the GROUP BY clause or be used in an aggregate function

2018-10-14 Thread muin


Django 2.1.2, Postgres 10

Model:
class Product(models.Model):
product_id = models.AutoField("产品ID", primary_key=True)
...

class SpecItem(models.Model):
spec_id = models.AutoField(primary_key=True)
product = models.ForeignKey(Product, on_delete=models.CASCADE, 
related_name="product_specs", null=True)
price = models.FloatField("价格", default=0)
...

When exwcute
qs = Product.objects.filter(valid=1)
serializer = ProductSerializer(
qs.annotate(cnt=Count("product_specs"), 
min_price=Min("product_specs__price")).filter(cnt__gt=0)
.order_by("min_price")[offset:offset + limit],
context={"request": request},
many=True)

It says django.db.utils.ProgrammingError: column 
"prome_product.product_name" must appear in the GROUP BY clause or be used 
in an aggregate function


Can anyone help me?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64c1b2f0-6125-45e0-a08b-7d5d3426f16d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: column "" must appear in the GROUP BY clause or be used in an aggregate function

2018-10-15 Thread muin
Thank you for your reply,"prome" is my app name.

I had changed to MySQL,it runs well on from the same code. And sqlite is 
also OK.

On Monday, October 15, 2018 at 3:19:11 PM UTC+8, ludovic coues wrote:
>
> I cannot find in the code you shared "prome_product" so I assume there is 
> missing code or a typo.
>
> The ProgrammingError should come with a line number or a stack trace where 
> the line causing issue is roughly in the middle. If it's the serializer 
> line, I suggest you split it, doing the annotate before calling serializer.
>
> Query set are "lazy loading", they don't fetch from the database untill 
> they have to. While it's great most of the time, that cause issue while 
> debugging. Try to call list(qs.annotate(...)[offset:offset+limit]) to force 
> the query set to execute.
>
> This won't give you an answer but that might help you to find the issue.
>
> Good luck!
>
> On Mon, Oct 15, 2018, 03:38 muin > wrote:
>
>> Django 2.1.2, Postgres 10
>>
>> Model:
>> class Product(models.Model):
>> product_id = models.AutoField("产品ID", primary_key=True)
>> ...
>>
>> class SpecItem(models.Model):
>> spec_id = models.AutoField(primary_key=True)
>> product = models.ForeignKey(Product, on_delete=models.CASCADE, 
>> related_name="product_specs", null=True)
>> price = models.FloatField("价格", default=0)
>> ...
>>
>> When exwcute
>> qs = Product.objects.filter(valid=1)
>> serializer = ProductSerializer(
>> qs.annotate(cnt=Count("product_specs"), 
>> min_price=Min("product_specs__price")).filter(cnt__gt=0)
>> .order_by("min_price")[offset:offset + limit],
>> context={"request": request},
>> many=True)
>>
>> It says django.db.utils.ProgrammingError: column 
>> "prome_product.product_name" must appear in the GROUP BY clause or be used 
>> in an aggregate function
>>
>>
>> Can anyone help me?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/64c1b2f0-6125-45e0-a08b-7d5d3426f16d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/64c1b2f0-6125-45e0-a08b-7d5d3426f16d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/59bc8447-1349-46d2-b430-84dae1cc3e4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: column "" must appear in the GROUP BY clause or be used in an aggregate function

2018-10-15 Thread muin
Thank you for your reply,"prome" is my app name.

It runs well on django1.11 and python2.7.6. This error happens when upgrade 
to django2.1.2 and python3.6.6

I had changed to MySQL,it runs well from the same code. And sqlite is also 
OK.


On Monday, October 15, 2018 at 3:19:11 PM UTC+8, ludovic coues wrote:
>
> I cannot find in the code you shared "prome_product" so I assume there is 
> missing code or a typo.
>
> The ProgrammingError should come with a line number or a stack trace where 
> the line causing issue is roughly in the middle. If it's the serializer 
> line, I suggest you split it, doing the annotate before calling serializer.
>
> Query set are "lazy loading", they don't fetch from the database untill 
> they have to. While it's great most of the time, that cause issue while 
> debugging. Try to call list(qs.annotate(...)[offset:offset+limit]) to force 
> the query set to execute.
>
> This won't give you an answer but that might help you to find the issue.
>
> Good luck!
>
> On Mon, Oct 15, 2018, 03:38 muin > wrote:
>
>> Django 2.1.2, Postgres 10
>>
>> Model:
>> class Product(models.Model):
>> product_id = models.AutoField("产品ID", primary_key=True)
>> ...
>>
>> class SpecItem(models.Model):
>> spec_id = models.AutoField(primary_key=True)
>> product = models.ForeignKey(Product, on_delete=models.CASCADE, 
>> related_name="product_specs", null=True)
>> price = models.FloatField("价格", default=0)
>> ...
>>
>> When exwcute
>> qs = Product.objects.filter(valid=1)
>> serializer = ProductSerializer(
>> qs.annotate(cnt=Count("product_specs"), 
>> min_price=Min("product_specs__price")).filter(cnt__gt=0)
>> .order_by("min_price")[offset:offset + limit],
>> context={"request": request},
>> many=True)
>>
>> It says django.db.utils.ProgrammingError: column 
>> "prome_product.product_name" must appear in the GROUP BY clause or be used 
>> in an aggregate function
>>
>>
>> Can anyone help me?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/64c1b2f0-6125-45e0-a08b-7d5d3426f16d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/64c1b2f0-6125-45e0-a08b-7d5d3426f16d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/67c5e1a4-a456-4f8f-afa5-c0a97d0d9dbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.