Re: same code runs on two machines and barfs on the third

2012-02-07 Thread kenneth gonsalves
On Tue, 2012-02-07 at 19:29 +1100, Mike Dewhirst wrote:
> On 7/02/2012 6:14pm, kenneth gonsalves wrote:
> > On Tue, 2012-02-07 at 08:06 +0100, Babatunde Akinyanmi wrote:
> >> Perhaps you made a change to a model and forgot to syncdb on your
> >> Fedora 15 machine.
> >
> 
> When you have eliminated all the possibilities what remains must be
> the 
> problem :)
> 
> The trick is to confirm your assumptions one by one.

code: all three machines are running code pulled from the same repo.
django version: all three are on r 17461
database: the table structure on all three is identical. (in fact two
machines have the same data also). Postgresql versions differ, but this
is a django error - not a database error.
The offending line of code worked fine on the F15 machine when it was
running F14
Altitude: two of the machines are at 7200 feet above sea level, but the
offending machine is at 3400 feet.

>  Ask me how I know. 

how?
-- 
regards
Kenneth Gonsalves

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django (and Python) speakers

2012-02-07 Thread Jeremy Dunck
I'd also like to see Malcolm again, but I fear that'll take a trip to Sydney. :)

On Tue, Feb 7, 2012 at 9:29 PM, Jeremy Dunck  wrote:
> The original musketeers, Jacob, Simon, and Adrian, are all great
> speakers, of course.
>
> I thought Jeff Balough, Mike Malone, and Eric Florenzano did very well
> on their talks.  David Cramer represents Disqus well and has recently
> released Sentry 2.
>
> As a particular pain points for me, I'd like to hear from someone
> using MySQL and Django at scale. Similarly, a walkthrough of how to
> work with celery under evented IO would be useful.
>
> Coverage of puppet (my preference) or Chef would also be interesting.
>
> PyPy deserves attention as well as the general progress towards Python 3.
>
> I'd like to hear Jeff Croft talk about design and open source.
>
> I fear I've given too many topics, but there you go. :)
>
> On Tue, Feb 7, 2012 at 5:00 PM, Steve Holden  wrote:
>> I don't know if readers have heard the news that PyCon has closed
>> registration early because it is full. So you may be interested in six
>> new conferences, three about Python and three about Django, that we
>> have just announced:
>>
>>  http://www.prweb.com/releases/2012/1/prweb8945991.htm
>>
>> With this announcement I would like to solicit suggestions for
>> speakers. Who do you think does an excellent job of covering their
>> material? Whom do you enjoy hearing? Who has information you need. The
>> conferences will be two-day single-track events, and besides having
>> guest speakers we will also be including some talks submitted by the
>> community. So we'll be trying to retain the "community" feel of
>> DjangoCon and PyCon.
>>
>> Amy other ideas for speakers or other activities please get in touch!
>>
>> regards
>>  Steve
>>
>> --
>> 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 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django (and Python) speakers

2012-02-07 Thread Jeremy Dunck
The original musketeers, Jacob, Simon, and Adrian, are all great
speakers, of course.

I thought Jeff Balough, Mike Malone, and Eric Florenzano did very well
on their talks.  David Cramer represents Disqus well and has recently
released Sentry 2.

As a particular pain points for me, I'd like to hear from someone
using MySQL and Django at scale. Similarly, a walkthrough of how to
work with celery under evented IO would be useful.

Coverage of puppet (my preference) or Chef would also be interesting.

PyPy deserves attention as well as the general progress towards Python 3.

I'd like to hear Jeff Croft talk about design and open source.

I fear I've given too many topics, but there you go. :)

On Tue, Feb 7, 2012 at 5:00 PM, Steve Holden  wrote:
> I don't know if readers have heard the news that PyCon has closed
> registration early because it is full. So you may be interested in six
> new conferences, three about Python and three about Django, that we
> have just announced:
>
>  http://www.prweb.com/releases/2012/1/prweb8945991.htm
>
> With this announcement I would like to solicit suggestions for
> speakers. Who do you think does an excellent job of covering their
> material? Whom do you enjoy hearing? Who has information you need. The
> conferences will be two-day single-track events, and besides having
> guest speakers we will also be including some talks submitted by the
> community. So we'll be trying to retain the "community" feel of
> DjangoCon and PyCon.
>
> Amy other ideas for speakers or other activities please get in touch!
>
> regards
>  Steve
>
> --
> 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 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: AssertFieldOutput

