Re: ModelForm save call with data and instance

2011-07-05 Thread Constantine Linnick
I Found problem, it was triple collision:
pycharm debugging sideeffect, wrong inheritance in _init_, but most 
destructive was form fields: it overwrites instance values with None.
(if someone find this post from search 

anyway, thanks for reply

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BBDLRNu6HNcJ.
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: Complex Query help - get items from the org to which the user belongs

2011-07-05 Thread Venkatraman S
On Wed, Jul 6, 2011 at 8:39 AM, Venkatraman S  wrote:

>
> On Wed, Jul 6, 2011 at 12:36 AM, Venkatraman S  wrote:
>
>> I tried asking around in IRC, and stumbled on a few possible solutions,
>> would be great if someone shed some more light:
>>
>> I have the following models:
>>
>> class Organization(models.Model):
>>   name= models.CharField(max_length=100, blank=False)
>>
>> class Employees(models.Model):
>>   org = models.ForeignKey(Organization,
>> related_name='employees')
>>   user= models.ForeignKey(User)
>>   name= models.CharField(max_length=100, blank=False)
>>
>> class Item(models.Model):
>>   name= models.CharField(max_length=100, blank=False)
>>   created_by  =
>> models.ForeignKey(User,related_name='created_by_whom')
>>
>> Problem : I need to get all Items from the Organization to which current
>> User belongs to.
>> So basically, get all employees from the Org that the current User belongs
>> to, and then get all items created by these employees. (So, this query
>> should also include the current User).
>>
>> Say there are 3 Users in an org : A, B and C with each creating 3,4,5
>> items respectively, and 'A' is the current user; then i need a query which
>> returns all these items(i.e, 12 items) when i supply A..
>>
>
>
> This is the equivalent raw sql:
> select count(1)
> from myapp_items a
> where a.created_by_id in
> (
> select e.user_id
> from myapp_employees e, myapp_organization o
> where e.org_id = o.id
> and o.id = (select o2.id from myapp_organization o2, myapp_employees e2
> where e2.org_id = o2.id and e2.user_id=<>)
> )
>
>
And this would be a probable query:
Items.objects.extra(where=['created_by_id in (select e.user_id from
myapp_employees e, myapp_organization o where e.org_id = o.id and o.id =
(select o2.id from myapp_organization o2, myapp_employees e2 where e2.org_id
= o2.id and e2.user_id=3)) ']).count()

Can some expert in django-ORM comment on this? (can the same be done without
a 'where' clause)

As  someone pointed out in IRC, i want to go up, down and then sideways in
this query ;)

-V

-- 
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: Complex Query help - get items from the org to which the user belongs

2011-07-05 Thread Venkatraman S
On Wed, Jul 6, 2011 at 12:36 AM, Venkatraman S  wrote:

> I tried asking around in IRC, and stumbled on a few possible solutions,
> would be great if someone shed some more light:
>
> I have the following models:
>
> class Organization(models.Model):
>   name= models.CharField(max_length=100, blank=False)
>
> class Employees(models.Model):
>   org = models.ForeignKey(Organization,
> related_name='employees')
>   user= models.ForeignKey(User)
>   name= models.CharField(max_length=100, blank=False)
>
> class Item(models.Model):
>   name= models.CharField(max_length=100, blank=False)
>   created_by  =
> models.ForeignKey(User,related_name='created_by_whom')
>
> Problem : I need to get all Items from the Organization to which current
> User belongs to.
> So basically, get all employees from the Org that the current User belongs
> to, and then get all items created by these employees. (So, this query
> should also include the current User).
>
> Say there are 3 Users in an org : A, B and C with each creating 3,4,5 items
> respectively, and 'A' is the current user; then i need a query which returns
> all these items(i.e, 12 items) when i supply A..
>


This is the equivalent raw sql:
select count(1)
from myapp_items a
where a.created_by_id in
(
select e.user_id
from myapp_employees e, myapp_organization o
where e.org_id = o.id
and o.id = (select o2.id from myapp_organization o2, myapp_employees e2
where e2.org_id = o2.id and e2.user_id=<>)
)

-- 
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 Kenneth Gonsalves
On Tue, 2011-07-05 at 13:57 -0700, bruno desthuilliers wrote:
> 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. 

or like the facebook guys write C in php.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.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: Multiple Databases

2011-07-05 Thread Venkatraman S
On Tue, Jul 5, 2011 at 6:39 PM, Nick  wrote:

> However, i also
> need to support dynamic database creation - i.e. one or more databases
> created from a single model (think of these as customer specific
> databases). I will be using sqlite and want to save the path/
> connection details of the dynamically created databases in one of the
> primary db's. Is this possible and if so what is the best approach to
> take?
>

Design-wise, i do not think dynamic db creation is a good idea. Its tough to
maintain and prone to errors.
If you are using Oracle DB, probably you can think in terms of setting VPDs
for loading/restricting access.

-V

-- 
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: I need to do reports, and I would like reports that are integrated with django admin.

2011-07-05 Thread Venkatraman S
On Wed, Jul 6, 2011 at 3:23 AM, Kase  wrote:

>
> I have no problem to make my pages with reports of objects, but I like
> that are integrated with django admin, in the same tuple in the object
> list.
>
> any suggestions?
>

Did you try creating a page and showing the information there - for eg. you
could create a link called 'Reports' on the top right of the page
and (after you extend the admin-base html file),  include the necessary
logic in the views.

-V
http://twitter.com/venkasub

-- 
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: Complex Query help - get items from the org to which the user belongs

2011-07-05 Thread Venkatraman S
On Wed, Jul 6, 2011 at 2:26 AM, Marc Aymerich  wrote:

> Say there are 3 Users in an org : A, B and C with each creating 3,4,5 items
> respectively, and 'A' is the current user; then i need a query which returns
> all these items(i.e, 12 items) when i supply A..
>
> Item.objects.filter(employees__org=A.org)
> This works¿?
>

I dont think this would work; Items doesnt have an FK for Emps.

-V

-- 
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 Xavier Ordoquy
Hi,

Is there anyway you can upload the project to bitbucket or github ?

Regards,
Xavier.

Le 6 juil. 2011 à 01:31, drakkan a écrit :

> 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.
> 
> I tryed gunicorn but it gives similar performance to uwsgi, I'm
> testing on my latptop (1 core). Maybe there is something wrong in my
> template but it is basically a base.html and then index.html that
> extends base.html, additinally I have some "include "
> where other.html is a small fragment of code
> 
> On 6 Lug, 01:07, Jonas Geiregat  wrote:
>> We all know python is slower in raw execution speed than it's brother Java 
>> but I can't imagine it to be _that_ slow.
>> 
>> Maybe there's something wrong with the queries you perform. Django's ORM is 
>> know for it's 'hidden execution' of queries. Some more insight in your 
>> querying code might be useful.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> 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 4http://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 4http://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

Re: Auth Login well documented but elusive

2011-07-05 Thread TuckFrance
Yeah it works just fine! Thanks again tevans!

On Jul 5, 2:42 am, Tom Evans  wrote:
> On Tue, Jul 5, 2011 at 2:10 AM, TuckFrance  wrote:
> > Having problems with getting login to work even though it's well
> > documented. The pages for success, invalid, and no info provided
> > aren't getting used at all. Instead, clicking login always redirects
> > to /login which is not what I want. Any ideas?
>
> > URLconf:
> > ...
> > (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> > View:
> > ...
> > def login(request):
>           ^^^
> >    username = request.POST['username']
> >    password = request.POST['password']
> >    user = authenticate(username=username, password=password)
> >    if user is not None:
> >        if user.is_active:
> >            login(request, user)
>
>            ^^^
>
> You're calling a function called 'login' from inside a function called
> 'login'. It's not going to end well. Either call your login view
> function something else, or import django.contrib.auth.login using a
> different name (from django.contrib.auth import login as
> django_login).
>
> Cheers
>
> Tom

-- 
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 admin - how to hide some fields in User edit?

2011-07-05 Thread Michał Sawicz
Dnia 2011-07-05, wto o godzinie 15:13 -0700, galgal pisze:
> I made it in that way, and it works:
Remember that you need to exclude the field from the form, too, if you
don't want malicious attempts to inject the groups to work. 
-- 
Michał (Saviq) Sawicz 


signature.asc
Description: This is a digitally signed message part


Re: Avoid DB hit while using messages

2011-07-05 Thread Russell Keith-Magee
On Wed, Jul 6, 2011 at 2:16 AM, Venkatraman S  wrote:
>
> I am showing messages using the messaging framework; so i check if there are
> any messages in my base.html (i.e, {% if messages %} ) and if yes i show the
> messages with suitable styling.
> Messages are being rendered fine and i do not have any problem with that.
>
> But i see that , accessing 'messages' is causing a db hit - i.e, the 'if
> clause above - is it possible to avoid this db hit?

Well, yes and no.

If you're using database backed storage, then no. The only way to
determine if there are messages or not is to query the database and
determine if there are messages. There's no magic mechanism here.

However, there are other message backends that don't require database
access. Django ships with a cookie-backed messages engine. Since the
message storage is a pluggable interface, it's also possible to build
a messages backend that stores in memcache, redis, or some other
non-database store. These don't require database access because they
don't store messages in the database. Whether they will work for your
situation is entirely up to your requirements.

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 admin - change permissions list

2011-07-05 Thread Michał Sawicz
Dnia 2011-07-05, wto o godzinie 15:16 -0700, galgal pisze:
> Is there any possibility to change permissions list in user edit page?
> I don't wan't to show all of permissions for example admin log entry
> or auth group etc. How can I modify a main queryset to exclude some of
> it? 

Override ModelAdmin.get_form(), get form_class from super() and modify
form_class.base_fields['fieldname'].queryset.

-- 
Michał (Saviq) Sawicz 


signature.asc
Description: This is a digitally signed message part


Re: django/python performance vs play/java

2011-07-05 Thread drakkan
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.

I tryed gunicorn but it gives similar performance to uwsgi, I'm
testing on my latptop (1 core). Maybe there is something wrong in my
template but it is basically a base.html and then index.html that
extends base.html, additinally I have some "include "
where other.html is a small fragment of code

On 6 Lug, 01:07, Jonas Geiregat  wrote:
> We all know python is slower in raw execution speed than it's brother Java 
> but I can't imagine it to be _that_ slow.
>
> Maybe there's something wrong with the queries you perform. Django's ORM is 
> know for it's 'hidden execution' of queries. Some more insight in your 
> querying code might be useful.
>
>
>
>
>
>
>
>
>
> > 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 4http://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:        0    0   0.1      0       4
> > Processing:    46  115  42.6    110     636
> > Waiting:       46  115  42.5    109     636
> > Total:         46  116  42.6    110     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 4http://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:    

Re: django/python performance vs play/java

2011-07-05 Thread Jonas Geiregat

We all know python is slower in raw execution speed than it's brother Java but 
I can't imagine it to be _that_ slow.


Maybe there's something wrong with the queries you perform. Django's ORM is 
know for it's 'hidden execution' of queries. Some more insight in your querying 
code might be useful.


> 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

Django admin - change permissions list

2011-07-05 Thread galgal
Is there any possibility to change permissions list in user edit page? I 
don't wan't to show all of permissions for example admin log entry or auth 
group etc.
How can I modify a main queryset to exclude some of it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/AW8MzS1_2bEJ.
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.



Odp: Re: Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-05 Thread galgal
I made it in that way, and it works:
def get_fieldsets(self, request, obj=None):
if obj:
if request.user.id == 1:
return self.declared_fieldsets
else:
if obj.get_profile().type==1:
return (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 
'last_name', 'email')}),
(_('Important dates'), {'fields': ('last_login', 
'date_joined')}),
)
else:
return (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 
'last_name', 'email')}),
(_('Permissions'), {'fields': ('is_active', 
'is_staff', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login', 
'date_joined')}),
)
else:
return self.add_fieldsets

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Mq--t4_P1qMJ.
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: Setting up EC2 for Django

