Re: Setting up my application

2007-05-19 Thread Duc Nguyen

Why can't it just be a "catch-all" url like:

(r'(?P\w+)/', 'theview')

and then in your view:

def theview(request, manufacturer):
if manufacturer in my_manufacturers:
   do_something()
else:
   # error out with unknown manufacturer msg?




Greg wrote:
> I'm working on creating an e-commerce site in Django.  I have a
> website that sells area rugs from 20 different manufacturers.  I am
> wondering what the best way to configure my urls.py file.  I've been
> thinking of a couple of different ways to accomplish this.
>
> 1) Contained all in one url line
> (r'^(mohawk|milliken|shaw|sphinx|etc...))/$', 'theview'),
>
> My 'theview' function would then find out what variable was passed to
> it.  And then query that manufacturer table.   So my url can get
> pretty long depending on how many manufacturers I have.  Also, if I
> did it this way how would I setup my view?  Would it be something like
> this
>
> def theview(request, manufacturer):
>rec = manufacturer.objects.all()
>return render_to_response('dispaly_manu.html', {'manu_records':
> rec})
>
> 2) Creating a separate url for each manufacturer
> (r'^/mohawk/$', 'django.views.generic.list_detail.object_list',
> mohawk_dict),
> (r'^/milliken/$', 'django.views.generic.list_detail.object_list',
> milliken_dict),
> (r'^/shaw/$', 'django.views.generic.list_detail.object_list',
> shaw_dict),
> (r'^/sphinx/$', 'django.views.generic.list_detail.object_list',
> sphinx_dict),
>
> This way seems like a waste.  Would I need to create a unique
> dictionary for each manufacturer?  Is there a way I can use the same
> dictionary for every manufacturer?
>
> Or does somebody have a better solution than what I came up with
> above?
>
> 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
-~--~~~~--~~--~--~---



Setting up my application

2007-05-19 Thread Greg

I'm working on creating an e-commerce site in Django.  I have a
website that sells area rugs from 20 different manufacturers.  I am
wondering what the best way to configure my urls.py file.  I've been
thinking of a couple of different ways to accomplish this.

1) Contained all in one url line
(r'^(mohawk|milliken|shaw|sphinx|etc...))/$', 'theview'),

My 'theview' function would then find out what variable was passed to
it.  And then query that manufacturer table.   So my url can get
pretty long depending on how many manufacturers I have.  Also, if I
did it this way how would I setup my view?  Would it be something like
this

def theview(request, manufacturer):
   rec = manufacturer.objects.all()
   return render_to_response('dispaly_manu.html', {'manu_records':
rec})

2) Creating a separate url for each manufacturer
(r'^/mohawk/$', 'django.views.generic.list_detail.object_list',
mohawk_dict),
(r'^/milliken/$', 'django.views.generic.list_detail.object_list',
milliken_dict),
(r'^/shaw/$', 'django.views.generic.list_detail.object_list',
shaw_dict),
(r'^/sphinx/$', 'django.views.generic.list_detail.object_list',
sphinx_dict),

This way seems like a waste.  Would I need to create a unique
dictionary for each manufacturer?  Is there a way I can use the same
dictionary for every manufacturer?

Or does somebody have a better solution than what I came up with
above?

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: tests: one failure --> all test declared failed

2007-05-19 Thread Russell Keith-Magee

On 5/19/07, Sandro Dentella <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
>   I'm trying to create a simple TestCase that should test several different
>   urls via get. I have a strange behaviour in that test works correctly if I
>   don't have @login-required decorator on the views *or* if I require
>   authentication *and all* url are correct.

The error you are reporting indicates that something in the Django
server is raising a HTTP status code of 500, which is an internal
server error. The follow-on problem is that you don't have a 500.html
template, which is what is getting reported by the test runner.
However, the real problem is whatever is causing the 500 error to
occur.

What exactly do you mean by 'all URLs are correct'? That there are no
errors in urls.py? Every GET request uses urls.py, so if there is an
error in urls.py, every test will fail as a result. If there is an
error in urls.py, the error you are reporting is not surprising.

Yours,
Russ Magee %-)

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



Re: Securing static files

2007-05-19 Thread Kyle Fox

Maybe I'm not understanding what the problem is, but why can't you
just make a new directory for each user?

> > user A uploads file 1 to /static_files//file1.jpg


--~--~-~--~~~---~--~~
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: mod_python without httpd.conf?

2007-05-19 Thread Graham Dumpleton

On May 19, 9:04 pm, Daniel Ellison <[EMAIL PROTECTED]> wrote:
> On Friday 18 May 2007 21:32:33 Graham Dumpleton wrote:
>
> > This will all only work if the web site administrator has also set:
>
> >   AllowOverride FileInfo
>
> > for the directory containing the .htaccess file you want to add the
> > the SetHandler directive to.
>
> Yes, that's true. Sorry, forgot to add that bit of info. Same for AuthConfig
> if you want to restrict access to sensitive projects in your .htaccess file.

Using mod_python there are actually ways around the lack of both these
overrides being set and the fact that it is possible to circumvent the
intention of the web administrator as far as them not providing you
these abilities in the first place, is why I personally wouldn't
recommend installing mod_python in a shared hosting environment where
there are many users running within the same web server. Luckily the
majority of people don't understand mod_python and how it works enough
so as to realise the mischief they could get up to. :-)

Anyway, will wait and see whether the original poster has FileInfo
override ability in .htaccess files before we consider the
workarounds.

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



newform and edit in line

2007-05-19 Thread yml

Hello,

I am trying to create a form equivalent to the edit inline that is
implemented in the admin interface.
I have a models with "Survey", "Poll", "Choice" as describe below and
I would like to have a single page to create my Survey with multiple
questions (*n) and multiple (*n) choices.

==models.py=
class Survey(models.Model):
name = models.CharField(maxlength=20)
description= models.CharField(maxlength=200)
start_date=models.DateField("Effective from")
end_date=models.DateField("Effective to")
class Poll(models.Model):
survey=models.ForeignKey(Survey)
question = models.CharField(maxlength=200,core=True)
pub_date = models.DateField('date published',auto_now=True)
class Choice(models.Model):
poll = models.ForeignKey(Poll, edit_inline=models.TABULAR,
num_in_admin=5)
choice = models.CharField(maxlength=200,core=True)
votes = models.IntegerField(core=True)
=

I do not understand yet how I can create such from with the newform
library.
so far I have the following views.py