2012-02-07 Thread akaariai
On Feb 8, 4:16 am, xina towner  wrote:
> Can anyone explain me exactly how assertFieldOutput works??

For that question there is exactly one answer:
https://code.djangoproject.com/browser/django/trunk/django/test/testcases.py#L362

 - Anssi

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: could i use a select?

2012-02-07 Thread akaariai
On Feb 8, 7:08 am, Vittorino Parenti 
wrote:
> Hi,
> I've an Invoice Model:
>
> class Invoice(models.Model):
>     ...
>     number = models.IntegerField(...)
>     customer = models.ForeignKey()
>     date_invoice = ...
>     total_invoice = ...
>     ...
>
> To have the top ten customer can i do?
> I have to use a select:
>
> SELECT SUM(total_invoice) AS total FROM invoice_invoice GROUP BY
> customer ORDER BY total DESC
>
> or can I use django methods? How?

I think you could do
Customer.objects.annotate(tot_invoice=Sum(invoice_set__total_invoice)).order_by('tot_invoice')
[0:10].

 - Anssi

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



could i use a select?

2012-02-07 Thread Vittorino Parenti
Hi,
I've an Invoice Model:

class Invoice(models.Model):
...
number = models.IntegerField(...)
customer = models.ForeignKey()
date_invoice = ...
total_invoice = ...
...

To have the top ten customer can i do?
I have to use a select:

SELECT SUM(total_invoice) AS total FROM invoice_invoice GROUP BY
customer ORDER BY total DESC

or can I use django methods? How?

Thanks,
Vittorino.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can prefetch_related() look up reverse relationship?

2012-02-07 Thread James DeMichele
That's awesome, thanks for sharing!

-Jamie

On Tue, Feb 7, 2012 at 7:55 AM, Jonathanz  wrote:

> I found it! The correct query shoud be
>
> Book.objects.all().prefetch_related('price_set')
>
>
> On Feb 7, 5:38 pm, Jonathanz  wrote:
> > I'm using django1.4 from svn trunk.
> > The models are as follows:
> >
> > class Book(models.Model):
> > # some stuff
> >
> > class Price(models.Model):
> > book = models.ForgeinKey(Book)
> >
> > Each book can have many prices.
> >
> > My query in view:
> > Book.objects.all().prefetch_related('price')
> >
> > I got this error:
> > Cannot find 'price' on Book object, 'price' is an invalid parameter to
> > prefetch_related()
> >
> > Am I missing something? or prefetch_related cannot handle reverse
> > lookup.
> >
> > Thanks in advance.
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



AssertFieldOutput

2012-02-07 Thread xina towner
Can anyone explain me exactly how assertFieldOutput works??

-- 
Gràcies,

Rubén

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about QuerySet

2012-02-07 Thread newme
thank you so much.

On Feb 7, 8:58 pm, Daniel Roseman  wrote:
> On Tuesday, 7 February 2012 11:36:04 UTC, newme wrote:
>
> > thank you.
> > then a basic python question.
> > how does queryset implement it?
> > does python also allow operator (e.g. []) overloading?
>
> It's not usually called overloading in Python, but yes. Classes can define
> a `__getitem__` method which determines what to do when the square-bracket
> notation is used. You can see the code 
> here:https://code.djangoproject.com/browser/django/trunk/django/db/models/...
> --
> DR.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django (and Python) speakers

2012-02-07 Thread Steve Holden
I don't know if readers have heard the news that PyCon has closed
registration early because it is full. So you may be interested in six
new conferences, three about Python and three about Django, that we
have just announced:

  http://www.prweb.com/releases/2012/1/prweb8945991.htm

With this announcement I would like to solicit suggestions for
speakers. Who do you think does an excellent job of covering their
material? Whom do you enjoy hearing? Who has information you need. The
conferences will be two-day single-track events, and besides having
guest speakers we will also be including some talks submitted by the
community. So we'll be trying to retain the "community" feel of
DjangoCon and PyCon.

Amy other ideas for speakers or other activities please get in touch!

regards
 Steve

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: field of tuples

2012-02-07 Thread akaariai
On Feb 7, 11:44 am, Jaroslav Dobrek  wrote:
> Hello,
>
> how can I create a field that contains tuples of entities? An example:
> A model "Candidate" (someone who applies for a job) might have a field
> "languages" which is a list of tuples consisting of a language and a
> proficiency level.

