Re: Profiling Django (WAS Django database-api)

2012-04-04 Thread Javier Guerra Giraldez
On Wed, Apr 4, 2012 at 4:07 AM, Tom Evans wrote: > One pretty cool method I've used for live debugging in the past is to > 'log' to rabbitmq (Note - not celery - raw amqp), and send messages to > a logging exchange. You can use a topic key so that different > processes can be distinguished. a sim

Re: Profiling Django (WAS Django database-api)

2012-04-04 Thread Tom Evans
On Tue, Apr 3, 2012 at 11:25 PM, Andre Terra wrote: > Hey Javier, > > Thanks for the reply. My problem with the logs in the past was that they > tended to make the task even slower (due to recursion) but I guess that's > probably because I didn't call the logging from the appropriate places in > t

Re: Profiling Django (WAS Django database-api)

2012-04-03 Thread Javier Guerra Giraldez
On Tue, Apr 3, 2012 at 5:25 PM, Andre Terra wrote: > To make things a little more complicated, the task involves writing a large > amount of data to a temp database, handling it and then saving some > resulting queries to the permanent DB. This makes it a tad harder to analyze > what goes on in th

Re: Profiling Django (WAS Django database-api)

2012-04-03 Thread Andre Terra
Hey Javier, Thanks for the reply. My problem with the logs in the past was that they tended to make the task even slower (due to recursion) but I guess that's probably because I didn't call the logging from the appropriate places in the code. To make things a little more complicated, the task inv

Re: Profiling Django (WAS Django database-api)

2012-04-03 Thread Javier Guerra Giraldez
On Tue, Apr 3, 2012 at 8:21 AM, Andre Terra wrote: > I have some complex and database intensive asynchronous tasks running under > celery which take a LONG time to complete and I'd just love to be able to > keep track of the queries they generate in order to optimize and possibly > remove the bigg

Profiling Django (WAS Django database-api)

2012-04-03 Thread Andre Terra
While I know of the two methods mentioned by Anssi, I've often wondered how to profile my code from a project level. I have some complex and database intensive asynchronous tasks running under celery which take a LONG time to complete and I'd just love to be able to keep track of the queries they

Re: Django database-api

2012-04-03 Thread KasunLak
(edit existing methods, add new methods..) the generated database api it would be good. Thanks again, Kasun On Apr 3, 1:41 pm, akaariai wrote: > On Apr 3, 11:27 am, KasunLak wrote: > > > Hi, > > > No, sorry for not giving more details. What I am asking is once we > > syn

Re: Django database-api