2011-07-05 Thread Nate Aune
If you don't need SSH access to the machines that power this whole setup, 
you can use DjangoZoom, our one-click Django deployment and hosting service. 
It's built on top of Amazon and uses Nginx, PostgreSQL and as of a few days 
ago, we also now support Mercurial. The only gotcha might be Solr which we 
don't support yet, but you could probably connect a 3rd party Solr provider 
such as http://websolr.com to satisfy that requirement.

Sign up for the beta at http://djangozoom.com and mention that you heard 
about it on this thread to get an invite.

Nate

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/skUgBuGRWgsJ.
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: ANN: django-iadmin

2011-07-05 Thread Tomáš Ehrlich
Hi Sax,
I've found, where is a problem, but it's much more complicated. I've
just filled issue: https://github.com/saxix/django-iadmin/issues/2

Hope we'll fix it soon, need to go sleep now

On 5 čnc, 23:18, Tomáš Ehrlich  wrote:
> I'm using latest Django svn checkout.
>
> I've just solved this problem, although still don't understand it.
>
> Problem was with models simply registered to admin like:
>
> admin.site.register(TaggedItem)
>
> So, I created simple model admin and it works:
>
> class TaggedItemAdmin(admin.ModelAdmin):
>     pass
>
> admin.site.register(TaggedItem, TaggedItemAdmin)
>
> On 5 čnc, 23:05, sax  wrote:
>
>
>
>
>
>
>
> > Ciao Tomáš,
> > which version of django are you using ? did you compare your settings with
> > the one into the testprj app ?
>
> > You can find the issue tracker 
> > athttps://github.com/saxix/django-iadmin/issues?sort=created&direction=...
>
> > let me know as i can help you
>
> > sax
>
> > 2011/7/5 Tomáš Ehrlich 
>
> > > Hi Sax,
> > > thanks for your work, i've already put it into my project.
>
> > > Unfortunately, I've got this error when accessing change_list view.
> > > Some apps works fine, but some of them shows this exception:
> > > File "/usr/lib/python2.6/dist-packages/django/contrib/admin/views/
> > > main.py" in __init__
> > >  81.         self.query_set = self.get_query_set(request)
>
> > > Exception Type: TypeError at /admin/markup/textprocessor/
> > > Exception Value: get_query_set() takes exactly 1 argument (2 given)
>
> > > I'm trying to figure out, what's wrong. Just posting in case you know
> > > about this.
>
> > > Does github have any issue tracker?
>
> > > Thanks
>
> > > On 4 čnc, 14:55, Stefano Apostolico  wrote:
> > > > Hi all,
>
> > > > I would like some feedback onhttps://
> > > github.com/saxix/djangoscreenshots-home-page-iadmin<
> > >https://github.com/saxix/django-iadmin>
> > > > .
>
> > > > Documentation in progress,  but demo application included.
>
> > > > Suggestions and comments are welcome, any help will be appreciated
>
> > > > sax
>
> > > --
> > > 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.

