django and database views

2009-01-05 Thread drakkan

Hi all,

I mapped a database view in django model as a normal database table,

all seems fine and I'm able to follow foreign key too, here is a
sample

class databaseview(models.Model):
  field1=
  
  
  user=models.ForeignKey(User)


however if i delete an user with records associated in the view I have
this error:

NotSupportedError: cannot delete from a view
HINT:  You need an unconditional ON DELETE DO INSTEAD rule.

django try to delete record from the view and this obviously fails,

there is a know workaround for this? any way to declare read only the
model?

regards
drakkan






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



Re: django and database views

2009-01-05 Thread drakkan



On 6 Gen, 00:06, "Russell Keith-Magee"  wrote:
> On Mon, Jan 5, 2009 at 11:31 PM, drakkan  wrote:
>
> > Hi all,
>
> > I mapped a database view in django model as a normal database table,
> ...
> > there is a know workaround for this? any way to declare read only the
> > model?
>
> In short, no. Django doesn't currently provide any support for database views.
>
> There might be a few tricks you could do (such as redefining delete()

thanks but this didn't work I already redefined delete as follow:


def delete(self):
pass

but the error is the same


> to be a no-op on the view model and on a custom default manager), but
> these certainly aren't tested or proven suggestions.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and database views

2009-01-05 Thread drakkan



On 6 Gen, 00:32, Malcolm Tredinnick  wrote:
> On Mon, 2009-01-05 at 06:31 -0800, drakkan wrote:
> > however if i delete an user with records associated in the view I have
> > this error:
>
> > NotSupportedError: cannot delete from a view
> > HINT:  You need an unconditional ON DELETE DO INSTEAD rule.
>
> > django try to delete record from the view and this obviously fails,
>
> > there is a know workaround for this? any way to declare read only the
> > model?
>
> There's no way to say a model is read only. But the solution is easy:
> don't try to delete anything on it. You are in complete control of your
> code. It's entirely up to you whether you try to delete or save things
> on a model, so if it hurts when you do that, just don't do it.

Malcolm, I try to delete an user from the auth_user table; the user is
referenced as foreign key in the view and the delete cascade django
default try to delete all the reference,

I need a foreign key like in the view to write code such as:

databaseview.user.username

so I can use select_related and get all needed database object with
only one query (I use the database view to aggregate some many to many
tables)

so a possible solution is delete the referenced foreign key from the
table on which the views is based on and then delete the target object
(an user object in my example),

however this is error prone, I'm searching a more clean solution such
as redefine delete() or some hack with custom manager,

thanks
drakkan
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and database views

2009-01-05 Thread drakkan



On 6 Gen, 00:41, drakkan  wrote:
> On 6 Gen, 00:32, Malcolm Tredinnick  wrote:
>
>
>
> > On Mon, 2009-01-05 at 06:31 -0800, drakkan wrote:
> > > however if i delete an user with records associated in the view I have
> > > this error:
>
> > > NotSupportedError: cannot delete from a view
> > > HINT:  You need an unconditional ON DELETE DO INSTEAD rule.
>
> > > django try to delete record from the view and this obviously fails,
>
> > > there is a know workaround for this? any way to declare read only the
> > > model?
>
> > There's no way to say a model is read only. But the solution is easy:
> > don't try to delete anything on it. You are in complete control of your
> > code. It's entirely up to you whether you try to delete or save things
> > on a model, so if it hurts when you do that, just don't do it.
>
> Malcolm, I try to delete an user from the auth_user table; the user is
> referenced as foreign key in the view and the delete cascade django
> default try to delete all the reference,
>
> I need a foreign key like in the view to write code such as:
>
> databaseview.user.username
>
> so I can use select_related and get all needed database object with
> only one query (I use the database view to aggregate some many to many
> tables)
>
> so a possible solution is delete the referenced foreign key from the
> table on which the views is based on and then delete the target object
> (an user object in my example),
>
> however this is error prone, I'm searching a more clean solution such
> as redefine delete() or some hack with custom manager,
>
> thanks
> drakkan
>
>

Ok, I'll try to explain with an example, with user objects I mean
standard django users (django.contrib.auth)


table1:

class table1(models.Model):
field1=
field2=...
user=models.ForeignKey(User)

I have a database view with fileds from table1 and some others
database tables:

class databaseview(models.Model):
  field1table1=
  field1table2=...
  
  user=models.ForeignKey(User)

I defined foreignkey relation in the models mapped to database view
too. This works fine when I access related objects and with
select_related I can load a full graph of object with only one
database query.

Suppose I want to delete an user. This user is in table1 and so in
databaseview too. Django default is to do a delete cascade so it tries
to remove the user from table1, databaseview and auth_user: it fails
when try to remove user from databaseview.

A possible solution would be :

- before issue user.delete(), issue something like
table1.objects.filter(user=u).delete() (this way user reference
disappear from databaseview too) and then u.delete()

however in my application I have several foreign key defined in the
model for the database view so this solution can be error prone, would
be really useful a way to define my mapped view read only or override
the delete cascade for this table,

is this possible with django or I need to find some other solution?

thanks
drakkan

>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



orm: delete performance and queries optimization

2009-01-08 Thread drakkan

In my database I have some tables full of records, when I delete an
object django use the cascade behaviour and this is good, however
seems it make a query for every related object and after this django
seems to issue a delete where id in () for every 100 objects

look at this, Oggetti returns 8244 records:

t=Test.objects.get(pk=10)
Oggetti.objects.filter(test=t).delete()

I interrupted the operation after about 30 minutes and:

len(connection.queries)
4188

now in the database I have 6044 records so only 2200 were deleted and
this make 4188 queries

I think some optimization is needed,

reagards
drakkan





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



Re: orm: delete performance and queries optimization

2009-01-09 Thread drakkan