2012-04-03 Thread akaariai
On Apr 3, 11:27 am, KasunLak wrote: > Hi, > > No, sorry for not giving more details. What I am asking is once we > syncdb the generated scripts (create table). Can we see the method > implementation of database access api? > > For example: If we have created and deployed a model called Poll > (tut

Re: Django database-api

2012-04-03 Thread KasunLak
; python manage.py sql APPNAME > > > > > > > > On Tue, Apr 3, 2012 at 8:45 AM, KasunLak wrote: > > Hi all, > > > I just wonder is there a way to browse/view the code of database api > > methods generated? Is there any tool for this? > > > Thanks

Re: Django database-api

2012-04-03 Thread Eugenio Minardi
Hi, Do you mean the SQL generated by your model? In this case you can use python manage.py sql APPNAME On Tue, Apr 3, 2012 at 8:45 AM, KasunLak wrote: > Hi all, > > I just wonder is there a way to browse/view the code of database api > methods generated? Is there any t

Django database-api

2012-04-02 Thread KasunLak
Hi all, I just wonder is there a way to browse/view the code of database api methods generated? Is there any tool for this? Thanks in advance, Kasun -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: Smaller Than in Django database API

2010-10-11 Thread Jonathan Barratt
Ah, most enlightening and makes perfect sense, thanks Tom! ? 11 ?.?. 2553 21:45 Tom Evans ?: > 2010/10/11 Jonathan Barratt : >> On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote: >> Note also that, AFAIK, multiple where criteria are accomplished by chaining >> filters rather than

Re: Smaller Than in Django database API

2010-10-11 Thread Sithembewena Lloyd Dube
@Jonathan, thanks. That does the trick. @Tom, thanks for bringing the subtle, yet important, difference between the two forms of that expression to my attention. 2010/10/11 Tom Evans > 2010/10/11 Jonathan Barratt : > > On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote: > > Note also that

Re: Smaller Than in Django database API

2010-10-11 Thread Tom Evans
2010/10/11 Jonathan Barratt : > On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote: > Note also that, AFAIK, multiple where criteria are accomplished by chaining > filters rather than providing them as a list to one filter call. > But I am new to Django myself, so if anyone corrects this advi

Re: Smaller Than in Django database API

2010-10-11 Thread Jonathan Barratt
On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote: > Hi all, > > How does one filer objects by "smaller than" criteria in the data access API? > For example, in the following line: I believe it's by appending the field name with _lte > MySite.objects.filter(rank < 11, display_on_site =

Smaller Than in Django database API

2010-10-11 Thread Sithembewena Lloyd Dube
Hi all, How does one filer objects by "smaller than" criteria in the data access API? For example, in the following line: MySite.objects.filter(*rank < 11*, display_on_site = 1).order_by('rank') - how would one handle the highlighted criterion? Thanks. -- Regards, Sithembewena Lloyd Dube http:

Django Database API in standalone mode

2010-05-09 Thread Ozgur Yılmaz
Hi everybody, I'm writing an open source asset,resource and project manager for animation and vfx studios. And I want to use Django's database api to handle all the db stuff. In my system every project is going to have its own database (probably sqlite3 files in project root folder).

Re: database API from external tools?

2008-10-31 Thread megrez80
database? I'm hoping to have the Django app > >>>> sitting on the web server, with the source tree inaccessible to a bunch > >>>> of workstations. ... > > >>> If you just want the Django database API, then put the Django code > >>> (i.e., django.

Re: database API from external tools?

2008-10-27 Thread Andrew Chapman
James Bennett wrote: On Sun, Oct 26, 2008 at 9:19 PM, Steve Holden <[EMAIL PROTECTED]> wrote: Here's a specific example of a piece of code that uses a web app's models. It should get you started - just dive in and write some code! The tricky bit is providing the settings without u

Re: database API from external tools?

2008-10-26 Thread James Bennett
On Sun, Oct 26, 2008 at 9:19 PM, Steve Holden <[EMAIL PROTECTED]> wrote: > Here's a specific example of a piece of code that uses a web app's > models. It should get you started - just dive in and write some code! > The tricky bit is providing the settings without using a "settings" > module. I ca

Re: database API from external tools?

2008-10-26 Thread Steve Holden
>>>> My question is how to package up and deploy the Django python code for >>>> external tools to access the database? I'm hoping to have the Django app >>>> sitting on the web server, with the source tree inaccessible to a bunch >>>> of w

Re: database API from external tools?

2008-10-26 Thread Russell Keith-Magee
de for >>> external tools to access the database? I'm hoping to have the Django app >>> sitting on the web server, with the source tree inaccessible to a bunch >>> of workstations. ... >> If you just want the Django database API, then put the Django code >>

Re: database API from external tools?

2008-10-26 Thread Andrew Chapman
sitting on the web server, with the source tree inaccessible to a bunch >> of workstations. ... > If you just want the Django database API, then put the Django code > (i.e., django.*) on the workstations, and just write your tools to > import that code, setting up DJANGO_SETTINGS_M

Re: database API from external tools?

2008-10-25 Thread Russell Keith-Magee
> looking at Django is because I also need python access to all the same > data that the web app is dealing with. The Django database API seems > great, but I can only easily run it on the web app server. I'm not sure why you think this. The Django database API is just a bunch of Python

database API from external tools?

2008-10-24 Thread Andrew Chapman
jango database API seems great, but I can only easily run it on the web app server. My question is how to package up and deploy the Django python code for external tools to access the database? I'm hoping to have the Django app sitting on the web server, with the source tree inaccessible

Re: Custom SQL or database API?

2008-09-02 Thread janedenone
On 2 Sep., 23:14, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-09-02 at 13:12 -0700,janedenonewrote: > > Hi, > > > I am in the process of moving my handmade website to a Django-based > > version. One of my SQL queries returns all articles by a certain > > author if this article is

Re: Custom SQL or database API?

2008-09-02 Thread Malcolm Tredinnick
On Tue, 2008-09-02 at 13:12 -0700, janedenone wrote: > Hi, > > I am in the process of moving my handmade website to a Django-based > version. One of my SQL queries returns all articles by a certain > author if this article is not a chapter or section of an article by > the same author: > > SELE

Custom SQL or database API?

2008-09-02 Thread janedenone
FROM pages, pages AS motherpages WHERE motherpages.page_id = pages.mother_id AND pages.author_id = 1234 AND pages.author_id <> motherpages.author_id Is it possible to do this with the Django database API, or do I need to retreat to custom SQL? Kind regard

Re: convenient method of getting related objects with the database API?

2008-08-26 Thread Karen Tracey
On Tue, Aug 26, 2008 at 4:41 PM, Andrew D. Ball <[EMAIL PROTECTED]>wrote: > > Is there a convenient way to get all objects related to > a given model instance? I want to check for objects > that would be deleted with a cascading delete before > actually performing a deletion. > The admin does th

convenient method of getting related objects with the database API?

2008-08-26 Thread Andrew D. Ball
Is there a convenient way to get all objects related to a given model instance? I want to check for objects that would be deleted with a cascading delete before actually performing a deletion. Peace, Andrew -- === Andrew D. Ball [EMAIL PROTECTED] Software Enginee

Re: Basic database API questions

2008-06-14 Thread Russell Keith-Magee
On Sat, Jun 14, 2008 at 8:26 PM, LB <[EMAIL PROTECTED]> wrote: > > Thanks for the fast replies ! No problems. > So I think I only have three options now : > > 1) change my model and replace the naissance field with three fields > corresponding to birth day, birth month and birth year. This is