-- 
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.



I need to do reports, and I would like reports that are integrated with django admin.

2011-07-05 Thread Kase

I have no problem to make my pages with reports of objects, but I like
that are integrated with django admin, in the same tuple in the object
list.

i dont know if exist extention, but one of these reports is complex
= /

I have an object, insurance, customer, policy, policy_year

and a i need a report containing the information of the client
relationship, policies (foreign key (customer)) policy_year (foreign
key (policy))

and display somthing like this

Customer: jon doo
Policy: x
2009
2010
2011
POLICY AND
2008
2009

I would like to make it accessible from the list of objects "customer"

PS: i know how to display this info in to view + template but really i
like to display in django admin ...

any suggestions?

-- 
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 Xavier Ordoquy
Hi,

Install Django debug toolbar and have a look at what's wrong with your 
application.
My numbers are very different from yours.

I just ran some tests and I am around 350 req/s with 4 sql queries.
I'm a on dual core (4 virtual cores), using gunicorn/mysql with debug turned 
off, 4 workers processes

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 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:gunicorn/0.12.2
Server Hostname:127.0.0.1
Server Port:8088

Document Path:  /project/1/
Document Length:4327 bytes

Concurrency Level:  4
Time taken for tests:   14.041 seconds
Complete requests:  5000
Failed requests:0
Write errors:   0
Total transferred:  22405000 bytes
HTML transferred:   21635000 bytes
Requests per second:356.10 [#/sec] (mean)
Time per request:   11.233 [ms] (mean)
Time per request:   2.808 [ms] (mean, across all concurrent requests)
Transfer rate:  1558.29 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.0  0   1
Processing:10   11   3.5 11  73
Waiting:   10   11   3.5 10  73
Total: 10   11   3.5 11  73

Percentage of the requests served within a certain time (ms)
  50% 11
  66% 11
  75% 11
  80% 11
  90% 11
  95% 12
  98% 14
  99% 23
 100% 73 (longest request)



-- 
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: Dreamhost Virtualenv Question

2011-07-05 Thread Jeremy
AHHH, that makes a little more sense.  I'm trying to install apps from
Github.  Things like Pinax, and different individual blogging apps so
that I can "plug" them into one Django project to give it multiple
bits of social functionality.  Obviously I'm having a lot of trouble
(some of it being that it sounds like I don't even know what I'm
saying).  I've tried to install these apps through PIP and other forms
on Dreamhost, but it keeps saying that I don't have permission.  The
way that I believed to get around this is to set up virtualenv on my
shared server space, and create the project inside of that, correct?
But if I do this, how can I view the project that I creating live?

Again, if this all sounds foolish, keep in mind I'm incredibly new to
all these concepts and my not understand them enough.  I've been
looking for someone locally to give me some Django lessons, but I keep
coming up dry.

Let me know if anyone can assist me.  Thanks guys.

On Jul 5, 3:26 pm, bruno desthuilliers 
wrote:
> I can only second Shawn here. FWIW, virtualenv is just a way to have
> different (more or less) isolated *Python* environments on a same
> system, and has no notion of a "Django project".

-- 
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: ANN: django-iadmin

2011-07-05 Thread Tomáš Ehrlich
I'm using latest Django svn checkout.

I've just solved this problem, although still don't understand it.

Problem was with models simply registered to admin like:

admin.site.register(TaggedItem)

So, I created simple model admin and it works:

class TaggedItemAdmin(admin.ModelAdmin):
pass

admin.site.register(TaggedItem, TaggedItemAdmin)

On 5 čnc, 23:05, sax  wrote:
> Ciao Tomáš,
> which version of django are you using ? did you compare your settings with
> the one into the testprj app ?
>
> You can find the issue tracker 
> athttps://github.com/saxix/django-iadmin/issues?sort=created&direction=...
>
> let me know as i can help you
>
> sax
>
> 2011/7/5 Tomáš Ehrlich 
>
>
>
>
>
>
>
> > Hi Sax,
> > thanks for your work, i've already put it into my project.
>
> > Unfortunately, I've got this error when accessing change_list view.
> > Some apps works fine, but some of them shows this exception:
> > File "/usr/lib/python2.6/dist-packages/django/contrib/admin/views/
> > main.py" in __init__
> >  81.         self.query_set = self.get_query_set(request)
>
> > Exception Type: TypeError at /admin/markup/textprocessor/
> > Exception Value: get_query_set() takes exactly 1 argument (2 given)
>
> > I'm trying to figure out, what's wrong. Just posting in case you know
> > about this.
>
> > Does github have any issue tracker?
>
> > Thanks
>
> > On 4 čnc, 14:55, Stefano Apostolico  wrote:
> > > Hi all,
>
> > > I would like some feedback onhttps://
> > github.com/saxix/djangoscreenshots-home-page-iadmin<
> >https://github.com/saxix/django-iadmin>
> > > .
>
> > > Documentation in progress,  but demo application included.
>
> > > Suggestions and comments are welcome, any help will be appreciated
>
> > > sax
>
> > --
> > 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.

-- 
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: ANN: django-iadmin

2011-07-05 Thread sax
Ciao Tomáš,
which version of django are you using ? did you compare your settings with
the one into the testprj app ?

You can find the issue tracker at
https://github.com/saxix/django-iadmin/issues?sort=created&direction=desc&state=open

let me know as i can help you

sax


2011/7/5 Tomáš Ehrlich 

> Hi Sax,
> thanks for your work, i've already put it into my project.
>
> Unfortunately, I've got this error when accessing change_list view.
> Some apps works fine, but some of them shows this exception:
> File "/usr/lib/python2.6/dist-packages/django/contrib/admin/views/
> main.py" in __init__
>  81. self.query_set = self.get_query_set(request)
>
> Exception Type: TypeError at /admin/markup/textprocessor/
> Exception Value: get_query_set() takes exactly 1 argument (2 given)
>
> I'm trying to figure out, what's wrong. Just posting in case you know
> about this.
>
> Does github have any issue tracker?
>
> Thanks
>
> On 4 čnc, 14:55, Stefano Apostolico  wrote:
> > Hi all,
> >
> > I would like some feedback onhttps://
> github.com/saxix/djangoscreenshots-home-page-iadmin<
> https://github.com/saxix/django-iadmin>
> > .
> >
> > Documentation in progress,  but demo application included.
> >
> > Suggestions and comments are welcome, any help will be appreciated
> >
> > sax
>
> --
> 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.
>
>

-- 
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 Maksymus007
Of course Java IS faster by a few factors then Python. I switched recently
to Play development from django and I also noticed different. Moreover Play
uses many mature tools, like JPA/Hibernate, ehcache etc which are called
industrial standards.
One more thing - Play! uses its own build-in http server, and keep one
connection to a database alive at all the time, Django run as FCGI or
mod_wsgi manages this a bit different.

On Tue, Jul 5, 2011 at 9:54 PM, drakkan  wrote:

> 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
> 

Re: ANN: django-iadmin

2011-07-05 Thread Tomáš Ehrlich
Hi Sax,
thanks for your work, i've already put it into my project.

Unfortunately, I've got this error when accessing change_list view.
Some apps works fine, but some of them shows this exception:
File "/usr/lib/python2.6/dist-packages/django/contrib/admin/views/
main.py" in __init__
  81. self.query_set = self.get_query_set(request)

Exception Type: TypeError at /admin/markup/textprocessor/
Exception Value: get_query_set() takes exactly 1 argument (2 given)

I'm trying to figure out, what's wrong. Just posting in case you know
about this.

Does github have any issue tracker?

Thanks

On 4 čnc, 14:55, Stefano Apostolico  wrote:
> Hi all,
>
> I would like some feedback 
> onhttps://github.com/saxix/djangoscreenshots-home-page-iadmin
> .
>
> Documentation in progress,  but demo application included.
>
> Suggestions and comments are welcome, any help will be appreciated
>
> sax

-- 
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 bruno desthuilliers
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.


-- 
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: Complex Query help - get items from the org to which the user belongs

2011-07-05 Thread Marc Aymerich
On Tue, Jul 5, 2011 at 9:06 PM, Venkatraman S  wrote:

> I tried asking around in IRC, and stumbled on a few possible solutions,
> would be great if someone shed some more light:
>
> I have the following models:
>
> class Organization(models.Model):
>   name= models.CharField(max_length=100, blank=False)
>
> class Employees(models.Model):
>   org = models.ForeignKey(Organization,
> related_name='employees')
>   user= models.ForeignKey(User)
>   name= models.CharField(max_length=100, blank=False)
>
> class Item(models.Model):
>   name= models.CharField(max_length=100, blank=False)
>   created_by  =
> models.ForeignKey(User,related_name='created_by_whom')
>
> Problem : I need to get all Items from the Organization to which current
> User belongs to.
> So basically, get all employees from the Org that the current User belongs
> to, and then get all items created by these employees. (So, this query
> should also include the current User).
>
> Say there are 3 Users in an org : A, B and C with each creating 3,4,5 items
> respectively, and 'A' is the current user; then i need a query which returns
> all these items(i.e, 12 items) when i supply A..
>

Item.objects.filter(employees__org=A.org)
This works¿?


-- 
Marc

-- 
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: Dreamhost Virtualenv Question

2011-07-05 Thread bruno desthuilliers
I can only second Shawn here. FWIW, virtualenv is just a way to have
different (more or less) isolated *Python* environments on a same
system, and has no notion of a "Django project".

-- 
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: Help-Multiple Databases

2011-07-05 Thread Shawn Milochik
On Tue, Jul 5, 2011 at 2:57 PM, Lycan  wrote:
> Hello,
> I am kind of new to Django and am trying to understand multi-db. Does
> anyone know where i can download a complete working example of django
> project implementing multi-db?
>
> Thanks
>

Check github and bitbucket. You can search by keywords in code, for
example using[1] .


[1] https://docs.djangoproject.com/en/1.3/ref/models/querysets/#using

-- 
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: Dreamhost Virtualenv Question

2011-07-05 Thread Shawn Milochik
On Tue, Jul 5, 2011 at 2:10 PM, Jeremy  wrote:
> Hello, I'm completely new to Django and the concept of virtualenv.
> I'm trying to set up a web site and add in third party applications
> such as the zinnia blogging app, but having some issues.  I believe
> that I've set up the virtualenv correctly, but could someone walk me
> through detailed steps as to install a third party app in the
> virtualenv, then VIEW this virtualenv project as a webpage in a
> browser?  Forgive me if I'm speaking non-sense, but I really need help
> with this.  Thank you.
>

Please define "third party app" and "virtualenv project."

You can install a Python package in virtualenv using pip. "Viewing a
virtualenv project as a webpage" is nonsense.

I could guess at what you mean, but if you can clarify a bit it would help.

Shawn

-- 
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/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.



Complex Query help - get items from the org to which the user belongs

2011-07-05 Thread Venkatraman S
I tried asking around in IRC, and stumbled on a few possible solutions,
would be great if someone shed some more light:

I have the following models:

class Organization(models.Model):
  name= models.CharField(max_length=100, blank=False)

class Employees(models.Model):
  org = models.ForeignKey(Organization,
related_name='employees')
  user= models.ForeignKey(User)
  name= models.CharField(max_length=100, blank=False)

class Item(models.Model):
  name= models.CharField(max_length=100, blank=False)
  created_by  =
models.ForeignKey(User,related_name='created_by_whom')

Problem : I need to get all Items from the Organization to which current
User belongs to.
So basically, get all employees from the Org that the current User belongs
to, and then get all items created by these employees. (So, this query
should also include the current User).

Say there are 3 Users in an org : A, B and C with each creating 3,4,5 items
respectively, and 'A' is the current user; then i need a query which returns
all these items(i.e, 12 items) when i supply A..

-V

-- 
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.



Help-Multiple Databases

2011-07-05 Thread Lycan
Hello,
I am kind of new to Django and am trying to understand multi-db. Does
anyone know where i can download a complete working example of django
project implementing multi-db?

Thanks

-- 
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: Dreamhost Virtualenv Question

2011-07-05 Thread Oscar Carballal
Take a look to this article i wrote a couple of months ago
blog.oscarcp.com/?p=167 its about installing django 1.3 on dreamhost, it may
help you

Enviado desde mi HTC
El 05/07/2011 20:13, "Jeremy"  escribió:
> Hello, I'm completely new to Django and the concept of virtualenv.
> I'm trying to set up a web site and add in third party applications
> such as the zinnia blogging app, but having some issues. I believe
> that I've set up the virtualenv correctly, but could someone walk me
> through detailed steps as to install a third party app in the
> virtualenv, then VIEW this virtualenv project as a webpage in a
> browser? Forgive me if I'm speaking non-sense, but I really need help
> with this. Thank you.
>
> --
> 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.
>

-- 
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.



Avoid DB hit while using messages

2011-07-05 Thread Venkatraman S
I am showing messages using the messaging framework; so i check if there are
any messages in my base.html (i.e, {% if messages %} ) and if yes i show the
messages with suitable styling.
Messages are being rendered fine and i do not have any problem with that.

But i see that , accessing 'messages' is causing a db hit - i.e, the 'if
clause above - is it possible to avoid this db hit?

-V
http://blizzardzblogs.blogspot.com/

-- 
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.



Dreamhost Virtualenv Question

2011-07-05 Thread Jeremy
Hello, I'm completely new to Django and the concept of virtualenv.
I'm trying to set up a web site and add in third party applications
such as the zinnia blogging app, but having some issues.  I believe
that I've set up the virtualenv correctly, but could someone walk me
through detailed steps as to install a third party app in the
virtualenv, then VIEW this virtualenv project as a webpage in a
browser?  Forgive me if I'm speaking non-sense, but I really need help
with this.  Thank you.

-- 
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: Model IPAddressField not validating?

2011-07-05 Thread candlerb
On Jul 5, 5:34 pm, Tom Evans  wrote:
> from django.core.validators import validate_ipv4_address
> ...
>     ip = models.IPAddressField(..., validators=[validate_ipv4_address])

This works perfectly, thank you. (Maybe worth a note in ref/models/
fields.html though?)

Cheers,

Brian.

-- 
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: Model IPAddressField not validating?

2011-07-05 Thread Tim Shaffer
Django trunk also contains validate_ipv6_address and validate_ipv46_address.

But as of 1.3 I think it only validates ipv4

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UW0HjULeuRgJ.
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.



Implementation of sso with django auth.

2011-07-05 Thread Ricardob
I'm trying to implement single sign-on using only django auth.

Let's assume two django projects, on different sub-domains:
site.com(auth) and app1.site.com(app1) The auth table in site.com is
master. site.com handles: login, logout, account registration, etc.

site.com sets SESSION_COOKIE_DOMAIN to .site.com to allow it to be
read by subdomains

app1 will have login_url set to a view in the app1 project, which does
the following:

retrieves site.com's session_id value(from cookie)
validates session_id by making a request to: site.com/validate/
[session_id]/
If False, redirects to site.com/login?next=[...]
If True, request user data to: site.com/attributes/[session_id]/
site.com/attributes/ delivers a dictionary with all the User
values, encrypted using a shared SSO_KEY(encryption done the same way
django encodes and decodes session_id)

Now, app1 has a model SSO_User which has two fields, a foreign key to
User model and an integer field. The SSO_User models links local auth
User to the id of master auth table.

Using the id retrieved from site.com, we check SSO_User for existing
local user, if true we simply update the values and login; if non
existing, we create the user and SSO_User and login.

app1(or any other sub-domain) can keep their own profile information,
without interfering with anything.

It seems simple to implement and safe, but before implementing I
wanted some opinions. What do you think?

-- 
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: Model IPAddressField not validating?

2011-07-05 Thread Tom Evans
On Tue, Jul 5, 2011 at 5:14 PM, candlerb  wrote:
> I have a model defined as follows with an IPAddressField:
>
> 
> class Nas(models.Model):
>    name = models.CharField(max_length=128)
>    ip = models.IPAddressField('IP Address', max_length=15,
> unique=True)
>    nas_type = models.CharField('NAS Type', max_length=32, blank=True)
>    huntgroup = models.ForeignKey(Huntgroup)
>
>    class Meta:
>        verbose_name = "NAS"
>        verbose_name_plural = "NASes"
>
>    def __unicode__(self):
>        return self.name + " (" + self.ip + ")"
> 
>
> However, the model doesn't seem to validate that the ip field is a
> valid IP address. Example:
>

No, it doesn't have any model level validation. If you check the
source, it is simply a char field with max length of 15 characters.
It's form field does have validation though, and you can add the same
validator used there as a validator on the model field:

from django.core.validators import validate_ipv4_address
...
ip = models.IPAddressField(..., validators=[validate_ipv4_address])

Also, as you can see in the name, this only supports IPv4. For a more
complete solution (requires postgres) I use the excellent
django-postgresql-netfields -
https://github.com/adamcik/django-postgresql-netfields

Cheers

Tom

-- 
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: Managing objects spred among several tables/databases.

2011-07-05 Thread Hummingbird
Can anybody pl. share his/her experience on this issue?
Thanks.

On Jul 2, 10:39 am, Hummingbird  wrote:
> Hi !
> I have a similar situation.
> (disclaimer:-- I have tried turbogears & web2py before.
> But could not find the following functionality there.
> So I have signed-in here to see whether I can get it in django).
>
> My form is composed of fields from various tables.
> When a user interacts with form, he/she may add/edit/delete/keep
> unchanged certain fields,
> After saving the form, I need to understand---
> 1) which table(s) should receive SQL add statement,
> 2) which one(s) need update stmt,
> 3) which one(s) to receive delete stmt.
>
> Some examples of (desktop) frameworks having this feature:--
> i) CursorAdaptor in VFP
> ii) DABO desktop framework
> But I am looking for a web framework having this feature.
>
> Without a proper method (rather class) to handle it, it would be very
> messy.
> There will be code repetitions, etc.
>
> I am eager to know whether there is any facility to do the above thing
> in django.
> In that case, I will happily switch to django.
> Any comments/advise/knowledge-sharing highly appreciated.
>
> Thanks.
>
> On Jun 30, 9:23 am, qMax  wrote:
>
>
>
> > Hello here.
>
> > My application task is to integrate several applications, and it
> > should manipulate objects, spread among several tables in several
> > databases. Final object is constructed by 'joining' tables by single
> > field (or derivatives).
> > A user should see such objects as solid entities and manipulate them
> > with basic CRUD operations (with search).
> > Backend should synchronize all changes in all databases.
> > And i wish i could use admin site for that.
>
> > If i guess correctly, all required magic should go into custom
> > QuerySet implementation to properly translate CRUD operations on
> > models into various distributed requests on databases, like zigzag-
> > joins, etc instead of usual sql.Queries.
>
> > I wonder if QuerySet is the only consolidation of such interface.
> > What else should i customize to make it work? (i see at least
> > db.models.Manager should be customized to use another queryset impl)
> > Also, how to figure out what subset of QuerySet interface is used in
> > admin site?
>
> > Maybe, someone already managed similar task and there are some recipes?- 
> > Hide quoted text -
>
> - Show quoted text -

