Re: Performance when retrieving data from related models

2013-03-17 Thread Peter of the Norse
You’re over thinking this by a large margin. getTendersForContractor should 
return a QuerySet. That way you can add things like .select_related as 
necessary in the view. 

Also, I’m a bit worried about the fact you have a function called 
getTendersForContractor. It really should be Tender.objects.forContractor. Or 
if the function is just a single filter call, it can be eliminated entirely.

On Mar 15, 2013, at 9:04 PM, Taras_96 wrote:

> qs = Tender.objects.sql_related(/*names of keyed relationships 
> here*/).prefetch_related('project', 'project__job_set') (the actual example 
> has many more relations in the prefetch_related). This fixes the problem of 
> hitting the database in loops such as the above, and the complexity can be 
> hidden in a data retrieval layer that the client calls into.
> 
> returnedTenders = getTendersForContractor(contractor) # << the actual query 
> with prefetches etc is done in this function
> 
> However, there are a few drawbacks to this:
[SNIP]
> * Each prefetch_related hits the database once - a lot better than 3k hits, 
> but not as minimal as a sql join which joins all of the tables
Actually, no. If you were to try and do the prefetch_related as a single SQL 
join, you would return an insane number of rows. A single prefetch_related 
wouldn't be a problem, but if you were to try and do a select with more than 
one many field, they would multiply. If you have an example of a join statement 
that doesn’t do that, we’d love to see it.

> * Prefetch_related selects related obects via the criteria: 'in (list of 
> ids'), which arguably can be slower
What database are you using where this is true?

> * Seems brittle - if you change the data model, you have to change all of the 
> queries in the data retrieval layer. Denomralising the data would reduce 
> this, but we'd still have the problem of retrieving more data than the client 
> may possibly want
Yes, if you change code in one place, you might have to change it someplace 
else to match it. Most of us just use the ORM as the data retrieval layer. 
Again, I’m worried you’re over thinking this.


Peter of the Norse
rahmc...@radio1190.org



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




Changing User model

2013-03-17 Thread Lachlan Musicman
Hola,

For a new project, I will be creating a separate Profile class for all
 information about my Users that isn't covered by User.

One thing I did want though, was to change the login username to the
email address.

>From what I've read in the code and docs, am I right in presuming that
I can subclass AbstractUser and just change
  USERNAME_FIELD = 'email'
to get this result?

All of the examples I've seen* suggest going all the way to
AbstractBaseUser - but I'm ok with AbstractUser, I just want the
single change?

Cheers
L.


*pydanny's 2 scoops and the docs here:
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#django.contrib.auth.models.CustomUser
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#a-full-example )


cheers
L.


--
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

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




Re: Auth System: clarification on usage

2013-03-17 Thread Russell Keith-Magee
On Mon, Mar 18, 2013 at 5:49 AM, fire_water  wrote:

> Hello,
>
> I am fairly new to Django but have started developing my first app. The
> app will require the general public to create an account before being
> allowed to post comments on the website.
>
> After reading through The Django 
> Bookand The
> Docs  , I think
> Django's built-in User Authentication system might be the tool I need. If
> so, I am a bit confused on the intended purpose of the Auth System probably
> because I am used to only using it with Django's built-in Admin app.
>
> I am seeking clarification on the following points of confusion:
>
> 1. When I think of Django user authentication, I think of a very limited
> number of special people (admins) with permission to access the Django
> admin site. "Special people only"
>
> 2. When I think of allowing the general public to create an account and
> authenticate with my website, I see that as something completely separate
> from the Admin site and all of it's associated database tables.
> Immediately, I think of creating a "users" table in myapp/models.py.
> "General public only"
>
> But it almost sounds like admin and public accounts are both handled by
> the Auth System and therefore live in the same database table. I would like
> to get a solid understanding of this before I proceed any further with my
> app. Thanks in advance for any clarification you can provide!


People visit your site. Each of them gets a User account. Some of them are
staff, and have permission to view staff portions of the site (e.g., admin)
or perform other administrative actions (e.g., workflows on the main site
that don't exist for normal users). Others can only view the main site (or
specific parts of the main site).