Re: Basic database API questions

2008-06-14 Thread LB
Thanks for the fast replies ! > So - what you were trying to do was combine the `month` and `gt` > operators - you can't do that. Django interpreted your query as 'join > the Contact with the naissance table, and check that the month > attribute is greater than 5'. Obviously, this doens't work be

Re: Basic database API questions

2008-06-14 Thread Russell Keith-Magee
On Sat, Jun 14, 2008 at 7:36 PM, LB <[EMAIL PROTECTED]> wrote: > > Thanks, > > Another question : > > why does > anniv = Contact.objects.filter(naissance__month=5) > works > > and > anniv = Contact.objects.filter(naissance__month__gt=5) > raise this exception : > : Join on field 'naissance' > not

Re: Basic database API questions

2008-06-14 Thread LB
Thanks, Another question : why does anniv = Contact.objects.filter(naissance__month=5) works and anniv = Contact.objects.filter(naissance__month__gt=5) raise this exception : : Join on field 'naissance' not permitted. --~--~-~--~~~---~--~~ You received this mess

Re: Basic database API questions

2008-06-14 Thread Russell Keith-Magee
On Sat, Jun 14, 2008 at 6:56 PM, LB <[EMAIL PROTECTED]> wrote: > > 1 ) how to get all contacts with a known birthday ? I tried : > > m = Contact.objects.filter(naissance__is_null=False) > but I got the following exception : > : Join on field 'naissance' > not permitted. You are close - but with

Basic database API questions

2008-06-14 Thread LB
Hi, I'm new to django and also new to databases. I'm trying to make a simple contact editor. So I created the following model : class Contact(models.Model): nom_famille = models.CharField("nom de famille", max_length=30) # french for last name prenom = models.CharField("prénom",

Re: Database API reference:

2008-04-02 Thread Jaap
Aaah, I missed another dict... Thanks for setting it right. --~--~-~--~~~---~--~~ 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

Re: Database API reference:

2008-04-02 Thread Collin Grady
You forgot to use person in front of the values of course, since they're still attributes of that dict :) So instead of pnr which is just printing static text "pnr", you need to do {{ person.pnr }} just like every other variable access :) --~--~-~--~~~---~--~~ You