-- 
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.



Model IPAddressField not validating?

2011-07-05 Thread candlerb
I have a model defined as follows with an IPAddressField:


class Nas(models.Model):
name = models.CharField(max_length=128)
ip = models.IPAddressField('IP Address', max_length=15,
unique=True)
nas_type = models.CharField('NAS Type', max_length=32, blank=True)
huntgroup = models.ForeignKey(Huntgroup)

class Meta:
verbose_name = "NAS"
verbose_name_plural = "NASes"

def __unicode__(self):
return self.name + " (" + self.ip + ")"


However, the model doesn't seem to validate that the ip field is a
valid IP address. Example:

>>> n = Nas(ip='wibble', name='bibble', huntgroup_id=12)
>>> n.full_clean()
>>> n.ip
'wibble'
>>>

However, it does validate other things, e.g. the presence of required
fields.

>>> n = Nas(ip='wibble', huntgroup_id=12)
>>> n.full_clean()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/
django/db/models/base.py", line 828, in full_clean
raise ValidationError(errors)
ValidationError: {'name': [u'This field cannot be blank.']}

is this a bug, or am I using it wrongly? I want to create models in
code, not in a form, but validate them before saving.

Thanks,

Brian.

-- 
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: Auth Login well documented but elusive

2011-07-05 Thread TuckFrance
Oh okay I think that makes sense. So I need to rename my view and use
that name at the end. I'll try this out tonight and let you know.
Thanks!

