How can I pass mock objects to views for testing purposes?

2007-11-01 Thread Manoj Govindan

One of my applications has a view that uses a random number generator.
I am having some trouble passing a mock random generator to the view
for testing purposes.
I am relying on the mock object to get predictable results for testing
the view's logic.

After several attempts I came up with an URL that looks like this:

from project.app.lib import RandomNumberGenerator

urlpatterns = patterns('',
(r'^total/$', 'project.app.views.sum_of_random_numbers',
{'generator': RandomNumberGenerator() }),
)

My view:

def sum_of_random_numbers(request, generator):
random_number = generator().random_number()

if random_number == 1:
# Render etc.
# elif etc.


Here is my test:

from django.test import Client

client = Client()
response = client.post('/total/', {'choice': 'random'})

I would like to pass a mock object as the 'generator' argument. How
should I go about this?
Are there any better ways to achieve what I am trying to do?

Any help would be welcome.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread James Bennett

On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote:
> The generated settings.py contains things that are perfectly normal "source
> code" like things that should be treated as such.  How does one only commit 
> part
> of a file to svn?

Why do you need to commit your project's settings file to a
publicly-viewable repository? If it's a private repo that only
authorized persons have access to, this isn't a problem.

> I think this kinda proves that the original design realized that there were 2
> types of settings, but didn't bother to separate them.

Yes, there are two types of settings: private settings and public
settings. And application-specific settings. Three! Three types of
settings: private settings, public settings, and application-specific
settings... and locale-specific settings. Four types of settings!

> My point is to separate them into 2 groups.  This separation would solve more
> than just the "keep secrets secret" problem, but also make it easier to manage
> the settings that are an integral part of the app.

Er... no, it'd make settings more complicated. Right now you configure
Django by putting name/value pairs into a single location: the
settings module. Your settings module is yours and yours alone, and
sharing it with someone you don't trust is a bad idea. Putting project
settings files into publicly-viewable places is, quite frankly, not
something Django ought to be encouraging.

> (db type, name, user, password) are all derived from an external source that 
> is
> going to be different for each installation   So it doesn't make sense for 
> them
> to be rolled into the set of files that is what gets installed.   (where
> "installation" is a copy of the files on a machine for either development,
> testing or production.  Even if multiple developers are working on a single
> production site, each developer will have their own installation.)

If you don't trust your developers to keep a lid on things that ought
to be private, you need to get new developers.

> I'm kinda confused by the resistance.  Do we really need to start presenting
> concrete use cases for combined vs separate?

You need to present a case for why it's so all-fired important for you
to be publicly posting full settings files, because to me that makes
no sense whatsoever; the settings file is not part of a Django-based
deliverable.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: uncommon newforms usage

2007-11-01 Thread Doug B

You might consider a single view and form class, and then doing your
split up in the template using form.field to print the fields you want
for that 'page' by passing the page in with the context.  Leave the
form processing to a single form and view.

Rather than worry with pages I'd probably just use one of the many
javascript tab libraries to break up the form, but then in view treat
as one huge form for the submit.  People without js enabled get the
huge form, but its still usable.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread Carl Karsten

James Bennett wrote:
> On 11/1/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>> View the whole settings file as something you don't just release
>> casually and then only post the bits you feel safe doing so. That is
>> absolutely normal configuration file practice.

The generated settings.py contains things that are perfectly normal "source 
code" like things that should be treated as such.  How does one only commit 
part 
of a file to svn?

I think it is worth pointing out the comment that is put in the generated 
settings.py:
# Make this unique, and don't share it with anybody.
If we go with your view, that should be removed, because there is nothing 
special about SECRET_KEY.

I think this kinda proves that the original design realized that there were 2 
types of settings, but didn't bother to separate them.

> 
> Apologies if I wasn't as clear as I could have been; this is really
> what I was getting at by pointing out that settings files contain,
> well, settings, and lots of them can be sensitive.

My point is to separate them into 2 groups.  This separation would solve more 
than just the "keep secrets secret" problem, but also make it easier to manage 
the settings that are an integral part of the app.

(db type, name, user, password) are all derived from an external source that is 
going to be different for each installation   So it doesn't make sense for them 
to be rolled into the set of files that is what gets installed.   (where 
"installation" is a copy of the files on a machine for either development, 
testing or production.  Even if multiple developers are working on a single 
production site, each developer will have their own installation.)

Support for the local_settings file is there, I just think it should be changed 
from an "If it exists" to assuming it exists, and seed it with the values that 
have been singled out as "secret."

>  Django's debug
> views go to moderate lengths to protect you (by hiding anything with
> "PASSWORD" in its name), but not posting full settings files publicly
> is really the only solution here.
> 

Um, no.  not the _only_ solution.  I hardly call that a solution, it is hardly 
even a workaround.

I'm kinda confused by the resistance.  Do we really need to start presenting 
concrete use cases for combined vs separate?

Carl K




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN: Security fix to i18n framework

2007-11-01 Thread Jason Cui
2007/10/31, Malcolm Tredinnick <[EMAIL PROTECTED]>:
>
>
> On Wed, 2007-10-31 at 13:40 +0800, Jason Cui wrote:
> > 2007/10/31, Malcolm Tredinnick <[EMAIL PROTECTED]>:
> >
> > On Tue, 2007-10-30 at 00:37 -0700, Jason Cui wrote:
> > > When I update my site from 0.96 to 0.96.1,my
> > internationalize function
> > > won't work for firefox, but fine for IE.
> > > I use english in views and templates, and trans it to
> > chinese in po
> > > file, and I have to local folder named en and zh, now, any
> > firefox
> > > users can only see english page, change the language options
> > is
> > > useless, but IE has no problem, show chinese page.
> >
> > Can anybody else confirm this?
> >
> > Malcolm
> > If my firefox's language setting has only zh and zh_cn options, it
> > will show chinese page,
> > when I add en to this setting, it will always show english page, even
> > if I set en as the last one.
>
> I've had some time now to look at this.
>
> It turns out that security bugfix has exposed a different bug in Django.
> It will only show up for the zh-cn, zh-tw and pt-br locales, which is
> why it wasn't noticed during testing prior to the security release.
>
> The workaround for now is to open up django/conf/global_settings.py and,
> in the LANGUAGES list, find the line that says
>
>('zh-cn', gettext_noop('Simplified Chinese')),
>
> and replace it with
>
>('zh_CN', gettext_noop('Simplified Chinese')),
>
> (For completeness, make similar changes to the zh-tw and pt-br lines,
> too. Replace the trailing hyphen and country modifier with an underscore
> and the all-capital-letter version.)
>
> I'm pretty sure this is the right (as in "simplest") fix for this
> problem globally, too. So it'll probably be what we end up landing in
> trunk. I'll talk to the other maintainers about whether we want to
> quickly make new releases or what to do here to mitigate this.
>
> Apologies for the temporary problems this has caused. We try our best,
> but sometimes things fall through the cracks.
>
> Regards,
> Malcolm
>
>
>
Thank you very much for your excellent work.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Query (PS)

2007-11-01 Thread Tim Chase

>> Depending on the checkbox selection it might produce a sql string
>> like:
>> SELECT user_id FROM Bio WHERE (race='A' OR race='W' OR race='H') AND
>> (eye_color='B' OR eye_color='G' OR eye_color='H') AND (hair_color='W'
>> OR hair_color='B')

Though my solution would be logically about the same as this, the
resulting query would look something like

  SELECT * FROM Bio WHERE race IN ('A', 'W', 'H') AND eye_color
IN ('B', 'G', 'H') AND hair_color IN ('W', 'B')

It returns the full records, not just the user_id field, though
you can use the .values() method on a recordset to pull back just
the fields you need/want.  However, it may be helpful to have the
results as full-fledged Bio-model objects.

Just so you're not thrown off by the absence of OR's in my
answer.  This could also be done in a more convoluted fashion
using Q() objects and operator.or_'ing them together, but that's
not quite as elegant.

-tim




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Query

2007-11-01 Thread Tim Chase

> class Bio(models.Model):
> HEIGHT_CHOICES = (
>   ('A',"< 5' (< 152cm)")
[snip]
>   ,('Z',"7' 0'' (213cm)")
>   ,('*',"> 7'' (> 213cm)")
>   )
> WEIGHT_CHOICES = (('A',"<100lbs (<45kg)"),('B',"100lbs (45kg)"),
[snip]
> ('R',">250lbs (>113kg)")
>   )
[snip some more]
> models.CharField(maxlength=1,choices=WEIGHT_CHOICES,blank=True,default='')
> height =
> models.CharField(maxlength=1,choices=HEIGHT_CHOICES,blank=True,default='')
[snip yet more]
> def add_param(request,chk_name,field_name):
> if request.POST.has_key(chk_name):
> ors = []
> for value in request.POST.getlist(chk_name):
> ors.append("%s='%s'" % (field_name,value))
> if len(ors):
> return '(' + join(ors,' OR ') + ')'
> return None
> 
> def profile_search_new(request):
> if request.method == 'POST':
> where = []
> 
> qry = add_param(request,'chk_race','race')
> if qry:
> where.append(qry)
[snip even more]
> if len(where):
> sql = "SELECT user_id FROM Bio WHERE " + join(where,'
> AND ')
> rows = sql_query(sql)
> 
> Depending on the checkbox selection it might produce a sql string
> like:
> SELECT user_id FROM Bio WHERE (race='A' OR race='W' OR race='H') AND
> (eye_color='B' OR eye_color='G' OR eye_color='H') AND (hair_color='W'
> OR hair_color='B')
> 
> I would like to do this in a more 'Django way'

I think what you're looking for would be something like

  results = Bio.objects.all()
  for fieldname, vbl_name in [
  ('race', 'chk_race'),
  ('height', 'chk_height'),
  ('eye_col', 'chk_eye_color'),
  # add other field/chk pairs here
  ]:
if vbl_name in request.POST:
  results = results.filter(**{
fieldname + '__in':
request.POST.getlist(vbl_name)
})
  do_something(results)

You'd have to toy around with it a little to make sure it's doing
what you want, but it basically builds successive filter() calls,
using "__in = []" format calls, and
then uses keyword expansion (the "**{...}" notation) to expand
those into the call.

-tim




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error with Psycopg2: argument of type _QuerySet is not iterable

2007-11-01 Thread [EMAIL PROTECTED]

> > if not assigned_user in 
> > User.objects.filter(groups__name__exact=assigned_group):
> >
> TypeError: argument of type '_QuerySet' is not iterable
>
> Am I doing something obviously wrong?

In case anyone else is experiencing this error, it was happening
because of stupidity on my part. In my example above, assigned_group
was a group object, not a string. I didn't expect the strange
TypeError that I got, but it was my coding error nonetheless.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread James Bennett

On 11/1/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> View the whole settings file as something you don't just release
> casually and then only post the bits you feel safe doing so. That is
> absolutely normal configuration file practice.

Apologies if I wasn't as clear as I could have been; this is really
what I was getting at by pointing out that settings files contain,
well, settings, and lots of them can be sensitive. Django's debug
views go to moderate lengths to protect you (by hiding anything with
"PASSWORD" in its name), but not posting full settings files publicly
is really the only solution here.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Searches Across Many-to-Many with Intermediate Table

2007-11-01 Thread Andy Brody

Awesome! I thought there would to be a way to use .values().distinct()
without tons of subsequent queries.

I actually just posted the core of my model -- there are several more
related classes, but this covers the basic idea. As a result, I might
be back looking for clarification on that keyword method, but I think
I'll see how far I get with what I have for now...

Many thanks,
Andy

On Nov 1, 8:29 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-11-01 at 11:35 -0700, Andy Brody wrote:
> > Ah, thanks for the values() hint. It seems to work decently. I don't
> > really need to access related model fields, I just want a list of
> > unique group objects associated with a given musician's activities.
>
> > The above becomes instead:
>
> > qset = theMusician.activity_set.all().values('group').distinct()
> > # returns list of {'group': id} without duplicates
>
> > grouplist = [Group.objects.get(id=valuesdict['group']) for valuesdict
> > in qset]
>
> If efficiency was a concern, this does a lot of queries (len(qset) of
> them). Instead, try
>
> grouplist = Group.objects.filter(id__in=[(d['group'] for d in
> qset])
>
> which constructs grouplist with only one extra query.
>
> > Or maybe it would be better to leave the duplicates testing in python:
>
> > grouplist = [act.group for act in theMusician.activity_set.all()]
> > group_ids = []
> > for group in grouplist[:]:
> > if group.id in group_ids:
> > grouplist.remove(group)
> > else:
> > group_ids.append(group.id)
>
> > Why doesn't set(grouplist) remove the duplicates, anyway?
>
> Because the instances aren't the same even when the id values are the
> same. get() returns a *new* instance each time.
>
> > Do these both make sense? Would one hit the database less than the
> > other?
>
> My modified solution is probably fastest for what you can do at the
> moment without custom SQL. Two SQL queries and one list comprehension in
> Python.
>
> Regards,
> Malcolm
>
> --
> What if there were no hypothetical questions?http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread Malcolm Tredinnick

On Thu, 2007-11-01 at 19:58 -0500, Carl Karsten wrote:
> James Bennett wrote:
> > On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote:
> >> Given that some settings.py files get shared/posted/uploaded to 
> >> code.google,
> >> etc. it seems this should not be in there by default:
> >>
> >> # Make this unique, and don't share it with anybody.
> >> SECRET_KEY = 'foo!'
> > 
> > By the same token, then, the database settings shouldn't be in the
> > settings file ;)
> > 
> > (same goes for things like API keys, passwords for externally-accessed
> > services...)
> > 
> 
> Yeah, I sense an enhancement...
> 
> When you run django-admin.py startproject mysite a settings.py gets created 
> with 
> lots of stuff.  I am wondering if these should be pulled out:
> 
> SECRET_KEY = 'foo!'
> 
> DATABASE_ENGINE = ''
> DATABASE_NAME = ''
> DATABASE_USER = ''
> DATABASE_PASSWORD = ''
> DATABASE_HOST = ''
> DATABASE_PORT = ''
> 
> and put in local_settings.py or something along these lines.

No. Look, this whole thread is really a non-issue. If you're going to
post your settings file somewhere publically, sanitise it! Otherwise
only post the portions you need to (which is what people normally do).
On your production machines, use normal permissions for access control.

View the whole settings file as something you don't just release
casually and then only post the bits you feel safe doing so. That is
absolutely normal configuration file practice.

Malcolm

-- 
How many of you believe in telekinesis? Raise my hand... 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread Carl Karsten

James Bennett wrote:
> On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote:
>> Given that some settings.py files get shared/posted/uploaded to code.google,
>> etc. it seems this should not be in there by default:
>>
>> # Make this unique, and don't share it with anybody.
>> SECRET_KEY = 'foo!'
> 
> By the same token, then, the database settings shouldn't be in the
> settings file ;)
> 
> (same goes for things like API keys, passwords for externally-accessed
> services...)
> 