=views.py
def survey_cud(request):
# initialize variables to sent to template
message = ''
submit_action = 'Add'
edit_id = ''
# generate default form
SurveyForm = forms.form_for_model(Survey)
f = SurveyForm()
# handle edit and delete events
if request.method=="GET":
if request.has_key("edit_id"):
# replace default form with form based on row to edit
survey = Survey.objects.get(pk=request.GET['edit_id'])
SurveyForm = forms.form_for_instance(survey)
f = SurveyForm()
submit_action = 'Update'
edit_id = request.GET['edit_id']
message = 'Editing survey ID ' + request.GET['edit_id']

if request.has_key('delete_id'):
Survey.objects.get(pk=request.GET['delete_id']).delete()
message = 'Survey deleted.'

# handle add and update events
if request.method == 'POST':
if request.POST['submit_action'] == 'Add':
# attempt to do add
add_f = SurveyForm(request.POST)
if add_f.is_valid():
add_f.save()
message = 'Contact added.'
else:
# validation failed: show submitted values in form
f = add_f

if request.POST['submit_action'] == 'Update':
# attempt to do update
survey = Survey.objects.get(pk=request.POST['edit_id'])
SurveyForm = forms.form_for_instance(survey)
update_f = SurveyForm(request.POST.copy())
if update_f.is_valid():
update_f.save()
message = 'Survey updated.'
else:
# validation failed: prepare form for new update
attempt
submit_action = 'Update'
edit_id = request.POST['edit_id']
f = update_f

# get existing surveys
survey_list = Survey.objects.all()

# return rendered HTML page
return render_to_response('dj_survey/template/cud_survey.html',
{ 'request': request,
  'message': message,
  'survey_list': survey_list,
  'form': f.as_table(),
  'submit_action': submit_action,
  'edit_id': edit_id
})


and the following template

==template=


  Surveys



{% if message %}
  {{ message }}
  
{% endif %}

{% if survey_list %}

  {% for survey in survey_list %}
  
{{ survey.name }}
Edit
Delete
  
  {% endfor %}


{% endif %}




{{ form }}

  

  




{% ifnotequal submit_action 'Add' %}
  
  Add New Survey
{% endifnotequal %}

=

Thank you very much for your help.

Yann


--~--~-~--~~~---~--~~
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: TypeError: save_file() got an unexpected keyword argument 'save'

2007-05-19 Thread derek

fixed it.  i was using the custom image uploader available here:
http://code.djangoproject.com/wiki/CustomUploadAndFilters
i simply added "save=True" to the def and the super call, and it works
fine.  (updated the code on the wiki too)

thanks,
derek


On May 19, 1:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2007-05-19 at 11:02 -0700, derek wrote:
> > i also am seeing this error:
>
> > TypeError at /do.upload_photo
> > save_file() got an unexpected keyword argument 'save'
> > Request Method:POST
> > Request URL:  http://local.allurstuff.com:8000/do.upload_photo
> > Exception Type:TypeError
> > Exception Value:   save_file() got an unexpected keyword argument
> > 'save'
> > Exception Location:
> > /usr/lib/python2.5/site-packages/django/db/models/
> > manipulators.py in save, line 105
>
> > my problem can't be outdated .pyc files, as i have just rebuilt this
> > machine and this is a fresh django 0.96 install.  can you tell me what
> > i can do to help debug this problem?
>
> I guess I'd start by putting some debugging prints into
> django/db/models/manipulators.py.
>
> If you have a look at the line that is failing, you can see the if-test
> just above it that checks that "f" is a FileField instance. If you
> haven't installed any third-party apps that would add extra FileField
> sub-classes (one thing to check), "f" should be either a FileField or an
> ImageField, both of which are defined in
> django/db/models/fields/__init__.py (and both of whose save_file()
> methods have a "save" argument).
>
> So let's check that "f" really is what we think it is. What is
> f.__class__.__name__ at the point of the error?
>
> We can also look at what the arguments are that save_fail() thinks it
> should be getting. Again, edit just prior to line 105 to insert
> something like the following:
>
> import inspect, sys
> print >> sys.stderr, inspect.getargspec(f.save_file)
> print >> sys.stderr, inspect.getsourcefile(f.__class__)
>
> Maybe some of the output there will give you or us some more clues about
> where the problem could lie.
>
> Regards,
> Malcolm


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



RE: Django newcomer - model question

2007-05-19 Thread Franco Gasperino


That solves it. Thanks! 

 - Franco

-Original Message-
From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Malcolm Tredinnick
Sent: Saturday, May 19, 2007 12:17 PM
To: django-users@googlegroups.com
Subject: Re: Django newcomer - model question


On Sat, 2007-05-19 at 12:02 -0700, [EMAIL PROTECTED] wrote:
> 
>   Greetings. I'm trying to get my head wrapped around django, and the 
> ORM model. So far, I've been pleased with what I've experienced.
> However, I'm having some trouble nailing down a couple relations.
> 
> A container can hold (reference) multiple items of the same primary 
> key.  I need a method of storage in the ORM so i can effectively say, 
> "that container can hold 5 of those items", for example.
> 
> CREATE TABLE items
> (
>   id SERIAL NOT NULL UNIQUE,
>   PRIMARY KEY (id)
> );
> 
> CREATE TABLE containers
> (
>   id SERIAL NOT NULL UNIQUE,
>   PRIMARY KEY (id)
> };
> 
> CREATE TABLE containers_to_items
> (
>   container_id INTEGER NOT NULL REFERENCES containers (id),
>   item_id INTEGER NOT NULL REFERENCES items (id),
>   item_count INTEGER NOT NULL,
> );
> 
> My attempt at creating a model design is as follows:
> 
> class Item (models.Model):
>   id = models.AutoField(primary_key=True)
> 
> class Container (models.Model):
>   id = models.AutoField(primary_key=True)
>   items = models.ManyToManyField(Item)
> 
> However, this creates the following relation/join table:
> 
> CREATE TABLE whatever_django_labels_it (
>   container_id INTEGER NOT NULL REFERENCES containers (id),
>   item_id INTEGER NOT NULL REFERENCES items (id),
>   UNIQUE (container_id, item_id)
> );
> 
> So i need to find out how to model the original relation table field 
> called item_count, to represent that a container can hold multiple 
> items, or I need to be able to drop the django-imposed UNIQUE 
> constraint so I can add multiple identical item_id values for a single

> container_id value:
> 
> INSERT INTO whatever_django_labels_it (container_id, item_id) VALUES 
> (1, 1); INSERT INTO whatever_django_labels_it (container_id, item_id) 
> VALUES (1, 1); INSERT INTO whatever_django_labels_it (container_id, 
> item_id) VALUES (1, 1);
> 
>   etc
> 
> Input?

Any time when you want to put extra fields on the intermediary table of
a many-to-many relationship, you need to model that table explicitly and
use a couple of ForeignKey fields to set up the relationship.

