Sample Django AppEngine App

2010-07-02 Thread Mak
I am completely new to Django. I am wondering if there is a sample
Django AppEngine application somewhere with explanation on how it is
setup?

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



Re: Get an ordered queryset from a FK relation

2010-07-02 Thread Dennis Kaarsemaker
On vr, 2010-07-02 at 16:10 -0700, eka (Esteban) wrote:

> I have an Entry model with a FK to User, what I want is to get a list
> of Users ordered by its Entry quantity. Can I achieve that using
> QuerySets?

queryset.annotate(Count('entry')).order_by('entry__count')

See http://docs.djangoproject.com/en/dev/topics/db/aggregation/

-- 
Dennis K.

They've gone to plaid!

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



Get an ordered queryset from a FK relation

2010-07-02 Thread eka (Esteban)
Hi all,

I have an Entry model with a FK to User, what I want is to get a list
of Users ordered by its Entry quantity. Can I achieve that using
QuerySets?

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django Personalization and Preferences?

2010-07-02 Thread zweb
On my web pages I have  labels for text fields. I want user to be able
to personalize the labels.

Example :
default label: Employee, alternative is that user can choose and
save-  Associate or Staff Member as label to be shown on all screens.


Approach I can think of:

1. When user logs in - gets his preferences from DB and save it in
session.

2. I create a custom template tag {% getlabeltext Employee %}

which is something like ( following is the psuedo code)

def getlabeltext(label):
''' if user has choosen another label use it else return the
default.'''
   if label in request.session:
return request.session[label]
   else:
   return label


Is there a better approach I should look at?

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



Re: drupal and django being friends

2010-07-02 Thread CLIFFORD ILKAY

On 07/02/2010 01:23 PM, garagefan wrote:

thanks. so the simple answer is... "tough luck"

perhaps i can set up the django app under a different domain name and
merely set up domain masking.


The answer isn't necessarily "tough luck". It *is* possible to use 
mod_python and mod_php on the same server. It really depends on the 
distro. Having said that, there is really no reason to use mod_python 
any more. If you're going to use Apache, mod_wsgi is the preferred 
option. The challenge you're going to have isn't with getting mod_wsgi 
and mod_php to cooperate. It's getting the mod_rewrite expressions 
right. You have to understand what is being done in the Drupal-supplied 
.htaccess file and make sure that the rules don't overlap with what you 
want to do in Django. Here is what I see in Drupal's .htaccess file:


# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

You'll need to modify that appropriately to accommodate the URL 
namespace of your Django app or Drupal will just intercept the request 
and show a 404 page.

--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

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



Re: drupal and django being friends

2010-07-02 Thread Bill Freeman
I suspect that you can do what you want with mod_rewrite, but
there is a learning curve.

Bill

On Fri, Jul 2, 2010 at 11:39 AM, garagefan  wrote:
> So i realize this isn't a specific django question but more of a
> python question and setting up the config file for the server.
>
> I know how to set up domains, and the handler and all that for a
> django site.
>
> But i've got a drupal site that i'm "attaching" a django gallery
> too... and in fact slowly converting the site over to django as time
> permits, this gallery being the first part.
>
> I was under the assumption that placing SetHandler None at the base
> url  would result in the entire site being handled
> normally and there wouldn't be an issue... however this only worked
> for the home page. so then i went a long and placed the same code for
> the 7 other urls, since they were returning "not found"... this didn't
> change a thing.
>
> so basically... i need my python.conf file to allow apache to handle
> the entire site except for a specific url normally (ie allowing drupal
> to run)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: www.djangoproject.com

2010-07-02 Thread Bill Freeman
What might be of help is adding the IP address to /etc/hosts, if you are
on linux.  There is a hosts file on Windows, but I'm no expert in Windows
so I can't tell you where it is or any funky things about the format.  That
would let you try the site (just putting the IP address in the browser
location bar doesn't seem to work, making me presume that the site
is in an apache  or equivalent).

Another nifty tool for diagnosing DNS problems is nslookup, but, again,
I can't tell you what to use on windows.

Bill

On Fri, Jul 2, 2010 at 2:19 PM, mhulse  wrote:
>> try rebooting, but there could be other DNS caches between you and a
>> good name server.
>
> If that's the case, would OpenDNS be of any help?
>
> 
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



RE: Re: drupal and django being friends

2010-07-02 Thread Henrik Genssen
you may try wsgi instead of mod_python...