Yeah, I sense an enhancement...

When you run django-admin.py startproject mysite a settings.py gets created 
with 
lots of stuff.  I am wondering if these should be pulled out:

SECRET_KEY = 'foo!'

DATABASE_ENGINE = ''
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''

and put in local_settings.py or something along these lines.

# this will attempt to load a file called local_settings.py
# which will override the information here.
try:
 from local_settings import *
except ImportError:
 pass

I am even thinking it might be a good idea to store them in a 
/home/user/.mysite/local_settings.py
or something that uses os.path.expanduser('~')

So that it is kept separate from the stuff that is not 'private.'

I can't really see a need to keep it version controlled, and hardly a point in 
other developers working on a project needing it to get automatically updated. 
(I can imagine a rare case, but I think the normal danger trump that 
convenience.)  I do pull a copy to a fresh box for testing, and it will be a 
slight bother to have to manually move those settings around.  but 1/2 the time 
I end up setting up a test DB/user anyway.  I sure don't need to keep copies of 
passwords archived.

So before I go hacking up a patch, any comments ?

Carl K


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Searches Across Many-to-Many with Intermediate Table

2007-11-01 Thread Malcolm Tredinnick

On Thu, 2007-11-01 at 11:35 -0700, Andy Brody wrote:
> Ah, thanks for the values() hint. It seems to work decently. I don't
> really need to access related model fields, I just want a list of
> unique group objects associated with a given musician's activities.
> 
> The above becomes instead:
> 
> qset = theMusician.activity_set.all().values('group').distinct()
> # returns list of {'group': id} without duplicates
> 
> grouplist = [Group.objects.get(id=valuesdict['group']) for valuesdict
> in qset]

If efficiency was a concern, this does a lot of queries (len(qset) of
them). Instead, try

grouplist = Group.objects.filter(id__in=[(d['group'] for d in
qset])

which constructs grouplist with only one extra query.

> Or maybe it would be better to leave the duplicates testing in python:
> 
> grouplist = [act.group for act in theMusician.activity_set.all()]
> group_ids = []
> for group in grouplist[:]:
> if group.id in group_ids:
> grouplist.remove(group)
> else:
> group_ids.append(group.id)
> 
> Why doesn't set(grouplist) remove the duplicates, anyway?

Because the instances aren't the same even when the id values are the
same. get() returns a *new* instance each time.

> Do these both make sense? Would one hit the database less than the
> other?

My modified solution is probably fastest for what you can do at the
moment without custom SQL. Two SQL queries and one list comprehension in
Python.

Regards,
Malcolm


-- 
What if there were no hypothetical questions? 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Dynamic Query

2007-11-01 Thread weissblitz

I'm developing my first Django website where the users should be able
to search other user profiles based on certain paramaters like race,
age, gender, height, weight, eye color, hair color, etc

This is how my model looks:  (code have been shortened to only include
the pertinent sections)

class Bio(models.Model):
HEIGHT_CHOICES = (
  ('A',"< 5' (< 152cm)")
  ,('B',"5' 0'' (152cm)")
  ,('C',"5' 1'' (155cm)")
  ,('D',"5' 2'' (157cm)")
  ,('E',"5' 3'' (160cm)")
  ,('F',"5' 4'' (163cm)")
  ,('G',"5' 5'' (165cm)")
  ,('H',"5' 6'' (168cm)")
  ,('I',"5' 7'' (170cm)")
  ,('J',"5' 8'' (173cm)")
  ,('K',"5' 9'' (175cm)")
  ,('L',"5' 10'' (178cm)")
  ,('M',"5' 11'' (180cm)")
  ,('N',"6' 0'' (183cm)")
  ,('O',"6' 1'' (185cm)")
  ,('P',"6' 2'' (188cm)")
  ,('Q',"6' 3'' (191cm)")
  ,('R',"6' 4'' (193cm)")
  ,('S',"6' 5'' (196cm)")
  ,('T',"6' 6'' (198cm)")
  ,('U',"6' 7'' (201cm)")
  ,('V',"6' 8'' (203cm)")
  ,('W',"6' 9'' (206cm)")
  ,('X',"6' 10'' (208cm)")
  ,('Y',"6' 11'' (211cm)")
  ,('Z',"7' 0'' (213cm)")
  ,('*',"> 7'' (> 213cm)")
  )
WEIGHT_CHOICES = (('A',"<100lbs (<45kg)"),('B',"100lbs (45kg)"),
('C',"110lbs (50kg)"),('D',"120lbs (54kg)"),('E',"130lbs (59kg)"),
('F',"140lbs (64kg)"),('G',"150lbs (68kg)"),('H',"160lbs (73kg)"),
('I',"170lbs (77kg)"),('J',"180lbs (82kg)"),('K',"190lbs (86kg)"),
('L',"200lbs (91kg)"),('M',"210lbs (95kg)"),('N',"220lbs (100kg)"),
('O',"230lbs (104kg)"),('P',"240lbs (109kg)"),('Q',"250lbs (113kg)"),
('R',">250lbs (>113kg)")
  )
RACE_CHOICES = (('A','Asian'),('B','Black'),('W','Caucasian or
White'),('H','Hispanic'),('E','Middle Eastener'),('M','Mixed'),
('I','Native American'),('O','Other'))
EYE_COLOR_CHOICES = (('L','Black'),('W','Brown'),('B','Blue'),
('G','Green'),('H','Hazel'))
HAIR_COLOR_CHOICES = (('L','Black'),('W','Brown'),('C','Balding'),
('G','Gray'),('B','Blond'))

user = models.ForeignKey(User)
race =
models.CharField(maxlength=1,choices=RACE_CHOICES,blank=True,default='')
weight =
models.CharField(maxlength=1,choices=WEIGHT_CHOICES,blank=True,default='')
height =
models.CharField(maxlength=1,choices=HEIGHT_CHOICES,blank=True,default='')
eye_color =
models.CharField(maxlength=1,choices=EYE_COLOR_CHOICES,blank=True,default='')
hair_color =
models.CharField(maxlength=1,choices=HAIR_COLOR_CHOICES,blank=True,default='')

In my html form I have checkboxes for each of the field options, like:

Black
Brown
Blue
Green
Hazel

The following view code collects the checkbox values and creates a
dynamic sql string:

def add_param(request,chk_name,field_name):
if request.POST.has_key(chk_name):
ors = []
for value in request.POST.getlist(chk_name):
ors.append("%s='%s'" % (field_name,value))
if len(ors):
return '(' + join(ors,' OR ') + ')'
return None

def profile_search_new(request):
if request.method == 'POST':
where = []

qry = add_param(request,'chk_race','race')
if qry:
where.append(qry)

qry = add_param(request,'chk_eye_color','eye_color')
if qry:
where.append(qry)

qry = add_param(request,'chk_weight','weight')
if qry:
where.append(qry)

qry = add_param(request,'chk_height','height')
if qry:
where.append(qry)

qry = add_param(request,'chk_hair_color','hair_color')
if qry:
where.append(qry)

if len(where):
sql = "SELECT user_id FROM Bio WHERE " + join(where,'
AND ')
rows = sql_query(sql)

Depending on the checkbox selection it might produce a sql string
like:
SELECT user_id FROM Bio WHERE (race='A' OR race='W' OR race='H') AND
(eye_color='B' OR eye_color='G' OR eye_color='H') AND (hair_color='W'
OR hair_color='B')

I would like to do this in a more 'Django way' without having to
resort to executing a direct sql string query.
I'm not sure how to build this 'filter' or if I should be using 'Q'
objects.

Hope the above code conveys my intention, let me know if I need to be
more specific.

Any advice is greatly appreciated!
Karl ;)


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

Re: Set attributes to input using newforms

2007-11-01 Thread Malcolm Tredinnick

On Thu, 2007-11-01 at 19:08 +, Henhiskan wrote:
> Hi fellows,
> Am using django-0.96 and I need to set an input html attribute from a
> newforms
> I need to use a time picker from dojo, for that I need to have
> something like this:
>  dojoType="dropdowntimepicker">
> 
> The only solution I can think of is to process the form.as_table()
> string and put the snip of code that I need, just before to sent to
> the browser.
> 
> By the way, where I can find some documentation of widgets for django
> 0.96?

Read the current documentation and just note any places where it says
"New in Django development version" -- they won't be available in 0.96.
The reason we add that note is so that the documentation at
www.djangoproject.com/documentation/ is relevant to all versions (well,
mostly the last released version + subversion). On rare occasions,
you'll need to specifically click through to the 0.96 docs, but we try
to keep the current stuff relevant to the last release so that everybody
can benefit from the updates.

Regards,
Malcolm

-- 
Despite the cost of living, have you noticed how popular it remains? 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and XML-Files

2007-11-01 Thread Malcolm Tredinnick

On Thu, 2007-11-01 at 09:56 -0700, johannes wrote:
> Hello,
> 
> I'm planning to alter an existing hobby-project-site from php and xml/
> xslt scripts into a python web-app.
> I just played around a little bit with django and must say I like it.
> First, having learned php, xslt and python by myself, I must say I'm
> definitely not a professional.
> My existing website is a kind of database, but without a database :-).
> Everything's stored in plain xml files. I have coded these xml-Files
> myself and then written some php/xslt scripts which transform them to
> html and display them in a browser.
> Now, I want to implement a basic authentication dialogue, where people
> can create an account log in and fill out forms which output xml-files
> which are later on (after I reviewed them) accessible via the
> webbrowser as the ones I have already written. This is what I like to
> do with python and django. After this I plan to transfer the existing
> php stuff to python/django.
> As I'm new django and still wondering if this is the right thing for
> what I want to do:
> Is this possible with django? And how do I do this?

You won't be using all of Django in this case. The ORM layer -- all the
models stuff -- won't be of any use to you, since that uses a database.

So, in your views, read and write your XML files just as you would
normally (using, say, Python's standard XML libraries). You will have to
write your own authentication layer and session management, though,
since they, again, depend on Django's ORM.

Regards,
Malcolm

-- 
Works better when plugged in. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



uncommon newforms usage

2007-11-01 Thread Milan Andric

Hi,

I'm working on an a little newforms problem and can surely use some
advice.

I have an application process that is broken up into several forms.
So I have one Application model class and several AppFormParts 1-8.
Since the application process is so painfully long we decided to break
it up into parts (smaller forms).  We also allow people to create an
application and continue it/update it later.

The only common field among all the AppFormParts is the workshops
field. It is hidden field on all the AppForms except the first, where
it gets set for the rest of the process.

Here are the components rough sketch:

"""
Forms
"""
class AppForm(forms.Form):

workshops = forms.MultipleChoiceField(
widget = widgets.CheckboxSelectMultiple(),
choices = [ (w.id,w) for w in
Workshop.objects.get_not_past_deadline() ],
help_text = 'Apply for any or all of the workshops by checking
the boxes. We encourage people to check all workshops to increase
their chances of being accepted into one of them.',
)

def save(self):
# save an application for each workshop
workshops = self.cleaned_data['workshops']
# remove these so we can loop through all fields
del(self.cleaned_data['workshops'])
del(self.cleaned_data['workshop'])
for w in workshops:
try:
# look for existing app
app = Application.objects.get(
  #needs a workshop object
  workshop=Workshop.objects.get(pk=w),
  #needs a user object
  user=self.cleaned_data['user'],
  )
except Application.DoesNotExist, Workshop.DoesNotExist:
# start new app
app = Application(
workshop=Workshop.objects.get(pk=w),
user=self.cleaned_data['user']
  )
# loop through all keys from the form and map to object
for key,val in self.cleaned_data:
if hasattr(app,key):
setattr(app,key,val)
obj.save()

class AppFormPart1(AppForm):

"""
Personal information section of the application.
This is the minimum requirement for an application to exist.
Field names correspond to Application model.
"""

title = forms.CharField(
)
organization = forms.CharField(
)
email_2 = forms.CharField(
)
phone = forms.CharField(
max_length=12,
)
[snip]

class AppFormPart2(AppForm):

def __init__(self):
self.workshops.widget = widgets.MultipleHiddenInput()

   . more fields

"""
view
"""

@login_required
def app_create_update(request, part=1):
from myproject.workshops import forms as myforms

next_part= part+ 1

if request.method == 'POST':

new_data = request.POST.copy()

# get form dynamically according to part param
Form = getattr(myforms,'AppFormPart%s' % part)
form = Form(new_data)

if form.is_valid():
form.cleaned_data['user'] = request.user
form.save()
# form validates, set the response message
request.user.message_set.create(
message=Application.USER_MSGS['saved'],
)
# redirect to next part
return HttpResponseRedirect( '/training/apply/%s/' %
next_part)
 else :
   [snip]

Please let me know if there's a better way to go about this.  Or where
the major problems lie.

Thanks,

--
Milan


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread James Bennett

On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
> Given that some settings.py files get shared/posted/uploaded to code.google,
> etc. it seems this should not be in there by default:
>
> # Make this unique, and don't share it with anybody.
> SECRET_KEY = 'foo!'

By the same token, then, the database settings shouldn't be in the
settings file ;)

(same goes for things like API keys, passwords for externally-accessed
services...)

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Searches Across Many-to-Many with Intermediate Table

2007-11-01 Thread Scott SA

Hi Andy,

On 10/31/07, Andy Brody ([EMAIL PROTECTED]) wrote:

>I'm using an intermediate table of Activities to relate Musicians,
>Instruments, and Groups. Is there a good way to select groups from the
>musician's activities? I've been doing stuff like [act.group for act
>in theMusician.activity_set.all()]. This works pretty well, except
>that there are duplicates if a musician plays more than one instrument
>in a group, and merely doing set( the_above ) doesn't get rid of them
>even though group1==group2 evaluates to True.
>
>Is there some better way to do this? It seems strange to be trying to
>remove the duplicates at this level rather than at the SQL level with
>a distinct(). The resulting SQL (which I don't want to write myself)
>should be something like:
>
>SELECT DISTINCT *
>FROM `app_group`
>WHERE `id`
>IN (
>
>SELECT `group_id`
>FROM `app_activity`
>WHERE `musician_id` = 1

Interesting, you're trying to solve a similar problem I've been working on for 
a while (not because its that difficult, but lack of time for that project).

The differences between our tasks are based upon a couple of more layers. Not 
only am I tracking musicians, instruments and activities but also events, 
stages, band-instances and such (I'm a photographer and manage other photogs, 
and photos, at larger events like festivals... where musicians and band 
compositions change on an hourly basis it seems).

I abandoned trying to make this a beautifully relational stage::band::musician 
structure for a significantly simpler heriarchical, keyword-based architecture. 
I put some of the logic into the heirarcy to solve problems like bands named 
after musicians via parent/child relationships. It is still an M2M design, but 
it is no longer bound by static relationships.

This also solved other problems I was trying to work-out, which included 
ratings, sub-activities/subjects as well as parallel attributes i.e. something 
applicable to multiple categorizations i.e. musicians that play in multiple 
bands over time.

Finally, and the best part, I can add or change new attributes via keywords 
without having to re-configure the architecture. 8^)

In my models, I have my Assets (images) and my Keywords (self-referential for 
heirarchy) and there is a M2M relationship between them. The heirarcy is 
essential i.e. the keyword musician is parent to all musicians. So if I don't 
care _which_ musician is playing a Djembe, or I want images of a Djembe and a 
Bagpipe (yes, I've seen it), I _can_ do that easily.

Anyway, I thought I'd pass on the thought of attacking the problem from a 
different viewpoint that may be more flexible over time. I probably didn't 
describe the solution I'm using well, but hopefuly some of it makes sense.

Of course, there are other solutions to this problem I just happen to like this 
because it is pretty simple (for me anyways).

Scott

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MS SQL and Django - Any current info?

2007-11-01 Thread Carl Karsten

Peter Bailey wrote:
> Can anyone tell me if there is any current news about MS SQL support?
> I am looking at frameworks for a client, and my preference is really
> to go the Django route. The plan will be to migrate over time from an
> asp environment with an MS SQL back end. So basically I am stuck
> having to use MS SQL for a while, and no support for it in Django will
> unfortunately be a show stopper. We will eventually migrate the
> databases to an Open Source alternative, but that is not an option at
> the start.
> 
> I have successfully connected to MS SQL via TurboGears and Elixir/
> SQLAlchemy, so I know it is possible via python, and I realize that
> most people here are not that interested in dealing with MS software.
> I have also looked at the latest tickets, but they really don't say
> anything definitive, although there appears to be some work being done
> on it.
> 
> I know this is an Open Source project, so it is hard to put schedules
> and dates to specific things, but if anyone can give me a realistic
> guess at when this support will be included (assuming it will be), I
> would greatly appreciate it.
> 

I am actually pretty sure it is actively supported, but given that support can 
come and go, here is how I can reassure you that it isn't a big mistake.

I have worked with MS SQL using both http://www.freetds.org based pymssql and 
odbc based cdODBC.  I have not worked with adodbapi which is what django uses, 
but given what I know about the things I have worked with, it A) can be done 
and 
B) probably has been done and C) I can do it if it hasn't.

