Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Matt Andrews
Hi Nik, Thanks - I do feel like by circumventing the ORM I've just "given up" and perhaps I'll reconsider -- none of my queries are particularly "specialist" (as the sample above indicates) - I just found Django generating odd things. To answer your questions: 1. Yes, reloading the page sees t

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Jani Tiainen
Hi, From your raw SQL I saw you're doing few joins. So I suppose you do quite a few foreign key fetches. You didn't mention anything how you originally tried to solve case with ORM. Could you please publish what you had when things were slow? 22.1.2013 12:26, Matt Andrews kirjoitti: Hi Nik

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Matt Andrews
Hi Jani, I made a StackOverflow post last year with an example of the ORM stuff I tried and the poor queries it produced: http://stackoverflow.com/questions/5843457/django-objects-all-making-360-queries-how-can-i-optimise-this-manytomany There's also this discussion about how using the same que

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Jani Tiainen
Hi, I see that you had quite a bunch of m2m keys. Have you tried recent version of Django (1.4+) with prefetch_related() [1] ? [1] 22.1.2013 13:57, Matt Andrews kirjoitti: Hi Jani, I made a StackOverflow post

Re: Looking for a session cart

2013-01-22 Thread frocco
Thanks, I tried it last night and it seems like a fit for me, porting my PHP app logic. On Monday, January 21, 2013 4:24:50 PM UTC-5, somecallitblues wrote: > > Use django-cart. It does store the cart content in db but it stores the > session as well, so it will nicely match the user to their c

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Matt Andrews
That looks really useful - for future reference, great! Sadly my webhost is still bundling Django 1.2.3 :( In general, though, these issues still come down to the fact that a SQL query as executed by Django takes several times longer than going directly to the DB. Is this down to my use of dict

Re: Database Transaction

2013-01-22 Thread Javier Guerra Giraldez
On Mon, Jan 21, 2013 at 10:03 PM, Jian Chang wrote: > you can't do the transaction between two different databases. i think the OP is talking about translation and not transaction. as in translating the data from an old representation to the new one. a better word might be migration. of course

Re: want to update only a few fields of a form

2013-01-22 Thread Sarfraz ahmad
can you please give me an example of validating only three fields of a form which have 5 fields thanx guys On Mon, Jan 21, 2013 at 7:17 PM, Babatunde Akinyanmi wrote: > Hi, this is well documented in the online documentation > https://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs > ht

Re: ignore field during form validation

2013-01-22 Thread Sarfraz ahmad
gusy i have form which has 5 fields i have defined a clean_field method which doesn't allow a duplicate entry in the database. bt when i tried to update the model instance while calling form.is_valid() method it calls the clean_field() method and returns error that entry already exists. O

Re: Global filtering of the querystes

2013-01-22 Thread akaariai
On 22 tammi, 08:32, Jani Tiainen wrote: > Hi, > > I've several models that share same attribute and form doing ajax > queries to/from form in a browser window. > > For example owner: > > class MyClass(models.Model): >      title = models.TextField(max_length=100) >      owner = models.TextField(ma

module object has not attribute JSONEncoder

2013-01-22 Thread ghjim
My root WSGI page is now throwing the error: "AttributeError at / module object has no attribute JSONEncoder" I have seen several posts about this with implications that it might be a Python bug. It started occurring to me after I did a number of system updates. I have been unable to back ou

Re: saving get objects to models

2013-01-22 Thread Bill Freeman
Forgive me if I am not being direct, but I'm not sure I understand your question. For the python statement that you include in your question to work, the following must be true: 1. There must be a query parameter on the url named "material". e.g.; http://localhost:8000/myview/?material=admantium

Upload multiple files using Ajax

2013-01-22 Thread Andre Lopes
Hi, I need to develop a form to upload multiple files. I was thinking in using an Ajax uploader. I have google some options but there are to many and I don't know which one to choose. Any recommendations about this subject? Best Regards, André. -- You received this message because you are su

What's the right pattern to re-use common view code?

2013-01-22 Thread andrew jackson
I have an object that shows up in lots of different parts of the system, say a Book. I want to display a list view of Book objects in many different places, e.g., When looking at an Author's detail page, I want to see a list of recent books they've written when looking at a publisher page,

Where can I put code that will get executed when page refreshes

2013-01-22 Thread frocco
I have a index.html template that extends base.html In Index I has: {% block side_menu %} Content {% endblock %} I fill this block from a database table. This only works if I click on the home link. if I click any other link to view, the side-menu is not populated. url(r'^$', 'ntw.views.inde

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Nikolas Stevenson-Molnar
Hi Matt, It's unlikely the problem lies with dictfetchall. The "small performance hit" mentioned by the docs probably refers to the fact that the function has a time complexity of (number of colulmns) * (number of rows). Since you're only getting 10 rows back, I can't see that having an appreci

Re: saving get objects to models

2013-01-22 Thread Satinderpal Singh
Thanks, for this help On Tue, Jan 22, 2013 at 9:34 PM, Bill Freeman wrote: > Forgive me if I am not being direct, but I'm not sure I understand your > question. You understand the problem very well. > For the python statement that you include in your question to work, the > following must be tru

Re: saving get objects to models

2013-01-22 Thread Sandeep kaur
On Tue, Jan 22, 2013 at 8:39 PM, Satinderpal Singh wrote: > How to save the objects to models without using form. I tried to save > the name object to the model, but unable to do so, > > material = Material.objects.get(name=request.GET['material']) > I think this will help you : p = table(material

Re: Database Transaction

2013-01-22 Thread Sandeep kaur
On Tue, Jan 22, 2013 at 7:32 PM, Javier Guerra Giraldez wrote: > On Mon, Jan 21, 2013 at 10:03 PM, Jian Chang wrote: >> you can't do the transaction between two different databases. > > i think the OP is talking about translation and not transaction. as > in translating the data from an old repr

Re: saving get objects to models

2013-01-22 Thread Satinderpal Singh
>> material = Material.objects.get(name=request.GET['material']) >> > I think this will help you : > p = table(material =material, ...[other fields of table to be saved]) > p.save() Thanks, this works for me. > Here table is your table where you want object value to be saved. > Hope this helps yo

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Matt Andrews
Hi Nik, I see the discrepancy both locally and when deployed, too -- that's what's so puzzling. If it helps, I'm using MySQL and running it on Windows locally and under Passenger on my remote Linux server (also on MySQL). Only other thing I can think of is that this "overhead" might literally b

Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Fellipe Henrique
Hello, It's possible, when the user make a login, I set one "global" variable, and get this value in my view? My question is because I have a inlineformset_factory, and I need to pass a user profile do my view.. but it`s doesn't work. Regards, T.·.F.·.A.·. S+F *Fellipe Henrique P. Soares*

Re: Django-SEO issue

2013-01-22 Thread Jeff Ammons
Were you able to figure out what was happening here? I'm experiencing the same issue. On Friday, August 17, 2012 2:16:53 PM UTC-6, jondbaker wrote: > > I've successfully installed Django-SEO, but when I try to limit the number > of backends (I only need/want my admin to have 'path' and not the o

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Mengu
hi fellipe, if you enable auth context processors and pass in RequestContext to render_to_response you can always access the user in your templates which also means you can access the associated profile as user.profile (assuming your model is named profile) please read more at https://docs.djang

Re: Upload multiple files using Ajax

2013-01-22 Thread Mengu
i used jquery.form plugin back in the day. it worked great but it had issues with large files. check out http://malsup.com/jquery/form/progress3.html and http://malsup.com/jquery/form/ On Jan 22, 6:05 pm, Andre Lopes wrote: > Hi, > > I need to develop a form to upload multiple files. > > I was t

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Nikolas Stevenson-Molnar
When running locally, are you also using a local database instance? IIRC the time that phpMyAdmin reports is the time taken for the database to execute the query, whereas the time reported by the debug toolbar (I /think/) is complete round-trip (send query, execute, return results). So if there is

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Tomas Neme
what mengu says is good for templates, but not so for views. But lo! your request should have a .user property that points to the currently logged user, so try request.user in your view On Tue, Jan 22, 2013 at 4:49 PM, Mengu wrote: > hi fellipe, > > if you enable auth context processors and

Re: What's the right pattern to re-use common view code?

2013-01-22 Thread Nikolas Stevenson-Molnar
Django does {% include %} too :) https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#include You could do something like: {% include "book_list.html" with books=auth.book_set.all %} _Nik On 1/22/2013 8:03 AM, andrew jackson wrote: > I have an object that shows up in lots of different p

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Fellipe Henrique
The problem is, I need to pass this request.user to one form, using a inlineformset_factory..in these code: class PedidoItensForm(ModelForm): class Meta: model = ItensPedido def __init__(self, *args, **kwargs): profile = kwargs.pop('vUserProfile', None) super(Pedid

Re: Django-SEO issue

2013-01-22 Thread Jonathan D. Baker
I wasn't. If anyone has a solution I'd still be interested in cleaning up the clutter and removing the backends I'm not using. On 01/22/2013 12:05 PM, Jeff Ammons wrote: > Were you able to figure out what was happening here? I'm experiencing > the same issue. > > On Friday, August 17, 2012 2:16:53

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Tomas Neme
vUserProfile=request.user.profile or vUserProfile=request.user.get_profile() to be more flexible On Tue, Jan 22, 2013 at 5:01 PM, Fellipe Henrique wrote: > The problem is, I need to pass this request.user to one form, using a > inlineformset_factory..in these code: > > class PedidoItensForm(Mod

Re: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-22 Thread Matt Andrews
Yes, local app, local DB (which is an exact copy of the production DB). Interestingly, I just tried pointing the local app at the remote database and total query time (for 10 queries) went from 115ms to 3477ms! Really odd. On Tuesday, January 22, 2013 7:54:53 PM UTC, Nikolas Stevenson-Molnar wro

Re: What's the right pattern to re-use common view code?

2013-01-22 Thread andrew jackson
...I can't believe i missed that as a builtin. Sorry! Thank you very much! -andrew On Tuesday, January 22, 2013 12:01:52 PM UTC-8, Nikolas Stevenson-Molnar wrote: > > Django does {% include %} too :) > https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#include > > You could do some

Re: Database Transaction

2013-01-22 Thread Javier Guerra Giraldez
On Tue, Jan 22, 2013 at 11:54 AM, Sandeep kaur wrote: > Yes, I also thought south will be helpful but when we need to do > complete migration like old table is without foreign keys but new > table has foreign keys etc. then I could not understand how to use > south. Can you provide me some tutoria