>reply to message:
>date: 02.07.2010 12:23:26
>from: "garagefan" 
>to: "Django users" 
>subject: Re: drupal and django being friends
>
>thanks. so the simple answer is... "tough luck"
>
>perhaps i can set up the django app under a different domain name and
>merely set up domain masking.
>
>On Jul 2, 1:15 pm, "Henrik Genssen"  wrote:
>> Hi,
>>
>> be sure not to use mod_python and mod_php as stated 
>> here:http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from...
>>
>>
>>
>> >reply to message:
>> >date: 02.07.2010 10:39:26
>> >from: "garagefan" 
>> >to: "Django users" 
>> >subject: drupal and django being friends
>>
>> >So i realize this isn't a specific django question but more of a
>> >python question and setting up the config file for the server.
>>
>> >I know how to set up domains, and the handler and all that for a
>> >django site.
>>
>> >But i've got a drupal site that i'm "attaching" a django gallery
>> >too... and in fact slowly converting the site over to django as time
>> >permits, this gallery being the first part.
>>
>> >I was under the assumption that placing SetHandler None at the base
>> >url  would result in the entire site being handled
>> >normally and there wouldn't be an issue... however this only worked
>> >for the home page. so then i went a long and placed the same code for
>> >the 7 other urls, since they were returning "not found"... this didn't
>> >change a thing.
>>
>> >so basically... i need my python.conf file to allow apache to handle
>> >the entire site except for a specific url normally (ie allowing drupal
>> >to run)
>>
>> >--
>> >You received this message because you are subscribed to the Google Groups 
>> >"Django users" group.
>> >To post to this group, send email to django-us...@googlegroups.com.
>> >To unsubscribe from this group, send email to 
>> >django-users+unsubscr...@googlegroups.com.
>> >For more options, visit this group 
>> >athttp://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-us...@googlegroups.com.
>To unsubscribe from this group, send email to 
>django-users+unsubscr...@googlegroups.com.
>For more options, visit this group at 
>http://groups.google.com/group/django-users?hl=en.
>

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



New Django tutorial

2010-07-02 Thread Rainy
Hi, I plan to make a bunch of Django tutorials and I just finished the
first one:

http://lightbird.net/dbe/

Please let me know how it can be improved and I'll incorporate
suggestions into upcoming tutorials. Thanks! -ak

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



Media files from PostgreSQL

2010-07-02 Thread Daniel Espinosa
Hi all,

Does any one know how to serve files stored in a PostgreSQL database?

I have a PHP application I want to migrate to Django, but I found it just
serve files stored on the disk, but not as Large Binary Object of
PostgreSQL, where they are stored by the PHP app.

-- 
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates:
LIBRE)

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



Re: Admin interface for model with optional 'self' relationship

2010-07-02 Thread Jonathan Hayward
Thank you! Solved.

On Mon, Jun 28, 2010 at 4:14 PM, Jeff Green  wrote:

> You need to also state that null=True. Also, you want to have ensure that
> the field defined in your db
> allows null values.
>
> On Mon, Jun 28, 2010 at 3:19 PM, Jonathan Hayward <
> christos.jonathan.hayw...@gmail.com> wrote:
>
>> I have a model with two foreign keys to itself:
>>
>> department = models.ForeignKey(u'self', blank = True, related_name =
>> u'member')
>> reports_to = models.ForeignKey(u'self', blank = True, related_name =
>> u'subordinate')
>>
>> When I tried to save test data from the admin interface, leaving those
>> items blank, I got a ValueError, pasted below. What do I need to be able to
>> save test data? I'm willing to assign non-blank values to those fields for
>> now, but there's a chicken-and-egg problem if the admin interface won't let
>> me save any instances until I already have an instance saved.
>>
>>  ValueError at /admin/directory/entity/add/
>>
>> Cannot assign None: "Entity.department" does not allow null values.
>>
>>   Request Method: POST Request URL:
>> http://linux:8000/admin/directory/entity/add/  Exception Type: ValueError 
>> Exception
>> Value:
>>
>> Cannot assign None: "Entity.department" does not allow null values.
>>
>>  Exception Location: 
>> /usr/lib/pymodules/python2.6/django/db/models/fields/related.py
>> in __set__, line 269 Python Executable: /usr/bin/python Python Version:
>> 2.6.5 Python Path: ['/home/jonathan/directory',
>> '/usr/local/lib/python2.6/dist-packages/pip-0.6.3-py2.6.egg',
>> '/home/jonathan/store/src/satchmo/satchmo/apps',
>> '/usr/local/lib/python2.6/dist-packages/django_threaded_multihost-1.3_3-py2.6.egg',
>> '/usr/local/lib/python2.6/dist-packages/django_signals_ahoy-0.1_1-py2.6.egg',
>> '/usr/local/lib/python2.6/dist-packages/django_tagging-0.3.1-py2.6.egg',
>> '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
>> '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
>> '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages',
>> '/usr/lib/python2.6/dist-packages/PIL',
>> '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6',
>> '/usr/lib/python2.6/dist-packages/gtk-2.0',
>> '/usr/lib/pymodules/python2.6/gtk-2.0',
>> '/usr/local/lib/python2.6/dist-packages']  Server time: Mon, 28 Jun 2010
>> 15:13:53 -050
>>
>> --
>> → Jonathan Hayward, christos.jonathan.hayw...@gmail.com
>> → An Orthodox Christian author: theology, literature, et cetera.
>> → My award-winning collection is available for free reading online:
>> ☩ I invite you to visit my main site at 
>> http://JonathansCorner.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-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
→ Jonathan Hayward, christos.jonathan.hayw...@gmail.com
→ An Orthodox Christian author: theology, literature, et cetera.
→ My award-winning collection is available for free reading online:
☩ I invite you to visit my main site at http://JonathansCorner.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need Help Fixing my Custom Manager's Method