Re: Database API reference:

2008-04-02 Thread Daniel Roseman
On Apr 2, 7:08 pm, Jaap <[EMAIL PROTECTED]> wrote: > Still Greek to me... So far I did it like this: > > [view] > def start(request): > group = Staff.objects.values('pnr', 'last_name') > return render_to_response('tlist.html', group) > > [template] > > {% for person in group %} > >

Re: Database API reference:

2008-04-02 Thread Jaap
Still Greek to me... So far I did it like this: [view] def start(request): group = Staff.objects.values('pnr', 'last_name') return render_to_response('tlist.html', group) [template] {% for person in group %} pnr last_name {% endfor %} Where did I go wrong?

Re: Database API reference:

2008-04-02 Thread [EMAIL PROTECTED]
In [3]: Page.objects.values('id', 'title') Out[3]: [{'id': 1, 'title': u'This is a test page'}] In [4]: Page.objects.values('id', 'title').filter(id__gt=1) Out[4]: [] On Apr 2, 12:22 pm, Jaap <[EMAIL PROTECTED]> wrote: > QuerySet methods that return new QuerySets: > values(*fields) > > Could an

Database API reference:

2008-04-02 Thread Jaap
QuerySet methods that return new QuerySets: values(*fields) Could anyone please give an example of this, using view and template? I have read the example using the interpreter, and cannot get it to work in view/template. FYI: I use version 0.96.1, Windows XP. --~--~-~--~~

Re: Problem using django database API

2008-01-25 Thread [EMAIL PROTECTED]
That would be User_Friend.objects.filter(from_user=user, active=True, to_user__name__startswith=q) On Jan 25, 12:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hello, > > I need help making a query with django with I'm not sure it's > possible. > > I have > > model: > class User_Friend(m

Problem using django database API

2008-01-25 Thread [EMAIL PROTECTED]
Hello, I need help making a query with django with I'm not sure it's possible. I have model: class User_Friend(models.Model): from_user = models.ForeignKey(User, related_name='from_user') to_user = models.ForeignKey(User, null=True, related_name='to_user') active = models.BooleanFie

Re: database API filter() vs get()

2007-12-17 Thread Brian Rosner
On 2007-12-17 22:41:08 -0700, Kenneth Gonsalves <[EMAIL PROTECTED]> said: > > > On 18-Dec-07, at 10:33 AM, MrJogo wrote: > >> What's the practical difference between calling >> DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where >> **kwargs can be whichever paramenters)? I understa

Re: database API filter() vs get()

2007-12-17 Thread MrJogo
I understand now. Thanks. On Dec 17, 9:11 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 18-Dec-07, at 10:33 AM, MrJogo wrote: > > > What's the practical difference between calling > > DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where > > **kwargs can be whichever paramenters

Re: database API filter() vs get()

2007-12-17 Thread Kenneth Gonsalves
On 18-Dec-07, at 10:33 AM, MrJogo wrote: > What's the practical difference between calling > DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where > **kwargs can be whichever paramenters)? I understand that filter > returns a QuerySet, but I don't really get how that affects me or my >

database API filter() vs get()

2007-12-17 Thread MrJogo
What's the practical difference between calling DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where **kwargs can be whichever paramenters)? I understand that filter returns a QuerySet, but I don't really get how that affects me or my code. --~--~-~--~~~---~-

Re: database api question (query/filter related objects)

2007-11-04 Thread Karen Tracey
On 11/4/07, Brot <[EMAIL PROTECTED]> wrote: > > Ok, thank you... that's standard python stuff. It's no secret, that > I'm new to python :-( > But I found another solution. I don't really now which on is the > better one?! > > partnerlist = [ep.partner for ep in > Event.objects.latest > ('date').eve

Re: database api question (query/filter related objects)

2007-11-04 Thread Brot
On Nov 4, 7:02 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On 11/4/07, Brot <[EMAIL PROTECTED]> wrote: > > > > > > partner_list = [ep.partner for ep in Event.objects.latest > > > ('date').eventpartner_set.all()] > > > Ok, that works! But there is another problem now. I would like to sort > >

Re: database api question (query/filter related objects)

2007-11-04 Thread Karen Tracey
On 11/4/07, Brot <[EMAIL PROTECTED]> wrote: > > > > > partner_list = [ep.partner for ep in Event.objects.latest > > ('date').eventpartner_set.all()] > > Ok, that works! But there is another problem now. I would like to sort > the list of partners. > The sort-criteria should be a field from the part

Re: database api question (query/filter related objects)

2007-11-04 Thread Brot
On Nov 4, 4:14 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:[snip] > > To get the last event I use: > > > Event.objects.latest('date') > > > To get a list of EventPartners i use: > > Event.objects.latest('date').eventpartner_set.all() > > > But how d

Re: database api question (query/filter related objects)

2007-11-04 Thread Karen Tracey
On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:[snip] To get the last event I use: > Event.objects.latest('date') > > To get a list of EventPartners i use: > Event.objects.latest('date').eventpartner_set.all() > > But how do I get a list of my Partners? I tried a few things, but I > didn't find a solu

database api question (query/filter related objects)

2007-11-04 Thread Brot
dels.Model): event = models.ForeignKey(Event) partner = models.ForeignKey(Partner) relationtype = models.CharField(max_length=2, choices=RELATIONTYPE_CHOICES) ... I want to have all Partners from the last event. Is there a simple query-solution with the django database-api? With a st

Re: Django database API - What is it good for?

2007-08-13 Thread TheMaTrIx
Also, if I'm not mistaken, when you use the database api, the input validation steps are taken care of by the framework, you don't just tell in the models what format fields should be in the database, but at the same time are telling the framework what input it should accept for that f

Re: Django database API - What is it good for?

2007-08-13 Thread Collin Grady
> >>> users = User.objects.filter(groups__contains="Staff") ? This line doesn't work because "groups" is a ManyToManyField, not a CharField, so __contains="Staff" doesn't make any sense. Something like users = User.objects.filter(groups__name="Staff") should work a little better :) --~--~-