See http://www.djangoproject.com/documentation/models/m2m_intermediary/
for an example.

Regards,
Malcolm





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



Re: Django newcomer - model question

2007-05-19 Thread Malcolm Tredinnick

On Sat, 2007-05-19 at 12:02 -0700, [EMAIL PROTECTED] wrote:
> 
>   Greetings. I'm trying to get my head wrapped around django, and the
> ORM model. So far, I've been pleased with what I've experienced.
> However, I'm having some trouble nailing down a couple relations.
> 
> A container can hold (reference) multiple items of the same primary
> key.  I need a method of storage in the ORM so i can effectively say,
> "that container can hold 5 of those items", for example.
> 
> CREATE TABLE items
> (
>   id SERIAL NOT NULL UNIQUE,
>   PRIMARY KEY (id)
> );
> 
> CREATE TABLE containers
> (
>   id SERIAL NOT NULL UNIQUE,
>   PRIMARY KEY (id)
> };
> 
> CREATE TABLE containers_to_items
> (
>   container_id INTEGER NOT NULL REFERENCES containers (id),
>   item_id INTEGER NOT NULL REFERENCES items (id),
>   item_count INTEGER NOT NULL,
> );
> 
> My attempt at creating a model design is as follows:
> 
> class Item (models.Model):
>   id = models.AutoField(primary_key=True)
> 
> class Container (models.Model):
>   id = models.AutoField(primary_key=True)
>   items = models.ManyToManyField(Item)
> 
> However, this creates the following relation/join table:
> 
> CREATE TABLE whatever_django_labels_it
> (
>   container_id INTEGER NOT NULL REFERENCES containers (id),
>   item_id INTEGER NOT NULL REFERENCES items (id),
>   UNIQUE (container_id, item_id)
> );
> 
> So i need to find out how to model the original relation table field
> called item_count, to represent that a container can hold multiple
> items, or I need to be able to drop the django-imposed UNIQUE
> constraint so I can add multiple identical item_id values for a single
> container_id value:
> 
> INSERT INTO whatever_django_labels_it (container_id, item_id) VALUES
> (1, 1);
> INSERT INTO whatever_django_labels_it (container_id, item_id) VALUES
> (1, 1);
> INSERT INTO whatever_django_labels_it (container_id, item_id) VALUES
> (1, 1);
> 
>   etc
> 
> Input?

Any time when you want to put extra fields on the intermediary table of
a many-to-many relationship, you need to model that table explicitly and
use a couple of ForeignKey fields to set up the relationship.

See http://www.djangoproject.com/documentation/models/m2m_intermediary/
for an example.

Regards,
Malcolm



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



Django hosting

2007-05-19 Thread Christian M Hoeppner

Hi there!

I was wondering what all of you are using to host django powered sites. I'm 
using a dedicated virtual at mediatemple, and am thinking of switching to a 
joyent accelerator. What do you think?

Kind regards,
Chris Hoeppner
www.pixware.org

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



Django newcomer - model question

2007-05-19 Thread franco . gasperino


  Greetings. I'm trying to get my head wrapped around django, and the
ORM model. So far, I've been pleased with what I've experienced.
However, I'm having some trouble nailing down a couple relations.

A container can hold (reference) multiple items of the same primary
key.  I need a method of storage in the ORM so i can effectively say,
"that container can hold 5 of those items", for example.

CREATE TABLE items
(
  id SERIAL NOT NULL UNIQUE,
  PRIMARY KEY (id)
);

CREATE TABLE containers
(
  id SERIAL NOT NULL UNIQUE,
  PRIMARY KEY (id)
};

CREATE TABLE containers_to_items
(
  container_id INTEGER NOT NULL REFERENCES containers (id),
  item_id INTEGER NOT NULL REFERENCES items (id),
  item_count INTEGER NOT NULL,
);

My attempt at creating a model design is as follows:

class Item (models.Model):
  id = models.AutoField(primary_key=True)

class Container (models.Model):
  id = models.AutoField(primary_key=True)
  items = models.ManyToManyField(Item)

However, this creates the following relation/join table:

CREATE TABLE whatever_django_labels_it
(
  container_id INTEGER NOT NULL REFERENCES containers (id),
  item_id INTEGER NOT NULL REFERENCES items (id),
  UNIQUE (container_id, item_id)
);

So i need to find out how to model the original relation table field
called item_count, to represent that a container can hold multiple
items, or I need to be able to drop the django-imposed UNIQUE
constraint so I can add multiple identical item_id values for a single
container_id value:

INSERT INTO whatever_django_labels_it (container_id, item_id) VALUES
(1, 1);
INSERT INTO whatever_django_labels_it (container_id, item_id) VALUES
(1, 1);
INSERT INTO whatever_django_labels_it (container_id, item_id) VALUES
(1, 1);

  etc

Input?


--~--~-~--~~~---~--~~
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: TypeError: save_file() got an unexpected keyword argument 'save'

2007-05-19 Thread Malcolm Tredinnick

On Sat, 2007-05-19 at 11:02 -0700, derek wrote:
> i also am seeing this error:
> 
> TypeError at /do.upload_photo
> save_file() got an unexpected keyword argument 'save'
> Request Method:   POST
> Request URL:  http://local.allurstuff.com:8000/do.upload_photo
> Exception Type:   TypeError
> Exception Value:  save_file() got an unexpected keyword argument
> 'save'
> Exception Location:   /usr/lib/python2.5/site-packages/django/db/models/
> manipulators.py in save, line 105
> 
> my problem can't be outdated .pyc files, as i have just rebuilt this
> machine and this is a fresh django 0.96 install.  can you tell me what
> i can do to help debug this problem?

I guess I'd start by putting some debugging prints into
django/db/models/manipulators.py.

If you have a look at the line that is failing, you can see the if-test
just above it that checks that "f" is a FileField instance. If you
haven't installed any third-party apps that would add extra FileField
sub-classes (one thing to check), "f" should be either a FileField or an
ImageField, both of which are defined in
django/db/models/fields/__init__.py (and both of whose save_file()
methods have a "save" argument).

So let's check that "f" really is what we think it is. What is
f.__class__.__name__ at the point of the error?

We can also look at what the arguments are that save_fail() thinks it
should be getting. Again, edit just prior to line 105 to insert
something like the following:

import inspect, sys
print >> sys.stderr, inspect.getargspec(f.save_file)
print >> sys.stderr, inspect.getsourcefile(f.__class__)

Maybe some of the output there will give you or us some more clues about
where the problem could lie.

Regards,
Malcolm



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



Re: TypeError: save_file() got an unexpected keyword argument 'save'

