Re: basci question about queryset for retrieving top element

2012-04-16 Thread HarpB
Both patterns will produce same query. You can also use django-debug-toolbar, which gives ur debugsqlshell tool. So you can execute code from the commandline and can see what the query will be. Django also has a code pattern for your case - for getting the first element, you can just use

Re: High Traffic

2012-04-16 Thread Andy McKay
Run django debug toolbar, see what queries you are running and how long they take and that you've got database indexes set up. Failing that, run a middleware or other logging tool to tell you slow pages. Then test with django debug toolbar. Rinse and repeat. -- You received this message because

Re: Problems extracting valid form data lately

2012-04-16 Thread Chris Seberino
> Field clean methods do not return cleaned_data dict, they return > specific data from within that dict. Tom Thanks so much! That fixed it! For the life of me I can't understand how my site has been operating for MONTHS without this bug manifesting itself. I guess my site didn't have to

Re: basci question about queryset for retrieving top element

2012-04-16 Thread NENAD CIKIC
OK, thanks for sharing this On 16 Apr, 07:54, Pavan Verma wrote: > I am a Django newbie and also interested in this question. > > From reading the Django bookhttp://www.djangobook.com/en/2.0/chapter05/, > I see that the query 'Publisher.objects.order_by('name')[0:2]' maps

Re: Passing parameters to class Meta:

2012-04-16 Thread Mario Gudelj
TIL don't override model class constructor if you don't really have to. Thanks for all your help guys! Now when I think about it I don't even know why I did it in the first place. On 17 April 2012 03:12, Javier Guerra Giraldez wrote: > On Mon, Apr 16, 2012 at 11:08 AM, Tom

Re: High Traffic

2012-04-16 Thread Yarden Sachs
thanks! have any advice for good performance? and profiling? On 17 באפר 2012 00:18, "CLIFFORD ILKAY" wrote: > On 04/16/2012 04:49 PM, Yarden Sachs wrote: > >> Sure, >> >> I experienced unknown performance issues(slow responses) when high >> traffic would hit that

Re: High Traffic

2012-04-16 Thread CLIFFORD ILKAY
On 04/16/2012 04:49 PM, Yarden Sachs wrote: Sure, I experienced unknown performance issues(slow responses) when high traffic would hit that site. > so, started to test what happens if i hit the web site with a big calculation, like len function on an 9k objects. when i try to do it from

Re: High Traffic

2012-04-16 Thread Yarden Sachs
it took 20 times more for EACH request. that means that if 20 users accross the web ask for differrent heavy data- instead of taking a second for each one, every user will wait for 20 seconds before the response will answer. On 16 באפר 2012 23:54, "Javier Guerra Giraldez"

Re: High Traffic

2012-04-16 Thread Javier Guerra Giraldez
On Mon, Apr 16, 2012 at 3:49 PM, Yarden Sachs wrote: > when i try to do it from client, it takes 0.7 secs to come back with > response, if try to do it from 10 parralel client, it takes 15 secs for one > http response! well, if you do a heavy and memory intensive task, then

Re: High Traffic

2012-04-16 Thread Yarden Sachs
Sure, I experienced unknown performance issues(slow responses) when high traffic would hit that site. so, started to test what happens if i hit the web site with a big calculation, like len function on an 9k objects. when i try to do it from client, it takes 0.7 secs to come back with

Re: High Traffic

2012-04-16 Thread Chris Czub
You're creating a contrived test though. If you really wanted the count of users you'd probably do a "count" in the database itself. I don't think you're getting any valuable data on your application's actual performance: you basically made a view that just loops over 9000 items. Of course it

Re: High Traffic

2012-04-16 Thread Yarden Sachs
what perpesfully used. for heavy system performance On 16 באפר 2012 23:38, "andrea mucci" wrote: > have you debugged the mysql query > > nginx+fgi work pretty well so is very very strange. > > have you tried to test, other type of query result without len method? > > > El

Re: High Traffic