Thanks for the answer, I already solved the problem using raw sql and
reconfiguring postgres with on delete cascade on relevant foreign key
(obviously this doesn't work with mysql and myisam),

my database can seems slow but consider I have about 20.000.000
records on some tables and I tested a mass delete, maybe my users will
never do this but I need to test an application before release

consider that other orm such sqlalchemy (with the right configuration)
can manage the mass delete without problems (tested on postgres), the
trick is to allow control on the database cascade behaivour, I
understand you are not interested to add this features to django :-(,
we can however use django and raw sql

regards
drakkan

On 9 Gen, 02:26, Malcolm Tredinnick  wrote:
> On Thu, 2009-01-08 at 04:54 -0800, drakkan wrote:
> > In my database I have some tables full of records, when I delete an
> > object django use the cascade behaviour and this is good, however
> > seems it make a query for every related object and after this django
> > seems to issue a delete where id in () for every 100 objects
>
> We need to pull out the ids since deletes can occur across multiple
> tables in various situations. We only do deletes in chunks since there
> are maximum lengths of SQL queries. 100 isn't a bad number. If you're
> needing to do tens of thousands of deletes regularly, use raw SQL.
>
> [...]
>
> > I think some optimization is needed,
>
> We take patches. :-)
>
> Just make sure the changes have a chance of working on all our database
> backends.
>
> Seriously, I'm a little surprised your database is only able to do less
> than 2.5 queries per second. Be that as it may, if you're needing to do
> mass deletes, do them directly. Django is never intended to be a
> complete replacement for SQL and typical "delete" usage for a web
> framework is a record or two, not thousands and thousands. Although it
> should still be able to handle the latter case comfortably (I just
> tested a 10,000 object delete and it only took a few minutes) unless
> your models are quite complicated or there are lots and lots of indexes
> to update or something. In other words, there are going to be
> circumstance-specific exceptions, so testing and profiling is a good
> idea. If this is a big problem for you, by all means look at what
> changes might be possible. The code in question is in
> django/db/models/base.py and django/db/models/query.py. It's a little
> complex, but not horribly scary.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Memory error

2009-08-05 Thread drakkan

here is the excpetion returned while trying to serve a large file:

Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/contrib/auth/
decorators.py" in __call__
  78. return self.view_func(request, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
_result_iter
  106. self._fill_cache()
File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
_fill_cache
  692. self._result_cache.append(self._iter.next
())
File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
iterator
  243. only_load=only_load)
File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
get_cached_row
  987. obj = klass(*fields)
File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in
__init__
  263. setattr(self, field.attname, val)

Exception Type: MemoryError at 
Exception Value:

any way to solve the issue?

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



Re: Memory error

2009-08-05 Thread drakkan

No sorry isn't a file upload but is django to serve a large file

On 5 Ago, 13:47, krylatij  wrote:
> tryhttp://docs.djangoproject.com/en/dev/ref/settings/#file-upload-max-me...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Memory error

2009-08-05 Thread drakkan

No I'm not serving static file I have a very large json file
dinamycally generated (based on a db query)

On 5 Ago, 15:28, Mike Ramirez  wrote:
> On Wednesday 05 August 2009 04:08:15 am drakkan wrote:
>
>
>
> > here is the excpetion returned while trying to serve a large file:
>
> > Traceback:
> > File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
> > in get_response
> >   92.                 response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "/usr/lib/python2.4/site-packages/django/contrib/auth/
> > decorators.py" in __call__
> >   78.             return self.view_func(request, *args, **kwargs)
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > _result_iter
> >   106.                 self._fill_cache()
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > _fill_cache
> >   692.                     self._result_cache.append(self._iter.next
> > ())
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > iterator
> >   243.                             only_load=only_load)
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > get_cached_row
> >   987.             obj = klass(*fields)
> > File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in
> > __init__
> >   263.                 setattr(self, field.attname, val)
>
> > Exception Type: MemoryError at 
> > Exception Value:
>
> > any way to solve the issue?
>
> > thanks
> > drakkan
>
> I assume you're using django to serve static files, this method isn't
> recommended, it is inefficient [1].  You'll want to serve static files
> through another method, such as a nginx server or follow the mod_python
> instructions on serving static files [2]. Personally, I find it is just
> better, even in development to follow this 'rule of thumb' and setup a vhost
> for serving media/static files through apache, bypassing django.
>
> [1]http://docs.djangoproject.com/en/dev/howto/static-files/#the-big-fat-...
>
> [2]http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serv...
>
> Mike
>
> --
> Overdrawn?  But I still have checks left!
>
>  signature.asc
> < 1KVisualizzaScarica
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Memory error

2009-08-05 Thread drakkan

The code is something like this

obj=DBModels.objects.filter(somefilter)
results=[]
for o in obj:
  results.append({'field1':o.field1,'field2':o.field2})

return JsonResponse(results)

where JsonResponse is a class derived from HttpResponse that add a
simplejson.dumps

I have a really large database and in some edge case I need to return
a large number of results (about 150.000 when I get the error). I make
only one query with select_related and I tried also with DEBUG=False
but nothing changed only the detailed stack trace isn't printed,

thanks
drakkan



On 5 Ago, 21:02, Peter Herndon  wrote:
> On 08/05/2009 12:26 PM, drakkan wrote:> No I'm not serving static file I have 
> a very large json file
> > dinamycally generated (based on a db query)
>
> Please post the relevant view and model code, so we can see what's
> happening.  Also, if your db query is actually a really large number of
> db queries, and you are running in debug mode (DEBUG = True in
> settings), then Django caches all of your SQL queries to assist with
> debugging -- at the expense of memory and performance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django models/ sqlalchemy

2009-08-26 Thread drakkan

You can:

1) redefine your sa models in django models.py
2) use sqlalchemy-migrate for database migration and initial data
population, I never used json for initial data with migrate

drakkan