2007-05-19 Thread derek

i also am seeing this error:

TypeError at /do.upload_photo
save_file() got an unexpected keyword argument 'save'
Request Method: POST
Request URL:http://local.allurstuff.com:8000/do.upload_photo
Exception Type: TypeError
Exception Value:save_file() got an unexpected keyword argument
'save'
Exception Location: /usr/lib/python2.5/site-packages/django/db/models/
manipulators.py in save, line 105

my problem can't be outdated .pyc files, as i have just rebuilt this
machine and this is a fresh django 0.96 install.  can you tell me what
i can do to help debug this problem?

thanks,
derek


On May 10, 8:58 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-05-10 at 23:46 +0200, Baurzhan Ismagulov wrote:
> > Hello,
>
> > I've upgraded r3709 to 0.96 and started getting the following error:
>
> > Traceback (most recent call last):
>
> >   File "/var/lib/python-support/python2.4/django/core/handlers/base.py", 
> > line 77, in get_response
> > response = callback(request, *callback_args, **callback_kwargs)
>
> >   File 
> > "/var/lib/python-support/python2.4/django/contrib/admin/views/decorators.py",
> >  line 55, in _checklogin
> > return view_func(request, *args, **kwargs)
>
> >   File 
> > "/var/lib/python-support/python2.4/django/views/decorators/cache.py", line 
> > 39, in _wrapped_view_func
> > response = view_func(request, *args, **kwargs)
>
> >   File 
> > "/var/lib/python-support/python2.4/django/contrib/admin/views/main.py", 
> > line 254, in add_stage
> > new_object = manipulator.save(new_data)
>
> >   File 
> > "/var/lib/python-support/python2.4/django/db/models/manipulators.py", line 
> > 105, in save
> > f.save_file(new_data, new_object, self.change and self.original_object 
> > or None, self.change, rel=False, save=False)
>
> > TypeError: save_file() got an unexpected keyword argument 'save'
>
> > This happens when I try to save a new record to a table using the admin
> > interface. I've looked at django/db/models/fields/__init__.py, the
> > method does seem to have the save kwarg. What is the problem?
>
> Sounds like your code is somehow inconsistent. The "save" parameter was
> added when ticket #639 was fixed (a little bit before 0.96 was
> released).
>
> There is a chance that some old *.pyc files from the pre-update version
> are getting in the way in your source tree (it shouldn't be happening,
> but it might be the case). Might depend on how you did the upgrade. Try
> removing old *.pyc files.
>
> Other than that, I don't really have any idea why you would be seeing
> this problem on a standard Django install. The code certainly seems to
> work and I haven't had any problems with it. So there is something
> "special" about your installation. That's not much help, except to
> encourage you to look closely at what might be unique about your
> particular setup.
>
> Regards,
> Malcolm


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



Re: mod_python without httpd.conf?

2007-05-19 Thread [EMAIL PROTECTED]

Thanks, 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: mod_python without httpd.conf?

2007-05-19 Thread [EMAIL PROTECTED]

Thank You, Dan


--~--~-~--~~~---~--~~
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: One, maybe two small bugs.

2007-05-19 Thread Marc-Antoine Parent