So my advice is run though the django tutorial using ado_mssql.  If you run 
into 
problems, post here.  If you don't get any response after a day or 2, forward 
it 
to me (above address) and I'll help you get through it.

Carl K

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread Carl Karsten

Todd O'Bryan wrote:
> I then point to production_settings as my DJANGO_SETTINGS_MODULE for
> mod_python and the production settings overwrite the settings that I
> use for production.
> 
> Of course, the last word should be "development," not "production."

Good idea.

What's funny is I do something similar for my db settings, but not for 
security, 
but to let one code base be used by 2 db's.  not sure if they are checked in or 
not.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: djangoAMF authentication, requests aren't carrying user credential

2007-11-01 Thread Graham Dumpleton



On Oct 30, 9:22 pm, "Tiger Uppercut" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I wasn't sure whether this was a djangoAMF issue or django, so apologies for
> the double posting.
>
> I'm having trouble using djangoAMF to communicate between my flex UI and my
> django site, django_wrapper.
>
> - My django_wrapper is served at /main by mod_wsgi.
>
> * The django code base is in /usr/local/deploy/django_wrapper
> * The wsgi script is in
> /usr/local/deploy/django_wrapper/apache/django_wrapper.wsgi [as noted 
> onhttp://code.google.com/p/modwsgi/wiki/IntegrationWithDjango]
>
> - My flex site is served at /main/flex by django.  The swf is stored at
> /var/www/mysite.com/static/myflex.swf
>
> - My djangoAMF gateway is set up at /main/gateway
>
> == urls.py ==
>
>  (r'^main/gateway/authService/authenticateVisitor',
>
> > 'django_wrapper.views.authAndLoginVisitor'),
> >  (r'^main/gateway/calcService/calcSum',
> > 'django_wrapper.views.calculate'),
>
> == views.py ==
>
> def authAndLoginVisitor(request,this_email,raw_password):
>
>
>
> > if request.user.is_authenticated() == True:
> > return "Already authenticated!"
>
> > this_user = auth.authenticate (email=this_email,
> > password=raw_password) # modified from django.contrib.auth to use
> > EmailBackend
> > if this_user is None: # could not find the
> > user
>
> > return False
> > else: # did find the user, now let's log him
> > in
>
> > auth.login(request,this_user)
> > return True
>
> > def calculate(request,arg1,arg2):
> > if request.user is not None:
> > print "In calculate, request.user is not none, it is = " + str(
> > request.user)
> > if request.user.is_authenticated() == True:
> > return arg1 + arg2
> > else:
> > return "Not authenticated!"
>
> The calculate function is called by the flex wrapper after
> authAndLoginVisitor is successfully called.
>
> == mysite.mxml ==
>
> var gatewayUrl:String = "https://www.mysite.com/main/gateway/";;
>
>
>
> > var serviceName:String = "calcService";
> > var serviceFactory:ServiceFactory = ServiceFactory.getInstance
> > (gatewayUrl);
> > var service:RemotingService = serviceFactory.getService(serviceName);
>
> > var pc:PendingCall = service.calcSum(2, 3);
> > pc.responder = new Responder(handleResult, handleError);
>
> However, the calculate function keeps thinking that the request is issued by
> an anonymous user.
>
> I added debugging code to the login() method of  auth/__init__.py
>
> [Tue Oct 30 01:32:31 2007] [error] User status just set
> [Tue Oct 30 01:32:31 2007] [error] request.session[_auth_user_id] = 11
> [Tue Oct 30 01:32:31 2007] [error] request.session[_auth_user_backend] =
> django_wrapper.backends.EmailBackend
> [Tue Oct 30 01:32:31 2007] [error] Set request.user = testuser
>
> So the request.user is set once login is called.  When I look in my
> auth_user table in the database, testuser's last_login is correctly set, as
> well.
>
> However, now fast forward to the calculate call.  Recall that I have a flex
> UI, so the actual URL in the browser windo.mysite.com/main/flexappears
> the same.
>
> When I call this function calculate request.user shows up as anonymous:
> [Tue Oct 30 02:52:36 2007] [error] In calculate, request.user is not none,
> it is = AnonymousUser
> [Tue Oct 30 02:57:33 2007] [error]  [Tue Oct 30 02:57:33 2007] [error] GET:,
> [Tue Oct 30 02:57:33 2007] [error] POST: {u'\\x00\\x03\\x00\\x00\\x00\\x01\\x00\\x13calcService.calcSum\\x00\\x02/[EMAIL
>  PROTECTED]@\\x08\\x00\\x00\\x00\\x00\\x00\\x00':
> [u'']}>,
> [Tue Oct 30 02:57:33 2007] [error] COOKIES:{'sessionid':
> 'c9726aabf90079d7cb9bbf549b6fc8c4'},
> ...
> [Tue Oct 30 02:57:33 2007] [error]  'HTTP_COOKIE':
> 'sessionid=c9726aabf90079d7cb9bbf549b6fc8c4',
>
> Any ideas why the request keeps showing up without the user credentials set
> in the login method earlier?
>
> Note that, if I apply a decorator, login_required, to calcService, and login
> through the standard django html form, the request has my correct
> credentials.  It's just when I try to do it "by hand", I'm running into this
> problem.

