Re: Best practice for shareable web application

2008-11-28 Thread Graham Dumpleton
On Nov 29, 2:34 pm, "Leon Yeh | New Avenue.net" <[EMAIL PROTECTED]> wrote: > Hi All, > > Usually, when I am working on django project, I have one database per > web site. So one company has all its database in one single mysql database. > > However recently I am working on a site that had

Best practice for shareable web application

2008-11-28 Thread Leon Yeh | New Avenue.net
Hi All, Usually, when I am working on django project, I have one database per web site. So one company has all its database in one single mysql database. However recently I am working on a site that had requirements similar to basecamp web site. Here are the new requirement: 1. Multiple

Re: adding with ORM is slow

2008-11-28 Thread [EMAIL PROTECTED]
Ah, you're correct, not sure what I was thinking of. Alex On Nov 28, 9:35 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2008-11-28 at 18:26 -0800, [EMAIL PROTECTED] wrote: > > Can you try doing Country.objects.create(name=name) instead? > > Have a look at the implementation of

Re: admin interface

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 18:30 -0800, mobil wrote: > How to make the admin interface display a list of table columns > instead of just a Users object This is covered in the first two parts of the tutorial. Or you can go directly the admin documentation. The appropriate setting is list_display:

Re: adding with ORM is slow

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 18:26 -0800, [EMAIL PROTECTED] wrote: > Can you try doing Country.objects.create(name=name) instead? Have a look at the implementation of create(). It's not some kind of secret sauce. It's a shortcut. We could remove it from Django and nothing would be slower or less

admin interface

2008-11-28 Thread mobil
How to make the admin interface display a list of table columns instead of just a Users object Select users to change * Add users Users Users object Users object Users object --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Raw SQL and model instances

2008-11-28 Thread [EMAIL PROTECTED]
Malcolm, I believe that should be params = dict(zip(fields, row)) On Nov 28, 8:34 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2008-11-28 at 19:54 +0900, Russell Keith-Magee wrote: > > [...] > > > >>> cursor.execute('SELECT ...') > > >>> row = cursor.fetchone() > > >>> a =

Re: adding with ORM is slow

2008-11-28 Thread [EMAIL PROTECTED]
Can you try doing Country.objects.create(name=name) instead? On Nov 28, 8:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2008-11-28 at 08:40 -0800, burb wrote: > > [...] > > > Code with cursor runs 100x faster than ORM code. > > [...] > > > this is 5x faster than work with ORM. >

Re: new comments and ratings

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 18:18 -0800, [EMAIL PROTECTED] wrote: > I'm afraid my reality belies the blithe comment in the docs that the > removal of ratings should only affect World Online. That's an old joke for stuff that primarily was kept around only for historical reasons. We realise that there

new comments and ratings

2008-11-28 Thread [EMAIL PROTECTED]
I'm afraid my reality belies the blithe comment in the docs that the removal of ratings should only affect World Online. For those of us who *were* using ratings, is there some recommended way for bringing ratings back? I have django-voting, but what I need is the old comment-style 1-5 ratings

Re: Preventing spam attacks on Ajax views

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 14:27 -0800, Julien Phalip wrote: > Hi, > > I'm building a rating app, so people can rate any kind of object (e.g. > a video, a news entry, etc.). The rating is done anonymously (there's > no user account on that site) and via an Ajax query. The view > currently only takes

Re: adding with ORM is slow

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 08:40 -0800, burb wrote: [...] > Code with cursor runs 100x faster than ORM code. [...] > this is 5x faster than work with ORM. > > Where am I doing mistake in using Django ORM? The only mistake is assuming the ORM should be as fast as that raw SQL. The ORM is doing a

Re: Ordering bookeditions by their rating

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 08:24 -0800, coan wrote: [...] > But isn't there a way to get all in one query? > In my head the query would look something like this: > user.edition_set.all().order_by(user__edition__rating) Yes, there is a way to do it like that and I've been wondering why you haven't