> Known bug, unfortunately. Disjunctions involving a common field don't
> have the correct SQL constructed. Will be fixed soon-ish (we have a
> plan, the work isn't finished yet).

Thanks a lot for both answers. That was swift!
And kudos for the good work in general.

Cheers,
Marc-Antoine


--~--~-~--~~~---~--~~
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: Authenticating w Apache

2007-05-19 Thread cwurld

Here is the answer I was looking for: http://www.djangosnippets.org/snippets/62/

I post it here to save others the time it took me to find this.


--~--~-~--~~~---~--~~
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: One, maybe two small bugs.

2007-05-19 Thread Malcolm Tredinnick

On Sat, 2007-05-19 at 15:37 +, Marc-Antoine Parent wrote:
> Good day!
> New to django, but familiar with the principles involved. Here is my
> situation. (sorry if long winded...)

[...snip...]
> For example, I can do this and get an accurate answer:
> 
> id=1
> Entry.objects.filter(Q(mainDivision__identifier = id)|
> Q(divisions__identifier = id))
> 
> Now, suppose that all I have for now are mainDivisions, i.e. the
> entry_divisions table is empty.
> And suppose I am retrieving by identifier rather than id...
> 
> id='someIdentifier'
> Entry.objects.filter(Q(divisions__identifier = id))
> => []
> which is accurate since the divisions relationship is empty;
> Entry.objects.filter(Q(mainDivision__identifier = id))
> => [, ,...]
> which is also accurate;
> However,
> Entry.objects.filter(Q(mainDivision__identifier = id)|
> Q(divisions__identifier = id))
> => []

Known bug, unfortunately. Disjunctions involving a common field don't
have the correct SQL constructed. Will be fixed soon-ish (we have a
plan, the work isn't finished yet).

> which does not agree with the semantics of 'OR'. So that is the first
> bug report (admittedly a corner case.)
> (I suspect it's an issue on INNER vs OUTER JOIN. Is there an easy way
> to look at the underlying SQL query)?

Yes. Have a look at the FAQ documentation page.

> Note: even with id, I also get some interesting behaviours
> 
> So I started on the track and started to enforce the mainDivision
> being in the divisions.
> (That was after I ran into the identifier bug, but before I realized
> my complex query worked with id...)
> 
> My first attempt was to add the following function in Entry:
> 
> def save(self):
> self.divisions.add(self.mainDivision)
> super(Entry, self).save()
> 
> (I first checked that 'add' could be applied many times without
> creating duplicates.)
> Of course, I ran in trouble with new objects, which do not have an Id
> yet, so I refined thus:
> 
> def save(self):
> if not self.id:
> super(Entry, self).save() # to get the Id
> self.divisions.add(self.mainDivision)
> super(Entry, self).save() # annoying double save...
> 
> If I apply 'save' to all instances of Entry in the shell, the
> relationship is added appropriately.
> However, if I modify or create an entry in the web admin interface,
> the relationship does not show up in divisions. I know 'save' is
> called (because I get stack traces if I raise something there), but
> the 'add' seems to fail in that case.
> Any clue? I am not sure this is a bug, but it sure puzzles me...

Related objects are saved after the main object saves in the standard
AddManipulator (django.db.models.manipulators) that the admin interface
is using. That could be causing some problems. We're not going to be
changing anything there, though, since the newforms-admin branch is
destined to replace that portion of the admin behaviour with the
manipulator-less system in newforms.

Regards,
Malcolm



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



Re: The setup.py problem on windows in django 0.96

2007-05-19 Thread Malcolm Tredinnick

On Sat, 2007-05-19 at 07:44 -0700, kernel1983 wrote:
> There is a problem while installing django 0.96 on windows
> 
> It's in the setup.py,line 24
> 
> package = dirpath[len_root_dir:].lstrip('/').replace('/', '.')
> 
> I think it should also consider the '\\'
> 
> package = dirpath[len_root_dir:].lstrip('/').replace('/',
> '.').lstrip('\\').replace('\\', '.')

It's been fixed in trunk, just after 0.96 was released. So you could
grab setup.py from a recent subversion checkout and just drop that into
place without too much trouble (although you'll probably want an updated
version of MANIFEST.in as well).

Regards,
Malcolm



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



Re: loading data from fixtures

2007-05-19 Thread Malcolm Tredinnick

On Sat, 2007-05-19 at 10:54 +, cesco wrote:
> Hi,
> 
> I'm experiencing a problem loading some data from fixtures. Some of
> the object loaded have danish letters (ø, å, æ) in their fields.
> 
> If I use the ANSI encoding for the JSON file I'm trying to load I get
> the following error message:
> "Problem installing fixture ...: 'utf8' codec can't decode bytes in
> position 2-6: unsupported Unicode code range"
> 
> If I use the UTF8 encoding I get the message:
> "Problem installing fixture ...: No JSON object could be decoded"
> 
> I tried also replacing the danish letters with their unicode encoding
> (ø -> \xf8, æ -> \xe6, å -> \xe5) but it didn't work (neither in ANSI
> nor in UTF-8).
> 
> Do you have any suggestion on how to solve this problem?

It feels like I am answering this quetion every single day: non-ASCII
characters are not supported in trunk at the moment. There are lots of
problems with them. That is exactly why the Unicode branch is in
development.

You will have to save your fixtures as UTF-8 when the Unicode branch is
merged, but then it should just work smoothly.

Regards,
Malcolm



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



Re: fixtures for generic relations?

2007-05-19 Thread Malcolm Tredinnick

On Sat, 2007-05-19 at 13:11 +0200, Bram - Smartelectronix wrote:
> Russell Keith-Magee wrote:
> >> how do I -in fixtures- explain a variable needs to come from another table?
> >> I don't want to write "content_type: 15" as elsewhere!
> > 
> > That's the way its done. GenericRelation is a convenience wrapper
> > around the content type and object id database entries; you need to
> > provide values for those two columns, and they're both specified as
> > integers.
> 
> True, but right now I have the initial_data written as:
> 
> INSERT INTO ... VALUES ((select id from django_content_type where name = 
> 'profile'), ..);
> 
> Which stays OK, even if I add/remove Models (which change the 
> content_type table content!)
> 
> > There has been some talk recently about establishing a common
> > interface for datatype coercion; providing a more natural interface
> > for datatype deserialization is one possible use case for coercion of
> > this type. However, there hasn't been any decisions made as yet. If
> > you want to make a suggestion, feel free to join into the discussion
> > on django-dev.
> 
> What about letting users use python scripts to generate the initial data 
> (if really needed/wanted)?
> 
> -
> 
> json = """
> [
>{
>  content_type: {{profile_contenttype.id}}
>}
>// more regular json goes here
> ]
> """
> 
> from django.template import Context, Template
> from django.contrib.contenttypes.models import ContentType
> 
> def get_json():
>c = Context({'profile_content_type': ContentType.objects.get.})
>t = Template(json )
>return t.render(c)
> 
> -
> 
> 
> I know that this kind of goes against what fixtures should be, but it 
> would be pretty flexible...

You can already do this as part of your test setup. Tests are just
Python files, after all, so you can do whatever extra customisation you
like in there.

Regards,
Malcolm


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



One, maybe two small bugs.

2007-05-19 Thread Marc-Antoine Parent

Good day!
New to django, but familiar with the principles involved. Here is my
situation. (sorry if long winded...)

I have an entry and categories (called divisions) in a many-to-many
relationship. However, each entry has a main division. So far the
model looks like this:

class Division(models.Model):
name = models.CharField(maxlength=100)
identifier = models.SlugField(maxlength=30, db_index=True,
unique=True)

class Entry(models.Model):
name = models.CharField(maxlength=255)
mainDivision = models.ForeignKey(Division,
related_name='entryMain_set')
divisions = models.ManyToManyField(Division, blank=True)

Conceptually, the mainDivision is treated as one of the divisions in
most cases; i.e. given a division, I want all entries connected
through either relationship. But in terms of modeling, I have two
options: either the mainDivision is included in the the "divisions"
set or not. (Any best practice?)
My initial choice was not, so as to avoid data duplication, and use
complex queries.
For example, I can do this and get an accurate answer:

id=1
Entry.objects.filter(Q(mainDivision__identifier = id)|
Q(divisions__identifier = id))

Now, suppose that all I have for now are mainDivisions, i.e. the
entry_divisions table is empty.
And suppose I am retrieving by identifier rather than id...

id='someIdentifier'
Entry.objects.filter(Q(divisions__identifier = id))
=> []
which is accurate since the divisions relationship is empty;
Entry.objects.filter(Q(mainDivision__identifier = id))
=> [, ,...]
which is also accurate;
However,
Entry.objects.filter(Q(mainDivision__identifier = id)|
Q(divisions__identifier = id))
=> []
which does not agree with the semantics of 'OR'. So that is the first
bug report (admittedly a corner case.)
(I suspect it's an issue on INNER vs OUTER JOIN. Is there an easy way
to look at the underlying SQL query)?
Note: even with id, I also get some interesting behaviours

So I started on the track and started to enforce the mainDivision
being in the divisions.
(That was after I ran into the identifier bug, but before I realized
my complex query worked with id...)

My first attempt was to add the following function in Entry:

def save(self):
self.divisions.add(self.mainDivision)
super(Entry, self).save()

(I first checked that 'add' could be applied many times without
creating duplicates.)
Of course, I ran in trouble with new objects, which do not have an Id
yet, so I refined thus:

def save(self):
if not self.id:
super(Entry, self).save() # to get the Id
self.divisions.add(self.mainDivision)
super(Entry, self).save() # annoying double save...

If I apply 'save' to all instances of Entry in the shell, the
relationship is added appropriately.
However, if I modify or create an entry in the web admin interface,
the relationship does not show up in divisions. I know 'save' is
called (because I get stack traces if I raise something there), but
the 'add' seems to fail in that case.
Any clue? I am not sure this is a bug, but it sure puzzles me...

Cheers,
Marc-Antoine


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



tests: one failure --> all test declared failed

2007-05-19 Thread Sandro Dentella

Hi,

  I'm trying to create a simple TestCase that should test several different
  urls via get. I have a strange behaviour in that test works correctly if I
  don't have @login-required decorator on the views *or* if I require
  authentication *and all* url are correct.

  Eg: all urls correct, login_required:

No fixtures found.
..
--
Ran 2 tests in 0.345s

OK


  it's enought that __a single url__ is broken that the output says all
  tests failed. If I don't have 'login_required' the test correctly reports
  just 1 failure. Below the test case I use and the traceback that has been
  raise when test_b required a page with errors (return_code=500).

  Do I miss something in this test case?
  
  Thanks as usual for your attention

  sandro
  *:-)