On Jul 5, 2:42 am, Tom Evans  wrote:
> On Tue, Jul 5, 2011 at 2:10 AM, TuckFrance  wrote:
> > Having problems with getting login to work even though it's well
> > documented. The pages for success, invalid, and no info provided
> > aren't getting used at all. Instead, clicking login always redirects
> > to /login which is not what I want. Any ideas?
>
> > URLconf:
> > ...
> > (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> > View:
> > ...
> > def login(request):
>           ^^^
> >    username = request.POST['username']
> >    password = request.POST['password']
> >    user = authenticate(username=username, password=password)
> >    if user is not None:
> >        if user.is_active:
> >            login(request, user)
>
>            ^^^
>
> You're calling a function called 'login' from inside a function called
> 'login'. It's not going to end well. Either call your login view
> function something else, or import django.contrib.auth.login using a
> different name (from django.contrib.auth import login as
> django_login).
>
> Cheers
>
> Tom

-- 
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: Questions on markdown

2011-07-05 Thread leo

thank you all good news, with your help, I found a
way to achieve my goal.

on the way to what i want.

On 2011-7-5 23:04, bruno desthuilliers wrote:


On Jul 5, 3:23 pm, Derek  wrote:

Good news: you're using Python and text processing is easy in Python.
Bad news:  even if you're using Python, you still have to know how to
use it ;)