As others have said: don't. If you ever need to do any DB queries
involving the proficiencies of the candidates (like "how many
candidates we have who are proficient in English") you are screwed.

You will most likely get what you want with:
class CandidateLangProficiency(models.Model):
 candidate = models.ForeignKey(Candidate,
related_name='proficiencies')
 lang = models.CharField(max_length=2, choices=(('fi',
'Finnish'), ...) # Or a foreign key.
 proficiency = models.IntegerField(choices=...)
 class Meta:
 unique_together = ('candidate', 'lang')

If you can use Django 1.4, its prefetch_related will be your friend.

If you really know what you are doing you can write a custom model
field. Django's documentation should contain examples of that.

 - Anssi

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Models inheritance in django: how to change PK "_ptr_id" on "id"?

2012-02-07 Thread akaariai
On Feb 7, 8:26 pm, Artyom Chernetzov  wrote:
> Here is model structure: Client is User, Client can be corporate or person:
>
>     class Client(User):
>         #fields
>
>     class ClientCorporate(Client):
>         #fields
>
>     class ClientPerson(Client):
>         #fields
>
> And client can make orders:
>
>     class Order(models.Model):
>         client=models.ForeignKey(Client)
>         #fields
>
> I try to create common orders list for any type of client, here is view:
>
>     def orders_list(request):
>         client=request.user.client
>         return list_detail.object_list(request,
>             queryset = client.order_set.all(),
>             #templates ...
>             )
>
> And it leads to an error:
>
> **DatabaseError while rendering: no such column: cabinets_order.client_id**
>
> I browse db and find that all User childs have column "user_prt_id". I
> can't find way to change pk name in inherited models. But maybe there is
> some better approach?

Use OneToOneField with parent_link = True, then you can change the
name of the db field. See:
https://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Generic relationships between existing entities, many2many

2012-02-07 Thread akaariai
A pretty good way to do this is using custom hand-written generic
foreign key. You basically need fields "type" (which can be just a
string) and the related object's id. And then implement everything
needed by yourself.

Whatever you do you will have problems. There is no way to get all the
different Tags in a single query (or well, there is always a way but
that query is going to be ugly). So, if you have multiple different
tag types for single object, you are going to need to run multiple
queries to actually fetch the tags. I guess what I am saying here is
that consider once again if you could change your requirements to
something that fits SQL databases better.

Having multiple m2m tables for the relations isn't a bad choice
either. You will need to run multiple queries in any case, and it
seems you will also need to handle the tags differently in your code.
This will most likely perform much better than using generic relations
based approach. Even if you can't touch the models, you can fake this
by a model which has just two foreign keys.

Anyways, using Django's generic foreign keys isn't always the best
solution. It usually doesn't work well if you need to travel the
foreign key in the wrong direction: if you need to get all the log
entries for an object, then using foreign key works. If you need to
fetch all objects having a given log entry (m2m reverse relation), it
just doesn't work well.

 - Anssi

On Feb 7, 9:11 pm, "arkai...@gmail.com"  wrote:
> Hi,
>
> So, I have the 4 entities represented below which are strong and
> independent entities on my application, now the problem is that each
> Article or Picture could be "tagged" with a Presenter or an Event, being as
> they are the 4 of them independent entities that could become more complex
> It doesn't look right to add Event and Presenter field to both Article and
> Picture or the contrary, specially because they could be tagged with none.
> In the long run as well other entities might need to be tagged and other
> taggable entities might appear.
>
> > class Article(models.Model):
>
> >     #Fields
> > class Picture(models.Model):
>
> >     #Fields
> > class Presenter(models.Model):
>
> >     # Fields
> > class Event(models.Model):
>
> >     # Fields
>
> > The closer I am getting is to some kind of double-headed Generic
>
> contenttype based intermediate model like this(haven't tested yet as it is
> a bit more complex than that), but I am looking for ideas:
>
> > class GenericTag(models.Model):
>
> >     # Event,Presenter instance..
> >     tagcontent_type = models.ForeignKey(ContentType)
>
> >     tagobject_id = models.PositiveIntegerField()
> >     tagcontent_object = generic.GenericForeignKey('tagcontent_type', 
> > 'tagobject_id')
>
> >     # Picture,Article instance
> >     objcontent_type = models.ForeignKey(ContentType)
>
> >     objobject_id = models.PositiveIntegerField()
> >     objcontent_object = generic.GenericForeignKey('objcontent_type', 
> > 'objobject_id')
>
> > And with that just do queries based on the information I have, I think
>
> there have to be more elegant ways to do this without stuffing all
> tagmodels as fields into taggablemodels.
> So, basically, there are several "taggable" objects and "tag" objects which
> will never overlap and I would like a way of relating them with django
> without touching the models themselves as they are entities of their own
> apps.
>
> I was looking into a proxy model with a many2many field, but cannot add
> fields to proxy models.
>
> Thanks
>
> --
> Arkaitz

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: number input format

2012-02-07 Thread akaariai
On Feb 7, 9:48 pm, Vittorino Parenti 
wrote:
> I know but doesn't work. maybe it's my problem. In input form I see
> '.'.
> Thanks,
> Vittorino.

If I remember correctly, you must also have localize=True for your
form fields. Maybe with correct settings.py this happens
automatically. As said, I don't remember. For more info, see:
https://docs.djangoproject.com/en/dev/topics/i18n/formatting/#locale-aware-input-in-forms

 - Anssi

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



list_editable raising a MultiValueDictKeyError

2012-02-07 Thread Nick
Whenever I use list_editable inside of the django admin attempting to
save the data results in

Exception Type: MultiValueDictKeyError
Exception Value:"Key 'form-0-id' not found in 

Whenever I create custom forms I simply add in the form-0 inputs as a
hidden field. How do I work around this in the admin?

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: number input format

2012-02-07 Thread Vittorino Parenti
I know but doesn't work. maybe it's my problem. In input form I see
'.'.
Thanks,
Vittorino.

On 7 Feb, 12:01, Denis Darii  wrote:
> from the django's global_settings:
>
> # Decimal separator symbol
> DECIMAL_SEPARATOR = '.'
>
> # Boolean that sets whether to add thousand separator when formatting
> numbers
> USE_THOUSAND_SEPARATOR = False
>
> # Number of digits that will be together, when spliting them by
> # THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
> NUMBER_GROUPING = 0
>
> # Thousand separator symbol
> THOUSAND_SEPARATOR = ','
>
> On Tue, Feb 7, 2012 at 11:56 AM, Vittorino Parenti <
>
>
>
>
>
> vpare...@thundersystems.it> wrote:
> > Hi,
> > I saw there is this setting DATE_INPUT_FORMATS for date.
> > Is there a similar solution for the numbers?
> > Thanks,
> > Vittorino.
>
> > --
> > 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
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> This e-mail and any file transmitted with it is intended only for the
> person or entity to which is addressed and may contain information that is
> privileged, confidential or otherwise protected from disclosure. Copying,
> dissemination or use of this e-mail or the information herein by anyone
> other than the intended recipient is prohibited. If you are not the
> intended recipient, please notify the sender immediately by return e-mail,
> delete this communication and destroy all copies.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Models inheritance in django: how to change PK "_ptr_id" on "id"?

2012-02-07 Thread Andre Terra
I just read your e-mail quick and somewhat carelessly, so forgive me if I'm
missing something.


Here's a list of things for you to check:

* Have you defined your Client model with abstract = True in its Meta
options?[1]
* Have you syncdb'd[2]?
* If you must name your pk something else, just follow the docs[3]

[1] http://django.me/abstract-base-classes
[2] http://django.me/syncdb
[3] http://django.me/automatic-primary-key-fields


Cheers,
AT


On Tue, Feb 7, 2012 at 4:26 PM, Artyom Chernetzov wrote:

> Here is model structure: Client is User, Client can be corporate or person:
>
> class Client(User):
> #fields
>
> class ClientCorporate(Client):
> #fields
>
>
> class ClientPerson(Client):
> #fields
>
> And client can make orders:
>
> class Order(models.Model):
> client=models.ForeignKey(Client)
> #fields
>
> I try to create common orders list for any type of client, here is view:
>
> def orders_list(request):
> client=request.user.client
> return list_detail.object_list(request,
> queryset = client.order_set.all(),
> #templates ...
> )
>
> And it leads to an error:
>
> **DatabaseError while rendering: no such column: cabinets_order.client_id**
>
> I browse db and find that all User childs have column "user_prt_id". I
> can't find way to change pk name in inherited models. But maybe there is
> some better approach?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/RrPQgVp3R2EJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Models inheritance in django: how to change PK "_ptr_id" on "id"?

2012-02-07 Thread Artyom Chernetzov
Here is model structure: Client is User, Client can be corporate or person:

class Client(User):
#fields
  
class ClientCorporate(Client):
#fields


class ClientPerson(Client):
#fields

And client can make orders:

class Order(models.Model):
client=models.ForeignKey(Client)
#fields

I try to create common orders list for any type of client, here is view:

def orders_list(request):
client=request.user.client
return list_detail.object_list(request,
queryset = client.order_set.all(),
#templates ...
)

And it leads to an error:

**DatabaseError while rendering: no such column: cabinets_order.client_id**

I browse db and find that all User childs have column "user_prt_id". I 
can't find way to change pk name in inherited models. But maybe there is 
some better approach?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/RrPQgVp3R2EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can prefetch_related() look up reverse relationship?

2012-02-07 Thread Jonathanz
I found it! The correct query shoud be

Book.objects.all().prefetch_related('price_set')


On Feb 7, 5:38 pm, Jonathanz  wrote:
> I'm using django1.4 from svn trunk.
> The models are as follows:
>
> class Book(models.Model):
>     # some stuff
>
> class Price(models.Model):
>     book = models.ForgeinKey(Book)
>
> Each book can have many prices.
>
> My query in view:
> Book.objects.all().prefetch_related('price')
>
> I got this error:
> Cannot find 'price' on Book object, 'price' is an invalid parameter to
> prefetch_related()
>
> Am I missing something? or prefetch_related cannot handle reverse
> lookup.
>
> Thanks in advance.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



forwarding a email

2012-02-07 Thread kalyani ram
Hello,

I am set up an email system with sending and receiving email and
replying to the received email. But to add a forward email feature is
complicating my work, as the content of the mail should be appended.
can someone help me in doing the task.
I want to forward an email just like it is done on gmail.
Thanks in advance.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Can prefetch_related() look up reverse relationship?

2012-02-07 Thread Jonathanz
I'm using django1.4 from svn trunk.
The models are as follows:

class Book(models.Model):
# some stuff

class Price(models.Model):
book = models.ForgeinKey(Book)

Each book can have many prices.

My query in view:
Book.objects.all().prefetch_related('price')

I got this error:
Cannot find 'price' on Book object, 'price' is an invalid parameter to
prefetch_related()

Am I missing something? or prefetch_related cannot handle reverse
lookup.

Thanks in advance.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about QuerySet

2012-02-07 Thread Daniel Roseman
On Tuesday, 7 February 2012 11:36:04 UTC, newme wrote:
>
> thank you. 
> then a basic python question. 
> how does queryset implement it? 
> does python also allow operator (e.g. []) overloading? 
>
>
It's not usually called overloading in Python, but yes. Classes can define 
a `__getitem__` method which determines what to do when the square-bracket 
notation is used. You can see the code here:
https://code.djangoproject.com/browser/django/trunk/django/db/models/query.py#L165
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rP7anxInSBkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Somebody please attend to me

2012-02-07 Thread coded kid
What I really mean is that I want users to post update and make other
users comment on them in django site. Not to Facebook.

On Feb 7, 12:24 pm, coded kid  wrote:
> The first link take me to google page. Is that the post?
>
> On Feb 7, 11:22 am, coded kid  wrote:
>
>
>
>
>
>
>
> > Thanks so much kelly! You rock. Will give it a try!
>
> > On Feb 7, 4:18 am, Kelly Nicholes  wrote:
>
> > > This is link holds the PERFECT answer for you:http://bit.ly/wc0psc
>
> > > If you want to do it differently, try:
>
> > > First you'll have to send an XMLHttpRequest (jQuery post() or get())
> > > to your server to post a form (create a modelform with a "Comment"
> > > model with all of the required fields.  You might want to look into
> > > generic content types for django models).  Save the comment out
> > > (associate it with the user from the request) in your view.  Then add
> > > a link to do a comment (if you want you can do fancy html5 stuff with
> > > the "editable" property on some div).  The click the link, dynamically
> > > (use jquery) to show another form (or create it if you'd like).  When
> > > they submit the friend comment, associate that friend comment with the
> > > original comment (you could parse this out of the ID attribute that
> > > you could set on the original comment) and save it just as you did the
> > > first...  Or just look for premade things...
>
> > > You could look into django's built-in comment 
> > > systemhttps://docs.djangoproject.com/en/1.2/ref/contrib/comments/example/
> > > Here's one called 
> > > django-facebook-commentshttps://bitbucket.org/sirpengi/django-facebook-comments
>
> > > On Jan 23, 4:38 am, coded kid  wrote:
>
> > > >  Please how can I get user post update, make their friends comment and
> > > > share the update in django? Just like the way FB update is. I hope you
> > > > get my point?  Thanks so much

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: No Module named URLS

2012-02-07 Thread coded kid
Thank so much! I've figured it out. Have fun :)

On Feb 6, 8:55 pm, Sandro Dutra  wrote:
> If I understand you're writing a template for admin, and this is not
> required 'cause the admin template is called by the contrib
> 'django.contrib.admin', in INSTALLED_APPS (settings file), only if you
> want to customize admin, you can override the admin files, putting
> them o 'yourtemplatesdir/admin/', and I think this is not the case.
>
> The only required steps to see the admin page is:
> 1. Check if 'django.contrib.admin' is uncommented in 'settings.py';
> 2. Uncomment the required lines in file 'urls.py';
> 3. Launch the dev server and acess localhost/admin/.
>
> Only this, nothing more...
>
> Templates.py? Templates can have any extension, this is true, but
> usually we put .html or .htm...
>
> 2012/2/6 akaariai :
>
>
>
>
>
>
>
> > On Feb 6, 5:09 pm, coded kid  wrote:
> >> Hey guys, I’m getting an error when trying to visit my admin page:
> >> TemplateSyntaxError at /admin/
> >> Caught ImportError while rendering: No module named urls
>
> >> In urls.py
> >> from django.conf.urls.defaults import patterns, include, url
> >> from django.contrib import admin
> >> admin.autodiscover()
>
> >> urlpatterns = patterns('',
> >> (r'^admin/',include(admin.site.urls)),
> >> )
>
> >> In Template.py
>
> >>    
> >> {% block branding %}{% endblock %}
> >>   {% if user.is_active and user.is_staff %}
> >>    {% trans 'Welcome,' %}  {% filter
> >> force_escape %}{% firstof user.first_name user.username %}{% endfilter
> >> %}.
> >>  {% block userlinks %} {% url 'django-admindocs-docroot' as docsroot
> >> %}  {% if docsroot %}  {% trans
> >> 'Documentation' %} {% endif %}  {% url 'admin:password_change' as
> >> password_change_url %}  {% if password_change_url %} 37  >> href="{{ password_change_url }}">  {% else %}   40 {% endif %} 41 {% trans 'Change password' %} >> a> /
>
> >> What do you think is the problem! I’ve been fighting with this for the
> >> pas 15hrs yet no success. Kindly help me out!
>
> > I don't spot any immediate reason for your problem. Some more
> > information is needed. A full stacktrace is always really good if you
> > happen to get one. Maybe the problem is in your admin.py. As said, it
> > is hard to say without more information.
>
> >  - Anssi
>
> > --
> > 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 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about QuerySet

2012-02-07 Thread newme
thank you.
then a basic python question.
how does queryset implement it?
does python also allow operator (e.g. []) overloading?

On Feb 3, 5:29 pm, akaariai  wrote:
> On Feb 3, 5:52 am, newme  wrote:
>
> > so it means when i call user[1] after user[0], it is possible that i
> > will get same record if someone else insert a new record into database
> > between 2 calls.
>
> Actually, there doesn't need to be an insert between the calls if you
> don't use .order_by(). Technically, without an ORDER BY the database
> is free to return the records in any order it wishes, even if there
> are no inserts in between.
>
> I think you really should fetch all the needed objects in one go. That
> is the correct way to do what you need. And in addition it is more
> efficient.
>
>  - Anssi

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Somebody please attend to me

2012-02-07 Thread coded kid
The first link take me to google page. Is that the post?

On Feb 7, 11:22 am, coded kid  wrote:
> Thanks so much kelly! You rock. Will give it a try!
>
> On Feb 7, 4:18 am, Kelly Nicholes  wrote:
>
>
>
> > This is link holds the PERFECT answer for you:http://bit.ly/wc0psc
>
> > If you want to do it differently, try:
>
> > First you'll have to send an XMLHttpRequest (jQuery post() or get())
> > to your server to post a form (create a modelform with a "Comment"
> > model with all of the required fields.  You might want to look into
> > generic content types for django models).  Save the comment out
> > (associate it with the user from the request) in your view.  Then add
> > a link to do a comment (if you want you can do fancy html5 stuff with
> > the "editable" property on some div).  The click the link, dynamically
> > (use jquery) to show another form (or create it if you'd like).  When
> > they submit the friend comment, associate that friend comment with the
> > original comment (you could parse this out of the ID attribute that
> > you could set on the original comment) and save it just as you did the
> > first...  Or just look for premade things...
>
> > You could look into django's built-in comment 
> > systemhttps://docs.djangoproject.com/en/1.2/ref/contrib/comments/example/
> > Here's one called 
> > django-facebook-commentshttps://bitbucket.org/sirpengi/django-facebook-comments
>
> > On Jan 23, 4:38 am, coded kid  wrote:
>
> > >  Please how can I get user post update, make their friends comment and
> > > share the update in django? Just like the way FB update is. I hope you
> > > get my point?  Thanks so much

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Somebody please attend to me

2012-02-07 Thread coded kid

Thanks so much kelly! You rock. Will give it a try!

On Feb 7, 4:18 am, Kelly Nicholes  wrote:
> This is link holds the PERFECT answer for you:http://bit.ly/wc0psc
>
> If you want to do it differently, try:
>
> First you'll have to send an XMLHttpRequest (jQuery post() or get())
> to your server to post a form (create a modelform with a "Comment"
> model with all of the required fields.  You might want to look into
> generic content types for django models).  Save the comment out
> (associate it with the user from the request) in your view.  Then add
> a link to do a comment (if you want you can do fancy html5 stuff with
> the "editable" property on some div).  The click the link, dynamically
> (use jquery) to show another form (or create it if you'd like).  When
> they submit the friend comment, associate that friend comment with the
> original comment (you could parse this out of the ID attribute that
> you could set on the original comment) and save it just as you did the
> first...  Or just look for premade things...
>
> You could look into django's built-in comment 
> systemhttps://docs.djangoproject.com/en/1.2/ref/contrib/comments/example/
> Here's one called 
> django-facebook-commentshttps://bitbucket.org/sirpengi/django-facebook-comments
>
> On Jan 23, 4:38 am, coded kid  wrote:
>
>
>
> >  Please how can I get user post update, make their friends comment and
> > share the update in django? Just like the way FB update is. I hope you
> > get my point?  Thanks so much

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: field of tuples

2012-02-07 Thread Sam Basl
Wouldn't it be better to do this sort of thing with a related model?
On Feb 7, 2012 4:44 AM, "Jaroslav Dobrek"  wrote:

> Hello,
>
> how can I create a field that contains tuples of entities? An example:
> A model "Candidate" (someone who applies for a job) might have a field
> "languages" which is a list of tuples consisting of a language and a
> proficiency level.
>
> Jaroslav
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: number input format

2012-02-07 Thread Denis Darii
from the django's global_settings:

# Decimal separator symbol
DECIMAL_SEPARATOR = '.'

# Boolean that sets whether to add thousand separator when formatting
numbers
USE_THOUSAND_SEPARATOR = False

# Number of digits that will be together, when spliting them by
# THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
NUMBER_GROUPING = 0

# Thousand separator symbol
THOUSAND_SEPARATOR = ','

On Tue, Feb 7, 2012 at 11:56 AM, Vittorino Parenti <
vpare...@thundersystems.it> wrote:

> Hi,
> I saw there is this setting DATE_INPUT_FORMATS for date.
> Is there a similar solution for the numbers?
> Thanks,
> Vittorino.
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



number input format

2012-02-07 Thread Vittorino Parenti
Hi,
I saw there is this setting DATE_INPUT_FORMATS for date.
Is there a similar solution for the numbers?
Thanks,
Vittorino.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



field of tuples

2012-02-07 Thread Jaroslav Dobrek
Hello,

how can I create a field that contains tuples of entities? An example:
A model "Candidate" (someone who applies for a job) might have a field
"languages" which is a list of tuples consisting of a language and a
proficiency level.

Jaroslav

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: same code runs on two machines and barfs on the third

2012-02-07 Thread Mike Dewhirst

On 7/02/2012 6:14pm, kenneth gonsalves wrote:

On Tue, 2012-02-07 at 08:06 +0100, Babatunde Akinyanmi wrote:

Perhaps you made a change to a model and forgot to syncdb on your
Fedora 15 machine.




When you have eliminated all the possibilities what remains must be the 
problem :)


The trick is to confirm your assumptions one by one. Ask me how I know.

Good luck

Mike

--
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.