Is the login mechanism relying on web application form based
submission, or relying on web server HTTP Basic authentication. If the
latter, you must enable the directive:

  WSGIPassAuthorization On

in Apache configuration for mod_wsgi, else the HTTP Basic auth
information isn't passed through to a WSGI application.

Graham


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New Forms Foreign key field Filtered choices

2007-11-01 Thread rm

Sorry, I made a slight mistake above.  I was just trying different
things.  When using the code I posted above, the view is not displayed
and I get an error saying:

'Contact' object has no attribute 'name'

But, when I use this code,

def away_edit(request, away_id):
aw = get_object_or_404(away, id=away_id)
aw_form = forms.form_for_instance(aw)
aw_form.base_fields['contact']=forms.ChoiceField(choices=[(obj.id,
obj) for obj in  Contact.objects.filter(is_staff=True)])

The form displays correctly and it actually does filter out the
choices as I want.  But, when I submit the form I get an error telling
me that "away_away.contact may not be NULL".   I am a lost.  Thanks
for any help you can give.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



New Forms Foreign key field Filtered choices

2007-11-01 Thread rm

I know this is a painful subject.  I have spent a couple of days
trying to figure this out, and I am almost there. (I think. :)

Here is the model (simplified to bare bones):

class away(models.Model):
contact = models.ForeignKey(Contact, verbose_name="Name of person
away", limit_choices_to= {'is_staff':True}, db_column='contact')

As you can see Contact is another model being referenced here which
has a field named "is_staff" that I want to use to filter out some
contacts so that they do not display as options in my form to add or
edit away instances. Unfortunately, the filter seems to only affect
the way the field is displayed in the admin forms, not on regular
forms.

This is how the start of my view to edit away instances looks like:

def away_edit(request, away_id):
aw = get_object_or_404(away, id=away_id)
aw_form = forms.form_for_instance(aw)

When displaying that form the 'contact' field displays as a dropdown
list, but it includes the choices I wanted filtered out.  So, after a
lot of searching, I found this post which seems to be addressing the
same issue:

http://groups.google.com/group/django-users/browse_thread/thread/cbbf169b6aaa3f39/3f08ba5b59feea3d?lnk=gst&q=form_for_model+foreign+key+filter#3f08ba5b59feea3d

However, I can't make it work.  This is how I have translated the
advice to my view:

def away_edit(request, away_id):
aw = get_object_or_404(away, id=away_id)
aw_form = forms.form_for_instance(aw)
aw_form.base_fields['contact']=forms.ChoiceField(choices=[(obj.id,
obj.name) for obj in  Contact.objects.filter(is_staff=True)])

When I do that, the form displays correctly and it actually does
filter out the choices as I want.  But, when I submit the form I get
an error telling me that "away_away.contact may not be NULL".

Can someone please explain to me why it gives me that error?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread Todd O'Bryan

I then point to production_settings as my DJANGO_SETTINGS_MODULE for
mod_python and the production settings overwrite the settings that I
use for production.

Of course, the last word should be "development," not "production."

Todd

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: keeping SECRET_KEY secret

2007-11-01 Thread Todd O'Bryan

I actually have a production_settings.py file that only exists on my
server, is not part of version control, and is only readable by the
Apache user.

It consists of:

from settings import *

DEBUG = False

DATABASE_NAME = blah
DATABASE_USER = blah
DATABASE_PASSWORD = blah
SECRET_KEY = blah

where the latter two are constructed using a random password generator
and, in my case, are 20 and 50 characters each.

I then point to production_settings as my DJANGO_SETTINGS_MODULE for
mod_python and the production settings overwrite the settings that I
use for production.

Todd

On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
> Given that some settings.py files get shared/posted/uploaded to code.google,
> etc. it seems this should not be in there by default:
>
> # Make this unique, and don't share it with anybody.
> SECRET_KEY = 'foo!'
>
> I am sure there are already a dozen or so good solutions to this problem, 
> plus mine:
>
> SECRET_KEY_file_name = os.path.expanduser('~/.secret')
> try:
>  SECRET_KEY_file = open(SECRET_KEY_file_name,'r')
>  SECRET_KEY = SECRET_KEY_file.read().strip()
> except IOError:
>  # if the file doesn't exist, gen a key and save it to the file.
>  from random import choice
>  SECRET_KEY_file = open(SECRET_KEY_file_name,'w')
>  SECRET_KEY =
> ''.join([choice('[EMAIL PROTECTED]&*(-_=+)') for i in
> range(50)])
>  SECRET_KEY_file.write( SECRET_KEY )
> finally:
>  SECRET_KEY_file.close()
>
> let the code war begin.
>
> Carl K
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



keeping SECRET_KEY secret

2007-11-01 Thread Carl Karsten

Given that some settings.py files get shared/posted/uploaded to code.google, 
etc. it seems this should not be in there by default:

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'foo!'

I am sure there are already a dozen or so good solutions to this problem, plus 
mine:

SECRET_KEY_file_name = os.path.expanduser('~/.secret')
try:
 SECRET_KEY_file = open(SECRET_KEY_file_name,'r')
 SECRET_KEY = SECRET_KEY_file.read().strip()
except IOError:
 # if the file doesn't exist, gen a key and save it to the file.
 from random import choice
 SECRET_KEY_file = open(SECRET_KEY_file_name,'w')
 SECRET_KEY = 
''.join([choice('[EMAIL PROTECTED]&*(-_=+)') for i in 
range(50)])
 SECRET_KEY_file.write( SECRET_KEY )
finally:
 SECRET_KEY_file.close()

let the code war begin.

Carl K

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Set attributes to input using newforms

2007-11-01 Thread Henhiskan

There is no widget docs for v0.96 documentation, but I just read the
doc of current dojo version, and find the solution to my problem,
just:

discovered_time =
forms.TimeField(widget=forms.TextInput(attrs={'dojoType':'dropdowntimepicker'}))

Cheers.-


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Set attributes to input using newforms

2007-11-01 Thread Henhiskan

Hi fellows,
Am using django-0.96 and I need to set an input html attribute from a
newforms
I need to use a time picker from dojo, for that I need to have
something like this:


The only solution I can think of is to process the form.as_table()
string and put the snip of code that I need, just before to sent to
the browser.

By the way, where I can find some documentation of widgets for django
0.96?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Searches Across Many-to-Many with Intermediate Table

2007-11-01 Thread Andy Brody

Ah, thanks for the values() hint. It seems to work decently. I don't
really need to access related model fields, I just want a list of
unique group objects associated with a given musician's activities.

The above becomes instead:

qset = theMusician.activity_set.all().values('group').distinct()
# returns list of {'group': id} without duplicates

grouplist = [Group.objects.get(id=valuesdict['group']) for valuesdict
in qset]


Or maybe it would be better to leave the duplicates testing in python:

grouplist = [act.group for act in theMusician.activity_set.all()]
group_ids = []
for group in grouplist[:]:
if group.id in group_ids:
grouplist.remove(group)
else:
group_ids.append(group.id)

Why doesn't set(grouplist) remove the duplicates, anyway?

Do these both make sense? Would one hit the database less than the
other?

Thanks again,
Andy

On Oct 31, 11:01 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-10-31 at 16:46 -0700, Andy Brody wrote:
> > Hi all,
>
> > I'm using an intermediate table of Activities to relate Musicians,
> > Instruments, and Groups. Is there a good way to select groups from the
> > musician's activities? I've been doing stuff like [act.group for act
> > in theMusician.activity_set.all()]. This works pretty well, except
> > that there are duplicates if a musician plays more than one instrument
> > in a group, and merely doing set( the_above ) doesn't get rid of them
> > even though group1==group2 evaluates to True.
>
> > Is there some better way to do this? It seems strange to be trying to
> > remove the duplicates at this level rather than at the SQL level with
> > a distinct(). The resulting SQL (which I don't want to write myself)
>
> Well, there's the first problem. If Django's ORM can't do something --
> we aren't trying to completely replicate SQL, after all, so there will
> always be some cases that can't be done in Python -- then writing custom
> SQL is not just possible, it's recommended.
>
> > should be something like:
>
> > SELECT DISTINCT *
> > FROM `app_group`
> > WHERE `id`
> > IN (
>
> > SELECT `group_id`
> > FROM `app_activity`
> > WHERE `musician_id` = 1
> > )
>
> Ideally, you want to be able to write something
> involving .values(...).distinct(). Unfortunately, referencing related
> model fields via values() isn't possible yet. It will be possible when
> the queryset-refactor work is completed (this is ticket #5768).
>
> Regards,
> Malcolm
>
> --
> The early bird may get the worm, but the second mouse gets the 
> cheese.http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Goutham D L
Solved:)

Really stupid mistake. I was using backslashes when i should have been using
forward slashes.(Iam on windows btw).
Thanks a lot for ur help.

Goutham

On 11/1/07, dunia <[EMAIL PROTECTED]> wrote:
>
>
> Goutham DL wrote:
> > Can some one please help me out here?
> >
> > On Nov 1, 7:03 pm, Goutham DL <[EMAIL PROTECTED]> wrote:
> >
> >> hi,
> >> Its still not working. Iam actually using django 0.96.The code that
> >> antoni gave is giving errors.
> >> Can someone please explain why i need to configure media_urls ?
> >> (media_root has been configured to the appropriate directory). I just
> >> want to link the css file with the html one.how will using
> >> django.views.static.serve help??
> >>
> >> On Nov 1, 3:26 pm, Gonzalo Delgado <[EMAIL PROTECTED]>
> >> wrote:
> >>
> >>
> >>> El Thu, 01 Nov 2007 10:13:13 -
> >>> Goutham DL <[EMAIL PROTECTED]> escribió:
> >>>
>  Hi,
> 
>  Iam new to django. Iam having problems loading css files (and images)
>  using the development server. Is it possible to load css files in the
>  development server or should i use mod_python?
>  (since iam a newbie to mod_python also i prefer using the development
>  server for sometime)
> 
>  Goutham
> 
> >>> http://www.djangoproject.com/documentation/0.96/static_files/
> >>>
> >>> --
> >>> Gonzalo Delgado <[EMAIL PROTECTED]>
> >>>
> >>>  application_pgp-signature_part
> >>> 1KDownload
> >>>
> >
> >
> > >
> >
> >
> in the file urls.py, put this:
>
> from django.conf import settings
> ...
> if settings.DEBUG:
> urlpatterns += patterns('', (r'^media/(?P.*)$',
> 'django.views.static.serve', {'document_root': '',
> 'show_indexes': True}),
> )
> now in your browser you can go to http://localhost:8000/media, and
> you'll see all the files that are under the path you specified above.
>
> in your templates, you can use it like this for ex.:
> 
> 
>
> i hope it helps, this works fine for me.
>
> ps: forgive me for my bad english ;)
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MS SQL and Django - Any current info?

2007-11-01 Thread Peter Bailey

Can anyone tell me if there is any current news about MS SQL support?
I am looking at frameworks for a client, and my preference is really
to go the Django route. The plan will be to migrate over time from an
asp environment with an MS SQL back end. So basically I am stuck
having to use MS SQL for a while, and no support for it in Django will
unfortunately be a show stopper. We will eventually migrate the
databases to an Open Source alternative, but that is not an option at
the start.

I have successfully connected to MS SQL via TurboGears and Elixir/
SQLAlchemy, so I know it is possible via python, and I realize that
most people here are not that interested in dealing with MS software.
I have also looked at the latest tickets, but they really don't say
anything definitive, although there appears to be some work being done
on it.

I know this is an Open Source project, so it is hard to put schedules
and dates to specific things, but if anyone can give me a realistic
guess at when this support will be included (assuming it will be), I
would greatly appreciate it.

Thanks,

Peter


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Search MySQL Full-Text

2007-11-01 Thread jacoberg2

Well i realized after i posted this that i am actually using
postgresql and not Mysql. So i am wondering if there is a way to
do boolean searches in the same manner as described at the
end of th article.



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django and XML-Files

2007-11-01 Thread johannes

Hello,

I'm planning to alter an existing hobby-project-site from php and xml/
xslt scripts into a python web-app.
I just played around a little bit with django and must say I like it.
First, having learned php, xslt and python by myself, I must say I'm
definitely not a professional.
My existing website is a kind of database, but without a database :-).
Everything's stored in plain xml files. I have coded these xml-Files
myself and then written some php/xslt scripts which transform them to
html and display them in a browser.
Now, I want to implement a basic authentication dialogue, where people
can create an account log in and fill out forms which output xml-files
which are later on (after I reviewed them) accessible via the
webbrowser as the ones I have already written. This is what I like to
do with python and django. After this I plan to transfer the existing
php stuff to python/django.
As I'm new django and still wondering if this is the right thing for
what I want to do:
Is this possible with django? And how do I do this?