Re: sql used in the save method

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 04:05 -0800, Robert wrote: > Hello !! > > I am using mysql as the backend and trying to use insert delayed of a > query (http://dev.mysql.com/doc/refman/5.0/en/insert-delayed.html), to > do this I have to change a bit the insert statement, and I want to > know if is

Re: Raw SQL and model instances

2008-11-28 Thread Malcolm Tredinnick
On Fri, 2008-11-28 at 19:54 +0900, Russell Keith-Magee wrote: [...] > >>> cursor.execute('SELECT ...') > >>> row = cursor.fetchone() > >>> a = Author(*row) > > At this point, a will be a fully populated Author instance, > indistinguishable from one retrieved using a queryset. > > The caveat

Re: Error in django.contrib.comments with {% comment_form_target %}

2008-11-28 Thread Gavin
I'm having exactly the same problem as Brandon above, only I haven't upgraded from .96 to 1.0. This is occurring with a fresh install of 1.0. I've tried all of the suggestions above as well as those in the linked django ticket #8571. Any insights? Cheers, -Gavin On Oct 22, 6:43 am, Brandon

Re: Missing base.css link in admin html pages

2008-11-28 Thread James Fassett
Looks like it was a case of an old django installation in the PythonPath for Apache. Very frustrating. I must have apt installed a django version for Ubuntu back in the day or accidentally ran setup.py on an older version of the trunk. The solution was to uninstall the apt package, remove all

Re: Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-28 Thread Graham Dumpleton
On Nov 29, 9:31 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > Just letting you know off list that I will respond, just need to find > some uninterrupted time to do so. Reply will be back to the list. Hmmm, wrong button. No matter .. Graham > Graham > > On Nov 28, 2:55 pm, Brian

Re: Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-28 Thread Graham Dumpleton
Just letting you know off list that I will respond, just need to find some uninterrupted time to do so. Reply will be back to the list. Graham On Nov 28, 2:55 pm, Brian <[EMAIL PROTECTED]> wrote: > > > This is a good question, and I haven't come to a conclusion. Probably > > > it'll be the

Preventing spam attacks on Ajax views

2008-11-28 Thread Julien Phalip
Hi, I'm building a rating app, so people can rate any kind of object (e.g. a video, a news entry, etc.). The rating is done anonymously (there's no user account on that site) and via an Ajax query. The view currently only takes one parameter, the rating value (a float), so I don't think I can

Re: time differences

2008-11-28 Thread Horst Gutmann
Please take a look at the documentation for the datetime and time modules :-) >>> import datetime >>> datetime.datetime.strptime('2008-09-16 08:01:16', '%Y-%m-%d %H:%M:%S') -- Horst On Fri, Nov 28, 2008 at 10:13 PM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > On Nov 28, 1:35 pm, "Horst Gutmann"

Re: locmem or memcache

2008-11-28 Thread Jeff Anderson
Peter Bengtsson wrote: > What's faster, locmem or memcache? > > I know that the docs rave on about how fast memcache is but what about > locmem? That sounds pretty fast to me since it doesn't need another > TCP service and just uses the RAM. > My particular site (for mobile phones without any

Re: Address Book Contact Importer in Python/Django?

2008-11-28 Thread ro60
At least for gmail the security issue is a little less of a slippery slope. One of the authentication methods is called AuthSub and it allows you to redirect to a google page for the user to login then redirects back the authenticated user to your app. In this way your app never actually handles

Re: time differences

2008-11-28 Thread Bobby Roberts
On Nov 28, 1:35 pm, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > If you convert timea into a normal datetime instance just substract > timea from timeb and you will get a datetime.timedelta instance which > has everything you need :-) > >     import datetime >     a = datetime.datetime(2008,

GeoDjango question about US zipcode lookup and spatial query

2008-11-28 Thread Aaron Lee
Hi all, I am checking out GeoDjango and going through the installation and presentation. I esp. like this one which is very well done http://geodjango.org/presentations/GeoDjango%20-%20A%20world-class%20Geographic%20Web%20Framework%20(DjangoCon%20-%20Sept.%206,%202008).pdf I do have a few basic

Re: runserver error on Mac OSX 10.5.5

2008-11-28 Thread jconway
On Nov 28, 2:49 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > > I uninstalled Macports and removed all the django files I > > could find, then ran setup.py install "manually" but no luck. > > What error did you get then? > copying build/scripts-2.5/django-admin.py -> /usr/local/bin error:

Re: rendering DB text in template

2008-11-28 Thread Django Newbie
Thank you. Alex Koshelev wrote: > Look at this: > http://docs.djangoproject.com/en/dev/topics/templates/#id2 > > > On Fri, Nov 28, 2008 at 21:43, Django Newbie <[EMAIL PROTECTED] > > wrote: > > > So I have some text fields in the db that have some embedded html >

Re: rendering DB text in template

2008-11-28 Thread Alex Koshelev
Look at this: http://docs.djangoproject.com/en/dev/topics/templates/#id2 On Fri, Nov 28, 2008 at 21:43, Django Newbie <[EMAIL PROTECTED]> wrote: > > So I have some text fields in the db that have some embedded html in the > text. How do I get the template to render the text as html? > > The

rendering DB text in template

2008-11-28 Thread Django Newbie
So I have some text fields in the db that have some embedded html in the text. How do I get the template to render the text as html? The text fields are recipe.ingredients and recipe.instructions Recipes .RecipeName{ font-size: large; font-weight: bold; }

Re: time differences

2008-11-28 Thread Horst Gutmann
If you convert timea into a normal datetime instance just substract timea from timeb and you will get a datetime.timedelta instance which has everything you need :-) import datetime a = datetime.datetime(2008, 11, 15) b = datetime.datetime.now() print b-a -- Horst On Fri, Nov