Good news: you sometimes don't have anything to do - except, of
course, reading the FineManual(tm) and using the appropriate filters:
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#linebreaks

@OP: unless of course you wanted to use other markup features



--
chlin

--
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: Questions on markdown

2011-07-05 Thread bruno desthuilliers


On Jul 5, 3:23 pm, Derek  wrote:
>
> Good news: you're using Python and text processing is easy in Python.
> Bad news:  even if you're using Python, you still have to know how to
> use it ;)


Good news: you sometimes don't have anything to do - except, of
course, reading the FineManual(tm) and using the appropriate filters:
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#linebreaks

@OP: unless of course you wanted to use other markup features

-- 
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: Help How to append or join db.StringProperty(required=True) + string or global variable

2011-07-05 Thread bruno desthuilliers


On Jul 5, 3:32 pm, ddghl  wrote:
> Help guys i need append or join django  title =
> db.StringProperty(required=True)    

db.StringProperty is not Django - are you sure you're at the right
place ?

But anyway, assuming you're using Django's templating system

> now is {{ article.title }}  => "Bla bla bla" but i need  
>
> {{ article.title + string or global variable  }}

{{ article.title }} and some more text
{{ article.title }} {{ some_var }}
{{ article.title }} {{ some_var.some_attribute }}

for the second and third examples you obviously need to have
"some_var" in the template's context, whether from the view or from a
context_processor.

FWIW, all this is fairly well documented in the FineManual(tm):
https://docs.djangoproject.com/en/1.3/topics/templates/

-- 
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: change values in "select list"

2011-07-05 Thread Tom Evans
On Tue, Jul 5, 2011 at 12:53 PM, Geoff Kuenning  wrote:
>
>
> On Jul 4, 11:10 pm, Tom Evans  wrote:
>
>> All of this is explained in the docs. Read the docs.
>
> He did; he said he did in his previous posting.  But although the docs
> are far better than many, I'm not sure I've _ever_ seen documentation
> that answered every question perfectly.  Add that to the fact that
> English isn't his first language, and from painful personal experience
> I can deeply sympathize with the fact that he didn't absorb everything
> on the first try.
>

He read the docs, but he still had no idea of how to progress. So I
gave him a step by step precis of what he needed to change (which you
helpfully chopped out, making out like I replied just telling him to
RTFM), and told him to re-read the docs again.

Have you read the documentation I linked to? It actually does answer
that question perfectly.

Tom

-- 
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.



Help How to append or join db.StringProperty(required=True) + string or global variable

2011-07-05 Thread ddghl

Help guys i need append or join django  title =
db.StringProperty(required=True)

now is {{ article.title }}  => "Bla bla bla" but i need  
   
{{ article.title + string or global variable  }} 

maybe someone knows

:working:




  
-- 
View this message in context: 
http://old.nabble.com/Help-How-to-append-or-join--db.StringProperty%28required%3DTrue%29-%2B-string-or-global-variable-tp31996850p31996850.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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: Questions on markdown

2011-07-05 Thread Derek
On Jul 5, 12:03 pm, DrBloodmoney  wrote:
> On Mon, Jul 4, 2011 at 2:22 PM, Petite Abeille  
> wrote:
>
> > On Jul 4, 2011, at 8:08 PM, leo wrote:
>
> >> what i want is
>
> > To quote the friendly manual:
>
> > "When you do want to insert a  break tag using Markdown, you end a 
> > line with two or more spaces, then type return."
>
> >http://daringfireball.net/projects/markdown/syntax#p
>
> If you're copy/pasting test that's not Markdown, then Markdown will
> not magically help you. If you have unformatted text that you want to
> turn into html, you're probably going to have to do a little text
> pre-processing.

Good news: you're using Python and text processing is easy in Python.
Bad news:  even if you're using Python, you still have to know how to
use it ;)