Re: Django database API - What is it good for?

2007-08-13 Thread James Bennett
On 8/13/07, Amirouche <[EMAIL PROTECTED]> wrote: > What do you mean, I can't understand. OK, suppose you are running an online store, so you have a database table "orders", which lists orders customers have placed, and another "addresses" which lists the addresses to ship the orders to. To calcul

Re: Django database API - What is it good for?

2007-08-13 Thread Amirouche
On Aug 13, 3:19 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 8/13/07, sagi s <[EMAIL PROTECTED]> wrote: > > > Surely not. It is... darn - Can I just use SQL and be done with it? > > Of course. > > But keep in mind that, when programming in an object-oriented > language, it's often more us

Re: Django database API - What is it good for?

2007-08-13 Thread James Bennett
On 8/13/07, sagi s <[EMAIL PROTECTED]> wrote: > Surely not. It is... darn - Can I just use SQL and be done with it? Of course. But keep in mind that, when programming in an object-oriented language, it's often more useful to get back a set of domain-specific objects -- which requires using Djang

Django database API - What is it good for?

2007-08-13 Thread sagi s
I've been playing around with Django for a couple of weeks. I'm finding myself spending most of my type tinkering with the Database API to try to wrestle the information I need out of my database. At this point it looks to me like I have replaced one set of incantations (SQL) f

Re: Many2Many question about Database API

2007-05-17 Thread Ben Jones
> Apparently it's a bug in the version of sqlite that's bundled with the > Windows installer (3.3.4). The Python 2.5 installer, that is. . . -- -Ben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django use

Re: Many2Many question about Database API

2007-05-16 Thread Ben Jones
I see where this has already been addressed in ticket #2457 http://code.djangoproject.com/ticket/2457 Apparently it's a bug in the version of sqlite that's bundled with the Windows installer (3.3.4). The command line version of sqlite that I'm running is much more recent, which explains the dif

Re: Many2Many question about Database API

2007-05-16 Thread Ben Jones
> Might be worthwhile having a look at the SQL Django is generating. From > the shell prompt import db.connection and have a look at > db.connection.queries after running the query. > > I wouldn't be too surprised to discover this is a bug caused by using a > left outer join here, in which case it