I'm not asking for ready made solutions, sure, but maybe someone could
give me some advice where such things are described (exist any
tutorials for this?) or puts me on the right track where to look.

Thanks in advance,
johannes


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching querysets

2007-11-01 Thread Jeremy Dunck

On 11/1/07, Joe <[EMAIL PROTECTED]> wrote:
> Correct me if I'm wrong, but wouldn't this place more load on the
> server to to this, as an anonymous user visiting the site for the
> first time would start a new session, and therefore bypass the cache?


Sessions aren't created unless you modify a value in the session.  If
you don't do that for anonymous users, there's no problem.

> My main question is this: If I changed the templates so there was only
> two versions (one for authenticated users that said log out, and one
> for anonymous users that said log in), how could I get the cache
> middleware to vary on request.user.is_authenticated, and NOT the value
> of
> the cookie header?

Well, you can do internal caching that varies like that, but HTTP
downstream caching's Vary header can't do that.  If you want to get
fancy, you could issue a different ETag for the two flavors.

But it sounds like you want to look at the low-level cache API in any case.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread dunia

Goutham DL wrote:
> Can some one please help me out here?
>
> On Nov 1, 7:03 pm, Goutham DL <[EMAIL PROTECTED]> wrote:
>   
>> hi,
>> Its still not working. Iam actually using django 0.96.The code that
>> antoni gave is giving errors.
>> Can someone please explain why i need to configure media_urls ?
>> (media_root has been configured to the appropriate directory). I just
>> want to link the css file with the html one.how will using
>> django.views.static.serve help??
>>
>> On Nov 1, 3:26 pm, Gonzalo Delgado <[EMAIL PROTECTED]>
>> wrote:
>>
>> 
>>> El Thu, 01 Nov 2007 10:13:13 -
>>> Goutham DL <[EMAIL PROTECTED]> escribió:
>>>   
 Hi,
 
 Iam new to django. Iam having problems loading css files (and images)
 using the development server. Is it possible to load css files in the
 development server or should i use mod_python?
 (since iam a newbie to mod_python also i prefer using the development
 server for sometime)
 
 Goutham
 
>>> http://www.djangoproject.com/documentation/0.96/static_files/
>>>   
>>> --
>>> Gonzalo Delgado <[EMAIL PROTECTED]>
>>>   
>>>  application_pgp-signature_part
>>> 1KDownload
>>>   
>
>
> >
>
>   
in the file urls.py, put this:

from django.conf import settings
...
if settings.DEBUG:
urlpatterns += patterns('', (r'^media/(?P.*)$', 
'django.views.static.serve', {'document_root': '', 
'show_indexes': True}),
)
now in your browser you can go to http://localhost:8000/media, and 
you'll see all the files that are under the path you specified above.

in your templates, you can use it like this for ex.:



i hope it helps, this works fine for me.

ps: forgive me for my bad english ;)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Antoni Aloy

The port is 8000 for Django, but I'll suppose is a typo.

Please check:

MEDIA_ROOT it should be your media folder and it must finist with /
MEDIA_URL = 'http://localhost:8000/media/

on urls.py

...
from django.con import settings
...