class SimpleTest(unittest.TestCase):
def setUp(self):
USERNAME = 'tester'
PASSWORD = 'passwd'

from django.contrib.auth.models import User
u, existent = User.objects.get_or_create(username=USERNAME,  )
u.set_password(PASSWORD)
u.is_staff = True
u.save()

self.client = Client()
ret = self.client.login('/timereport/reason/', USERNAME, PASSWORD)

def test_a(self):
path = '/timereport/transit/'
response = self.client.get(path)
self.failUnlessEqual(response.status_code, 200)

def test_b(self):
path = '/timereport/reason/'
response = self.client.get(path)
self.failUnlessEqual(response.status_code, 200)



No fixtures found.
EE
==
ERROR: test_a (jungle.apps.sys.tests.SimpleTest)
--
Traceback (most recent call last):
  File "/home/sandro/src/django/jungle/apps/sys/tests.py", line 45, in setUp
ret = self.client.login('/timereport/reason/', USERNAME, PASSWORD)
  File "/misc/src/django/trunk/django/test/client.py", line 256, in login
response = self.get(path)
  File "/misc/src/django/trunk/django/test/client.py", line 197, in get
return self.request(**r)
  File "/misc/src/django/trunk/django/test/client.py", line 156, in request
response = self.handler(environ)
  File "/misc/src/django/trunk/django/test/client.py", line 34, in __call__
response = self.get_response(request)
  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 
126, in get_response
  File "/misc/src/django/trunk/django/views/defaults.py", line 88, in 
server_error
t = loader.get_template(template_name) # You need to create a 500.html 
template.
  File "/misc/src/django/trunk/django/template/loader.py", line 79, in 
get_template
source, origin = find_template_source(template_name)
  File "/misc/src/django/trunk/django/template/loader.py", line 72, in 
find_template_source
raise TemplateDoesNotExist, name
TemplateDoesNotExist: 500.html

==
ERROR: test_b (jungle.apps.sys.tests.SimpleTest)
--
Traceback (most recent call last):
  File "/home/sandro/src/django/jungle/apps/sys/tests.py", line 45, in setUp
ret = self.client.login('/timereport/reason/', USERNAME, PASSWORD)
  File "/misc/src/django/trunk/django/test/client.py", line 256, in login
response = self.get(path)
  File "/misc/src/django/trunk/django/test/client.py", line 197, in get
return self.request(**r)
  File "/misc/src/django/trunk/django/test/client.py", line 156, in request
response = self.handler(environ)
  File "/misc/src/django/trunk/django/test/client.py", line 34, in __call__
response = self.get_response(request)
  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 
126, in get_response
  File "/misc/src/django/trunk/django/views/defaults.py", line 88, in 
server_error
t = loader.get_template(template_name) # You need to create a 500.html 
template.
  File "/misc/src/django/trunk/django/template/loader.py", line 79, in 
get_template
source, origin = find_template_source(template_name)
  File "/misc/src/django/trunk/django/template/loader.py", line 72, in 
find_template_source
raise TemplateDoesNotExist, name
TemplateDoesNotExist: 500.html

--
Ran 2 tests in 0.254s

FAILED (errors=2)

-- 
Sandro Dentella  *:-)
e-mail: [EMAIL PROTECTED] 
http://www.tksql.orgTkSQL Home page - My GPL 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

The setup.py problem on windows in django 0.96

2007-05-19 Thread kernel1983

There is a problem while installing django 0.96 on windows

It's in the setup.py,line 24

package = dirpath[len_root_dir:].lstrip('/').replace('/', '.')

I think it should also consider the '\\'

package = dirpath[len_root_dir:].lstrip('/').replace('/',
'.').lstrip('\\').replace('\\', '.')


--~--~-~--~~~---~--~~
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: CentOS python rpm

2007-05-19 Thread Christian M Hoeppner

> Not quite, because the original poster said he was using CentOS 4.4.
> That means he needs a specially built version of the Python rpm so that
> it doesn't, for example replace the python->python2.3 symlink on install
> (otherwise every rpm that depends on python in a binary API-compatible
> fashion would break).

You hit the nail, Malcolm. There's quite a lot depending on python, so it 
would be great to have an "alternative" install, including mod_python.

The guys at MediaTemple, have posted on their blog something about an edge 
range of servers, for those wanting to be up to date rather than stable. But 
for now, I'll have to stay with this...

--~--~-~--~~~---~--~~
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: My Learning Path

2007-05-19 Thread Todd O'Bryan

Check out How to Think Like a Computer Scientist (Python version). It's
an intro CS text, so it may be a little basic, but it does a very good
job of introducing all of the important Python concepts in a very
easy-to-understand way. Dive Into Python is a terrific book, but it
assumes considerable experience with some other language and PHP may not
not provide enough of that to make it easily accessible.

Here's the link:

http://www.ibiblio.org/obp/thinkCSpy/

Todd

On Sat, 2007-05-19 at 01:52 -0700, chell wrote:
> Thanks for the reply. I think I'll do the following (as I can't afford
> books at the moment):
> 
> 1. Dive into Python
> 2. Django Tutorial
> 3. Django Book
> 4. A first project (maybe a blog) using the Django documentation if I
> have to
> 
> Does that sound good?
> 
> 
> On 19 Mai, 10:24, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
> > chell wrote:
> > > Hello,
> >
> > > I'm a beginner to Python and Djano. I have some experience with PHP,
> > > but that's all.
> >
> > Be ready to be blown away with blissfulness:)
> >
> > To get your feet wet with python you can check out Dive Into Python,
> > freely available online:http://www.diveintopython.org/
> >
> > While you can maybe "get by" writing Django apps without an in-depth
> > knowledge of python, to do anything useful will be difficult.  Plus, in
> > my opinion, python is pretty fun.
> >
> > I guess I would recommend flipping through the DIP site while going
> > through the Django tutorial and Django book.
> >
> > My learning path was:
> >
> > 1) Beginning Python - From Novice To Professional (2005)
> > 2) Django tutorial
> > 3) Django book (http://www.djangobook.com)
> > 1/2/3) Django documentation (which is mostly pretty darn good) when
> > needed, and either the python docs or the DIP site if I run into
> > something I am unsure about.
> >
> > You can consider jumping into IRC as well if you haven't already.
> >
> > Cheers,
> >
> > Kelvin
> >
> > --
> > Kelvin Nicholson
> > Voice: +886 9 52152 336
> > Voice: +1 503 715 5535
> > GPG Keyid: 27449C8C
> > Data: [EMAIL PROTECTED]
> > Skype: yj_kelvin
> > Site:http://www.kelvinism.com
> 
> 
> > 


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