2010-07-02 Thread Daniel Roseman
On Jul 2, 6:53 pm, b14ck  wrote:
> Hi everyone.
>
> I'm working on a mid-sized web project, and have run into a bit of a
> dead-end trying to figure out how to make my custom manager method
> `for_user` return a a proper Django QuerySet.
>
> First off, here's my: myproject/partylines/models.py source code which
> contains the problem that I'm trying to figure 
> out:http://pastie.org/private/zrqc0wklg4nwpmu8oce8aq
>
> I'm attempting (in another part of my website) to render a form which
> displays a dropdown of all Partyline objects that a given user owns.
> My form looks like:http://pastie.org/private/mimiwo1vlafz5cxktn2gla
>
> As you can see, the form accepts a custom parameter (user), and should
> modify the queryset to show *only* Partyline objects that the
> specified user owns. In the original paste which contains my manager
> code, you'll see that I've overridden the default 'objects' manager
> with my custom manager that has a single method, `for_user`, that
> returns a list of Partylines that a user owns.
>
> Basically, since my `for_user` manager method returns a list, and not
> a QuerySet, the __init__ field in my `PartylineReportForm` class
> doesn't work because it requires a QuerySet.
>
> What I'm trying to figure out is, how can I modify my `for_user`
> manager method to return a QuerySet instead of a list? I've been
> googling this for hours, and haven't seen any examples or found any
> documentation.
>
> If anyone could help me out I would greatly appreciate it.
>
> Thanks so much!

The trouble is that you have used a Python list comprehension to
filter the users in your manager, instead of using the ORM to
translate into SQL commands to filter in the database. Not only is
this incompatible with the modelform you want to use, it's also
significantly less efficient - you will be getting every single User
entry from the table, instantiating Django objects, then throwing them
away. (In fact, because each call to is_owner does a separate call to
user.get_profile, you'll be hitting the database multiple times for
each User in your database).

Instead, you need do this in a `filter()` call. I can't do the
conversion myself because you haven't provided the code to your
UserProfile and its is_creator method, but it looks like you're
familiar with building up queries via Q objects, so you should be OK.
--
DR.

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



Re: www.djangoproject.com

2010-07-02 Thread mhulse
> try rebooting, but there could be other DNS caches between you and a
> good name server.

If that's the case, would OpenDNS be of any help?



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



Need Help Fixing my Custom Manager's Method

2010-07-02 Thread b14ck
Hi everyone.

I'm working on a mid-sized web project, and have run into a bit of a
dead-end trying to figure out how to make my custom manager method
`for_user` return a a proper Django QuerySet.

First off, here's my: myproject/partylines/models.py source code which
contains the problem that I'm trying to figure out:
http://pastie.org/private/zrqc0wklg4nwpmu8oce8aq

I'm attempting (in another part of my website) to render a form which
displays a dropdown of all Partyline objects that a given user owns.
My form looks like: http://pastie.org/private/mimiwo1vlafz5cxktn2gla

As you can see, the form accepts a custom parameter (user), and should
modify the queryset to show *only* Partyline objects that the
specified user owns. In the original paste which contains my manager
code, you'll see that I've overridden the default 'objects' manager
with my custom manager that has a single method, `for_user`, that
returns a list of Partylines that a user owns.

Basically, since my `for_user` manager method returns a list, and not
a QuerySet, the __init__ field in my `PartylineReportForm` class
doesn't work because it requires a QuerySet.

What I'm trying to figure out is, how can I modify my `for_user`
manager method to return a QuerySet instead of a list? I've been
googling this for hours, and haven't seen any examples or found any
documentation.

If anyone could help me out I would greatly appreciate it.

Thanks so much!

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



Re: drupal and django being friends

2010-07-02 Thread garagefan
thanks. so the simple answer is... "tough luck"

perhaps i can set up the django app under a different domain name and
merely set up domain masking.

On Jul 2, 1:15 pm, "Henrik Genssen"  wrote:
> Hi,
>
> be sure not to use mod_python and mod_php as stated 
> here:http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from...
>
>
>
> >reply to message:
> >date: 02.07.2010 10:39:26
> >from: "garagefan" 
> >to: "Django users" 
> >subject: drupal and django being friends
>
> >So i realize this isn't a specific django question but more of a
> >python question and setting up the config file for the server.
>
> >I know how to set up domains, and the handler and all that for a
> >django site.
>
> >But i've got a drupal site that i'm "attaching" a django gallery
> >too... and in fact slowly converting the site over to django as time
> >permits, this gallery being the first part.
>
> >I was under the assumption that placing SetHandler None at the base
> >url  would result in the entire site being handled
> >normally and there wouldn't be an issue... however this only worked
> >for the home page. so then i went a long and placed the same code for
> >the 7 other urls, since they were returning "not found"... this didn't
> >change a thing.
>
> >so basically... i need my python.conf file to allow apache to handle
> >the entire site except for a specific url normally (ie allowing drupal
> >to run)
>
> >--
> >You received this message because you are subscribed to the Google Groups 
> >"Django users" group.
> >To post to this group, send email to django-us...@googlegroups.com.
> >To unsubscribe from this group, send email to 
> >django-users+unsubscr...@googlegroups.com.
> >For more options, visit this group 
> >athttp://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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: drupal and django being friends