2012-04-16 Thread Javier Guerra Giraldez
On Mon, Apr 16, 2012 at 2:25 PM, Yarden Sachs wrote: > * COUNTING THE RESULTS IS NOT THE POINT ok, then that len(User.objects.all()) is not an appropriate benchmark, right? what you're doing is a view that fetches all 9K records from the DB, without any filtering. will your

Re: High Traffic

2012-04-16 Thread andrea mucci
have you debugged the mysql query nginx+fgi work pretty well so is very very strange. have you tried to test, other type of query result without len method? El 16/04/2012, a las 22:22, Yarden Sachs escribió: > i have 9000 rows. and using mod_wsgi on apache2. what am i doing wrong? i > tried

Re: High Traffic

2012-04-16 Thread Yarden Sachs
ofcourse... i am using django since dec 10, and now i dont know what to do On 16 באפר 2012 23:30, "Ramiro Morales" wrote: > On Mon, Apr 16, 2012 at 5:22 PM, Yarden Sachs wrote: > > i have 9000 rows. and using mod_wsgi on apache2. what am i doing wrong? > i >

Re: High Traffic

2012-04-16 Thread Ramiro Morales
On Mon, Apr 16, 2012 at 5:22 PM, Yarden Sachs wrote: > i have 9000 rows. and using mod_wsgi on apache2. what am i doing wrong? i > tried to switch to nginx+fcgi. and tried ubuntu srrver as well. same > results. > > any ideas? Do you have DEBUG=False in your settings? --

Re: High Traffic

2012-04-16 Thread Yarden Sachs
i have 9000 rows. and using mod_wsgi on apache2. what am i doing wrong? i tried to switch to nginx+fcgi. and tried ubuntu srrver as well. same results. any ideas? On 16 באפר 2012 23:18, "andrea mucci" wrote: > hi Yarden > > how many users have you in your database? > you

Re: High Traffic

2012-04-16 Thread andrea mucci
hi Yarden how many users have you in your database? you use mod_fcgi or mod_python? ( more recommendable will be mod_fcgi or mod_fcgid ) Django is framework that suppert very very large traffic. you can see an example here

Re: High Traffic

2012-04-16 Thread Yarden Sachs
using aws ec2 & rds. so rolling out that. i monitor every query for high performance. but Users all is very simple query. what do u think it could other than those? thanks for all the help On Monday, April 16, 2012 10:59:55 PM UTC+3, creecode wrote: > > Hello Yarden, > > On Monday, April

Re: High Traffic

2012-04-16 Thread creecode
Hello Yarden, On Monday, April 16, 2012 12:25:36 PM UTC-7, Yarden Sachs wrote: Hello, I am using django 1.3 on apache 2.* on windows server 2008. > mysql 5.* > > When i try to access a view that does this: def view(request): > len(User.objects.all()) return HttpResponse() > > i have about 9K

High Traffic

2012-04-16 Thread Yarden Sachs
Hello, I am using django 1.3 on apache 2.* on windows server 2008. mysql 5.* When i try to access a view that does this: def view(request): len(User.objects.all()) return HttpResponse() i have about 9K results on that. i am doing len and not .count, because i want to test the server. the server

Re: Missing manage.py

2012-04-16 Thread Tonton
after project you need to do start app for making module T. On Mon, Apr 16, 2012 at 8:17 PM, Buddy Lindsey, Jr. wrote: > If you are using Django 1.4 check in the application folder of your > project below your project folder. It should be in there. > > > Faeez Abd Rahman

Re: Missing manage.py

2012-04-16 Thread Buddy Lindsey, Jr.
If you are using Django 1.4 check in the application folder of your project below your project folder. It should be in there. Faeez Abd Rahman wrote: Hi, I have a problem whenever I create a new project using the start project command, no manage.py file is created. I'm using Mac OS X. Thank

Re: Missing manage.py

2012-04-16 Thread andrea mucci
hi could you post django version python version you use virtualenv? if yes what version and the code you use to generate the project cheers El 16/04/2012, a las 13:26, Faeez Abd Rahman escribió: > Hi, > > I have a problem whenever I create a new project using the start project > command, no