You might have some special reason for wanting two different user tables,
but as a general principle, I can't say I see the point. If you've got
multiple user tables, then admin users who want to use the site need a
second, completely separate account. You then need to track the correlation
between Normal User accounts and Admin User accounts.

It also means that content needs to be owned either by an admin user or a
normal user. For example, consider a comment system -- comments have an
author, but that author is a foreign key to a single table. If you've got
two User tables, you can only link to one of them, so either admin users
can't create comments, or admin users need two user accounts.

So - in summary - although Django's admin users the auth.User model and
table, there's nothing admin specific about it. It's a general purpose user
table, and you can (and should) use it for your general site authentication.

Yours,
Russ Magee %-)

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




Auth System: clarification on usage

2013-03-17 Thread fire_water
Hello,

I am fairly new to Django but have started developing my first app. The app 
will require the general public to create an account before being allowed 
to post comments on the website.

After reading through The Django 
Bookand The 
Docs  , I think 
Django's built-in User Authentication system might be the tool I need. If 
so, I am a bit confused on the intended purpose of the Auth System probably 
because I am used to only using it with Django's built-in Admin app.

I am seeking clarification on the following points of confusion:

1. When I think of Django user authentication, I think of a very limited 
number of special people (admins) with permission to access the Django 
admin site. "Special people only"

2. When I think of allowing the general public to create an account and 
authenticate with my website, I see that as something completely separate 
from the Admin site and all of it's associated database tables. 
Immediately, I think of creating a "users" table in myapp/models.py. 
"General public only"

But it almost sounds like admin and public accounts are both handled by the 
Auth System and therefore live in the same database table. I would like to 
get a solid understanding of this before I proceed any further with my app. 
Thanks in advance for any clarification you can provide!

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




error at /accounts/register/ [Errno 101] Network is unreachable

2013-03-17 Thread Satinderpal Singh
I am using smtp for sending the mail from my system, i used the
following settings for the mail, but got an error while anybody trying
to register.
DEFAULT_FROM_EMAIL = 'my_m...@gmail.com'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'my_m...@gmail.com'
EMAIL_HOST_PASSWORD = '*'
EMAIL_USE_TLS = True
EMAIL_PORT = 587

-- 
Satinderpal Singh
http://devplace.in/~satinder/wordpress/
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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




Re: My Data dont be updated with my forms

2013-03-17 Thread Rafael E. Ferrero
Thanks Dan i'll try your advice !!
El 16/03/2013 22:22, "Dan Gentry"  escribió:

> Rafael,
>
> This is a bit of a wild guess, but I'm wondering if your form isn't
> validating.  Since your template doesn't seem to be displaying any errors,
> you wouldn't know it.
>
> Also, since the Url column is marked as unique, but you are excluding it
> from the form, it may be the field throwing the error.
>
> Just to check, add {{form.errors}} to your template and give it a try.
>
> Best of luck,
>
> Dan
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Problem with my logout template (and admin logout template)

2013-03-17 Thread VVilku
I have a problem with logout admin template and my logout template (from my 
application).

Why 'admin-template' overrides my 
template("test_app/templates/registration/logged_out.html")?

'Login' template works fine, I have a problem only with 'logout'.

Below is working example (in attachment).

Clicking on 'logout' applies the template admin.

regards,
VVilku

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




django_logout_problem.rar
Description: application/rar


Re: Settings object has no attribute 'ROOT_URLCONF' while deploying using apache and mod_wsgi

2013-03-17 Thread jirka . vejrazka
I'd look at how you reference your settings during imports. The error message 
spells "Settings" with uppercase "S" which feels incorrect.

   HTH

 Jirka
-Original Message-
From: Navid Shaikh 
Sender: django-users@googlegroups.com
Date: Sun, 17 Mar 2013 02:20:29 
To: 
Reply-To: django-users@googlegroups.com
Subject: Settings object has no attribute 'ROOT_URLCONF'  while deploying
 using apache and mod_wsgi

Hi folks,

(Before posting I searched in archive and the question is kind of similar 
to thread [1].)

I am getting error:
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'

I am using 
a) Django version 1.3.2.
b) Apache
c) mod_wsgi
 
I followed standard Django docs [2] to implement configurations.

Below are my some config file excerpts:
(I renamed my actual site name with mysite)