-- 
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.



Multiple Databases

2011-07-05 Thread Nick
Hi, I'm evaluating django for a project, though i haven't used it
previously. I have used pylons,sqlalchemy,elixir,formalchemy etc in
the past so am at least familiar, if a little rusty with that but i
would like to try django for all the it provides. I've read through
the docs and googled for a bit without any luck, so i'm here to ask
you for help.

I would like to have two main databases, i see this is covered in the
docs and is nicely implemented for general use cases. However, i also
need to support dynamic database creation - i.e. one or more databases
created from a single model (think of these as customer specific
databases). I will be using sqlite and want to save the path/
connection details of the dynamically created databases in one of the
primary db's. Is this possible and if so what is the best approach to
take?

Thanks
Nick

-- 
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: Related model getting autocomplete="off"

2011-07-05 Thread candlerb
Sorry, please ignore this question.

All rows get autocomplete="off", and it doesn't make adifference.

The problem than autocomplete() doesn't work like live(): if you call
autocomplete() and then later add a new field to the DOM, that new
field doesn't get autocomplete enabled.

-- 
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: change values in "select list"

2011-07-05 Thread Andre Terra
If he's going to ask around for help and show code, then English is
the language of choice, for the simple reason that more developers
speak it. As his questions grow in complexity (which is to be
expected) so will the burden of having to figure out the German words.

As for the python keywords, show me a non-obscure japanese programming
language and I'll concede. There's a reason no such thing exists.

For the record, English isn't my first language either. I'm pretty
sure a lot of German companies code in English much like Brazilian
companies do.

There are numerous references online that talk about this issue, so
for the sake of everyone in the list I'll refrain from extending the
matter any further.


Sincerely,
Andre Terra

On 7/5/11, Geoff Kuenning  wrote:
>
>
> On Jul 5, 2:00 am, Andre Terra  wrote:
>> For what it's worth, it will do you good to name everything in
>> English, even if it's not your native language. Python's keywords are
>> in English (if, while, for, class, return, break...) and sticking to
>> one language makes the code easier to maintain (you might have a
>> developer on your team who doesn't speak German) and readable for
>> those of us who can only speak a language or two.
>
> I couldn't disagree more strongly.  The fact that Python's keywords
> are in English has NOTHING to do with the choice of variable names;
> you might as well argue that because APL is in love with Greek
> letters, all APL programs should be written in Greek.
>
> The argument about a non-German-speaking developer is just plain
> silly; the application is being developed by a German-speaking company
> in a German-speaking country.  If they hire a non-German-speaking
> developer, that person will necessarily learn German very fast.
>
> (Reductio ad absurdum: since every major programming language uses
> English keywords, you are fundamentally claiming that it is a mistake
> to ever write code in your native language.  You are also claiming
> that if a language with Japanese keywords ever gains prominence--and
> it's worth noting that Ruby was invented by a Japanese speaker--all
> developers must then learn Japanese before writing in that language.)
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: ModelForm save call with data and instance

2011-07-05 Thread bruno desthuilliers
On Jul 5, 8:17 am, Constantine  wrote:
> def view(request)
>     form = MyForm(request.POST, instance = MyModel(myfiled = 1))
>     if form.is_valid():
>         obj = form.save()
>
> but POST will NEVER merged with instance i've looked through stack:
(snip)
> in doesn't populate instance with cleaned data
>

Err... Actually, yes it does:
https://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L305

-- 
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: change values in "select list"

2011-07-05 Thread Geoff Kuenning


On Jul 5, 2:00 am, Andre Terra  wrote:
> For what it's worth, it will do you good to name everything in
> English, even if it's not your native language. Python's keywords are
> in English (if, while, for, class, return, break...) and sticking to
> one language makes the code easier to maintain (you might have a
> developer on your team who doesn't speak German) and readable for
> those of us who can only speak a language or two.

I couldn't disagree more strongly.  The fact that Python's keywords
are in English has NOTHING to do with the choice of variable names;
you might as well argue that because APL is in love with Greek
letters, all APL programs should be written in Greek.

The argument about a non-German-speaking developer is just plain
silly; the application is being developed by a German-speaking company
in a German-speaking country.  If they hire a non-German-speaking
developer, that person will necessarily learn German very fast.

(Reductio ad absurdum: since every major programming language uses
English keywords, you are fundamentally claiming that it is a mistake
to ever write code in your native language.  You are also claiming
that if a language with Japanese keywords ever gains prominence--and
it's worth noting that Ruby was invented by a Japanese speaker--all
developers must then learn Japanese before writing in that language.)

-- 
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: change values in "select list"

2011-07-05 Thread Geoff Kuenning


On Jul 4, 11:10 pm, Tom Evans  wrote:

> All of this is explained in the docs. Read the docs.

He did; he said he did in his previous posting.  But although the docs
are far better than many, I'm not sure I've _ever_ seen documentation
that answered every question perfectly.  Add that to the fact that
English isn't his first language, and from painful personal experience
I can deeply sympathize with the fact that he didn't absorb everything
on the first try.

-- 
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 tests and namespaced reversed urls

2011-07-05 Thread Mateusz Harasymczuk
I have a problem with tests and namespaced reversed urls.
It fails tests.
However when running a server they works properly.
I have tried

#urls.py
url(r'^', include('ns.urls', namespace="ns"), name="ns"),

#ns/urls.py
url(r'name/$', NameView.as_view(), name='home'),

#template.html

{% url ns:home %}

and

{% load url from future %}
{% url "ns:home" %}




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fFl7CNOAb50J.
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.



Related model getting autocomplete="off"

2011-07-05 Thread candlerb
I have an Admin view on a model which has related (child) models. I
have extra=1. It displays like this:

[Child1]
[Child2]
[ ]
+ Add another Foo

I have jQuery autocomplete attached to those model fields.

All is fine, except: when I click on 'Add another Foo', the
dynamically added field has autocomplete="off", and so autocomplete
doesn't work there.

The only place I can see autocomplete set is in media/js/inlines.js,
but that's for fetching a couple of global fields.

Any idea if this behaviour is intentional, or a bug? (Django-1.3)

Thanks,

Brian.

-- 
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: Confusing path example for mod_wsgi?

2011-07-05 Thread candlerb
Thanks Tom and Bruno for all the help - my project looks much cleaner
now.

-- 
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: Questions on markdown

2011-07-05 Thread DrBloodmoney
On Mon, Jul 4, 2011 at 2:22 PM, Petite Abeille  wrote:
>
> On Jul 4, 2011, at 8:08 PM, leo wrote:
>
>> what i want is
>
> To quote the friendly manual:
>
> "When you do want to insert a  break tag using Markdown, you end a line 
> with two or more spaces, then type return."
>
> http://daringfireball.net/projects/markdown/syntax#p

If you're copy/pasting test that's not Markdown, then Markdown will
not magically help you. If you have unformatted text that you want to
turn into html, you're probably going to have to do a little text
pre-processing. Good news: you're using Python and text processing is
easily in python.

-- 
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: Setting up EC2 for Django

2011-07-05 Thread DrBloodmoney
On Sat, Jul 2, 2011 at 10:14 AM, Soviet  wrote:
> Hello
> I need to set up EC2 instance to run Django+Python+PostgreSQL+Apache
> +Solr+nginx+Mercurial etc. This is all black magic for me - I was only
> using shared hosting like webfaction, where everything is dumb-
> friendly :). But you know, "the customer is always right", and I have
> to run it on Amazon. I did hours of googling, but everything is either
> old/outdated or doesn't cover the tools I have to install. So far I'm
> stuck on connecting to my instance through PuTTY :D.
>
> Can anyone provide some useful link or step by step tutorial? I have
> no experience using Unix command-line-stuff, but im a fast learner :).
> Any help would be appreciated. Also, beer is on me when we meet! :)