Re: Passing parameters to class Meta:

2012-04-16 Thread Javier Guerra Giraldez
On Mon, Apr 16, 2012 at 11:08 AM, Tom Evans wrote: > Surely you would want what business a payment relates to to be stored > directly in the database?! At which point it simply becomes an > additional field in your payment model, and the only problems come > with

Re: Dynamically generated models using exec. Is it too custly?

2012-04-16 Thread Arruda
Hummm, I see, thanks for that, I didn't know about type. And is there a way to generate functions too?(I was also doing it using exec). And do you have any idea of how can I see the difference in performance when using one or the other? Thanks. Em segunda-feira, 16 de abril de 2012

Re: Dynamically generated models using exec. Is it too custly?

2012-04-16 Thread Jeff Heard
Check https://github.com/JeffHeard/ga_dynamic_models. It may be similar to what you're looking for. Even if you don't want the code, you can see a way of dynamically generating models. On Mon, Apr 16, 2012 at 12:40 PM, Philip Mountifield < pmountifi...@formac.net> wrote: > Did you know that

Re: Dynamically generated models using exec. Is it too custly?

2012-04-16 Thread Philip Mountifield
Did you know that you can use the type function to dynamiclly generate a class definition? See http://docs.python.org/library/functions.html?highlight=type#type From the example: class X(object): ... a = 1 Is exactly the same as doing... X = type('X', (object,), dict(a=1))

Dynamically generated models using exec. Is it too custly?

2012-04-16 Thread Arruda
I'm doing something like this to generate some models dynamically: SIMILAR_MODELS_TEMPLATE= > """ > @some_decorator > class %(PREFIX)sModel (Some_Abs_model): > \"""%(DESCRIPTION)s > \""" > pass > """ then I have a factory: > def similar_models_factory(prefix,description): >

Re: Passing parameters to class Meta:

2012-04-16 Thread Tom Evans
On Mon, Apr 16, 2012 at 4:50 PM, Mario Gudelj wrote: > Hi Tom, > > Thanks for chiming in, mate. > > What I'm doing here is I'm getting the subdomain from the request and > matching it to the business when paypal PDT notification gets posted with > GET to my app. > > I then

Re: Passing parameters to class Meta:

2012-04-16 Thread Mario Gudelj
Hi Tom, Thanks for chiming in, mate. What I'm doing here is I'm getting the subdomain from the request and matching it to the business when paypal PDT notification gets posted with GET to my app. I then need to save the payment info and sine a foreign key for the payment is business I need to

Re: AutoFields must have primary_key=True?

2012-04-16 Thread Masklinn
On 2012-04-16, at 17:17 , Roy Smith wrote: >> AssertionError: AutoFields must have primary_key=True. > > Is this a bug? Unlikely considering the assertion was specifically added to AutoField as part of a commit noting: > Refactored the way save() works so that non-integer primary keys are >

Re: Problems extracting valid form data lately

2012-04-16 Thread Tom Evans
On Mon, Apr 16, 2012 at 4:39 PM, Chris Seberino wrote: >        def clean_username(self): > > """ >                custom validation > code >                """ > >                if "username" in self.cleaned_data: >                        username =

Re: Passing parameters to class Meta:

2012-04-16 Thread Mario Gudelj
Hey Javier, Thanks for the reply. There are thousands of different businesses, so I guess I'll have to go with the last option... Is this kind of what you're referring to there http://stackoverflow.com/questions/7114710/using-a-mixin-with-a-django-form-class ? Thanks again. -m On 17 April

Re: Problems extracting valid form data lately

2012-04-16 Thread Chris Seberino
INVITATION_CODE = "You should have received one of these." PAR_EMAIL_ADD = "Will be used for all communications." PASSWORD= "" STUD_FIRST_NAME = "Enter what the student prefers to go by." STUD_LAST_NAME = "" COURSE_1= "Select the course enrolled in and/or getting tutoring in."