Re: Where is newform admin in trunk?

2007-05-19 Thread James Bennett

On 5/19/07, ivan_d <[EMAIL PROTECTED]> wrote:
> I read that newform admin was merged to trunk

I don't see anything in that thread which says it's been merged, and
it hasn't been merged; it's still a separate branch. If you want, you
can look at the code here:

http://code.djangoproject.com/browser/django/branches/newforms-admin

Or check out a copy of the branch by doing

svn co http://code.djangoproject.com/svn/django/branches/newforms-admin/django

> What is current status about newform admin ? Or where can I read about
> it (im just starting with Django and Im a little desoriented)?

The best thing to do is search the archives of the django-developers
mailing list:

http://groups.google.com/group/django-developers/

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



faster serving of static files with django/modpython

2007-05-19 Thread Paul Rudin



I know that serving static files isn't recommended, but for various
reasons people do it sometimes anyway. 

I had a little poke around in the code and noticed that for mod_python
at least it's pretty easy to improve the performance from the current
situation. I simply subclassed HttpResponse to make an
HttpFileResponse object, having a file attribute, which I just set to
a file name, rather than setting the contents of an HttpResponse
object from a read of the file. 

In ModPythonHandler I just used req.sendfile rather than req.write for
responses of this type.

On my system some simple benchmarking with ab suggests that it's
rougly twice as fast doing it this way, although no doubt the exact
difference will vary depending on lots of things.


--~--~-~--~~~---~--~~
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: fixtures for generic relations?

2007-05-19 Thread Bram - Smartelectronix

Russell Keith-Magee wrote:
>> how do I -in fixtures- explain a variable needs to come from another table?
>> I don't want to write "content_type: 15" as elsewhere!
> 
> That's the way its done. GenericRelation is a convenience wrapper
> around the content type and object id database entries; you need to
> provide values for those two columns, and they're both specified as
> integers.

True, but right now I have the initial_data written as:

INSERT INTO ... VALUES ((select id from django_content_type where name = 
'profile'), ..);

Which stays OK, even if I add/remove Models (which change the 
content_type table content!)

> There has been some talk recently about establishing a common
> interface for datatype coercion; providing a more natural interface
> for datatype deserialization is one possible use case for coercion of
> this type. However, there hasn't been any decisions made as yet. If
> you want to make a suggestion, feel free to join into the discussion
> on django-dev.

What about letting users use python scripts to generate the initial data 
(if really needed/wanted)?

-

json = """
[
   {
 content_type: {{profile_contenttype.id}}
   }
   // more regular json goes here
]
"""

from django.template import Context, Template
from django.contrib.contenttypes.models import ContentType

def get_json():
   c = Context({'profile_content_type': ContentType.objects.get.})
   t = Template(json )
   return t.render(c)

-


I know that this kind of goes against what fixtures should be, but it 
would be pretty flexible...


  - bram

--~--~-~--~~~---~--~~
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: mod_python without httpd.conf?

2007-05-19 Thread Daniel Ellison

On Friday 18 May 2007 21:32:33 Graham Dumpleton wrote:
> This will all only work if the web site administrator has also set:
>
>   AllowOverride FileInfo
>
> for the directory containing the .htaccess file you want to add the
> the SetHandler directive to.

Yes, that's true. Sorry, forgot to add that bit of info. Same for AuthConfig 
if you want to restrict access to sensitive projects in your .htaccess file.

Dan

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



loading data from fixtures

2007-05-19 Thread cesco

Hi,

I'm experiencing a problem loading some data from fixtures. Some of
the object loaded have danish letters (ø, å, æ) in their fields.

If I use the ANSI encoding for the JSON file I'm trying to load I get
the following error message:
"Problem installing fixture ...: 'utf8' codec can't decode bytes in
position 2-6: unsupported Unicode code range"

If I use the UTF8 encoding I get the message:
"Problem installing fixture ...: No JSON object could be decoded"

I tried also replacing the danish letters with their unicode encoding
(ø -> \xf8, æ -> \xe6, å -> \xe5) but it didn't work (neither in ANSI
nor in UTF-8).

Do you have any suggestion on how to solve this problem?

Any help would be very appreciated
Francesco


--~--~-~--~~~---~--~~
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: nested dictionaries in templates

2007-05-19 Thread Sven Herzing

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Aidas,

thx for the fast help. I hope i get better with django soon, that I can
help others too.

greets
Sven