On 26 Ago, 17:29, ajay  wrote:
> HI,
>     I have used sqlalchemy for database model creation instead django
> default ORM.
>     Now i need to use fixture to load the initial data as i run test
> cases.
>     This is error message "DeserializationError: Invalid model
> identifier:"
>     The models are not defined in models.py file as i am using
> alchemy .
>     Is there any way i can use fixture to load initial data in my
> database .
>
>     my structure of app look like this
>          models.py
>          views.py
>           alchemy.py     - database models are defined here .
>           tests.py
>
>    I am using json as serialized data.
>
> With Thanks
> Vijay
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



File Field max size and admin interface

2009-09-13 Thread drakkan

Hi,

I'm using the admin interface with some filefield, I tested with a big
file (200 MB) and it was successfully uploaded, this is ok but I would
like a way to limiting the uploaded size for example to a maximun of
10 MB, any hints?

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



send_mail and cc

2009-03-27 Thread drakkan

Hi all,

there is a way to send cc mail using django mail wrapper?

reading the official docs:

http://docs.djangoproject.com/en/dev/topics/email/#topics-email

seems only possible to define to and bcc recipients but not cc,

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



Re: send_mail and cc

2009-03-28 Thread drakkan

ok for the records subclassing EmailMessage this way work:

class MyEmailMessage(EmailMessage):
def __init__(self, subject='', body='', from_email=None, to=None,
cc=None, bcc=None,
connection=None, attachments=None, headers=None):
super(MyEmailMessage,self).__init__
(subject,body,from_email,to,bcc,connection,attachments,headers)
self.cc=cc

def message(self):
msg=super(MyEmailMessage,self).message()
msg['Cc']= ', '.join(self.cc)
return msg

def recipients(self):
return self.to + self.cc + self.bcc

regards
drakkan

On 28 Mar, 01:13, Malcolm Tredinnick  wrote:
> On Fri, 2009-03-27 at 16:50 -0700, drakkan wrote:
> > Hi all,
>
> > there is a way to send cc mail using django mail wrapper?
>
> > reading the official docs:
>
> >http://docs.djangoproject.com/en/dev/topics/email/#topics-email
>
> > seems only possible to define to and bcc recipients but not cc,
>
> That's correct, since "to" is functionally equivalent to "cc" (whereas
> "to" and "bcc" are not). You can, and are encouraged to, subclass the
> email message class if you want to add things like that.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django and i18n what's wrong???

2009-04-13 Thread drakkan

Hi, I'm trying to use i18n with django. I followed the docs and
created my transalations for english,italian and spanish

in settings I have:

ugettext = lambda s: s

LANGUAGES = (
('en', ugettext('English')),
('it', ugettext('Italian')),
('es', ugettext('Spanish')),
)

and I installed the locale middleware

MIDDLEWARE_CLASSES = (
'django.contrib.csrf.middleware.CsrfMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
)

If I change the settings:

LANGUAGE_CODE

all is fine both javascript and coded string are correctly transalted.

If I comment LANGUAGE_CODE settings and change the browser language
preference only javascript is correctly translated. I have the same
issue if I change

request.LANGUAGE_CODE

or

request.session[settings.LANGUAGE_COOKIE_NAME]

so the problem seems related to locale middleware.

Someone with the same issue? Is this a django bug or a my
misconfiguration?

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



Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

The string that doesn't works are defined in models.py:

STATUS=(
(1,_('Active')),
(0,_('Inactive')),
)

class TestModel(models.Model):
status=models.IntegerField("Status",choices=STATUS,default=1)

in my view I have:

'status':u.get_status_display()

ant this is not transalted, why?

On 13 Apr, 19:11, drakkan  wrote:
> Hi, I'm trying to use i18n with django. I followed the docs and
> created my transalations for english,italian and spanish
>
> in settings I have:
>
> ugettext = lambda s: s
>
> LANGUAGES = (
>     ('en', ugettext('English')),
>     ('it', ugettext('Italian')),
>     ('es', ugettext('Spanish')),
> )
>
> and I installed the locale middleware
>
> MIDDLEWARE_CLASSES = (
>     'django.contrib.csrf.middleware.CsrfMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'django.middleware.locale.LocaleMiddleware',
>     'django.middleware.doc.XViewMiddleware',
> )
>
> If I change the settings:
>
> LANGUAGE_CODE
>
> all is fine both javascript and coded string are correctly transalted.
>
> If I comment LANGUAGE_CODE settings and change the browser language
> preference only javascript is correctly translated. I have the same
> issue if I change
>
> request.LANGUAGE_CODE
>
> or
>
> request.session[settings.LANGUAGE_COOKIE_NAME]
>
> so the problem seems related to locale middleware.
>
> Someone with the same issue? Is this a django bug or a my
> misconfiguration?
>
> thanks
> drakkan1000
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

I found a workaround I have to do:

'status':_(u.get_status_display())

even if I have already marked the string for translation in models:

STATUS=(
(1,_('Active')),
(0,_('Inactive')),
)

this is a really strange behaviour ...

On 13 Apr, 21:07, drakkan  wrote:
> The string that doesn't works are defined in models.py:
>
> STATUS=(
>     (1,_('Active')),
>     (0,_('Inactive')),
> )
>
> class TestModel(models.Model):
>     status=models.IntegerField("Status",choices=STATUS,default=1)
>
> in my view I have:
>
> 'status':u.get_status_display()
>
> ant this is not transalted, why?
>
> On 13 Apr, 19:11, drakkan  wrote:
>
> > Hi, I'm trying to use i18n with django. I followed the docs and
> > created my transalations for english,italian and spanish
>
> > in settings I have:
>
> > ugettext = lambda s: s
>
> > LANGUAGES = (
> >     ('en', ugettext('English')),
> >     ('it', ugettext('Italian')),
> >     ('es', ugettext('Spanish')),
> > )
>
> > and I installed the locale middleware
>
> > MIDDLEWARE_CLASSES = (
> >     'django.contrib.csrf.middleware.CsrfMiddleware',
> >     'django.contrib.sessions.middleware.SessionMiddleware',
> >     'django.middleware.common.CommonMiddleware',
> >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> >     'django.middleware.locale.LocaleMiddleware',
> >     'django.middleware.doc.XViewMiddleware',
> > )
>
> > If I change the settings:
>
> > LANGUAGE_CODE
>
> > all is fine both javascript and coded string are correctly transalted.
>
> > If I comment LANGUAGE_CODE settings and change the browser language
> > preference only javascript is correctly translated. I have the same
> > issue if I change
>
> > request.LANGUAGE_CODE
>
> > or
>
> > request.session[settings.LANGUAGE_COOKIE_NAME]
>
> > so the problem seems related to locale middleware.
>
> > Someone with the same issue? Is this a django bug or a my
> > misconfiguration?
>
> > thanks
> > drakkan1000
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