Re: Many2Many question about Database API

2007-05-16 Thread Malcolm Tredinnick
On Wed, 2007-05-16 at 20:53 -0500, Ben Jones wrote: > Thanks for the help, Russ. > > > > > For test data, I have entered 3 categories and 3 pieces of content > > > (one in each of the 3 categories). > > > > You have 3 categories and 3 content objects, but what is in the m2m > > table between the

Re: Many2Many question about Database API

2007-05-16 Thread Ben Jones
Thanks for the help, Russ. > > For test data, I have entered 3 categories and 3 pieces of content > > (one in each of the 3 categories). > > You have 3 categories and 3 content objects, but what is in the m2m > table between them? What is the matrix of category/content > relationships? It's the

Re: Many2Many question about Database API

2007-05-16 Thread Russell Keith-Magee
On 5/17/07, Ben Jones <[EMAIL PROTECTED]> wrote: > > I have 2 models that I'm using "for training": Content and Category > with a ManyToMany field in Content to relate them. > > For test data, I have entered 3 categories and 3 pieces of content > (one in each of the 3 categories). You have 3 cate

Many2Many question about Database API

2007-05-16 Thread Ben Jones
First, since this is my first post to this group, let me say that Django is phenomenal. So serious. In fact, "phenomenal" doesn't even begin to scratch the surface . . . using that phrase to describe it is an insult! Many, many thanks to everyone who has contributed! On to business . . . I have

Re: [database-api] Using .select_related() with a multi-table query (bug?)