Aidas Bendoraitis wrote:
> Hi Sven!
> 
> To get a value from a dictionary by a variable key, you either need a
> custom filter like {{ dictionary|dict_value:key }}
> 
> def dict_value(dict, key):
> """ returns the value of a dictionary key ...
> """
> try:
> return dict[key]
> except:
> return None
> 
> register.filter('dict_value', dict_value)
> 
> ... or you can go through the items like this:
> 
> {% for key_value in dictionary.items %}
> {{ key_value.0 }}{# the key #}
> {% for item in key_value.1 %}{# the value, that is the queryset #}
> {{ item }}
> {% endfor %}
> {% endfor %}
> 
> Regards,
> Aidas Bendoraitis aka Archatas
> 
> 
> 
> On 5/17/07, Sven Herzing <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I'm sorry that I have to ask again for help, but, I couldn't figure it
> out how to access nested directories in templates.
> 
> My Problem ist, that I have 3 categories (which I get from the DB), and
> for every category a queryset.
> 
> and the structure looks like this
> 
> {'rahmen':
> [, ],
>  'laufrad':
> [, ,  laufrad2, lr2>],
> 'lenker':
> [, ,  lenker2, len2>, ]
> }
> 
> I have the keywords for the dictionary in an array (mygroups) which I
> access in the template like this:
> 
> {% for entry in mygroups %}
> {{ entry }}
> 
>  and here I would like to access the dictionaries like this
> 
> {% for prod in product.entry %}
> {{ prod.name }}
> {% endfor %}
> {% endfor %}
> 
> The template manual says that if there is a point in a variable, it trys
> to treat it like a dictionary or a list, but what if the word after the
> point isn't parameter of the dictironary?
> I also tried sth like this {% for prod in product.{{ entry }} %}, but
> this didn't work either.
> 
> Is this kind of access possible?
> 
> regards
> Sven Herzing
> 
> 
>>

> 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGTsze4uR1pQ+2BeoRAtGvAKCV41i3tXin9/jb81Meirsqqpi33gCcDHWO
oIhx7sa3qdPsn8+bnPkRvn4=
=NwHW
-END PGP SIGNATURE-

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



Where is newform admin in trunk?

2007-05-19 Thread ivan_d

I read that newform admin was merged to trunk (here
http://groups.google.com/group/django-developers/browse_thread/thread/704546f4b30d5c86/a4ead31d11b8a79a),
but I cant find it. Concrete:

- I cant find django/contrib/admin/options.py
- I cant find django/contrib/admin/sites.py

What is current status about newform admin ? Or where can I read about
it (im just starting with Django and Im a little desoriented)?
And how plan is about merging newform admin to trunk?

Thanks for answer
Ivan Devat


--~--~-~--~~~---~--~~
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: My Learning Path

2007-05-19 Thread Paul Rudin

chell <[EMAIL PROTECTED]> writes:

>
> Maybe you guys could point me to some ressources and provide the order
> in which I should work through them in order to learn Django
> properly.
>

I'd suggest working through the python tutorial first
, and then the django tutorial
.




--~--~-~--~~~---~--~~
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: My Learning Path

2007-05-19 Thread Kelvin Nicholson

> 
> Does that sound good?
> 
> 

Sounds good! I guess I should have added that my first project was 
re-doing my personal blog:)

Good luck,

Kelvin

-- 
Kelvin Nicholson
Voice: +886 9 52152 336
Voice: +1 503 715 5535
GPG Keyid: 27449C8C
Data: [EMAIL PROTECTED]
Skype: yj_kelvin
Site: http://www.kelvinism.com

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



Re: URLPattern - can't fetch a detail page

2007-05-19 Thread Tyson Tate

Can you post a stack trace and more details from your url.py file?

-Tyson

On May 18, 2007, at 1:05 PM, Panos Laganakos wrote:

> Thanks for the reply mate, but that doesn't seem to be the issue. I
> still can't figure out what's going wrong here :/


--~--~-~--~~~---~--~~
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: My Learning Path

2007-05-19 Thread chell

Thanks for the reply. I think I'll do the following (as I can't afford
books at the moment):

1. Dive into Python
2. Django Tutorial
3. Django Book
4. A first project (maybe a blog) using the Django documentation if I
have to

Does that sound good?


On 19 Mai, 10:24, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
> chell wrote:
> > Hello,
>
> > I'm a beginner to Python and Djano. I have some experience with PHP,
> > but that's all.
>
> Be ready to be blown away with blissfulness:)
>
> To get your feet wet with python you can check out Dive Into Python,
> freely available online:http://www.diveintopython.org/
>
> While you can maybe "get by" writing Django apps without an in-depth
> knowledge of python, to do anything useful will be difficult.  Plus, in
> my opinion, python is pretty fun.
>
> I guess I would recommend flipping through the DIP site while going
> through the Django tutorial and Django book.
>
> My learning path was:
>
> 1) Beginning Python - From Novice To Professional (2005)
> 2) Django tutorial
> 3) Django book (http://www.djangobook.com)
> 1/2/3) Django documentation (which is mostly pretty darn good) when
> needed, and either the python docs or the DIP site if I run into
> something I am unsure about.
>
> You can consider jumping into IRC as well if you haven't already.
>
> Cheers,
>
> Kelvin
>
> --
> Kelvin Nicholson
> Voice: +886 9 52152 336
> Voice: +1 503 715 5535
> GPG Keyid: 27449C8C
> Data: [EMAIL PROTECTED]
> Skype: yj_kelvin
> Site:http://www.kelvinism.com


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



Re: My Learning Path

2007-05-19 Thread Kelvin Nicholson

chell wrote:
> Hello,
> 
> I'm a beginner to Python and Djano. I have some experience with PHP,
> but that's all.
> 

Be ready to be blown away with blissfulness:)

To get your feet wet with python you can check out Dive Into Python, 
freely available online: http://www.diveintopython.org/

While you can maybe "get by" writing Django apps without an in-depth 
knowledge of python, to do anything useful will be difficult.  Plus, in 
my opinion, python is pretty fun.

I guess I would recommend flipping through the DIP site while going 
through the Django tutorial and Django book.

My learning path was:

1) Beginning Python - From Novice To Professional (2005)
2) Django tutorial
3) Django book (http://www.djangobook.com)
1/2/3) Django documentation (which is mostly pretty darn good) when 
needed, and either the python docs or the DIP site if I run into 
something I am unsure about.

You can consider jumping into IRC as well if you haven't already.

Cheers,

Kelvin



-- 
Kelvin Nicholson
Voice: +886 9 52152 336
Voice: +1 503 715 5535
GPG Keyid: 27449C8C
Data: [EMAIL PROTECTED]
Skype: yj_kelvin
Site: http://www.kelvinism.com

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



My Learning Path

2007-05-19 Thread chell

Hello,

I'm a beginner to Python and Djano. I have some experience with PHP,
but that's all.

My ultimate goal is to be able to create web applications using the
Django framework. I realise that I should probably learn Python first.
The problem is that there are so many ressources out there, so it's a
bit overwhelming for a beginner like me.

Maybe you guys could point me to some ressources and provide the order
in which I should work through them in order to learn Django
properly.

Thanks so much in advance,

chell


--~--~-~--~~~---~--~~
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 Developers for Online News Start Up

2007-05-19 Thread Hive9

Engineer for Online News Start Up

Company Overview
Hive9 is an early stage funded start up located in Kendall Square in
Cambridge, MA.  Hive9 is in the online news space specializing in
technology involving machine learning, natural language processing,
information retrieval and human computer interaction.  Current team
consists of MIT alumni with engineering and research experience at
Google, Microsoft, and several start-ups.

Position Type: Full-time

Location: Cambridge, MA

Qualifications

* Development experience in Python (Django framework) and
databases such as MySQL or Postgres.
* Familiarity with web front-end technologies (HTML/XML/
JavaScript)
* Comfortable with working in a Linux environment
* Quick learner - ready to learn new technologies on the job

Education
Bachelors or advanced degree in Computer Science is preferred.

Compensation
We offer competitive salary and equity with benefits such as paid
vacation and medical insurance.

Contact
Please send resumes to: [EMAIL PROTECTED]

More information: http://www.hive9.com


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