2010-07-02 Thread Henrik Genssen
Hi,

be sure not to use mod_python and mod_php as stated here:
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs


>reply to message:
>date: 02.07.2010 10:39:26
>from: "garagefan" 
>to: "Django users" 
>subject: drupal and django being friends
>
>So i realize this isn't a specific django question but more of a
>python question and setting up the config file for the server.
>
>I know how to set up domains, and the handler and all that for a
>django site.
>
>But i've got a drupal site that i'm "attaching" a django gallery
>too... and in fact slowly converting the site over to django as time
>permits, this gallery being the first part.
>
>I was under the assumption that placing SetHandler None at the base
>url  would result in the entire site being handled
>normally and there wouldn't be an issue... however this only worked
>for the home page. so then i went a long and placed the same code for
>the 7 other urls, since they were returning "not found"... this didn't
>change a thing.
>
>so basically... i need my python.conf file to allow apache to handle
>the entire site except for a specific url normally (ie allowing drupal
>to run)
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To post to this group, send email to django-us...@googlegroups.com.
>To unsubscribe from this group, send email to 
>django-users+unsubscr...@googlegroups.com.
>For more options, visit this group at 
>http://groups.google.com/group/django-users?hl=en.
>

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



Re: django simple captcha issue

2010-07-02 Thread tsmets
No stack trace ... ?
What parts are you using text-to-speech... ?
How did you configure it ... ?



On Jul 1, 9:52 pm, weiwei  wrote:
> Hi all,
>
> I am using django-simple-captcha, it works fine on my dev environment
> (windows). But after i deployed to linux server, all other views/pages
> are working fine. But  when i request  /captcha/image/{{imagekey}}/ i
> got server internal error 500.
>
> Something I missed to configure?
>
> Thanks a lot

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



Re: Managing the balance between SSL and impact on the server

2010-07-02 Thread tsmets

>From a deployment perspective, it is better to have "one" front-end
server that has the site certificate.
That server would then redirect the traffic to the the internal
server, either in SSL (other encryption keys) or in plain HTTP. That
SSL server needs to be pretty powerfull has it is the one dealing with
all the encrypting (twice if you want to have internal traffic also
encrypted).

>From a devlopper perspective now :
It would have been nice to have a tag in the urls.py that shows which
URL are encrypted and which are not :)
This question is in fact a security & deployment issue ... and should
(ideally) have ZERO impact on the way the code is being developped.

Based on the recommendation in the doco's, I wrote my login form using
as much as possible the available functionnalities :

Here is a snipplet from my current code top-level "urls.py" :


(r'^login-window/$', 'django.contrib.auth.views.login',
{'template_name': 'prompt_login.html'}),


The prompt_login page contains mainly this

{% csrf_token %}


  {{ form.username.label_tag }}
  {{ form.username }}


  {{ form.password.label_tag }}
  {{ form.password }}





  



The question for this code is where would it be sensible to put the
enforcement of https / ssl connection

Are there people from the dev team who have (strong) opinion on this ?
Are there people dealing with Medical records or highly private data
(portefolio?) ... who have wise ideas to share ?

\T,

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



Re: Django for system administration apps

2010-07-02 Thread Dennis Kaarsemaker
On vr, 2010-07-02 at 07:08 -0700, PieterB wrote:
> 
> On Jul 2, 3:57 pm, Dennis Kaarsemaker  wrote:
> > On vr, 2010-07-02 at 06:42 -0700, PieterB wrote:
> 
> > puppet using django as well.
> 
> Without going into detail, how have you made the coupling between the
> two

Servers are represented by a django model with a couple of attributes
such as status (manually defined/imported), os (set on import),
architecture (likewise) and roles. The latter is an m2m to a ServerRole
class. One of its fields is puppet_roles, which is a comma separated
string of roles. Servers also have a puppet_settings field where one can
finetune. We use that for things like:

$ldap = 0 # no ldap authentication
$sox = 1  # in SOX scope

The actual link to puppet is simple. It has two parts: part one is a a
view and a template to generate nodes.pp. This is the template. servers
is a list of (fqdn, status, settings, classes) base::common is the "this
is a generic machine with no specified role" class that sets up MTA,
snmp, nrpe, ntp etc...

{% for node in servers %}node "{{ node.0 }}" {
$sdb_status="{{ node.1 }}"
{% if node.2 %}{{ node.2|indent:"4" }}
{% endif %}include {{ 
node.3|default:"base::common"|split:","|quoted|join:"," }}
}
{% endfor %}{% endautoescape %}