I'm using ugettext, I have to use the lazy variant?

On 13 Apr, 21:53, Ramiro Morales  wrote:
> On Mon, Apr 13, 2009 at 4:30 PM, drakkan  wrote:
>
> > I found a workaround I have to do:
>
> > 'status':_(u.get_status_display())
>
> > even if I have already marked the string for translation in models:
>
> > STATUS=(
> >    (1,_('Active')),
> >    (0,_('Inactive')),
> > )
>
> > this is a really strange behaviour ...
>
> To which one of the *gettext* function(s) are the _ alias
> defined in both models.py and views.py?
>
> --
> Ramiro Moraleshttp://rmorales.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

ok I'll try it,

thanks
drakkan1000

On 13 Apr, 22:39, Alex Gaynor  wrote:
> On Mon, Apr 13, 2009 at 4:37 PM, drakkan  wrote:
>
> > I'm using ugettext, I have to use the lazy variant?
>
> > On 13 Apr, 21:53, Ramiro Morales  wrote:
> > > On Mon, Apr 13, 2009 at 4:30 PM, drakkan  wrote:
>
> > > > I found a workaround I have to do:
>
> > > > 'status':_(u.get_status_display())
>
> > > > even if I have already marked the string for translation in models:
>
> > > > STATUS=(
> > > >    (1,_('Active')),
> > > >    (0,_('Inactive')),
> > > > )
>
> > > > this is a really strange behaviour ...
>
> > > To which one of the *gettext* function(s) are the _ alias
> > > defined in both models.py and views.py?
>
> > > --
> > > Ramiro Moraleshttp://rmorales.net
>
> Yes, for any module level strings you need to use the lazy variant.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and i18n what's wrong???

2009-04-14 Thread drakkan

Ok remain two minor issue:

1) http://code.djangoproject.com/ticket/5494
2) ugettext_lazy are not json serializable so when I use transaltion
to populate ajax widgets I have to explicitily convert to unicode, but
this is really a minor issue

any eta for 1)? will be in django 1.1, still the same issue with
django trunk

thanks
drakkan1000

On 13 Apr, 22:43, drakkan  wrote:
> ok I'll try it,
>
> thanks
> drakkan1000
>
> On 13 Apr, 22:39, Alex Gaynor  wrote:
>
> > On Mon, Apr 13, 2009 at 4:37 PM, drakkan  wrote:
>
> > > I'm using ugettext, I have to use the lazy variant?
>
> > > On 13 Apr, 21:53, Ramiro Morales  wrote:
> > > > On Mon, Apr 13, 2009 at 4:30 PM, drakkan  wrote:
>
> > > > > I found a workaround I have to do:
>
> > > > > 'status':_(u.get_status_display())
>
> > > > > even if I have already marked the string for translation in models:
>
> > > > > STATUS=(
> > > > >    (1,_('Active')),
> > > > >    (0,_('Inactive')),
> > > > > )
>
> > > > > this is a really strange behaviour ...
>
> > > > To which one of the *gettext* function(s) are the _ alias
> > > > defined in both models.py and views.py?
>
> > > > --
> > > > Ramiro Moraleshttp://rmorales.net
>
> > Yes, for any module level strings you need to use the lazy variant.
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your right to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



formfield_for_foreignkey: how to know if we are modifyng an entry

2010-06-26 Thread drakkan
Hi,

I'm customizing the django admin and I need to do a particular filter
for a foreign key if I'm modifying a model, I'm using the following
method, it works but it seems to me an hack, is there a better way to
do the same thing?

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "domain":
mod=False
ID=-1
for val in request.path.split('/'):
try:
ID=int(val)
mod=True
break
except:
pass
if mod:
m_user=MailUser.objects.get(pk=ID)
kwargs["queryset"] = 
Domain.objects.filter(id=m_user.domain_id)
..
return db_field.formfield(**kwargs)
.

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



Re: formfield_for_foreignkey: how to know if we are modifyng an entry

2010-06-27 Thread drakkan
On 27 Giu, 18:00, Walt  wrote:
> I'm not sure if it works in this context but have you tried
> self.instance.id?

No it doesn't work in my context, other ideas?

>
> Walt
>
> -~

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



django cron script works in django 1.1.1 but not in 1.1.2 and 1.2.1

2010-06-06 Thread drakkan
Hi,

I'm migrating my sites to django 1.2.1 however I noticed my cron
scripts doesn't work anymore with the latest django version, I'm using
the setup_environ method

http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

and I tryed also the DJANGO_SETTINGS_MODULE environment variable
method with the same results:

1) my cron script work fine in 1.1.1 but not in 1.1.2 and 1.2.1
2) the script exit with a trace such this:

Traceback (most recent call last):
  File "syncdomains.py", line 16, in 
from systemcp.domini.models import Domain, ProtectedArea,
HttpErrors
  File "/home/nicola/workspace/SystemPanel/src/systemcp/domini/
models.py", line 3, in 
from systemcp.utenti.models import UserInfo
  File "/home/nicola/workspace/SystemPanel/src/systemcp/utenti/