An easy way to practice learning how to admin linux servers is to
download virtualbox and then download a server image (*.iso) from your
linux distro of choice (I prefer the Ubuntu/Debian side of things..
rec Ubuntu server). You can set up and then destroy without doing any
damage so you can easily setup again. The only way to learn this stuff
is to just get your hands dirty... it's not hard just kind of hard to
google generally. It's better to have specific errors to google for.

-- 
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: Confusing path example for mod_wsgi?

2011-07-05 Thread bruno desthuilliers


On Jul 4, 9:51 pm, candlerb  wrote:
> On Jul 4, 4:29 pm, Tom Evans  wrote:
>
> > The only reliable and approved way to access your
> > settings is:
>
> >   from django.conf import settings
>
> Excellent, that makes it a lot tidier.

I think this should be written in big bold letters everywhere in
django's doc...

> Here's my full django.wsgi, which I have inside the top-level mysite
> directory:
>
> 
> import os
> import sys
>
> path = os.path.dirname(__file__)

you might be better with

  path = os.path.dirname(os.path.abspath(__file__))

but anyway; your wsgi file should not be in your project root.

> It still fails if I comment out the second bit of path setup (the ".."
> one). However, if I change those two lines to
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> and
>
> ROOT_URLCONF = 'urls'

Congratulations .

> then the app does seem to work happily with just /path/to/mysite in
> the path. Is this a reasonable thing to do? (I guess only if you ever
> have one django project in your path)

Why would you have 2 django projects in your path in this context ?-)

-- 
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: Confusing path example for mod_wsgi?

2011-07-05 Thread bruno desthuilliers
On Jul 4, 9:51 pm, candlerb  wrote:
> OK, that's what wasn't clear to me in the documentation. For some
> reason, I can refer to 'bar' by itself when using runserver, but with
> wsgi I need to add /path/to and /path/to/foo to sys.path (or else
> refer to 'foo.bar' everywhere).

This has to do with 1/ how Python looks for modules (sys.patth), 2/
the fact that your manage.py from the root of your project (and not
from the parent directory) and 3/ some weird things happening with
manage.py and not when running behing apache or another web server.

wrt/ point #1 and #2: Python looks for modules / packages in the path
listed in sys.path, which always start with the current working
directory, so when you're running manage.py from within directory
"foo", foo is first on your sys.path, and you can directly import
'bar'. When running mod_wsgi, if you only adds "/path/to" in your
sys.path, Python will be able to find package "foo" (yes, your Django
project IS a Python package - it has a __init__.py file), and from
this sub-modules (foo.settings) and sub-packages (foo.bar), but NOT
'bar' (there's no package named 'bar' in your sys.path at this
point).

You can either add both '/path/to' and '/path/to/foo' in your sys.path
and point os.environ['DJANGO_SETTINGS_MODULE'] to 'foo.settings' and
settings.ROOT_URLCONF to 'foo.urls',  or only add '/path/to/foo' in
your sys.path and point os.environ['DJANGO_SETTINGS_MODULE'] to
'settings' and settings.ROOT_URLCONF to 'urls' (but then any use of
'foo.whatever' will break).

As far as I'm concern I prefer the second solution - I don't want to
have to change anything in my code when I rename my project dir or
move an app to another project or whatever.

wrt/ point #3, I can only point you to Graham Dumpleton's excellent
post:
http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

-- 
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: forcing authentication without a password

2011-07-05 Thread Tom Evans
On Mon, Jul 4, 2011 at 10:15 PM, Josh Stratton
 wrote:
> I've setup my authentication system to use the standard name/password with
> good results, but some of the users are coming directly from Google Apps
> with an OpenID I've authenticated by hand.  What I'd like is if they are
> authenticated from Google Apps, I can just call
> auth_login, but they haven't actually been "authenticated" in django's
> eyes.  All I'd like to do is log in as if they had typed their
> username and password.  If I just try to logon the user, I get an error
> saying the "backend" hasn't been set.  Right now I can hack a login by
> setting the backend to the same one used by the other method, but when I go
> to the another tab and go back to the site, I see that I'm not actually
> logged in on that page, like something isn't stored in the session
> correctly.  This seems like it should be a simple problem, but it's
> extremely frustrating.  I'd just like to say, "Hey, I trust this person, log
> them in even though I don't know their password".
>
> Thanks.
>

Users must be authenticated before you call login. You can
authenticate them using a custom auth backend:

https://docs.djangoproject.com/en/1.3/topics/auth/#handling-authorization-in-custom-backends

Define your own custom auth backend (in addition to the current one
you are using) which takes an optional 'openid_authenticated'
argument. The authenticate method in the auth backend should simply
find the user with the appropriate username, and return it.

When you receive a user authenticated through openid, simply call
django.contrib.auth.authenticate, passing this new additional
argument. The user returned from djanog.contrib.auth.authenticate will
then have the appropriate backend set, and login will correctly store
the right parameters in the users session.

Cheers

Tom

-- 
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: Auth Login well documented but elusive

2011-07-05 Thread Tom Evans
On Tue, Jul 5, 2011 at 2:10 AM, TuckFrance  wrote:
> Having problems with getting login to work even though it's well
> documented. The pages for success, invalid, and no info provided
> aren't getting used at all. Instead, clicking login always redirects
> to /login which is not what I want. Any ideas?
>
> URLconf:
> ...
> (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> View:
> ...
> def login(request):
  ^^^
>    username = request.POST['username']
>    password = request.POST['password']
>    user = authenticate(username=username, password=password)
>    if user is not None:
>        if user.is_active:
>            login(request, user)
   ^^^

You're calling a function called 'login' from inside a function called
'login'. It's not going to end well. Either call your login view
function something else, or import django.contrib.auth.login using a
different name (from django.contrib.auth import login as
django_login).

Cheers

Tom

-- 
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.