The second part is a cronjob that updates nodes.pp and signs incoming
certificate requests from known machines. This runs on all
puppetmasters.

-- 
Dennis K.

They've gone to plaid!

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



Re: Django for system administration apps

2010-07-02 Thread PieterB


On Jul 2, 3:57 pm, Dennis Kaarsemaker  wrote:
> On vr, 2010-07-02 at 06:42 -0700, PieterB wrote:

> puppet using django as well.

Without going into detail, how have you made the coupling between the
two

> --
> Dennis K.
>
> They've gone to plaid!

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



Re: Django for system administration apps

2010-07-02 Thread Dennis Kaarsemaker
On vr, 2010-07-02 at 06:42 -0700, PieterB wrote:

> How frequently is Django used to write system administration
> applications?

I don't know how often others do it, but we use it to manage hundreds of
servers by having a central database with django frontend and
integrating that with tools like kickstart and puppet using django as
well.

> I want to write django frontend's for some linux tools and scripts we
> use in the futures.
> Is django a good solution for this or should I use other techniques/
> frameworks (zope, pylons...)?

The framework you use is only a technical detail. Django is a very nive
technical detail and made our life much easier :)

> I also want to write an app querying an external db for reporting, but
> I guess that's not a problem either?

Depends on what you want, but probably not.

-- 
Dennis K.

They've gone to plaid!

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



Django for system administration apps

2010-07-02 Thread PieterB
How frequently is Django used to write system administration
applications?
I want to write django frontend's for some linux tools and scripts we
use in the futures.
Is django a good solution for this or should I use other techniques/
frameworks (zope, pylons...)?

I also want to write an app querying an external db for reporting, but
I guess that's not a problem either?

Can someone provide a link to some example(s)?
I can find a lot of "djangosites", but this is something totally
different.

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



Re: Newbie Q: Is there a way to prevent Django from creating fields w. 'Not Null' by default?

2010-07-02 Thread derek
On Jul 1, 10:16 pm, Barto  wrote:
> I've been following 'Writing Your First Django App. Pt. 1'
> substituting my own object names in experiment.
>
> Noticed that when I told Django to create my tables, it did so giving
> all (psycopg2/postgres) fields the 'notnull' setting. Easy to change
> this via PgAdmin, but I'm wondering if it is possible to prevent 'notnull' 
> from being assumed as default.

Also see:
http://groups.google.com/group/django-users/browse_thread/thread/24b0f7fbcf58801e/d1cac0dba8dc993b

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



Re: recursive ordering self ForeignKey

2010-07-02 Thread alain31
MTT is exactly what I need. Just installed and works fine.
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Looking for Django Developer(s) in Long Island for part time and full time

2010-07-02 Thread roberto
http://djangogigs.com
http://djangozen.com
http://python.org/community/jobs/

On Jul 1, 10:03 am, normlevy  wrote:
> Hello Django User group...
>
> I am looking on the site for how to post a job opening to your
> community...and I apologize in advance if I am not doing the right.
>
> We are looking for 1 or 2 local (NY Metro area - preferably Long
> Island) Django developers to work with me on a new audible Tweet
> platform we developed calledhttp://ShoutOmatic.com
>
> If you, or anyone you know is looking for part time or full time work
> please contact me normlevy @ shoutomatic  com
>
> We are an exciting start-up and build our platforms with Django...
>
> Thank you for any guidance you may have for us to find Django
> developers
>
> Norm Levy
> ShoutOmatic

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



Re: After sync signal?

2010-07-02 Thread felix
you might have already seen this ticket:

http://code.djangoproject.com/ticket/7561

re: post-sync isn't actually post sync


you could patch your deployed version of django of course

I would just use a standalone script or command that you run after
syncing.
if you can



On Jul 1, 5:34 pm, Jari Pennanen  wrote:
> Hi!
>
> I'm trying to add rows to database after sync, but I need to do it
> after *all* of the apps has been synced. Since my after sync function
> traverses all these apps and builds interesting information to the
> database.
>
> While post_syncdbhttp://docs.djangoproject.com/en/dev/ref/signals/#post-syncdb
> allows to connect to sender, I need to know is there a way to connect
> to "last sender"... Since there isn't any kind of "after sync signal".
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: recursive ordering self ForeignKey

2010-07-02 Thread Daniel Roseman
On Jul 2, 12:22 pm, alain31  wrote:
> Hello, I have a category model with a self foreign key:
>
> class Category(models.Model):
>     title = models.CharField(max_length=100)
>     parent = models.ForeignKey('self', blank=True, null=True,
> related_name = 'childs')
>     def __unicode__(self):
>         if not self.parent:
>             return self.title
>         else:
>             return self.parent.__unicode__() + u'/' + self.title
>
> I want to order (in admin and in querysets) categories with respect to
> the result of my __unicode__
> function (ex: /cat1/cat4 < /cat2/cat3). I tried ordering option in
> CategoryAdmin, Meta class with ordering
> but nothing worked ... May I add a __cmp__ function somewhere ?