models.py", line 76, in 
admin.site.register(UserInfo,UserInfoAdmin)
  File "/usr/lib/python2.6/site-packages/django/contrib/admin/
sites.py", line 90, in register
validate(admin_class, model)
  File "/usr/lib/python2.6/site-packages/django/contrib/admin/
validation.py", line 20, in validate
models.get_apps()
  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
line 115, in get_apps
self._populate()
  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
line 64, in _populate
self.load_app(app_name)
  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
line 78, in load_app
models = import_module('.models', app_name)
  File "/usr/lib/python2.6/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
  File "/home/nicola/workspace/SystemPanel/src/systemcp/ftp/
models.py", line 4, in 
from systemcp.domini.models import Domain
ImportError: cannot import name Domain

this trace tipycally mean circolar import  but I'm sure I don't have
this error in my code, maybe I have to change my envirornment
initialization for cron script since 1.1.2?

If I execute the same imports I do in my cron script using python
manage.py shell, they works fine so I think something changed in the
environment initialization

any hints?

thanks
drakkan

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



Re: django cron script works in django 1.1.1 but not in 1.1.2 and 1.2.1

2010-06-06 Thread drakkan
with 1.2.0 beta 1 my cron script works too

On 6 Giu, 15:14, drakkan  wrote:
> Hi,
>
> I'm migrating my sites to django 1.2.1 however I noticed my cron
> scripts doesn't work anymore with the latest django version, I'm using
> the setup_environ method
>
> http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/
>
> and I tryed also the DJANGO_SETTINGS_MODULE environment variable
> method with the same results:
>
> 1) my cron script work fine in 1.1.1 but not in 1.1.2 and 1.2.1
> 2) the script exit with a trace such this:
>
> Traceback (most recent call last):
>   File "syncdomains.py", line 16, in 
>     from systemcp.domini.models import Domain, ProtectedArea,
> HttpErrors
>   File "/home/nicola/workspace/SystemPanel/src/systemcp/domini/
> models.py", line 3, in 
>     from systemcp.utenti.models import UserInfo
>   File "/home/nicola/workspace/SystemPanel/src/systemcp/utenti/
> models.py", line 76, in 
>     admin.site.register(UserInfo,UserInfoAdmin)
>   File "/usr/lib/python2.6/site-packages/django/contrib/admin/
> sites.py", line 90, in register
>     validate(admin_class, model)
>   File "/usr/lib/python2.6/site-packages/django/contrib/admin/
> validation.py", line 20, in validate
>     models.get_apps()
>   File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> line 115, in get_apps
>     self._populate()
>   File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> line 64, in _populate
>     self.load_app(app_name)
>   File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> line 78, in load_app
>     models = import_module('.models', app_name)
>   File "/usr/lib/python2.6/site-packages/django/utils/importlib.py",
> line 35, in import_module
>     __import__(name)
>   File "/home/nicola/workspace/SystemPanel/src/systemcp/ftp/
> models.py", line 4, in 
>     from systemcp.domini.models import Domain
> ImportError: cannot import name Domain
>
> this trace tipycally mean circolar import  but I'm sure I don't have
> this error in my code, maybe I have to change my envirornment
> initialization for cron script since 1.1.2?
>
> If I execute the same imports I do in my cron script using python
> manage.py shell, they works fine so I think something changed in the
> environment initialization
>
> any hints?
>
> thanks
> drakkan

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



Re: django cron script works in django 1.1.1 but not in 1.1.2 and 1.2.1