if settings.DEBUG:
urlpatterns += patterns('',
   (r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root':'./media/'}),
)


-- 
Antoni Aloy López
Binissalem - Mallorca
http://www.trespams.com
Soci de Bulma - http://www.bulma.cat

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Goutham D L
hi
Actually i did exactly what u have done in the trunk version. Let me be more
explicit.

I have a login.html file in which i have a link to login.css.
login.html is in templates directory
login.css is in media/css directory
both media and templates are in my project directory
now i configured media_root to point to media
now if i type 127.0.0.1/media/css/login.css, i can see the css file.(the url
has been configured)
But the effects of the css file can't be seen on the login(html) page.
the linking inside the html file to the css file is proper.
Am i missing something simple here?

Goutham

On 11/1/07, Antoni Aloy <[EMAIL PROTECTED]> wrote:
>
>
> 2007/11/1, Goutham DL <[EMAIL PROTECTED]>:
> >
> > hi,
> > Its still not working. Iam actually using django 0.96.The code that
> > antoni gave is giving errors.
> The code is prepared for the trunk version of Django, but if you take
> a look at the settings file and the url.py file you'll see how it
> deals with the media.
>
> On the other hand, it just uses the ideas of
> http://www.djangoproject.com/documentation/0.96/static_files/ but
> splitting the configuration  .
> The trunk version is rock solid and has lot of improvements.
>
> --
> Antoni Aloy López
> Binissalem - Mallorca
> http://www.trespams.com
> Soci de Bulma - http://www.bulma.cat
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Antoni Aloy

2007/11/1, Goutham DL <[EMAIL PROTECTED]>:
>
> hi,
> Its still not working. Iam actually using django 0.96.The code that
> antoni gave is giving errors.
The code is prepared for the trunk version of Django, but if you take
a look at the settings file and the url.py file you'll see how it
deals with the media.

On the other hand, it just uses the ideas of
http://www.djangoproject.com/documentation/0.96/static_files/ but
splitting the configuration  .
The trunk version is rock solid and has lot of improvements.

-- 
Antoni Aloy López
Binissalem - Mallorca
http://www.trespams.com
Soci de Bulma - http://www.bulma.cat

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Ramdas S
I think your problem is something more elementary!

You are not calling the CSS file from the right path. CSS files have to be
served by another server other than Django development server.

Why do not you try it with inline css first and see whether it works.

Ramdas S


On 11/1/07, Goutham DL <[EMAIL PROTECTED]> wrote:
>
>
> hi,
> Its still not working. Iam actually using django 0.96.The code that
> antoni gave is giving errors.
> Can someone please explain why i need to configure media_urls ?
> (media_root has been configured to the appropriate directory). I just
> want to link the css file with the html one.how will using
> django.views.static.serve help??
>
> On Nov 1, 3:26 pm, Gonzalo Delgado <[EMAIL PROTECTED]>
> wrote:
> > El Thu, 01 Nov 2007 10:13:13 -
> > Goutham DL <[EMAIL PROTECTED]> escribió:
> >
> >
> >
> > > Hi,
> >
> > > Iam new to django. Iam having problems loading css files (and images)
> > > using the development server. Is it possible to load css files in the
> > > development server or should i use mod_python?
> > > (since iam a newbie to mod_python also i prefer using the development
> > > server for sometime)
> >
> > > Goutham
> >
> > http://www.djangoproject.com/documentation/0.96/static_files/
> >
> > --
> > Gonzalo Delgado <[EMAIL PROTECTED]>
> >
> >  application_pgp-signature_part
> > 1KDownload
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching querysets

2007-11-01 Thread Joe

Sorry, meant to NOT vary on the value of the cookie header.

On Nov 1, 11:39 am, Joe <[EMAIL PROTECTED]> wrote:
> Correct me if I'm wrong, but wouldn't this place more load on the
> server to to this, as an anonymous user visiting the site for the
> first time would start a new session, and therefore bypass the cache?
>
> Is there a way I could hack the middleware to look at something
> besides the HTTP headers to determine caching?
>
> My main question is this: If I changed the templates so there was only
> two versions (one for authenticated users that said log out, and one
> for anonymous users that said log in, how could I get the cache
> middleware to vary on request.user.is_authenticated, and the value of
> the cookie header?
>
> On Oct 30, 10:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Tue, 2007-10-30 at 05:43 -0700, Joe wrote:
> > > I am running into a performace problem with Django and scaling.
>
> > > I have enabled the caching middleware, but had to set
> > > CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True so I could continue to use the
> > > admin interface.
>
> > > Now, authenticated users are beginning to put a noticeable load on the
> > > server.
>
> > > How do I implement caching on my normal views for authenticated
> > > users?  I can't just use the decorator because I have a "Hello,
> > > Username" message on the page.
>
> > I keep meaning to look at this further, because I'm sure that if we work
> > it out properly, CACHE_MIDDLEWARE_ANONYMOUS_ONLY shouldn't be necessary.
> > So what I'm saying here is based on no testing, but it will take you two
> > minutes to try out and see.
>
> > There's a middleware ordering problem here: if you're using
> > CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you need to have the session middleware
> > come *before* the cache middleware in the middleware ordering. This is
> > so that on the request path, we already know if the user is anonymous
> > before attempting to hit the cache.
>
> > If you turn off CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you should put the
> > session middleware *after* the cache middleware. This is because the
> > important path here is the response path: the session middleware sets
> > the Vary: Cookie header and so the cache middleware knows to use that to
> > generate the cache key.
>
> > So, just flipping the anonymous caching setting isn't all you need to do
> > in this case. You also need to move the SessionMiddleware. Put it after
> > CacheMiddleware in MIDDLEWARE_CLASSES and see if that improves things.
> > This might not solve all your problems in one swing, since it will
> > generate a new cache key for every session cookie. So if you are getting
> > lots of different users, you'll eventually toss old entries out from the
> > cache and have to regenerate them.
>
> > What we need to do, longer-term is solve the problem of how to split
> > request ordering and response ordering for middleware (and this list
> > isn't the place for that discussion) so that we can have something on
> > the request path to say "all anonymous users should be treated the
> > same", whilst letting the session middleware have the chance to set the
> > "Vary: Cookie" header before it gets to the cache middleware so that
> > authenticated users are cached properly. Right now, we can't do both.
> > It'll be fixed one day.
>
> > Regards,
> > Malcolm
>
> > --
> > How many of you believe in telekinesis? Raise my 
> > hand...http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Goutham DL

Can some one please help me out here?

On Nov 1, 7:03 pm, Goutham DL <[EMAIL PROTECTED]> wrote:
> hi,
> Its still not working. Iam actually using django 0.96.The code that
> antoni gave is giving errors.
> Can someone please explain why i need to configure media_urls ?
> (media_root has been configured to the appropriate directory). I just
> want to link the css file with the html one.how will using
> django.views.static.serve help??
>
> On Nov 1, 3:26 pm, Gonzalo Delgado <[EMAIL PROTECTED]>
> wrote:
>
> > El Thu, 01 Nov 2007 10:13:13 -
> > Goutham DL <[EMAIL PROTECTED]> escribió:
>
> > > Hi,
>
> > > Iam new to django. Iam having problems loading css files (and images)
> > > using the development server. Is it possible to load css files in the
> > > development server or should i use mod_python?
> > > (since iam a newbie to mod_python also i prefer using the development
> > > server for sometime)
>
> > > Goutham
>
> >http://www.djangoproject.com/documentation/0.96/static_files/
>
> > --
> > Gonzalo Delgado <[EMAIL PROTECTED]>
>
> >  application_pgp-signature_part
> > 1KDownload


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching querysets

2007-11-01 Thread Joe

Sorry for the mistake. This should read:

Correct me if I'm wrong, but wouldn't this place more load on the
server to to this, as an anonymous user visiting the site for the
first time would start a new session, and therefore bypass the cache?

Is there a way I could hack the middleware to look at something
besides the HTTP headers to determine caching?

My main question is this: If I changed the templates so there was only
two versions (one for authenticated users that said log out, and one
for anonymous users that said log in), how could I get the cache
middleware to vary on request.user.is_authenticated, and NOT the value
of
the cookie header?

On Nov 1, 11:39 am, Joe <[EMAIL PROTECTED]> wrote:
> Correct me if I'm wrong, but wouldn't this place more load on the
> server to to this, as an anonymous user visiting the site for the
> first time would start a new session, and therefore bypass the cache?
>
> Is there a way I could hack the middleware to look at something
> besides the HTTP headers to determine caching?
>
> My main question is this: If I changed the templates so there was only
> two versions (one for authenticated users that said log out, and one
> for anonymous users that said log in, how could I get the cache
> middleware to vary on request.user.is_authenticated, and the value of
> the cookie header?
>
> On Oct 30, 10:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Tue, 2007-10-30 at 05:43 -0700, Joe wrote:
> > > I am running into a performace problem with Django and scaling.
>
> > > I have enabled the caching middleware, but had to set
> > > CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True so I could continue to use the
> > > admin interface.
>
> > > Now, authenticated users are beginning to put a noticeable load on the
> > > server.
>
> > > How do I implement caching on my normal views for authenticated
> > > users?  I can't just use the decorator because I have a "Hello,
> > > Username" message on the page.
>
> > I keep meaning to look at this further, because I'm sure that if we work
> > it out properly, CACHE_MIDDLEWARE_ANONYMOUS_ONLY shouldn't be necessary.
> > So what I'm saying here is based on no testing, but it will take you two
> > minutes to try out and see.
>
> > There's a middleware ordering problem here: if you're using
> > CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you need to have the session middleware
> > come *before* the cache middleware in the middleware ordering. This is
> > so that on the request path, we already know if the user is anonymous
> > before attempting to hit the cache.
>
> > If you turn off CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you should put the
> > session middleware *after* the cache middleware. This is because the
> > important path here is the response path: the session middleware sets
> > the Vary: Cookie header and so the cache middleware knows to use that to
> > generate the cache key.
>
> > So, just flipping the anonymous caching setting isn't all you need to do
> > in this case. You also need to move the SessionMiddleware. Put it after
> > CacheMiddleware in MIDDLEWARE_CLASSES and see if that improves things.
> > This might not solve all your problems in one swing, since it will
> > generate a new cache key for every session cookie. So if you are getting
> > lots of different users, you'll eventually toss old entries out from the
> > cache and have to regenerate them.
>
> > What we need to do, longer-term is solve the problem of how to split
> > request ordering and response ordering for middleware (and this list
> > isn't the place for that discussion) so that we can have something on
> > the request path to say "all anonymous users should be treated the
> > same", whilst letting the session middleware have the chance to set the
> > "Vary: Cookie" header before it gets to the cache middleware so that
> > authenticated users are cached properly. Right now, we can't do both.
> > It'll be fixed one day.
>
> > Regards,
> > Malcolm
>
> > --
> > How many of you believe in telekinesis? Raise my 
> > hand...http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching querysets

2007-11-01 Thread Joe

Correct me if I'm wrong, but wouldn't this place more load on the
server to to this, as an anonymous user visiting the site for the
first time would start a new session, and therefore bypass the cache?

Is there a way I could hack the middleware to look at something
besides the HTTP headers to determine caching?

My main question is this: If I changed the templates so there was only
two versions (one for authenticated users that said log out, and one
for anonymous users that said log in, how could I get the cache
middleware to vary on request.user.is_authenticated, and the value of
the cookie header?

On Oct 30, 10:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2007-10-30 at 05:43 -0700, Joe wrote:
> > I am running into a performace problem with Django and scaling.
>
> > I have enabled the caching middleware, but had to set
> > CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True so I could continue to use the
> > admin interface.
>
> > Now, authenticated users are beginning to put a noticeable load on the
> > server.
>
> > How do I implement caching on my normal views for authenticated
> > users?  I can't just use the decorator because I have a "Hello,
> > Username" message on the page.
>
> I keep meaning to look at this further, because I'm sure that if we work
> it out properly, CACHE_MIDDLEWARE_ANONYMOUS_ONLY shouldn't be necessary.
> So what I'm saying here is based on no testing, but it will take you two
> minutes to try out and see.
>
> There's a middleware ordering problem here: if you're using
> CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you need to have the session middleware
> come *before* the cache middleware in the middleware ordering. This is
> so that on the request path, we already know if the user is anonymous
> before attempting to hit the cache.
>
> If you turn off CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you should put the
> session middleware *after* the cache middleware. This is because the
> important path here is the response path: the session middleware sets
> the Vary: Cookie header and so the cache middleware knows to use that to
> generate the cache key.
>
> So, just flipping the anonymous caching setting isn't all you need to do
> in this case. You also need to move the SessionMiddleware. Put it after
> CacheMiddleware in MIDDLEWARE_CLASSES and see if that improves things.
> This might not solve all your problems in one swing, since it will
> generate a new cache key for every session cookie. So if you are getting
> lots of different users, you'll eventually toss old entries out from the
> cache and have to regenerate them.
>
> What we need to do, longer-term is solve the problem of how to split
> request ordering and response ordering for middleware (and this list
> isn't the place for that discussion) so that we can have something on
> the request path to say "all anonymous users should be treated the
> same", whilst letting the session middleware have the chance to set the
> "Vary: Cookie" header before it gets to the cache middleware so that
> authenticated users are cached properly. Right now, we can't do both.
> It'll be fixed one day.
>
> Regards,
> Malcolm
>
> --
> How many of you believe in telekinesis? Raise my 
> hand...http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Here we advertise you on in whole world through internet,its very easy way.........!

2007-11-01 Thread net expert
Its true that today world is Internet world,every thing is
globelised,differences go away
WE gave you our service on your pay demand,if you want to advertise your
product,website,yourself profile or any thing you want,we advertise you in
whole world,just contact us and try our sevice

its true that through our service you get be popular in world in few
minutes..we advertise any thing
contact us our advertiser 00923007530720
or Email us,give your full detail otherwise your request may be
rejected.
[EMAIL PROTECTED]

come first get first...this our policy

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: OneToOneField direction? (was Re: QuerySet.count() inaccurate across ForeignKey relationships)

2007-11-01 Thread George Vilches

Karen Tracey wrote:
> On 11/1/07, *George Vilches* <[EMAIL PROTECTED] 
> > wrote:
> [snip]
> 
> For reporting purposes though, we would like to be able to
> .select_related() on User, and get a cached copy of each of the OneToOne
> relationships.  It seems reasonable by the very essence of OneToOne, but
> I don't know if there's some limitation that would prevent that
> following from happening.  However, when we pull 50 users, having 50*N
> tables of extra queries when we need data from a few separate places
> makes the whole task unappealing to use the Django ORM for.  I wouldn't
> think about asking that this should be in the ORM, except that Django
> supports reverse foreign keys so intelligently that it seems a direct
> 1:1 correlation between rows is intuitive to go in either direction.
> 
> 
> In the absence of explicit support for the reverse relation on OneToOne 
> fields, can't you use the QuerySet extra() method ( 
> http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none)
>  
> to pull in all the various tables/columns you are interested in in a 
> single query? 

We have used this in a few places already, and it's fine for just 
manipulating the data directly, but we really wanted to have instances 
of the Models themselves populated from that single query.  The models 
have a bunch of nice methods for manipulating the data, and it would be 
annoying to have to manually create instances of 10+ models and insert 
40+ columns of data into them to get to use those helper methods.  Too 
much typing. :)

 > p.s. to the Django website maintainers: pretty favicon!

Agreed, I like it.


George

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Obscure error installing Django

2007-11-01 Thread Julio César Carrascal Urquijo

I've tracked it down to something similar to this:
http://code.djangoproject.com/ticket/5530#comment:1

The ImportError that is been raised on
http://code.djangoproject.com/browser/django/trunk/django/db/backends/mysql/base.py#L20
is causing the session error. It probably should be changed also to a
raise ImproperlyConfigured so the error is reported correctly: For
some reason the FastCGI process was using the outdated version the
server has instead of 1.2.2 that I had installed (even though it is on
sys.path).

Thanks for your help.



On Nov 1, 1:40 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-11-01 at 04:50 +, Julio César Carrascal Urquijo wrote:
>
>
>
> > I'm installing Django on a shared hosting account but I've been
> > fighting the las two hours with this error:
>
> >  /home//django_src/django/contrib/sessions/middleware.py in
> > process_request(self= > object>, request=,
> > POST:)
> >13 engine = __import__(settings.SESSION_ENGINE, {}, {},
> > [''])
> >14 session_key =
> > request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
> >15 request.session = engine.SessionStore(session_key)
> >16
> >17 def process_response(self, request, response):
> > request = ,
> > POST:,
> > request.session undefined, engine =  > 'django.contrib.sessions.backends.db' fr...ngo_src/django/contrib/
> > sessions/backends/db.pyc'>, engine.SessionStore undefined, session_key
> > = None
>
> > AttributeError: 'module' object has no attribute 'SessionStore'
> >   args = ("'module' object has no attribute 'SessionStore'",)
>
> > It's probably something I missed because It goes away if I disable the
> > session middleware (that means I can't use auth or admin apps) so at
> > least the core of Django is working.
>
> > I took a look at the values of settings.SESSION_ENGINE and engine:
>
> > * settings.SESSION_ENGINE was 'django.contrib.sessions.backends.db'
> > * engine.__file__ was '/home//django_src/django/contrib/sessions/
> > backends/db.pyc'
>
> > which seems correct, but...
>
> > * dir(engine) was ['__builtins__', '__doc__', '__file__', '__name__',
> > 'settings']
>
> > ... an empty module. Anyone knows why this might be happening?
>
> I have no suggestions to offer here. I can't repeat this using Python
> 2.3 and latest subversion trunk (as you're using). I don't have
> mod_fastcgi set up for testing, though, so it might be something special
> going on there, but I can't imagine what it would be.
>
> If you run the same commands from the "manage.py shell" prompt, does it
> work? That is, do something like
>
> >>> from django.conf import settings
> >>> engine = __import__(settings.SESSION_ENGINE, {}, {},[''])
> >>> dir(engine)
>
> That should show more than you saw above. If it doesn't, I'm back to
> being stuff, because I don't know what's going on. If there are
> differences, your checkout is incomplete somehow.
>
> Regards,
> Malcolm
>
> --
> I don't have a solution, but I admire your 
> problem.http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Off Topic: Slug regular expression

2007-11-01 Thread Jeremy Dunck

On 11/1/07, cjl <[EMAIL PROTECTED]> wrote:
>
> Do I need it if Django is already appending slashes?
>

No.

Writing regular expressions is obviously something that can be done
different ways.  I think you should write your URLconfs expecting the
slashes to be there so that you let Django append it and therefore
have a single URL format.  This gives you a little more coherence when
people link to you, and also helps with search ranking a little.

If you have APPEND_SLASH = False and wish to accept either form, then
you need to have the ? after the final "/" in order to match either
form.

The answer to what that last "?" did, though, is answered in the re
syntax guide which Tim posted.
( http://docs.python.org/lib/re-syntax.html )
Quoting:
"
"?"
Causes the resulting RE to match 0 or 1 repetitions of the
preceding RE. ab? will match either 'a' or 'ab'.
"

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Goutham DL

hi,
Its still not working. Iam actually using django 0.96.The code that
antoni gave is giving errors.
Can someone please explain why i need to configure media_urls ?
(media_root has been configured to the appropriate directory). I just
want to link the css file with the html one.how will using
django.views.static.serve help??

On Nov 1, 3:26 pm, Gonzalo Delgado <[EMAIL PROTECTED]>
wrote:
> El Thu, 01 Nov 2007 10:13:13 -
> Goutham DL <[EMAIL PROTECTED]> escribió:
>
>
>
> > Hi,
>
> > Iam new to django. Iam having problems loading css files (and images)
> > using the development server. Is it possible to load css files in the
> > development server or should i use mod_python?
> > (since iam a newbie to mod_python also i prefer using the development
> > server for sometime)
>
> > Goutham
>
> http://www.djangoproject.com/documentation/0.96/static_files/
>
> --
> Gonzalo Delgado <[EMAIL PROTECTED]>
>
>  application_pgp-signature_part
> 1KDownload


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



template question

2007-11-01 Thread [EMAIL PROTECTED]

I have this code in my view, for example:

a=['a','b','c'] # a list of row labels
b=[1,2,3] # a list of col label
c=tab # an array (list of list) with len(a) rows and len(b) cols.
return render_to_response('template.html',{'a':a,'b':b,'c':c})

then on the template side, it's easy to print c
{% for row in c %}
  
  {% for col in row %}
{{ col }}
  {% endfor %}
  
{% endfor %}

but in each cell, I want to add my col and rows label separate with
comma with the c value ?
how to index a and b below for having corresponding row and col
labels ?
{{ col }},{{ a }},{{ b }}


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



template question

2007-11-01 Thread [EMAIL PROTECTED]

I have this code in my view, for example:

a=['a','b','c'] # a list of row labels
b=[1,2,3] # a list of col label
c=tab # an array (list of list) with len(a) rows and len(b) cols.
return render_to_response('template.html',{'a':a,'b':b,'c':c})

then on the template side, it's easy to print c
{% for row in c %}
  
  {% for col in row %}
{{ col }}
  {% endfor %}
  
{% endfor %}

but in each cell, I want to add my col and rows label separate with
comma with the c value ?
how to index a and b below for having corresponding row and col
labels ?
{{ col }},{{ a }},{{ b }}


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: OneToOneField direction? (was Re: QuerySet.count() inaccurate across ForeignKey relationships)

2007-11-01 Thread Karen Tracey
On 11/1/07, George Vilches <[EMAIL PROTECTED]> wrote:
[snip]

> For reporting purposes though, we would like to be able to
> .select_related() on User, and get a cached copy of each of the OneToOne
> relationships.  It seems reasonable by the very essence of OneToOne, but
> I don't know if there's some limitation that would prevent that
> following from happening.  However, when we pull 50 users, having 50*N
> tables of extra queries when we need data from a few separate places
> makes the whole task unappealing to use the Django ORM for.  I wouldn't
> think about asking that this should be in the ORM, except that Django
> supports reverse foreign keys so intelligently that it seems a direct
> 1:1 correlation between rows is intuitive to go in either direction.
>

In the absence of explicit support for the reverse relation on OneToOne
fields, can't you use the QuerySet extra() method (
http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none)
to pull in all the various tables/columns you are interested in in a single
query?

Karen

p.s. to the Django website maintainers: pretty favicon!

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django newbie, URL resloving problem

2007-11-01 Thread RajeshD



On Nov 1, 7:26 am, gizmo <[EMAIL PROTECTED]> wrote:
> Hello,
> I started learning about Django and I followed an example 
> athttp://www.djangobook.com/en/beta/chapter03/
>
> I've done:
> from django.conf.urls.defaults import *
> from gizmo_site.datetime import current_datetime

This suggests that you have a Django app called 'datetime'. I would
recommend renaming it as Python has a built-in 'datetime' module. It
may be possible for the two to co-exist, but the error you are seeing
(django.contrib.auth: 'module' object has no attribute 'timedelta') is
because Django is looking for the Python built-in datetime module's
timedelta function and it encounters your module of that name instead
which has no timedelta function (and even if it did, it would be the
wrong one.)

Jakub already explained why your URL match is failing.

Hope the above helps too.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: OneToOneField direction? (was Re: QuerySet.count() inaccurate across ForeignKey relationships)

2007-11-01 Thread Malcolm Tredinnick

On Thu, 2007-11-01 at 08:53 -0400, George Vilches wrote:
> (Off-list because this mostly doesn't apply to non qs-rf people)
> 
> Thank you for the clarification on OneToOneFields and required 
> relationships.  We've been working with a very high volume legacy 
> database that we're importing the data into, and that data's not exactly 
> pristine.  We're used to related tables solving the problems with 
> non-correlated data, it sounds like we're just going to be forced to 
> clean it up, and that's fine.  Django's ORM provides a different way of 
> approaching the problem, and we just have to be willing to take full 
> advantage of that mechanism and not the previous SQL "trickery" that's 
> been used. :)
> 
> As always, your involvement in these questions is appreciated. 
> Sometimes what we expect intuitively is a bug just isn't because we're 
> taking advantage of a "non-feature" of the system.
> 
> ---
> 
> I had one other question in there directed to you, regarding 
> OneToOneFields.  In the new qs-rf, is it *possible* to make these 
> relationships bidirectional for the purposes of caching data?

Probably best to ask these questions on django-developers in future, so
that we can get a few opinions.

It might be possible when I fix up #5020. There's probably no good
reason that won't work for reverse relations. By default
select_related() won't follow reverse relations ... there are just too
many possibilities and, by and large, it would be very inefficient,
since you generally don't care about them (in the 90% case). However,
with the features of #5020 in place, you could probably specify the
reverse relations you wanted to follow and have it work. After all, User
has an implicit field called "member_set", or something like that, in
your example, so qs.select_related('member_set') might work -- not quite
sure what the reverse for a OneToOneField looks like, because I've never
used it -- I tend to stick to ForeignKey(unique=True) for a lot of those
types of things, but that's mostly an implementation detail.

I haven't finished integrating David Cramer's work there. His idea is
quite a good one, but I have to port the whole implementation across.
I've started doing it in it a branch locally, but it's still work in
progress. So I don't know if this really will work easily in practice,
but it's not beyond the realms of possibility.

> If they're not going to be currently but it is something the ORM is 
> capable of, it would be something I would work on as well as the Bit 
> class.  Here's our deal:
> 
> class User(models.Model): pass
> 
> class Member(models.Model):
>models.OneToOneField(User)
> class MemberAvatar(models.Model):
>models.OneToOneField(User)
> class MemberBadges(models.Model):
>models.OneToOneField(User)
> ...
> 
> We have 10+ of these types of tables.  The data makes sense to be 
> separated because there's a lot of large data blocks in some of these 
> columns, and we have *very large* amounts of data (100GB range on one 
> implementation of this system), so having it all in one table is 
> inappropriate.
> 
> For reporting purposes though, we would like to be able to 
> .select_related() on User, and get a cached copy of each of the OneToOne 
> relationships.  It seems reasonable by the very essence of OneToOne, but 
> I don't know if there's some limitation that would prevent that 
> following from happening.  However, when we pull 50 users, having 50*N 
> tables of extra queries when we need data from a few separate places 
> makes the whole task unappealing to use the Django ORM for.

Well, I'd be rearranging my access so that it's only N extra queries:
collect all the User objects first and then add a
filter(user_id__in=[...]). But I understand your point.

For some things, though, Django's ORM isn't going to be ideal. We aren't
trying to be SQLAlchemy. That's intentional.

Something that's been requested in the past and might be worth fleshing
out in the future (probably after queryset-refactor, though) is how to
take a result set from custom SQL and easily convert that back into a
collection of models. So that people can write their own custom SQL but
get back models in a QuerySet sort of format. Not exactly a QuerySet,
since adding extra filters probably won't work easily, but it's
interesting to play with. That's possibly even post-1.0 work, but it's
also not something that necessarily has to sit in core after the
queryset refactor lands, so I'm hoping there's some exploration that
happens there in a few months.

Regards,
Malcolm

-- 
Why be difficult when, with a little bit of effort, you could be
impossible. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 

Re: OneToOneField direction? (was Re: QuerySet.count() inaccurate across ForeignKey relationships)

2007-11-01 Thread George Vilches

Alright, I guess it's not offlist.  Sorry for the extra chatter folks.

George Vilches wrote:
> (Off-list because this mostly doesn't apply to non qs-rf people)
> 
> Thank you for the clarification on OneToOneFields and required 
> relationships.  We've been working with a very high volume legacy 
> database that we're importing the data into, and that data's not exactly 
> pristine.  We're used to related tables solving the problems with 
> non-correlated data, it sounds like we're just going to be forced to 
> clean it up, and that's fine.  Django's ORM provides a different way of 
> approaching the problem, and we just have to be willing to take full 
> advantage of that mechanism and not the previous SQL "trickery" that's 
> been used. :)
> 
> As always, your involvement in these questions is appreciated. 
> Sometimes what we expect intuitively is a bug just isn't because we're 
> taking advantage of a "non-feature" of the system.
> 
> ---
> 
> I had one other question in there directed to you, regarding 
> OneToOneFields.  In the new qs-rf, is it *possible* to make these 
> relationships bidirectional for the purposes of caching data?
> 
> If they're not going to be currently but it is something the ORM is 
> capable of, it would be something I would work on as well as the Bit 
> class.  Here's our deal:
> 
> class User(models.Model): pass
> 
> class Member(models.Model):
>models.OneToOneField(User)
> class MemberAvatar(models.Model):
>models.OneToOneField(User)
> class MemberBadges(models.Model):
>models.OneToOneField(User)
> ...
> 
> We have 10+ of these types of tables.  The data makes sense to be 
> separated because there's a lot of large data blocks in some of these 
> columns, and we have *very large* amounts of data (100GB range on one 
> implementation of this system), so having it all in one table is 
> inappropriate.
> 
> For reporting purposes though, we would like to be able to 
> .select_related() on User, and get a cached copy of each of the OneToOne 
> relationships.  It seems reasonable by the very essence of OneToOne, but 
> I don't know if there's some limitation that would prevent that 
> following from happening.  However, when we pull 50 users, having 50*N 
> tables of extra queries when we need data from a few separate places 
> makes the whole task unappealing to use the Django ORM for.  I wouldn't 
> think about asking that this should be in the ORM, except that Django 
> supports reverse foreign keys so intelligently that it seems a direct 
> 1:1 correlation between rows is intuitive to go in either direction.
> 
> As always, we don't ask that you actually do anything for this if it 
> isn't done, we would just like to know if it's possible, and if you have 
> any thoughts about where the likely place to go about fixing it is in 
> qs-rf.  Or, you can tell us that we're wrong about our assumption that 
> OneToOneFields should be bidirectional, because of XXX, and we'll 
> respect your decisions.  You know what's better for Django than us, by 
> far. :)
> 
> 
> Thanks,
> George
> 
> 
> Malcolm Tredinnick wrote:
>> On Thu, 2007-11-01 at 00:43 -0400, George Vilches wrote:
>>> Karen Tracey wrote:
 On 10/31/07, *George Vilches* <[EMAIL PROTECTED] 
 > wrote:

 Or (I just saw your follow-up e-mail), is all of this a moot point 
 since
 something like this is going to be made totally invalid in the future?


 That's it.  Targeting a non-unique column in a ForeignKey field is 
 invalid.  It's invalid now, and will continue to be invalid.  The 
 difference is that it's not caught and flagged as an error now, and will 
 be when queryset-refactor gets merged into trunk. 

 If you can whittle down your real problem to an example that does not 
 include this kind of invalid relationship (you said you are actually 
 using OneToOne fields?) maybe we could make some progress on 
 understanding/solving the real issue you are facing.
>>> Here's an example that's a lot closer to home:
>>>
>>> class Person(models.Model):
>>>  name = models.CharField(max_length=100)
>>>  status = models.IntegerField()
>>>
>>> class PersonInfo(models.Model):
>>>  person = models.OneToOneField(Person)
>>>  phone = models.CharField(max_length=10)
>>>
>>>
>>>
>>>  >>> from qs.models import *
>>>  >>> Person.objects.create(name='user1', status=1)
>>> 
>>>  >>> PersonInfo.objects.create(person_id=1, phone='111')
>>> 
>>>  >>> PersonInfo.objects.create(person_id=99, phone='222')
>>> 
>>>
>>> Yes, I know.  At this point we've added a PersonInfo that doesn't map to 
>>> an existing person (id=99).
>>>
>>> If at this point you're saying, "well that's stupid", I would ask you to 
>>> point out where it says that a OneToOneField has any sort of forced 
>>> referential integrity across the relationship (it most definitely is not 
>>> generating constraints like the unique ForeignKey does).  
>> On 

OneToOneField direction? (was Re: QuerySet.count() inaccurate across ForeignKey relationships)

2007-11-01 Thread George Vilches

(Off-list because this mostly doesn't apply to non qs-rf people)

Thank you for the clarification on OneToOneFields and required 
relationships.  We've been working with a very high volume legacy 
database that we're importing the data into, and that data's not exactly 
pristine.  We're used to related tables solving the problems with 
non-correlated data, it sounds like we're just going to be forced to 
clean it up, and that's fine.  Django's ORM provides a different way of 
approaching the problem, and we just have to be willing to take full 
advantage of that mechanism and not the previous SQL "trickery" that's 
been used. :)

As always, your involvement in these questions is appreciated. 
Sometimes what we expect intuitively is a bug just isn't because we're 
taking advantage of a "non-feature" of the system.

---

I had one other question in there directed to you, regarding 
OneToOneFields.  In the new qs-rf, is it *possible* to make these 
relationships bidirectional for the purposes of caching data?

If they're not going to be currently but it is something the ORM is 
capable of, it would be something I would work on as well as the Bit 
class.  Here's our deal:

class User(models.Model): pass

class Member(models.Model):
   models.OneToOneField(User)
class MemberAvatar(models.Model):
   models.OneToOneField(User)
class MemberBadges(models.Model):
   models.OneToOneField(User)
...

We have 10+ of these types of tables.  The data makes sense to be 
separated because there's a lot of large data blocks in some of these 
columns, and we have *very large* amounts of data (100GB range on one 
implementation of this system), so having it all in one table is 
inappropriate.

For reporting purposes though, we would like to be able to 
.select_related() on User, and get a cached copy of each of the OneToOne 
relationships.  It seems reasonable by the very essence of OneToOne, but 
I don't know if there's some limitation that would prevent that 
following from happening.  However, when we pull 50 users, having 50*N 
tables of extra queries when we need data from a few separate places 
makes the whole task unappealing to use the Django ORM for.  I wouldn't 
think about asking that this should be in the ORM, except that Django 
supports reverse foreign keys so intelligently that it seems a direct 
1:1 correlation between rows is intuitive to go in either direction.

As always, we don't ask that you actually do anything for this if it 
isn't done, we would just like to know if it's possible, and if you have 
any thoughts about where the likely place to go about fixing it is in 
qs-rf.  Or, you can tell us that we're wrong about our assumption that 
OneToOneFields should be bidirectional, because of XXX, and we'll 
respect your decisions.  You know what's better for Django than us, by 
far. :)


Thanks,
George


Malcolm Tredinnick wrote:
> On Thu, 2007-11-01 at 00:43 -0400, George Vilches wrote:
>> Karen Tracey wrote:
>>> On 10/31/07, *George Vilches* <[EMAIL PROTECTED] 
>>> > wrote:
>>>
>>> Or (I just saw your follow-up e-mail), is all of this a moot point since
>>> something like this is going to be made totally invalid in the future?
>>>
>>>
>>> That's it.  Targeting a non-unique column in a ForeignKey field is 
>>> invalid.  It's invalid now, and will continue to be invalid.  The 
>>> difference is that it's not caught and flagged as an error now, and will 
>>> be when queryset-refactor gets merged into trunk. 
>>>
>>> If you can whittle down your real problem to an example that does not 
>>> include this kind of invalid relationship (you said you are actually 
>>> using OneToOne fields?) maybe we could make some progress on 
>>> understanding/solving the real issue you are facing.
>> Here's an example that's a lot closer to home:
>>
>> class Person(models.Model):
>>  name = models.CharField(max_length=100)
>>  status = models.IntegerField()
>>
>> class PersonInfo(models.Model):
>>  person = models.OneToOneField(Person)
>>  phone = models.CharField(max_length=10)
>>
>>
>>
>>  >>> from qs.models import *
>>  >>> Person.objects.create(name='user1', status=1)
>> 
>>  >>> PersonInfo.objects.create(person_id=1, phone='111')
>> 
>>  >>> PersonInfo.objects.create(person_id=99, phone='222')
>> 
>>
>> Yes, I know.  At this point we've added a PersonInfo that doesn't map to 
>> an existing person (id=99).
>>
>> If at this point you're saying, "well that's stupid", I would ask you to 
>> point out where it says that a OneToOneField has any sort of forced 
>> referential integrity across the relationship (it most definitely is not 
>> generating constraints like the unique ForeignKey does).  
> 
> On the contrary, it is asking for referential integrity at database
> table creation time. Have a look at the output of "manage.py sql
> " for that app. Unfortunately, SQLite and MySQL with the MyIsam
> storage engine won't raise complaints (since they don't enforce the
> integri

Re: Django newbie, URL resloving problem

2007-11-01 Thread eXt

On 1 Lis, 12:26, gizmo <[EMAIL PROTECTED]> wrote:
> Hello,
> I started learning about Django and I followed an example 
> athttp://www.djangobook.com/en/beta/chapter03/
>
> I've done:
> from django.conf.urls.defaults import *
> from gizmo_site.datetime import current_datetime
>
> urlpatterns =
> patterns('',
> (r'^\now$', current_datetime), )
>
> When I tried to start server the error is occures :
>
> Validating models...
> django.contrib.auth: 'module' object has no attribute 'timedelta'
Strange. What Django version is this? Have you used timedelta anywhere
in your code?

> and when I openhttp://127.0.0.1:8000/there is a description of
> error:
>
> Using the URLconf defined in gizmo_site.urls, Django tried these URL
> patterns, in this order:
>
>1. ^\now$
>
> The current URL, /, didn't match any of these.
>
> Can someone tell me what I'm doing wrong?  Thank you
When you go to http://127.0.0.1:8000/ Django looks for handler for
'/'. Do you have something like that in your ulrs.py? No, but you have
a handler for '\now' errr... which should be plain 'now' i think. So:

Change  (r'^\now$', current_datetime) to (r'^now$', current_datetime),
and then go to http://localhost:8000/now instead of just http://localhost:8.

HTH

--
Jakub Wisniowski


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeError in admin in latest django

2007-11-01 Thread Bert Heymans

Malcolm,

Thanks for the explanation, I did mean to reply to your other message,
sorry for working on your nerves.

I understand now why it's a bad idea to use setdefaultencoding().

Bert

On Nov 1, 4:12 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-10-31 at 10:10 -0700, Bert Heymans wrote:
> > Malcolm,
>
> > I found this thread, someone who claims to maintain the Python FAQ
> > says it's OK to use the routine but(!) only in sitecustomize.py:
>
> By "that routine", I guess you meant setdefaultencoding() [see the
> problem with top-posting... there's no context for your answer, and in
> this case, even reading the entire message of mine you quote, I can't
> see where this arose in that message. Still, let's struggle onwards.]
>
> >http://groups.google.com/group/comp.lang.python/browse_frm/thread/464...
>
> Search on django-dev. There are a number of posts where it's recommended
> not to use it, by developers (e.g. in [1]). It's been considered an
> error that it wasn't removed after the initial experimentation period.
> Customizing your site, particularly your site encoding introduces the
> risk of non-portability, since assumptions that are made throughout
> Python are now not necessarily true.
>
> Change the default encoding at your own risk and, if things break, stop
> doing that. You can't rely on it being true on other machines, after
> all, so if you want code that is at all portable, you must assume the
> default encoding is ASCII.
>
> [1]http://mail.python.org/pipermail/python-dev/2007-June/073593.html
>
>
>
> > I'm kind of confused now, ...
>
> > Especially after reading PEP100:
>
> >http://www.python.org/dev/peps/pep-0100/
>
> PEP 100 is quite old. As it mentions, it actually pre-dates PEPs and
> whilst it discusses setdefaultencoding(), it doesn't recommend using it
> (or not recommend -- it's a spec, not a best practices document, for
> better or worse) .
>
> Malcolm
>
> --
> Plan to be spontaneous - tomorrow.http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django newbie, URL resloving problem

2007-11-01 Thread gizmo

Hello,
I started learning about Django and I followed an example at
http://www.djangobook.com/en/beta/chapter03/

I've done:
from django.conf.urls.defaults import *
from gizmo_site.datetime import current_datetime

urlpatterns =
patterns('',
(r'^\now$', current_datetime), )

When I tried to start server the error is occures :

Validating models...
django.contrib.auth: 'module' object has no attribute 'timedelta'

and when I open http://127.0.0.1:8000/ there is a description of
error:

Using the URLconf defined in gizmo_site.urls, Django tried these URL
patterns, in this order:

   1. ^\now$

The current URL, /, didn't match any of these.

Can someone tell me what I'm doing wrong?  Thank you

Melita


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Context processor not loading

2007-11-01 Thread Marty Alchin

On 11/1/07, Jon Atkinson <[EMAIL PROTECTED]> wrote:
> As I understand it, this is all I need to do to have the context
> processor execute properly, however neither 'spam' is output to the
> console (I'm using the ./manage.py server), nor is 'eggs', or the
> token 'cp_test' passed to the template. I'm sure I'm doing something
> stupid, but what?

You also have to make sure you're using RequestContext[1] when you
render the template, or none of the context processors will execute.

-Gul

[1] 
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Default value for ForeignKey

2007-11-01 Thread Dan Ellis

On Nov 1, 2:55 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:

> Set it in your model's save() method.

I guess the point is that it's bad practice to hard-code magic values.
Having thought about it some more, two options that spring to mind
are:

1) Have a boolean 'default' field in the Severity model to determine
which one should be used in a new Alert.
2) Have a prototype Alert that can be cloned for new Alerts, perhaps
just an instance with prototype=True.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Context processor not loading

2007-11-01 Thread Jon Atkinson

Hi,

I'm having trouble with a context processor not running when I make a
request. I've tried to reduce this to the simplest case I can:

My projects tree is as follows:

project/
context_processors/
__init__.py
globals.py

The file, 'globals.py', contains the following:

def globals(request):
print "spam"
return { 'cp_test': "eggs" }

In settings.py, I have defined the following:

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.request',
'project.context_processors.globals.globals',
)

As I understand it, this is all I need to do to have the context
processor execute properly, however neither 'spam' is output to the
console (I'm using the ./manage.py server), nor is 'eggs', or the
token 'cp_test' passed to the template. I'm sure I'm doing something
stupid, but what?

--Jon

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Off Topic: Slug regular expression

2007-11-01 Thread cjl

Do I need it if Django is already appending slashes?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Gonzalo Delgado
El Thu, 01 Nov 2007 10:13:13 -
Goutham DL <[EMAIL PROTECTED]> escribió:

> 
> Hi,
> 
> Iam new to django. Iam having problems loading css files (and images)
> using the development server. Is it possible to load css files in the
> development server or should i use mod_python?
> (since iam a newbie to mod_python also i prefer using the development
> server for sometime)
> 
> Goutham
> 
 

http://www.djangoproject.com/documentation/0.96/static_files/


-- 
Gonzalo Delgado <[EMAIL PROTECTED]>


pgpgJU7MKhjNx.pgp
Description: PGP signature


Re: CSS problem

2007-11-01 Thread Antoni Aloy

2007/11/1, Goutham DL <[EMAIL PROTECTED]>:
>
> Hi,
Hi
> Iam new to django. Iam having problems loading css files (and images)
> using the development server. Is it possible to load css files in the
> development server or should i use mod_python?
> (since iam a newbie to mod_python also i prefer using the development
> server for sometime)
>
> Goutham
>
I have created an small start project with django, that will show you
how to load css and image files from the development server

http://appfusedjango.googlecode.com/svn/

Hope it helps!

-- 
Antoni Aloy López
Binissalem - Mallorca
http://www.trespams.com
Soci de Bulma - http://www.bulma.cat

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CSS problem

2007-11-01 Thread Horst Gutmann

Sure :-)
http://www.djangoproject.com/documentation/static_files/

- Horst

On 11/1/07, Goutham DL <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Iam new to django. Iam having problems loading css files (and images)
> using the development server. Is it possible to load css files in the
> development server or should i use mod_python?
> (since iam a newbie to mod_python also i prefer using the development
> server for sometime)
>
> Goutham
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



CSS problem

2007-11-01 Thread Goutham DL

Hi,

Iam new to django. Iam having problems loading css files (and images)
using the development server. Is it possible to load css files in the
development server or should i use mod_python?
(since iam a newbie to mod_python also i prefer using the development
server for sometime)

Goutham


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN: Satchmo 0.6 Released

2007-11-01 Thread Jon Atkinson

Great - just as I downloaded 0.5 and got it working, I have to start over :-)

--Jon

On 10/31/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
> On 10/31/07, Chris Moffitt <[EMAIL PROTECTED]> wrote:
> >
> > There have been some spurious routing issues but it looks fine now.
> > Are you still not seeing it?
>
> Yep, up 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ascii decode error bites again

2007-11-01 Thread Ivan Sagalaev

Kenneth Gonsalves wrote:
> ProgrammingError at /web/admin/web/fosscalendar/add/
> ERROR: character 0xe28099 of encoding "UNICODE" has no equivalent in  
> "LATIN1" INSERT INTO  
> "web_fosscalendar" ("name","year","startdate","enddate","city_id","venue 
> ","organiser","scope","website","contact") VALUES ('lll', 
> 2007,'2007-11-01','2007-11-01','1','','ll','lll','','Users’ Group')
> Request Method:   POST
> Request URL:  http://nrcfosshelpline.in/web/admin/web/fosscalendar/add/
> Exception Type:   ProgrammingError
> Exception Value:  ERROR: character 0xe28099 of encoding "UNICODE" has  
> no equivalent in "LATIN1"

Ah... So this is what you called "ascii cannot decode etc" in your 
original post? This is an absolutely different issue that has nothing to 
do with Python's default usage of ascii for decoding or even Django's 
unicode internals.

What happens here is your Postgres database is configured to store data 
in Latin 1 encoding. Thus it just cannot store any non-ascii characters, 
including that curly single quote. If you want to do this you have to 
either encode your data manually into something containing only ascii 
characters (like using \u or � escapes) or just convert the 
database to be in a more capable encoding (any unicode that that version 
of Postgres would support).

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---