No, because ordering of querysets is done in the database.

Your best bet is to use something like MPTT, which stores ordering
(via 'left' and 'right' fields) on each record in the tree.

Oh, and by the way, the last line is much better written like this:
return u'%s/%s' % (self.parent, self.title)
--
DR.

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



Postgis : Distance lookup using ST_Distance_sphere

2010-07-02 Thread orgoz
Hi,

This is my first message here, and I am sorry for my poor english...

I am trying to excecute some distance lookup but I have a problem to
use the ST_Distance_sphere postgis function.

In Django documentation, I read this (http://docs.djangoproject.com/en/
dev/ref/contrib/gis/geoquerysets/#id7):

"On every distance lookup but dwithin, an optional third element,
'spheroid', may be included to tell GeoDjango to use the more accurate
spheroid distance calculation functions on fields with a geodetic
coordinate system (e.g., ST_Distance_Spheroid would be used instead of
ST_Distance_Sphere)."

But when I try to execute a distance lookup with 'distance_lte' on a
Postgis 1.5 database, the query is executed with "ST_Distance" instead
of "ST_Distance_sphere". Why ? Did I forget something ?

This is my code :

stations = Station.objects.filter(point__distance_lte=(pnt,
D(km=10))).count()
from django.db import connection
print connection.queries

Which returns this :
[{'time': '0.144', 'sql': 'SELECT "spatial_ref_sys"."srid",
"spatial_ref_sys"."auth_name", "spatial_ref_sys"."auth_srid",
"spatial_ref_sys"."srtext", "spatial_ref_sys"."proj4text" FROM
"spatial_ref_sys" WHERE "spatial_ref_sys"."srid" = 900913 '}, {'time':
'0.903', 'sql': 'SELECT COUNT(*) FROM "prices_station" WHERE
ST_Distance("prices_station"."point", ST_GeomFromEWKB(E\'001\\\
\001000000 1277015000270036205353Q\
\\\270372277h341z0242560...@\'::bytea)) <=
1.0'}]

Thanks a lot
Regards.

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



Re: django simple captcha issue

2010-07-02 Thread martikk
Try to change PIL version

On Jul 1, 10:52 pm, weiwei  wrote:
> Hi all,
>
> I am using django-simple-captcha, it works fine on my dev environment
> (windows). But after i deployed to linux server, all other views/pages
> are working fine. But  when i request  /captcha/image/{{imagekey}}/ i
> got server internal error 500.
>
> Something I missed to configure?
>
> Thanks a lot

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



Re: /i18n/setlang/ broken?

2010-07-02 Thread tsmets
oups, I was not expected to copy past the whole file ...

My problem is the following ...
When people login I put in the session :
lang = 

When I use set lang, django sets
django_language = 

I now use "django_language" but ... is this the correct one to have
the translation working automatically ... ?

\T,


On Jun 30, 3:04 am, tsmets  wrote:
> To make your code more portable, I would suggest to have settings.py
> file as follow : see below.
> It is still unclear to me what needs to be done to catch up the
> language in my profile.
> Another issue I have is that all the languages are shown ...
> How to limit the number of languages to a sub-set (in my case :
> English / French / German / Dutch / Spanish (Catalan)).
>
> \T,
>
> ps : No way to add this to the group post through the interface...
> hence my mail directly to you (+ a cc to django-us...@googlegroup).
>
> On Apr 8, 12:51 pm, chr  wrote:
>
> > btw, here's the minimal-app:http://github.com/statesofpop/i18ntest
>

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



recursive ordering self ForeignKey

2010-07-02 Thread alain31
Hello, I have a category model with a self foreign key:

class Category(models.Model):
title = models.CharField(max_length=100)
parent = models.ForeignKey('self', blank=True, null=True,
related_name = 'childs')
def __unicode__(self):
if not self.parent:
return self.title
else:
return self.parent.__unicode__() + u'/' + self.title

I want to order (in admin and in querysets) categories with respect to
the result of my __unicode__
function (ex: /cat1/cat4 < /cat2/cat3). I tried ordering option in
CategoryAdmin, Meta class with ordering
but nothing worked ... May I add a __cmp__ function somewhere ?

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



Re: Apache causes full path of django.wsgi path written into url?

2010-07-02 Thread ALJ
... actually ... it has to be the mod_rewrite that is causing the
problem with mod_wsgi. But I don't get why.

On Jul 2, 11:00 am, ALJ  wrote:
> I successfully set up a django site to redirect all non secure content
> to https. However, I want to bring it back a little and only use https
> for account details and admin ("/accounts" and "/admin").
>
> I've set up a rewrite in apache for those areas and the redirect seems
> to be working, but it writes the full path of the django.wsgi into the
> url!
>
> "https://www.mydomain.net/C:/www/mysite/pdbsite/apache/django.wsgi/
> accounts/login/?next=/promotions/"
>
> (... that knocking sound is me banging my head on the wall ...)
>
> Part of the the httpd.conf is:
>
> --
> 
>
>     ...
>
>    DocumentRoot "C:/www/mydomain/pdbsite/main/site_media"
>
>         #Make sure that all connections to the admin and accounts dirs are
> secure
>         
>         RewriteEngine On
>         RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [QSA,NC,R,L]
>         
>
>         #Aliases -
>         ...
>         Alias /media "C:/Python26/Lib/site-packages/django/contrib/admin/
> media"
>         WSGIScriptAlias / "C:/www/mysite/pdbsite/apache/django.wsgi"
>
>        ...
> 
>
> 
> The url.py is:
>
> urlpatterns = patterns('',
>     url(r'^admin/', include(admin.site.urls)),
>     url(r'^$','django.views.generic.simple.redirect_to',
> {'url':'promotions'}),
>     url(r'^accounts/login/$', 'django.contrib.auth.views.login',
> {'template_name': 'login.html'}, name="login"),
>     url(r'^accounts/logout/$', 'pdbsite.main.views.logout_view', {},
> name='logout'),
>     url(r'^accounts/change_password/
> $','django.contrib.auth.views.password_change' 
> {"template_name":"password_change.html","post_change_redirect":'password_change_done'},
> name='password_change'),
>     url(r'^accounts/change_password/password_change_done/
> $','django.contrib.auth.views.password_change_done',
> {"template_name":"password_change_done.html"},
> name='password_change_done'),
> ...

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



Raw SQL queries and nested fields

2010-07-02 Thread pablo platt
Hi

I have a Product model that holds info common to all product types.
Product has a m2m categories field.
SimpleProduct and BundleProduct extends Product (one2one relation).
BundleProduct have a m2m products field (only SimpleProducts allowed).

class Product(models.Model):
>   name=models.CharField()
>   description=models.CharField()
>   categories = models.ManyToManyField(Category)
>
> class SimpleProduct(Product):
>   some_field=models.CharField()
>
> class BundleProduct(Product):
>   products = models.ManyToManyField(Product)
>

When showing a list of products I'm making the following queries:

> products = Product.objects.filter()
> for p in products:
>   for category in p.categories.all():
> ...
>   if hasattr(p, 'bundleproduct'):
> for child in p.products.all():
>   for category in child.categories.all():
>

This could end with a huge number of queries.
I can improve it with:

> Product.objects.filter(...).select_related('simpleproduct',
> 'bundleproduct')
>
I can further improve by using the select_reverse app for the m2m
categories field.

That's a big improvement but it can still end with a large number of queries
because each BundleProduct can have several products.
There are other product types like ConfigurableProduct. So a BundleProduct
can have a ConfigurableProduct child that has several SimpleProduct children

Is it possible to make a custom query that will fetch everything with a
single query and put it in a queryset so I can iterate it and work with it
as usual?

The docs about raw queries show simple use case. Is it possible to fetch
deep nested objects like products[1].categories.all()[2]
without making additional queries?

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Managing the balance between SSL and impact on the server

2010-07-02 Thread steven314
> So I should be looking at SESSION_COOKIE_SECURE (http://
> docs.djangoproject.com/en/dev/topics/http/sessions/)?

Cookies are passed along with the request, not in a separate
connection. Therefore with browsers that support secure only cookies,
setting SESSION_COOKIE_SECURE = True would require all requests which
needed the session (in your case, all of them, I believe) to be served
over SSL.

> > Steven, you say you have login on SSL and then have the cookie passed
> > over unencrypted channel for the rest of the site. Is there any risk
> > with this or mitigating steps that should be taken?

I'm no security expert ;-) but it would certainly be easier to steal a
cookie that is being transferred over an insecure connection, at which
point the thief could impersonate the user of the cookie that was
stolen. BUT this would require that the thief have access to the
network somewhere between the client and server (so it's not _that_
easy). Also note that the Django cookie does not contain the password
(no cookies should ever contain secrets like this).

Other options might be to consider using
SESSION_EXPIRE_AT_BROWSER_CLOSE or SESSION_COOKIE_AGE to reduce the
lifetime of the cookie, at the expense of requiring your users to log
in more frequently.

Given that you say your content is not particularly sensitive, I would
presume that saving the CPU cycles and only using SSL for auth and
personal data transfer is acceptable -- but maybe the extra CPU cycles
are not significant. Only you and your stakeholders can determine what
level of paranoia you need for your site.

Hope this helps!
Steven.

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



Apache causes full path of django.wsgi path written into url?

2010-07-02 Thread ALJ
I successfully set up a django site to redirect all non secure content
to https. However, I want to bring it back a little and only use https
for account details and admin ("/accounts" and "/admin").

I've set up a rewrite in apache for those areas and the redirect seems
to be working, but it writes the full path of the django.wsgi into the
url!

"https://www.mydomain.net/C:/www/mysite/pdbsite/apache/django.wsgi/
accounts/login/?next=/promotions/"

(... that knocking sound is me banging my head on the wall ...)


Part of the the httpd.conf is:

--


...

   DocumentRoot "C:/www/mydomain/pdbsite/main/site_media"

#Make sure that all connections to the admin and accounts dirs are
secure

RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [QSA,NC,R,L]


#Aliases -
...
Alias /media "C:/Python26/Lib/site-packages/django/contrib/admin/
media"
WSGIScriptAlias / "C:/www/mysite/pdbsite/apache/django.wsgi"

   ...



The url.py is:

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$','django.views.generic.simple.redirect_to',
{'url':'promotions'}),
url(r'^accounts/login/$', 'django.contrib.auth.views.login',
{'template_name': 'login.html'}, name="login"),
url(r'^accounts/logout/$', 'pdbsite.main.views.logout_view', {},
name='logout'),
url(r'^accounts/change_password/
$','django.contrib.auth.views.password_change' 
{"template_name":"password_change.html","post_change_redirect":'password_change_done'},
name='password_change'),
url(r'^accounts/change_password/password_change_done/
$','django.contrib.auth.views.password_change_done',
{"template_name":"password_change_done.html"},
name='password_change_done'),
...


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



Re: Managing the balance between SSL and impact on the server

2010-07-02 Thread ALJ
... having looked through the django documentation, would I be right
in thinking that the protocol is to have a secure login page where the
session cookie is set, drop out of secure connection, but continue to
pass cookies over the secure connection, leaving the pages themselves
to be served over unsecured connection?

So I should be looking at SESSION_COOKIE_SECURE (http://
docs.djangoproject.com/en/dev/topics/http/sessions/)?

ALJ

On Jul 1, 10:32 pm, ALJ  wrote:
> Thanks for that Euan.
>
> Steven, you say you have login on SSL and then have the cookie passed
> over unencrypted channel for the rest of the site. Is there any risk
> with this or mitigating steps that should be taken?
>
> (Sorry ... don't have my head around it)
>
> ALJ
>
> On 1 July, 15:20, steven314  wrote:
>
> > It's a very common pattern to use SSL for login and private profile
> > details and then have the cookie passed over an unencrypted channel
> > for the rest of the site.
>
> > I have implemented an approach where nginx handles all the SSL and
> > proxies requests to apache (which directly serves non-SSL requests).
> > Transitions between SSL and non-SSL are achieved with rewrites at the
> > nginx and apache level, which also means that SSL can be made optional
> > on, say, the admin URLs.
>
> > This breaks request.is_secure() as it stands but this is easy to work
> > around.
>
> > Bear in mind that IE may give you loud warnings about insecure content
> > if you don't also adjust the MEDIA_URL to use SSL where
> > appropriate.
>
> > Steven.

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



Re: How can I access attributes in intermediate class

2010-07-02 Thread cat in a tub
I found model inheritance may be a better solution: combine may model
into one (Similar to views combining tables in database)


Quote:

Model inheritance in Django works almost identically to the way normal
class inheritance works in Python. The only decision you have to make
is whether you want the parent models to be models in their own right
(with their own database tables), or if the parents are just holders
of common information that will only be visible through the child
models.

There are three styles of inheritance that are possible in Django.

   1. Often, you will just want to use the parent class to hold
information that you don't want to have to type out for each child
model. This class isn't going to ever be used in isolation, so
Abstract base classes are what you're after.
   2. If you're subclassing an existing model (perhaps something from
another application entirely) and want each model to have its own
database table, Multi-table inheritance is the way to go.
   3. Finally, if you only want to modify the Python-level behaviour
of a model, without changing the models fields in any way, you can use
Proxy models.


On Jun 29, 12:04 pm, Alexandre González  wrote:
> I was intrigued so I did it, I get this solution:
>
> from models import User, Group, Membership
>
> def example(request):
>     example_group_id = 1 #I create only one group to test, this is his id
>
>     group = Group.objects.get(pk=example_group_id)
>     for user in group.members.iterator(): #Get all user in the group
> throught the membership
>         membership = Membership.objects.get(person=user, group=group) #Get
> the membership object using the user and the group as keys
>         membership.date_joined # Now you can read your date_joined
>
> Perhaps it isn't the best way to do it, but it works :p
>
> I hope this helps you,
> Álex González
>
> On Tue, Jun 29, 2010 at 19:45, cat in a tub  wrote:
>
>
>
> > class User(models.Model):
> >    name = models.CharField(max_length=128)
>
> > class Group(models.Model):
> >    name = models.CharField(max_length=128)
> >    members = models.ManyToManyField(User, through='Membership')
>
> > class Membership(models.Model):
> >    person = models.ForeignKey(User)
> >    group = models.ForeignKey(Group)
> >    date_joined = models.DateField()
>
> > What if I want to access Membership.data_joined in Group class?
>
> > 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptxhttp://mirblu.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Any implement of event bus in django

2010-07-02 Thread cat in a tub
Hi

I am wondering whether there is any implement of event bus (a
centralized control of sub/dist event via ajax sync).
Google use this design pattern in its ad-words by java. Does django
have similar solutions ?

Cheers
Homer

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