Re: How to change widgets for admin site?

2012-04-16 Thread Guillaume Chorn
Shoot! I was thinking that might be the case originally, but I must have overlooked TextField in the model field docs. Thanks!!! I'm still curious though--how can I find out what all of the CSS classes are that are defined by the default admin style sheet (I guess I'm asking where this style

Re: Passing parameters to class Meta:

2012-04-16 Thread Tom Evans
On Mon, Apr 16, 2012 at 4:11 PM, Mario Gudelj wrote: > Hi Djangoers, > > I have an issue I can't work out. This is the situation: > > I have a model called payment, which has a custom constructor which takes a > parameter. This is the code: > > class Payment(models.Model):

Re: Passing parameters to class Meta:

2012-04-16 Thread Javier Guerra Giraldez
On Mon, Apr 16, 2012 at 10:11 AM, Mario Gudelj wrote: > I think I need to somehow pass the business object to model = Payment inside > the Meta class... how many 'business' options are there? if it's a fixed num, you could add a Proxy 'subclass' for each one that simply

Re: AutoFields must have primary_key=True?

2012-04-16 Thread Marcin Tustin
I came up against this also. My work-around was to create a model that exists explicitly for the purpose of generating sequential integers (I also need them to be unique, so it's acceptable for my purposes). You might like to have two fields to accomplish the same thing with duplicates (which I

Re: AutoFields must have primary_key=True?

2012-04-16 Thread Gerald Klein
Auto-incrementing fields are meant to be primary keys that is their purpose. I have never tried it but a formula in the default value for an integer field to increment it might work On Mon, Apr 16, 2012 at 10:17 AM, Roy Smith wrote: > I need an integer field which generates

Re: Any tool to validate django templates?

2012-04-16 Thread Marcin Tustin
Thanks. Neither of those would help with my problem, which is that django itself was refusing to parse my template. My solution was to simply comment out regions, and re-instate them until the error was once again detected. On Mon, Apr 16, 2012 at 16:12, John Yeukhon Wong

AutoFields must have primary_key=True?

2012-04-16 Thread Roy Smith
I need an integer field which generates increasing integers. But I don't want it to be my primary key. In fact, it can't be, because I want the ability to manually reset it to something else. The auto-increment is just a default value. If I do: > class Image(Model): > serial =

Re: Any tool to validate django templates?

2012-04-16 Thread Mario Gudelj
PyCharm does a very good job here when it comes to highlighting and error detection in templates. Try it out. On 17 April 2012 01:12, John Yeukhon Wong wrote: > Would this help? > >

Re: Any tool to validate django templates?

2012-04-16 Thread John Yeukhon Wong
Would this help? http://stackoverflow.com/questions/3086637/how-should-i-validate-html-in-django-templates-during-the-development-process I quite like the not-accepted-as-answer. Just go through your urls. Essentially, you have two types of possible template errors: 1. human errors (missing a

Passing parameters to class Meta:

2012-04-16 Thread Mario Gudelj
Hi Djangoers, I have an issue I can't work out. This is the situation: I have a model called payment, which has a custom constructor which takes a parameter. This is the code: class Payment(models.Model): id = models.AutoField(primary_key=True) amount = models.FloatField("Total payment

Re: Building composite keys?

2012-04-16 Thread Gerald Klein
I understand serial by nature is unique. On Mon, Apr 16, 2012 at 9:24 AM, Roy Smith wrote: > I've got a model in django 1.4: > > class Image(Model): >serial = AutoField(primary_key=True) >version = IntegerField(default=1) > > I want (serial, version) to be unique. Is

Re: How to change widgets for admin site?

2012-04-16 Thread Daniel Roseman
On Monday, 16 April 2012 06:24:54 UTC+1, Gchorn wrote: > > Hello, I'm trying to create a blog site using Django (with "Post" as > my main model and "text" as the attribute corresponding to the main > body of text for each post). On the admin page, when someone is > filling out fields to create

Re: Building composite keys?

2012-04-16 Thread Javier Guerra Giraldez
On Mon, Apr 16, 2012 at 9:24 AM, Roy Smith wrote: > I want (serial, version) to be unique. class Meta unique_together = [('serial','version')] -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Building composite keys?

2012-04-16 Thread Roy Smith
I've got a model in django 1.4: class Image(Model): serial = AutoField(primary_key=True) version = IntegerField(default=1) I want (serial, version) to be unique. Is there a way to express that in the model layer? --- Roy Smith r...@panix.com -- You received this message because you

Re: [Question] Filter Queryset in a Template

2012-04-16 Thread Javier Guerra Giraldez
On Mon, Apr 16, 2012 at 6:00 AM, Nikhil Somaru wrote: > If I do the filtering in views.py, I the template would have to make > assumptions about the type of context variables I will be passing it. > > Or am I seeing this the wrong way? i think so. the view is where you

Re: Any tool to validate django templates?

2012-04-16 Thread william ratcliff
Wing IDE also highlights templates. On Apr 16, 2012 3:16 AM, "Matt Schinckel" wrote: > Generally, I just use syntax highlighting in my text editor: that usually > helps me find errors. > > TextMate has a nice HTML (Django Template) mode. > > Matt. > > > On Monday, April 16,

Re: How to change widgets for admin site?

2012-04-16 Thread Guillaume Chorn
Hi Marc, Thanks for your reply. Are you referring to the "max_length" element of my "text" CharField? If so, I don't think this is the issue; I've set the max length to 10,000 characters which is quite long. Also this setting does not change the size of the text input area relative to my other

Missing manage.py

2012-04-16 Thread Faeez Abd Rahman
Hi, I have a problem whenever I create a new project using the start project command, no manage.py file is created. I'm using Mac OS X. Thank you 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

Re: [Question] Filter Queryset in a Template

2012-04-16 Thread waax
You can use templatetags for example: https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs On Saturday, April 14, 2012 10:51:51 AM UTC+2, Nikhil Somaru wrote: > > Greetings, > > > I would like to do something like queryset filtering in a template. Is the > only solution

Re: [Question] Filter Queryset in a Template

2012-04-16 Thread Nikhil Somaru
I appreciate your reply, but you haven't quite helped me out. If I do the filtering in views.py, I the template would have to make assumptions about the type of context variables I will be passing it. Or am I seeing this the wrong way? On 15 April 2012 00:41, dummyman dummyman

Re: Passing additional variables to flatpage template

2012-04-16 Thread Tom Evans
On Sat, Apr 14, 2012 at 9:27 PM, Swaroop Shankar V wrote: > Hi All, > > Am using flatpage app in my application. I want to send > few additional variables that can be accessible from the flatpage templates. > So how can i accomplish the same? > You cannot. The only way to

Re: How to change widgets for admin site?

2012-04-16 Thread Marc Patermann
Hi, Gchorn schrieb (16.04.2012 07:24 Uhr): Hello, I'm trying to create a blog site using Django (with "Post" as my main model and "text" as the attribute corresponding to the main body of text for each post). On the admin page, when someone is filling out fields to create a new blog post, I

Re: Problems extracting valid form data lately

2012-04-16 Thread Blackpearl
you can check the form data dictionary by: if form.is_valid(): print form.__dict__ -- 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

Re: Any tool to validate django templates?

2012-04-16 Thread Matt Schinckel
Generally, I just use syntax highlighting in my text editor: that usually helps me find errors. TextMate has a nice HTML (Django Template) mode. Matt. On Monday, April 16, 2012 2:12:14 AM UTC+9:30, Marcin wrote: > > Hi all, > > I've got a template that isn't parsing, but the error is the >

Re: Problems extracting valid form data lately

2012-04-16 Thread Kejun He
paste your form code please On Sun, Apr 15, 2012 at 11:54 PM, Andy McKay wrote: > What does your form code look like? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to