time differences

2008-11-28 Thread Bobby Roberts
I need to know the # of seconds between two dates for my django application. I believe this has to be done with straight python. I've read the py docs on time functions but it doesn't make sense to me. Can anyone help? Here's my situation: timea='11/15/2008 11:35 AM' timeb=datetime.now() How

Re: ERROR: null value in column "id" violates not-null constraint

2008-11-28 Thread Karen Tracey
On Fri, Nov 28, 2008 at 12:07 PM, dbee <[EMAIL PROTECTED]> wrote: > > So django is supposed to be auto incrementing id when i insert a new > value. Instead though, I get ... > > ERROR: null value in column "id" violates not-null constraint > > INSERT INTO "mobi1_campaigns" ("userProfile_id",

Re: adding with ORM is slow

2008-11-28 Thread redbaron
> cursor.execute("delete from app_country where name = %s", (name,)) > cursor.execute("insert into app_country (name) values (%s)", (name,)) > > this is 5x faster than work with ORM. 1. Replace it with single update statement. 2. Do you use transactions? Like

Missing base.css link in admin html pages

2008-11-28 Thread James Fassett
Hi all, I have a strange problem that I can't account for. When I run `python manage.py runserver` for my site and browse to the /admin/ everything works fine. Once I put the site on my server the html spit out by the admin is missing the tag for the base.css stylesheet. e.g. On the server:

Missing base.css link in admin html pages

2008-11-28 Thread James Fassett
Hi all, I have a strange problem that I can't account for. When I run `python manage.py runserver` for my site and browse to the /admin/ everything works fine. Once I put the site on my server the html spit out by the admin is missing the tag for the base.css stylesheet. e.g. On the

adding with ORM is slow

2008-11-28 Thread burb
I have following code: class Country(models.Model): name = models.CharField(max_length = 200, primary_key = True) # ORM variant for name in file: models.Country(name = name).save() # cursor variant for name in file: if cursor.execute("select * from app_country where name = %s", (name,))

Re: NetBeans IDE for Python

2008-11-28 Thread Ovnicraft
2008/11/27 itsnotvalid <[EMAIL PROTECTED]> > > It says for requesting username as password to access. Did I miss > anything here? try guest:guest > > > On Nov 27, 11:14 pm, Ovnicraft <[EMAIL PROTECTED]> wrote: > > 2008/11/27 AndyB <[EMAIL PROTECTED]> > > > > > > > > > More to the point - has

Re: Passing in dynamic id's to a template tag?

2008-11-28 Thread Alex Koshelev
Standard `simple_tag` shortcut resolves variables well. On Fri, Nov 28, 2008 at 19:29, truebosko <[EMAIL PROTECTED]> wrote: > > Mulling over the docs I can't find an answer to this, say I want to do > something like so: > > {% get_shipping 'ontario' product.id %} > > Parsing ontario is simple

ERROR: null value in column "id" violates not-null constraint

2008-11-28 Thread dbee
So django is supposed to be auto incrementing id when i insert a new value. Instead though, I get ... ERROR: null value in column "id" violates not-null constraint INSERT INTO "mobi1_campaigns" ("userProfile_id", "name", "description", "send_date", "create_date", "campaign_hash",

Re: forms and modelform

2008-11-28 Thread Buddy
Yes, I try it before to my ask here. I get error if use likethis (class B(forms.ModelForm, A): ### TypeError at /A/ Error when calling the metaclass bases metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases Request

Re: forms and modelform

2008-11-28 Thread Daniel Roseman
On Nov 28, 3:47 pm, Buddy <[EMAIL PROTECTED]> wrote: > I have model: > > class A(forms.Form): >     p1 = forms.CharField() >     p2 = forms.CharField() > > class B(A): >     class Meta: >         model = User >         fields = ('username', 'email', 'first_name', 'last_name',) > >

Passing in dynamic id's to a template tag?

2008-11-28 Thread truebosko
Mulling over the docs I can't find an answer to this, say I want to do something like so: {% get_shipping 'ontario' product.id %} Parsing ontario is simple enough, but how do I parse product.id to actually come in as a number? No matter what I've tried it just comes in as 'product.id' and I

Re: Ordering bookeditions by their rating

2008-11-28 Thread coan
On Nov 28, 1:50 pm, Peter Bengtsson <[EMAIL PROTECTED]> wrote: > The trick is to use .query.group_by. > Here's an example that will work:: Thank you for taking the time to putting this example together! You are hereby granted the title "django query ninja"! What I was trying to do was perhaps

forms and modelform

2008-11-28 Thread Buddy
I have model: class A(forms.Form): p1 = forms.CharField() p2 = forms.CharField() class B(A): class Meta: model = User fields = ('username', 'email', 'first_name', 'last_name',) http://dpaste.com/94378/ but fields that define in class B not apears when I render it

Re: Help organizing inline fields in User

2008-11-28 Thread mondonauta
well... maybe i missed something, but i've already tried what u told me. i copied and pasted the fieldsets from django.contrib.auth.admin.UserAdmin to my ProfessorAdmin class and i modified it in order to add my custom fields in the formset i wanted. well what i got is this error:

Re: Overriding contrib.auth User save()

2008-11-28 Thread sergioh
I did not notice you were trying to override in a wrong way, sorry about that. Actually for override the user model you need to: class CustomUser(User): #your new fields, DRY user fields objects = MyCustomManager() class MyCustomManager(models.Manager): def

Re: Form Widget Attributes

2008-11-28 Thread sergioh
Probably you will need to create your custom widget and override the method: def id_for_label(self, id_): # See the comment for RadioSelect.id_for_label() if id_: id_ += '_0' return id_ id_for_label = classmethod(id_for_label) at the checkboxmultiple

Re: sql used in the save method

2008-11-28 Thread sergioh
There is On Nov 28, 8:05 am, Robert <[EMAIL PROTECTED]> wrote: > Hello !! > > I am using mysql as the backend and trying to use insert delayed of a > query (http://dev.mysql.com/doc/refman/5.0/en/insert-delayed.html), to > do this I have to change a bit the insert statement, and I want to > know

Form Widget Attributes

2008-11-28 Thread Alfonso
I'd like to specify a unique id for each checkbox iteration in a CheckboxSelectMultiple setup. This is what I have so far: grading = forms.BooleanField(label="Site Grading", widget=forms.CheckboxSelectMultiple(choices=grading_choices)) So in my form using the tag {{ form.grading }} gives me:

Re: Overriding contrib.auth User save()

2008-11-28 Thread sergioh
On Nov 28, 8:02 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 28 nov, 09:45, Paddy Joy <[EMAIL PROTECTED]> wrote: > > > Thanks however I'm guessing: > > > > admin.site.unregister(User) > > > admin.site.register(User, NewModelForm) > > > will only work in the admin site? > > Yes.

Re: Implement file upload in admin interface

2008-11-28 Thread redbaron
My current solution is. 1. Define new model Batches: class Batches(models.Model): batchfile = model.FileField(upload_to="noop") 2. In admin.py define new form with custom validators: class BatchUploadForm(forms.ModelFormi): class Meta: model = Batches def

Re: Need help for sorting

2008-11-28 Thread laspal
Ok thanks but I ran into some other problem. I have company1 with 3 callreports with dates -> 20 Nov, 25 Nov, 28 Nov company 2 with callreports dates -> 10 Nov, 13 nov. so my problem here is when I do : company_list = Company.objects.select_related().order_by('- callreports__meetingdate') gives

Re: Help organizing inline fields in User

2008-11-28 Thread sergioh
You could use field sets to get your information organized: fieldsets = ( ('Account Information', { 'fields':('company_name', 'username', 'password', 'email', 'is_active')}), ('Company Information',{'fields': ('physical_address', 'city', 'state', 'zip_code',

Help organizing inline fields in User

2008-11-28 Thread mondonauta
hello everybody, i've already created a custom user profile and added it to the User by foreignkey, AUTH_PROFILE_MODULE and i have been able to add the custom profile to the admin page by coding in admin.py this: ___ from django.contrib import admin from

locmem or memcache

2008-11-28 Thread Peter Bengtsson
What's faster, locmem or memcache? I know that the docs rave on about how fast memcache is but what about locmem? That sounds pretty fast to me since it doesn't need another TCP service and just uses the RAM. My particular site (for mobile phones without any media) is so tiny that I wouldn't

Re: Ordering bookeditions by their rating

2008-11-28 Thread Peter Bengtsson
The trick is to use .query.group_by. Here's an example that will work:: >>> from collection.models import Edition, User, Rating >>> Rating.objects.all().delete() >>> Edition.objects.all().delete() >>> >>> e1 = Edition.objects.create(title=u'Title1', binding=u'') >>> e2 =

Re: Ordering bookeditions by their rating

2008-11-28 Thread coan
On Nov 28, 12:56 pm, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 28 nov, 11:07, coan <[EMAIL PROTECTED]> wrote: > What's the point of having two distinct models for Bookcollection and > Rating ??? Looks like mostly redundant to me. Good point, I have considered moving ratings into the

sql used in the save method

2008-11-28 Thread Robert
Hello !! I am using mysql as the backend and trying to use insert delayed of a query (http://dev.mysql.com/doc/refman/5.0/en/insert-delayed.html), to do this I have to change a bit the insert statement, and I want to know if is possible to know before executing the sql what is the sql INSERT

Re: Overriding contrib.auth User save()

2008-11-28 Thread bruno desthuilliers
On 28 nov, 09:45, Paddy Joy <[EMAIL PROTECTED]> wrote: > Thanks however I'm guessing: > > > > > admin.site.unregister(User) > > admin.site.register(User, NewModelForm) > > will only work in the admin site? Yes. > Not actually using the admin site at > the moment but would nice to have something

Re: Ordering bookeditions by their rating

2008-11-28 Thread bruno desthuilliers
On 28 nov, 11:07, coan <[EMAIL PROTECTED]> wrote: > I have book editions in my database. Users can rate editions. If they > want, they can also add them to their book collection. > Here is a simplified overview of the models: > > class Edition(models.Model): > title =

Re: Implement file upload in admin interface

2008-11-28 Thread Ben Lau
Hi redbaron, My approach is to subclass ModelAdmin to implement a import command . It should need to override the __call__() and create a import_view() function to handle the import form. Example: class XXXAdmin(admin.ModelAdmin): def __call__(self, request, url):

Re: Raw SQL and model instances

2008-11-28 Thread Georg Göttlich
Hello Russ, thank you very much. This is exactly what I wanted to know. Best regards, Georg Göttlich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Raw SQL and model instances

2008-11-28 Thread Russell Keith-Magee
On Fri, Nov 28, 2008 at 6:42 PM, Georg Göttlich <[EMAIL PROTECTED]> wrote: > > Hello everybody, > > this question has probably been ask quite often already, but I > couldn't find anything proper on it. So here it is: > > Is there a way to feed the result cursor of a custom sql query back > into

Re: Raw SQL and model instances

2008-11-28 Thread Daniel Roseman
On Nov 28, 9:42 am, Georg Göttlich <[EMAIL PROTECTED]> wrote: > Hello everybody, > > this question has probably been ask quite often already, but I > couldn't find anything proper on it. So here it is: > > Is there a way to feed the result cursor of a custom sql query back > into the ORM, thus

Re: Implement file upload in admin interface

2008-11-28 Thread redbaron
I try to implement same thing.I need some place where I could upload file, django should parse it and populate database with new data. To make it more ease I defined new model BatchUpload with only one field batch. Now I need to customize upload handler method in admin site. Could anyone give

Ordering bookeditions by their rating

2008-11-28 Thread coan
I have book editions in my database. Users can rate editions. If they want, they can also add them to their book collection. Here is a simplified overview of the models: class Edition(models.Model): title = models.models.CharField(max_length=255) binding=

Raw SQL and model instances

2008-11-28 Thread Georg Göttlich
Hello everybody, this question has probably been ask quite often already, but I couldn't find anything proper on it. So here it is: Is there a way to feed the result cursor of a custom sql query back into the ORM, thus recieving model instances, as if you'd use a queryset? Thanks a lot, Georg

Re: Logout- Back Button

2008-11-28 Thread jai_python
Any possible to clear browser cache alone using javascript? it ill help to solve this back button problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: runserver error on Mac OSX 10.5.5

2008-11-28 Thread Horst Gutmann
MacPorts fragments a normal Python installation up into multiple smaller packages. For example: The sqlite3 support which is actually part of the core Python package is there in py25-sqlite3. But if you've already uninstalled MacPorts this is moot now, except if you want to reinstall it to get

Re: Overriding contrib.auth User save()

2008-11-28 Thread Paddy Joy
Thanks however I'm guessing: > > admin.site.unregister(User) > admin.site.register(User, NewModelForm) > will only work in the admin site? Not actually using the admin site at the moment but would nice to have something that would work globally. I nearly have the monkey patch working however