ManyToOne : cannot form a proper query :(

2009-03-03 Thread [CPR]-AL.exe
for example, i have this models: (like here: http://www.djangoproject.com/documentation/models/many_to_one/) from django.db import models class Reporter(models.Model): first_name = models.CharField(max_le

Re: ManyToOne : cannot form a proper query :(

2009-03-03 Thread [CPR]-AL.exe
Ooops, mean "How", not "Who" ... srry... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send em

Re: ManyToOne : cannot form a proper query :(

2009-03-03 Thread [CPR]-AL.exe
Mean, "two reporters", of course --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to

Re: ManyToOne : cannot form a proper query :(

2009-03-04 Thread [CPR]-AL.exe
Thanks, but i've already read that and there's no answer for my question. In SQL this would be some query with nested joins.. but i don't know how to make this query in django.. On 3 мар, 19:17, Alex Gaynor wrote: > On Tue, Mar 3, 2009 at 11:13 AM, [CPR]-AL.exe wrote: > &g

Re: ManyToOne : cannot form a proper query :(

2009-03-05 Thread [CPR]-AL.exe
So, it seems, that there is no way to do what i want? On 3 мар, 19:17, Alex Gaynor wrote: > On Tue, Mar 3, 2009 at 11:13 AM, [CPR]-AL.exe wrote: > > > for example, i have this models: > > (like here:http://www.djangoproject.com/documentation/

Re: ManyToOne : cannot form a proper query :(

2009-03-09 Thread [CPR]-AL.exe
/en/dev/topics/db/sql/ > > > if needed. > > On Mar 5, 4:25 am, "[CPR]-AL.exe" wrote: > > > So, it seems, that there is no way to do what i want? > > --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: ManyToOne : cannot form a proper query :(

2009-03-09 Thread [CPR]-AL.exe
Oh, nevermind, i figured out how to make nested joins only with q objects! On 9 мар, 17:26, "[CPR]-AL.exe" wrote: > Thanks, but i thought that there's some django-way to do such a > thing... is there a way i can add raw SQL query to Q object? That will > (perhaps) solv

Anyway to render a template without inheritance?

2009-06-22 Thread [CPR]-AL.exe
Hello. Is there any way to render a template, omitting the "extends" tag? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To un

MultiValueField with required=True problem

2009-05-18 Thread [CPR]-AL.exe
Hello there. I've created a field+widget set that i use to render a number of checkboxes and a TextInput with comma-separated values. The problem is, when i set required = True, I get a ValidationError if only checkboxes are selected (but i don't get it if TextInput is filled) Here are the clas

Re: MultiValueField with required=True problem

2009-05-18 Thread [CPR]-AL.exe
class CheckboxSelectWithTextInputWidget(forms.MultiWidget): def __init__(self,choices, attrs=None): widgets = ( forms.CheckboxSelectMultiple(choices = choices), forms.TextInput(), ) super(CheckboxSelectWithTextInputWidget,self).__init__ (widget

Re: MultiValueField with required=True problem

2009-05-19 Thread [CPR]-AL.exe
de, TextInput is required: > > forms.TextInput(), > > > On May 18, 1:15 pm, "[CPR]-AL.exe" wrote: > > class CheckboxSelectWithTextInputWidget(forms.MultiWidget): > > > > def __init__(self,choices, attrs=None): > > > >

Re: MultiValueField with required=True problem

2009-05-19 Thread [CPR]-AL.exe
It is required On 19 май, 08:05, Thierry wrote: > Isn't required the default behaviour of Field: > > http://docs.djangoproject.com/en/dev/ref/forms/fields/ > > From the above code, TextInput is required: > > forms.TextInput(), > > On May 18, 1:15 pm, &q

Re: MultiValueField with required=True problem

2009-05-20 Thread [CPR]-AL.exe
So, what is the best way to throw a ValidationError only if None of values a entered in subclassed field? On 19 май, 23:10, Sam Chuparkoff wrote: > On Mon, 2009-05-18 at 10:13 -0700, [CPR]-AL.exe wrote: > > I've created a field+widget set that i use to render a number of > &

Re: MultiValueField with required=True problem

2009-05-20 Thread [CPR]-AL.exe
I understood that, i just thought there is some nicer way to do it :) Thx. On Wed, May 20, 2009 at 11:52 PM, Sam Chuparkoff wrote: > > On Wed, 2009-05-20 at 07:09 -0700, [CPR]-AL.exe wrote: > > So, what is the best way to throw a ValidationError only if None of > > v

ImageField form validation doesn't work.

2009-05-25 Thread [CPR]-AL.exe
Hello. I have a simple form with only ImageField declared in it and I've got the following problem: when I am trying to upload something that is not am image, i get no errors at all. Form.is_valid() returns True. What should I do to validate the imagedata? --~--~-~--~~

Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Hi there. I'm trying to do something like this: SELECT * FROM table WHERE tablefield IN ( SELECT tablefield FROM table GROUP BY tablefield HAVING (COUNT(tablefield ) > 1) ) Tried it in many ways, but didn't suceed. Is there a way to do it with Django ORM without having to iterate over object

Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
To make it more clear: I have something like a forum and want to find duplicate messages (meaing the message field should be identical) to create a report for the moderator. On 19 янв, 14:02, "[CPR]-AL.exe" wrote: > Hi there. > > I'm trying to do something like this: &

Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
> SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) > 1) > > On Wed, Jan 19, 2011 at 11:02 AM, [CPR]-AL.exe wrote: > >> Hi there. >> >> I'm trying to do something like this: >> >> SELECT * >> FROM table >> WHERE tablefield

Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
there are many cases where a developer will > purposely bypass the ORM at bottlenecks and directly query SQL for > optimization. > > > > > > > > On Wed, Jan 19, 2011 at 11:07 AM, [CPR]-AL.exe wrote: > > Umm... Don't know, actually. That seems, that it would be okay, too

Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
f you need to grab the ORM'd row, just do "row_orm = > model.get(id=iterated_id_here)" > > This is what I tend to do for raw sql queries. > > > > > > > > On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe wrote: > > Hmm, yeah, but that still iterate

Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Wait, wat... o.O I'l try that now, thx. On Wed, Jan 19, 2011 at 2:50 PM, Tom Evans wrote: > On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe > wrote: > > Hmm, yeah, but that still iterates over the objects and filters out > > them by count on the application server,

Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Oh, no, that wouldn't work with CharField. Or, maybe I'm doing something wrong. About a queryset - I mistaken aggregate() for annotate(). On 19 янв, 14:52, "[CPR]-AL.exe" wrote: > Wait, wat... o.O I'l try that now, thx. > > > > > > > > &

Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
ges=Count('message')).filter(num_messages__gt = 1) But results vary with the query in my first statement. Or, maybe i'm not doing it right. On 19 янв, 14:58, "[CPR]-AL.exe" wrote: > Oh, no, that wouldn't work with CharField. Or, maybe I'm doing > something wrong. &g