2010-06-06 Thread drakkan
On 6 Giu, 16:31, Karen Tracey  wrote:
> On Sun, Jun 6, 2010 at 9:14 AM, drakkan  wrote:
> > I'm migrating my sites to django 1.2.1 however I noticed my cron
> > scripts doesn't work anymore with the latest django version, I'm using
> > the setup_environ method
>
> >http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/
>
> > and I tryed also the DJANGO_SETTINGS_MODULE environment variable
> > method with the same results:
>
> > 1) my cron script work fine in 1.1.1 but not in 1.1.2 and 1.2.1
> > 2) the script exit with a trace such this:
>
> > Traceback (most recent call last):
> >  File "syncdomains.py", line 16, in 
> >    from systemcp.domini.models import Domain, ProtectedArea,
> > HttpErrors
> >  File "/home/nicola/workspace/SystemPanel/src/systemcp/domini/
> > models.py", line 3, in 
> >    from systemcp.utenti.models import UserInfo
> >  File "/home/nicola/workspace/SystemPanel/src/systemcp/utenti/
> > models.py", line 76, in 
> >    admin.site.register(UserInfo,UserInfoAdmin)
> >  File "/usr/lib/python2.6/site-packages/django/contrib/admin/
> > sites.py", line 90, in register
> >    validate(admin_class, model)
> >  File "/usr/lib/python2.6/site-packages/django/contrib/admin/
> > validation.py", line 20, in validate
> >    models.get_apps()
> >  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> > line 115, in get_apps
> >    self._populate()
> >  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> > line 64, in _populate
> >    self.load_app(app_name)
> >  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> > line 78, in load_app
> >    models = import_module('.models', app_name)
> >  File "/usr/lib/python2.6/site-packages/django/utils/importlib.py",
> > line 35, in import_module
> >    __import__(name)
> >  File "/home/nicola/workspace/SystemPanel/src/systemcp/ftp/
> > models.py", line 4, in 
> >    from systemcp.domini.models import Domain
> > ImportError: cannot import name Domain
>
> > this trace tipycally mean circolar import  but I'm sure I don't have
> > this error in my code, maybe I have to change my envirornment
> > initialization for cron script since 1.1.2?
>
> > If I execute the same imports I do in my cron script using python
> > manage.py shell, they works fine so I think something changed in the
> > environment initialization
>
> > any hints?
>
> There is a circular import. The code is in the process of importing Domain
> and hits code where it again attempts to import Domain. The resulting
> ImportError was mistakenly suppressed in 1.1, this issue was reported in
> ticket #11696 (http://code.djangoproject.com/ticket/11696) and the fix for
> that has caused the problem to surface in your cron script.
>
> Now, the circular import is not directly in your app code. What's happening
> is your app code, in models.py, is registering models with the admin (line
> 76 of /home/nicola/workspace/
> SystemPanel/src/systemcp/utenti/models.py is attempting to register an admin
> module for UserInfo.When DEBUG is on, admin registrations trigger validation
> code that first loads all app models, and that is what is resulting in the
> circular import, because your cron script is already in the process of
> importing one of the models.
>
> One fix would be to remove the admin registrations from models.py: that's
> generally not a good place for them. Having them in models.py tends to lead
> to mysteriously missing models in the admin when you run on production
> server with debug off, since then models.py is not necessarily loaded before
> the admin code is called to process requests. Moving admin registrations to
> an admin.py file and calling admin.autodiscover() from urls.py is the
> currently best-practice way of ensuring admin registrations are done when
> they need to be...and it would avoid this circular import you are seeing in
> your cron script.
>
> Another way to fix it would be to turn of DEBUG when running the cron
> script. Then the admin validation code won't be called, which will avoid the
> circular import. But really, admin registrations should not be done in
> models.py.
>
> Karen
> --http://tracey.org/kmt/


Thanks Karen,

I moved all the admin registrations in a separate admin.py file and
now all is fine,

drakkan

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



django/python performance vs play/java

2011-07-05 Thread drakkan
Hi,

I did a small test app that basically render a web page and do 3
queries to the database (these queries are needed to fetch some data
displayed on the web page). I deployed this app with nginx+uswgi

here is the relevant nginx conf:

location / {
uwsgi_pass 127.0.0.1:49152;
include uwsgi_params;
}

I configured nginx to serve the static files too:

location /media {
root ;
autoindex on;
}

I launch uswgi as follow:

uwsgi --chdir= --
module='django.core.handlers.wsgi:WSGIHandler()' --env
DJANGO_SETTINGS_MODULE=myapp.settings --master --pidfile=/tmp/project-
master.pid --socket=127.0.0.1:49152 --max-requests=5000 --process=5

then I benchmarked the app with ab:

ab -n 1000 -c 4 http://127.0.0.1:80/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:nginx
Server Hostname:127.0.0.1
Server Port:80

Document Path:  /
Document Length:24293 bytes

Concurrency Level:  4
Time taken for tests:   28.914 seconds
Complete requests:  1000
Failed requests:0
Write errors:   0
Total transferred:  24423000 bytes
HTML transferred:   24293000 bytes
Requests per second:34.59 [#/sec] (mean)
Time per request:   115.654 [ms] (mean)
Time per request:   28.914 [ms] (mean, across all concurrent
requests)
Transfer rate:  824.89 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.1  0   4
Processing:46  115  42.6110 636
Waiting:   46  115  42.5109 636
Total: 46  116  42.6110 636

Percentage of the requests served within a certain time (ms)
  50%110
  66%121
  75%131
  80%139
  90%161
  95%177
  98%203
  99%220
 100%636 (longest request)

now I implemented the same app using playframework, a java based
framework and benchmarked with ab again:


ab -n 1000 -c 4 http://127.0.0.1:9000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:Play!
Server Hostname:127.0.0.1
Server Port:9000

Document Path:  /
Document Length:19614 bytes

Concurrency Level:  4
Time taken for tests:   4.436 seconds
Complete requests:  1000
Failed requests:0
Write errors:   0
Total transferred:  19961000 bytes
HTML transferred:   19614000 bytes
Requests per second:225.44 [#/sec] (mean)
Time per request:   17.743 [ms] (mean)
Time per request:   4.436 [ms] (mean, across all concurrent
requests)
Transfer rate:  4394.59 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.0  0   1
Processing: 7   18   6.6 16  47
Waiting:6   17   6.6 16  47
Total:  7   18   6.6 16  47

Percentage of the requests served within a certain time (ms)
  50% 16
  66% 19
  75% 22
  80% 23
  90% 27
  95% 30
  98% 34
  99% 38
 100% 47 (longest request)


so play is outperforming django! obviously django is not in debug mode
ecc..., is there something wrong in my test setup (I already tried to
adjust the uwsgi launch line I tryed more process or 1 process with
threads ecc with no relevant improvement) or django/python is simply
much slower than java? I tried to run play behind nginx proxy too: the
results are pratically identical. Note the response time too: the
slowest play response is 47 ms, the fastest django one is 110 ms,

any suggestion to improve performance is appreciated,

thanks in advance,
drakkan

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



Re: django/python performance vs play/java

2011-07-05 Thread drakkan
t; Server Hostname:        127.0.0.1
> > Server Port:            9000
>
> > Document Path:          /
> > Document Length:        19614 bytes
>
> > Concurrency Level:      4
> > Time taken for tests:   4.436 seconds
> > Complete requests:      1000
> > Failed requests:        0
> > Write errors:           0
> > Total transferred:      19961000 bytes
> > HTML transferred:       19614000 bytes
> > Requests per second:    225.44 [#/sec] (mean)
> > Time per request:       17.743 [ms] (mean)
> > Time per request:       4.436 [ms] (mean, across all concurrent
> > requests)
> > Transfer rate:          4394.59 [Kbytes/sec] received
>
> > Connection Times (ms)
> >              min  mean[+/-sd] median   max
> > Connect:        0    0   0.0      0       1
> > Processing:     7   18   6.6     16      47
> > Waiting:        6   17   6.6     16      47
> > Total:          7   18   6.6     16      47
>
> > Percentage of the requests served within a certain time (ms)
> >  50%     16
> >  66%     19
> >  75%     22
> >  80%     23
> >  90%     27
> >  95%     30
> >  98%     34
> >  99%     38
> > 100%     47 (longest request)
>
> > so play is outperforming django! obviously django is not in debug mode
> > ecc..., is there something wrong in my test setup (I already tried to
> > adjust the uwsgi launch line I tryed more process or 1 process with
> > threads ecc with no relevant improvement) or django/python is simply
> > much slower than java? I tried to run play behind nginx proxy too: the
> > results are pratically identical. Note the response time too: the
> > slowest play response is 47 ms, the fastest django one is 110 ms,
>
> > any suggestion to improve performance is appreciated,
>
> > thanks in advance,
> > drakkan
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> Jonas Geiregat
> jo...@geiregat.org

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



Re: django/python performance vs play/java

2011-07-06 Thread drakkan


On 5 Lug, 22:57, bruno desthuilliers 
wrote:
> On 5 juil, 21:54, drakkan  wrote:
>
> (snip)
>
> > or django/python is simply much slower than java?
>
> According to most benchmarks, Python (that is: current canonical
> implementation of...) is indeed way "slower" than Java (idem), that's
> a fact. FWIW, according to the same benchmarks, Java is slower than C+
> +, which is slower than C, which can be slower than your-platform-
> highly-optimized-assembly-code - but you need to be very good at hand-
> optimizing assembly code to beat any decent C compiler.  You may
> notice a pattern here (if you don't, try implementing a simple blog in
> assembly, then port it to a different platform, and come back when
> you're done ).
>
> To make a long story short: if you're looking for raw execution speed,
> forget about Java and go for C - and let us know when you'll have a
> working prototype.

Bruno, I'm talking about an high level framework such as play (http://
www.playframework.org/). Develop an application with play is as simple
as a django one, until now I used django and I like python more than
java and I want to understand if I'm doing something wrong or if is
the framework/programming language that is performing so bad. I sent
my code to Xavier, I noticed now I sent a private email, if someone
other would like to see my test code I can resend the link to download
it, however is a really simple app that make two db queries and render
a template I cannot see anything wrong in it

thanks
drakkan

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



Re: django/python performance vs play/java

2011-07-06 Thread drakkan


On 6 Lug, 12:46, Thomas Guettler  wrote:
> Hi,
>
> I would choose the framework, that you like. You can optimize later. And
> this would be the same for all frameworks: You need a good cache strategy.
>
> Are you expecting several hundred requests per minute?
>
> I guess there is something wrong with your benchmark. I don't think 
> django/python
> is much slower.

I need to develop a web app that need to run on low end hw (probably
intel atom, not decided yet). I love django/python and I already used
it in several web apps and I would like to use it in this project too.
However it seems that the performance difference between play/java and
django/python grow when the hw resource decrease. For example on a 8
core server play is "only" 2-2.5x faster that django (no one will
notice this difference if you don't have a very high traffic website),
on an intel atom play is 15x faster than django and this is
noticeable.

I know about caching and play support memcached too, I guess if I
enable memcached on both framework the results doesn't change much,

thanks for your suggestions

>
>   Thomas
>
> On 06.07.2011 01:31, drakkan wrote:
>
> > Hi,
>
> > thanks for your comments, I installed django-debug toolbar and I can
> > confirm I'm doing similar queries from both django and play. The query
> > I do with hibernate in play should be slower since I'm doing a left
> > outer join while django do an inner join, since the field on which I
> > join cannot be null.
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de

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



Re: django/python performance vs play/java

2011-07-06 Thread drakkan
On 6 Lug, 14:03, akaariai  wrote:
> On Jul 5, 10:54 pm, drakkan  wrote:
>
> > so play is outperforming django! obviously django is not in debug mode
> > ecc..., is there something wrong in my test setup (I already tried to
> > adjust the uwsgi launch line I tryed more process or 1 process with
> > threads ecc with no relevant improvement) or django/python is simply
> > much slower than java? I tried to run play behind nginx proxy too: the
> > results are pratically identical. Note the response time too: the
> > slowest play response is 47 ms, the fastest django one is 110 ms,
>
> > any suggestion to improve performance is appreciated,
>
> Which database do you use? If you happen to use PostgreSQL, then
> connection creation can be a major source of your performance
> problems. In that case, try using pgbouncer or PgPoolII. Play would
> most likely use a connection pool by default, while Django relies on
> external connection pooling.
>
> I have an application which does a lot more than 3 queries. With
> connection pooling enabled:
> Requests per second:    90.69 [#/sec] (mean)
>
> Without connection pooling:
> Requests per second:    32.98 [#/sec] (mean)
>

using pgpool I get a 2,5x performance improvement thanks! I'll try on
intel atom again to see if there I have more improvements

>  - Anssi
>
>  - Anssi

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



Re: django/python performance vs play/java

2011-07-06 Thread drakkan
You can download the code here:

http://77.43.75.110/temp/cinquestelle.tar.gz

you need sorl as dependencies too:

http://pypi.python.org/pypi/sorl-thumbnail/3.2.5


On 6 Lug, 15:57, Björn Lindqvist  wrote:
> 2011/7/6 drakkan :
>
> > Bruno, I'm talking about an high level framework such as play (http://
> >www.playframework.org/). Develop an application with play is as simple
> > as a django one, until now I used django and I like python more than
> > java and I want to understand if I'm doing something wrong or if is
> > the framework/programming language that is performing so bad. I sent
> > my code to Xavier, I noticed now I sent a private email, if someone
> > other would like to see my test code I can resend the link to download
> > it, however is a really simple app that make two db queries and render
> > a template I cannot see anything wrong in it
>
> Please send the link. Just because you can't see anything wrong with
> the code, doesn't mean there isn't anything wrong with it. Likely, you
> are doing something wrong which eats up the performance but without
> seeing the source, one can only speculate on what that may be. Your
> "simple" app aren't as simple as you think it is.
>
> There are dozens of similar threads created on the python related
> mailing lists each year. In some cases python is slower than language
> X, in other cases it is faster (because much of the core is
> implemented in C, for example) other times it does not matter because
> the task is IO bound anyway.
>
> --
> mvh/best regards Björn Lindqvisthttp://www.footballexperts.net/

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



Re: django/python performance vs play/java

2011-07-08 Thread drakkan


On 8 Lug, 14:44, Thomas Guettler  wrote:
> On 06.07.2011 15:33, drakkan wrote:> On 6 Lug, 14:03, akaariai 
>  wrote:
> >> On Jul 5, 10:54 pm, drakkan  wrote:
>
> ...
>
> > using pgpool I get a 2,5x performance improvement thanks! I'll try on
> > intel atom again to see if there I have more improvements
>
> Hi,
>
> I am interessted in the result. Please post them to the list.

test from my laptop

django+uwsgi+pgpool2:

Requests per second:71.40 [#/sec] (mean)

Percentage of the requests served within a certain time (ms)
  50% 56
  66% 64
  75% 70
  80% 73
  90% 81
  95% 86
  98% 93
  99% 98
 100%134 (longest request)


without pgpool2:

Requests per second:35.87 [#/sec] (mean)

Percentage of the requests served within a certain time (ms)
  50%107
  66%119
  75%128
  80%135
  90%154
  95%171
  98%196
  99%213
 100%306 (longest request)


play 1.2.2 default options and default template engine (no japid)

Requests per second:186.12 [#/sec] (mean)

Percentage of the requests served within a certain time (ms)
  50% 20
  66% 23
  75% 26
  80% 27
  90% 32
  95% 35
  98% 42
  99% 47
 100% 68 (longest request)

the db is postgres 8.4

I have no time to try jinja2 now, I guess it should speed up django a
bit,

drakkan


>
>   Thomas
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de

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



django 1.8 customize site title

2015-05-02 Thread drakkan
Hi,

I would like to customize django 1.8 site title without override the 
 template using AdminSite,

I customized AdminSite as per doc here:

https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#customizing-the-adminsite-class

this seems to work, however the html title still has "Django 
administration", 

I added site_header and site_title to AdminSite, is this a bug or am I 
doing something wrong?

here is the html

Django administration | MyCustomTitle



thanks


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6668d66c-4235-47a0-933c-0a81e50142b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.8 customize site title

2015-05-04 Thread drakkan
the problem was caused by django-admin-bootstrapped

Il giorno lunedì 4 maggio 2015 18:46:08 UTC+2, André Luiz ha scritto:
>
> You can do it in in urls.py for example[1]
>
> [1]: https://gist.github.com/dvl/0bed149bee4556b32d7a
>
> 2015-05-02 5:55 GMT-03:00 drakkan >:
>
>> Hi,
>>
>> I would like to customize django 1.8 site title without override the 
>>  template using AdminSite,
>>
>> I customized AdminSite as per doc here:
>>
>>
>> https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#customizing-the-adminsite-class
>>
>> this seems to work, however the html title still has "Django 
>> administration", 
>>
>> I added site_header and site_title to AdminSite, is this a bug or am I 
>> doing something wrong?
>>
>> here is the html
>>
>> Django administration | MyCustomTitle
>> 
>>
>>
>> thanks
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/6668d66c-4235-47a0-933c-0a81e50142b2%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/6668d66c-4235-47a0-933c-0a81e50142b2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/09296221-49f1-4082-8f7d-ca5e22502fab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django 1.7 migrations upgrade from south: db.delete_foreign_key replacement?

2014-11-14 Thread drakkan
Hi,

I'm migrating my app to 1.7 and to builtin django migrations from south, I 
need something like this:

http://south.readthedocs.org/en/latest/databaseapi.html#db-delete-foreign-key

how to remove a foreign key using django builtin migration api?

Please note that my purpose is to remove the foreign key and then add it 
back with "ON DELETE CASCADE" constraint, actually I use the south api to 
remove the foreign key and then database specific sql to add it with the 
constraint I need. I would like to avoid to use sql specific code to find 
the foreign key too,

thanks
Nicola

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7111b53e-a435-40d5-ac9e-703df77b6a30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.7 migrations upgrade from south: db.delete_foreign_key replacement?

2014-11-14 Thread drakkan


Il giorno venerdì 14 novembre 2014 23:35:46 UTC+1, Markus Holtermann ha 
scritto:
>
> Hey Nicola,
>
> Django's migration system doesn't natively support "drop this foreign key 
> constraint from the database", because you shouldn't be able to run into 
> such a situation with the migration system at all (if you do, that's a bug 
> from my point of view). I suggest you go with a "RunSQL" operation where 
> you drop the constraint: 
> https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunSQL
>
>
The problem here is that django does not create foreign key with a 
predefined name so I have to do a query using different sql for each 
supported db to find the foreign key name and then issue the sql statements 
using RunSQL, I think that in my case the simplest solution is to set 
db_constraint=False on the foreign key that need a cascade enforcement in 
the database and then reuse the sql I already have to create the constraint 
inside the database,

seems no better solution is possibile, if there is a bug here is in django 
that don't allow constraint enforcement at the db level and try to emulate 
what the db can do natively and much quicker

Nicola

 

> /Markus
>
> On Friday, November 14, 2014 4:23:52 PM UTC+1, drakkan wrote:
>>
>> Hi,
>>
>> I'm migrating my app to 1.7 and to builtin django migrations from south, 
>> I need something like this:
>>
>>
>> http://south.readthedocs.org/en/latest/databaseapi.html#db-delete-foreign-key
>>
>> how to remove a foreign key using django builtin migration api?
>>
>> Please note that my purpose is to remove the foreign key and then add it 
>> back with "ON DELETE CASCADE" constraint, actually I use the south api to 
>> remove the foreign key and then database specific sql to add it with the 
>> constraint I need. I would like to avoid to use sql specific code to find 
>> the foreign key too,
>>
>> thanks
>> Nicola
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6c300aca-c1e0-4898-9808-127131c090e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.