2007-04-21 Thread Malcolm Tredinnick
On Wed, 2007-04-18 at 19:57 -0300, Luiz Carlos Geron wrote: > Hi, > I have three models, listed at [1], that I want to get data from with > only one query, because of performance issues with my app. The way > that worked so far is: > > league_ids = [12, 21] > bets = > models.Bet.objects.filter(g

Re: [database-api] Using .select_related() with a multi-table query (bug?)

2007-04-21 Thread Luiz Carlos Geron
Any ideas on how I can do this with one query? On 4/18/07, Luiz Carlos Geron <[EMAIL PROTECTED]> wrote: > Hi, > I have three models, listed at [1], that I want to get data from with > only one query, because of performance issues with my app. The way > that worked so far is: > > league_ids = [12,

[database-api] Using .select_related() with a multi-table query (bug?)

2007-04-18 Thread Luiz Carlos Geron
Hi, I have three models, listed at [1], that I want to get data from with only one query, because of performance issues with my app. The way that worked so far is: league_ids = [12, 21] bets = models.Bet.objects.filter(game__league__id__in=league_ids).order_by('bet__game__league.id', 'game_part'

Re: Database API blind spot

2007-01-23 Thread James Bennett
On 1/22/07, Tim Chase <[EMAIL PROTECTED]> wrote: > Or, alternatively, one could do something like > > SELECT c.* FROM camps c INNER JOIN application a ON c.id = a.camp_id > > which might also be another way to let the optimizer take a crack > at doing it well. Yeah, though AFAIK the 'extra' metho

Re: Database API blind spot

2007-01-22 Thread Tim Chase
> SELECT * FROM camps where id in (SELECT DISTINCT camp_id FROM application); Computing the DISTINCT portion here may be superfluous, and possibly (depending on your DB) a premature mis-optimization. Whether DISTINCT or not, membership via IN will still behave the same, but DISTINCT will requi

Re: Database API blind spot

2007-01-22 Thread James Bennett
On 1/22/07, Chris Brand <[EMAIL PROTECTED]> wrote: > I have an app with Applications, each of which is for a single Camp. > What I want to do is retrieve all the Camps for which there exists an > Application. The straightforward way is to retrieve a list of distinct values for 'camp_id' from the

Database API blind spot

2007-01-22 Thread Chris Brand
I have the feeling that this is something that should be straightforward, but I can't see how to do it. I have an app with Applications, each of which is for a single Camp. What I want to do is retrieve all the Camps for which there exists an Application. Thanks, Chris --~--~-~--~--

Re: Nested Relationships between tables in Django Database API

2006-12-09 Thread Russell Keith-Magee
On 12/10/06, Darin Lee <[EMAIL PROTECTED]> wrote: > In the console, if I populate the Contest, the instance produces a > "category_set" method/property (as expected and documented). However, > if you "dir(c.category_set)" there is no "finalist_set" method/ > property in the category_set's namespac

Nested Relationships between tables in Django Database API

2006-12-09 Thread Darin Lee
Hi All, Just curious, does the Django Database API support nested relationships more than one level deep? It's starting to look like it doesn't... for example, let's say I have three tables: Contest, Categories, and Finalists; related as such: Contest, Category foreign

Re: Database API

2006-10-17 Thread RajeshD
> > p.id = ??? (max_id in table + 1 or NOT SET > but how can i do > this) > p.save() Try: p.id = None p.save() Django will select the next id in the sequence for your new product. --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Database API

2006-10-17 Thread Daniel Austria
Hi, to those who are experienced in django: i just want to avoid making mistakes at the database level. intro: I have an existing produkt p (class produkt) in the database. It has a few other keys to the table attribute. So attribute (class attribute) has a ForeignKey to produkt. todo: Take the

Re: Database API question: I am not able to return a QuerySet

2006-07-31 Thread Suriya
DavidA wrote: > Suriya, > > You will probably have to do this in custom SQL or using extra(). Your > query requires a subselect to get the "current B's" (B's with max(date) > for each A). > > Here's the SQL that I think you need (if I understand the problem > correctly): > > select * from _A join

Re: Database API question: I am not able to return a QuerySet

2006-07-31 Thread SmileyChris
Suriya wrote: > This returns the list of rows in table A that have status > in table B set to 1 at some point in the past. What I want > is the latest status from table B. I see. Yes, you can either use a (grouping) custom SQL query or refactor. How I would do it is to have just one model (B)

Re: Database API question: I am not able to return a QuerySet

2006-07-31 Thread DavidA
Suriya, You will probably have to do this in custom SQL or using extra(). Your query requires a subselect to get the "current B's" (B's with max(date) for each A). Here's the SQL that I think you need (if I understand the problem correctly): select * from _A join _B on _B.a_id = _A.id where _B.

Re: Database API question: I am not able to return a QuerySet

2006-07-30 Thread Suriya
SmileyChris wrote: > How about just making the query like this: > > A.objects.filter(b__status=1) This returns the list of rows in table A that have status in table B set to 1 at some point in the past. What I want is the latest status from table B. For example, if table B has the two entries:

Re: Database API question: I am not able to return a QuerySet

2006-07-30 Thread SmileyChris
How about just making the query like this: A.objects.filter(b__status=1) --~--~-~--~~~---~--~~ 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 u

Database API question: I am not able to return a QuerySet

2006-07-30 Thread Suriya
Hi all, I have a situation here where I do not know how to use the filter() function in the database API to obtain a QuerySet. I am describing the schema and what I have done, below. I hope you have an answer to my question. # Only the necessary fields are shown here class A(models.Model

Re: use data model and database api along

2006-07-29 Thread Ian Clelland
On 7/29/06, Gennan Chen <[EMAIL PROTECTED]> wrote: > I will like to django's ORM in my standalone app (not web app). Do I always > its admin tool to create tables? Or it can reuse the table structure I > create in the db? You should be able to use the Django ORM on an existing database (not that

use data model and database api along

2006-07-29 Thread Gennan Chen
Hi!I will like to django's ORM in my standalone app (not web app).  Do I always its admin tool to create tables? Or it can reuse the table structure I create in the db? Gen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Group

Re: Unicode strings through Database API

2006-06-30 Thread Paul
Jeremy Dunck wrote: > I've seen some situations where multiple encodings were stuck into the > same column, and you don't want to go there. I can believe that :-/ That for the advice. Things seem to be working now I've encoded into utf-8. Even Django's admin interface seems to understand utf-8

Re: Unicode strings through Database API

2006-06-30 Thread Jeremy Dunck
On 6/30/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > On 6/30/06, Paul <[EMAIL PROTECTED]> wrote: > > The string I'm assigning to the field is a unicode string. Django is > > trying to do a .encode('ascii') on it and failing. Understandable > > really > > Are you sure it's the unicode type, and no

Re: Unicode strings through Database API

2006-06-30 Thread Jeremy Dunck
On 6/30/06, Paul <[EMAIL PROTECTED]> wrote: > The string I'm assigning to the field is a unicode string. Django is > trying to do a .encode('ascii') on it and failing. Understandable > really Are you sure it's the unicode type, and not just a byte string? > I assume I have to do a .encode('utf-8

Re: Unicode strings through Database API

2006-06-30 Thread Paul
Ok, I've dug a little more and I realised I'd got the wrong end of the stick. The string I'm assigning to the field is a unicode string. Django is trying to do a .encode('ascii') on it and failing. Understandable really I assume I have to do a .encode('utf-8') on it before I store it. Does that

Unicode strings through Database API

2006-06-30 Thread Paul
Hi, I'm in need of a little education. This may be a python issue rather than a Django one, but is anybody can help I'd appreciate it. I've written an a little script which gets external data and inserts it into the database using the Django models. Unfortunately (or fortunately, depending on yo

Database API

2006-05-09 Thread wizeman
simple SQL query: SELECT name, consultant_id FROM users INNER JOIN consultants ORDER BY name; How do I do that with the database API? I've tried these statements, and some variations, but they all fail: - Consultant.objects.all().order_by('name') - Consultant.objects.all().order

Re: UNICODE database API How to

2006-04-18 Thread [EMAIL PROTECTED]
An easier way would be to use the codecs module to open the file for reading or writing in a particular encoding (the system default encoding is assumed when using open() or file(), which is apparently different from iso-8859-1 in the case above). I have to deal with encoded files quite frequently

Re: UNICODE database API How to

2006-04-18 Thread yml
Thank you Ivan, Happy to see that in any case my pb would have been solved today. ;-) --~--~-~--~~~---~--~~ 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@googlegro

Re: UNICODE database API How to

2006-04-18 Thread Ivan Sagalaev
yml wrote: >f = open("departments.txt") >regexobj = re.compile("([0-9]+)\s+([\w\s?]+)",re.UNICODE) > > >for l in f.readlines(): >fileencoding = "iso-8859-1" > > Ah! I was just about to suggest this. Your file seems to be not in utf-8 actually. And since you were opening it with codecs.open

Re: UNICODE database API How to

2006-04-18 Thread Gábor Farkas
> =Department(department=matches[1].encode('utf-8','replace') hi, you can remove that ['replace']. there shouldn't be any unicode character that cannot be represented in utf-8, so the error-condition for which you specify the behaviour is never going to happen. gabor --~--~-~--~~

Re: UNICODE database API How to

2006-04-18 Thread yml
Here it is the script that is working for me. This was done thanks to this great pages (http://effbot.org/zone/unicode-objects.htm) it took me 3 days to find it on internet. Thank you google and of course thank you to the author :-) # -*- coding: utf8 -*- import os,codecs from django.models.ann

Re: UNICODE database API How to

2006-04-18 Thread yml
Hello Thank you for your help but so far I do not have any success. I am reading form a the lines from a file. Here it is the kind of error I am getting : the current line is :07 ArdFche matches ('07', 'Ard\xe8che\r\n') Traceback (most recent call last): File "E:\instal\django\view_serviceala

Re: UNICODE database API How to

2006-04-17 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: from django.models.page import pages p = pages.Page(path=u"/föö", source=u"/bär") p.save() Interesting. I get here a 'Segmentation fault'. Both in in m-r and trunk... q = pages.get_object(path__exact=u"/föö") q.path

Re: UNICODE database API How to

2006-04-17 Thread [EMAIL PROTECTED]
Ivan Sagalaev wrote: > It depends very much on the definition of "correctly". Django's ORM > expect single-byte strings which for unicode means utf-8. >>> from django.models.page import pages >>> p = pages.Page(path=u"/föö", source=u"/bär") >>> p.save() >>> q = pages.get_object(path__exact=u"/f

  1   2   >