mysite-httpd.conf (filename)
-

WSGIScriptAlias / "/usr/share/slate/apache/mysite.wsgi"

-

mysite.wsgi   (filename)
--
#!/usr/bin/python
#
# For Apache mod_wsgi.
import os
import sys

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

sys.path.append(path)   # /usr/share/slate/
sys.path.append(os.path.dirname(path))  # /usr/share/

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
--

After reading thread[1] , I think that there is problem in setting 
'DJANGO_SETTINGS_MODULE', as I have 'ROOT_URLCONF variable
set in settings.py.


Please point out where I am doing it wrong.

Links:
[1] http://www.mail-archive.com/django-users@googlegroups.com/msg28764.html
[2] https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/


Thanks and Regards,
Navid Shaikh.

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



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




Settings object has no attribute 'ROOT_URLCONF' while deploying using apache and mod_wsgi

2013-03-17 Thread Navid Shaikh
Hi folks,

(Before posting I searched in archive and the question is kind of similar 
to thread [1].)

I am getting error:
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'

I am using 
a) Django version 1.3.2.
b) Apache
c) mod_wsgi
 
I followed standard Django docs [2] to implement configurations.

Below are my some config file excerpts:
(I renamed my actual site name with mysite)

mysite-httpd.conf (filename)
-

WSGIScriptAlias / "/usr/share/slate/apache/mysite.wsgi"

-

mysite.wsgi   (filename)
--
#!/usr/bin/python
#
# For Apache mod_wsgi.
import os
import sys

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

sys.path.append(path)   # /usr/share/slate/
sys.path.append(os.path.dirname(path))  # /usr/share/

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
--

After reading thread[1] , I think that there is problem in setting 
'DJANGO_SETTINGS_MODULE', as I have 'ROOT_URLCONF variable
set in settings.py.


Please point out where I am doing it wrong.

Links:
[1] http://www.mail-archive.com/django-users@googlegroups.com/msg28764.html
[2] https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/


Thanks and Regards,
Navid Shaikh.

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




Re: Trouble creating super user on Django 1.5 in windows

2013-03-17 Thread Nonami Animashaun
Resolved: 

Apparently there was a bug in python 3.2 on windows that added an extra 
character to strings when the built-in input function is used. I switched 
my default python installation  to python 3.3 and hope Django 1.5 is fully 
compatible with it

On Friday, March 15, 2013 11:33:02 AM UTC+1, Nonami Animashaun wrote:
>
> I am trying to create a super user but fjango is not accepting my keyboard 
> inputs. After syncdb django suggest that I enter yes to create super user 
> but no matter how I type "YES" it complains that I must type "yes" or "no".
>
> I tried doing a manage.py createsuperuser but django complains about all 
> the usernames I use. calls them invalid user invalid entries.
>

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




Re: Django on Jython - Newbie installation difficulties

2013-03-17 Thread Alexey Kinyov
You are welcome :)

I'm just interesting what kind of task and environment do you have?
I've never played with Jython and never needed to use it, so it's
uncommon for me.

Sure. If you need your Python code to interact "directly" (not through
network API) with Java code, Jython seems reasonable solution, I don't
know much more on topic :)

Alex
///

On Sat, Mar 16, 2013 at 11:42 PM, SeeGull  wrote:
> Thanks for the response.
>
> 1. I have now isolated the problem with the install. It is indeed a version
> compatibility mismatch. Django 1.5* does not support Jython 2.5*.
>
> Django 1.5* requires the unstable development version Jython 2.7*
> Django 1.4* is compatible with the stable old version Jython 2.5*
>
> I have now chosen the Django 1.4* route. I can up-version later as soon as a
> stable Jython 2.7* is released.
>
> 2. Why Jython at all? I am experimenting. I have a web site concept that
> points strongly in the direction of a Python based solution. However, the
> ability to easily extend the functionality with Java code embedding and JVM
> execution is quite interesting too. I am a lazy programmer and want to
> maximise the leverage I can get with my minimal code.
>
> Would you suggest a different approach?
>
>
>
> --
> View this message in context: 
> http://python.6.n6.nabble.com/Django-on-Jython-Newbie-installation-difficulties-tp5010361p5010374.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 unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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