Re: Trying to get fixtures working - problem with Site

2007-03-12 Thread Russell Keith-Magee

On 3/13/07, Chris Moffitt <[EMAIL PROTECTED]> wrote:
>
> Russell Keith-Magee wrote:
> > Can you provide a specific example? Like I said, I'm adding a unit
> > test to cover all the edge cases of serialization - if you have a
> > specific example that is failing, I'd like to make sure that your
> > example is covered in the test.
> >
> >
> You hit it.  It was a One to One field that was causing the problem.
>
> Now, I'm moving on to another problem when I try to load the data.  I
> have a place where it thinks there is a Null value but I don't know
> where it is having problems.  I'd suggest that it display a little more
> info about where the problem is, instead of this somewhat vague error-
>
>  ['This field cannot be null.']
>
> Since I have quite a few fields, it would be helpful if it told me what
> field or atleast which model it was getting stuck on.

Hrm. The test case checks Null values for every data field, so that
shouldn't be a problem. The only simple reason I can think of is a
required field that doesn't have a representation in your data file.

How are you producing your data file? Is this failure caused by a data
file produced by dump, or is it manually created? Can you provide a
small fixture file (and model) that exhibits the problem?

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: permissions in template

2007-03-12 Thread bgcooper

Funny that I should run into this post the same day that I'm trying to
work out how to do this.

I've got the same problem. From the shell:

>>> user = User.objects.get(id = 3)
>>> user.get_all_permissions()
Set(['ivms.can_play'])
>>> user.has_perm('ivms.can_play')
True

Fantastic. When I try and access it via my template it doesn't work.
e.g.

{% if perms.ivms.can_play %}
I have permissions
{% else %}
I don't have permissions
{% endif %}

Do I need to load any template tags to access this tag?

Note that I'm still using 0.95.

Thanks,
Ben


On Mar 13, 12:02 am, "masuran" <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
> I've created a custom permission on one of my models and I've given a
> user the custom permission.
>
> When I go into the shell (manage.py shell), I can confirm that the
> user has the custom permission. But when I use thepermsobject in one
> of my templates, it simple doesn't work.
>
> {% ifperms.custom_perm %}
>  do something
> {% endif %}
>
> According to the documentation, thepermsobject is included in 
> thetemplatelanguage. So I assume I don't have to create the object and
> pass it to mytemplate?
> I've even tried the fix posted herehttp://code.djangoproject.com/ticket/2418
> but to no avail. I still can't use thepermsobject in mytemplate.


--~--~-~--~~~---~--~~
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: Intializing newforms Form objects

2007-03-12 Thread Nebojša Đorđević

On Mar 8, 2007, at 16:50 , anders conbere wrote:

> I'm hoping to make a generic function that would do both __dict__ and
> handle m2m fields (o2m fields as well) that would let you one off
> these kinds of things.  The problem with this stuff being that if you
> have an object with any signifigant number of m2m fields there's just
> a lot of cruft in your view.

http://django-utils.googlecode.com/svn/branches/0.1/forms/

Take a look, it comes with generic views also. Unfortunately no docs  
(yet).

-- 
Nebojša Đorđević - nesh, ICQ#43799892
Studio Quattro - Niš - Serbia
http://studioquattro.biz/ | http://code.google.com/p/django-utils/
Registered Linux User 282159 [http://counter.li.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
-~--~~~~--~~--~--~---



object has no attribute get

2007-03-12 Thread GufyMike


This error is similar to ticket #999
http://code.djangoproject.com/ticket/999

I have renamed the field in question to something unique already and adjusted 
the the database to reflect this.  I'm still at a loss what the fix could be. 

Error:
'UserProfile' object has no attribute 'get'
Request Method: POST
Request URL:http://sylia.gufymike.com/mm/addmanga/submit/
Exception Type: AttributeError
Exception Value:'UserProfile' object has no attribute 'get'
Exception 
Location: 
/usr/lib64/python2.4/site-packages/django/db/models/fields/__init__.py 
in get_manipulator_new_data, line 289

Traceback (most recent call last):
File "/usr/lib64/python2.4/site-packages/django/core/handlers/base.py" in 
get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File 
"/home/gufymike/My_Docs/Work_Area/Projects/django-site/floaties/mangamooch/views.py"
 
in add_manga
  78. user_manip.save(user_update)
File "/usr/lib64/python2.4/site-packages/django/db/models/manipulators.py" in 
save
  88. param = f.get_manipulator_new_data(new_data)
File "/usr/lib64/python2.4/site-packages/django/db/models/fields/__init__.py" 
in get_manipulator_new_data
  289. val = new_data.get(self.name, self.get_default())

  AttributeError at /mm/addmanga/submit/
  'UserProfile' object has no attribute 'get'

Class involved:

class UserProfile(models.Model):
"""
User Profile extends the auth.models.User model.  This contains the 
info related
to the User for the site.
"""
user = models.ForeignKey(User, unique=True, 
edit_inline=models.TABULAR, num_in_admin=1,min_num_in_admin=1, 
max_num_in_admin=1,num_extra_on_change=0)
activation_key = models.CharField(maxlength=40, blank=True)
key_expires = models.DateTimeField(blank=True)
my_points = models.FloatField(max_digits=5, decimal_places=2, 
editable=False, default=5, blank=True)
avatar = models.ImageField(upload_to="users/%Y/%m/%d", 
validator_list=[validators.isValidImage], blank=True, )
signature = models.TextField(maxlength=200, , core=True, blank=True)
avrscore = models.FloatField(max_digits=2, decimal_places=1, 
blank=True)
ipaddr = 
models.IPAddressField(validator_list=[validators.isValidIPAddress4], 
blank=True)
newmess = models.BooleanField(editable=False, default=False, 
blank=True, null=True)


code its breaking on:
userprofile_data = UserProfile.objects.get(user = 
request.user.id)
user_manip = 
UserProfile.ChangeManipulator(userprofile_data.id)
new_points = 
calc_points(user_data.get_profile().my_points, new_data['condition'], 
new_data['language'])
user_update = UserProfile(my_points = new_points)
user_manip.save(user_update)

Thanks 
-- 
A mouse is an elephant built by the Japanese.

--~--~-~--~~~---~--~~
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: Duplicating model/view structure across several Django apps

2007-03-12 Thread akonsu

yes, i was thinking that may be models.py might import actual models
from elsewhere? if it can you will still have separate one-line
models.py but i think it is acceptable. no?

On Mar 12, 11:59 pm, "Mark Engelberg" <[EMAIL PROTECTED]>
wrote:
> Well, as far as I can tell, for each entry in my INSTALLED_APPS (from
> settings.py), it looks in that directory, and expects to find a
> models.py there.  So I'm looking for an alternative to duplicating the
> same models.py file in multiple directories.
>
> --Mark
>
> On 3/12/07, akonsu <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > hello,
>
> > but model.py is imported it as any module. what prevents you from just
> > having it on the PYTHONPATH and not necessarily in the application
> > directory?
>
> > may be i misunderstood the question...
>
> > konstantin
>
> > On Mar 12, 9:37 pm, "Mark Engelberg" <[EMAIL PROTECTED]> wrote:
> > > So I've got several applications which share the same model/view
> > > structure.  I have kept the applications separate because conceptually
> > > I want them separate in the admin interface, I want them to store
> > > their respective info in separate tables in the database, and most
> > > importantly, I want to retain the ability to tweak one without
> > > affecting the others if it becomes necessary at a later time.
>
> > > But for now, they are all identical, and I want to avoid duplicating
> > > the model/view code.  I think I understand how to keep the view code
> > > in one place, routing the URLs from all the apps to the same views.py
> > > and templates.
>
> > > However, it is less clear how to avoid duplicating the models.  It
> > > appears that to install an app, you need to have a unique subdirectory
> > > with its own model.py.  I tried having a fairly empty model.py that
> > > merely imports everything from a master "model.py", but Django doesn't
> > > seem to see the imported models (for example, syncdb doesn't seem to
> > > be aware of the imported models).  I'm thinking that on Unix, it might
> > > be possible to set up a symbolic link to a master model.py, so it
> > > appears that there are multiple model.py files (one in each app
> > > directory), but in fact, there is only one.  However, I'm testing this
> > > on a Windows machine before deploying it, so I'd like to find a
> > > solution that also works under Windows.
>
> > > Any suggestions?
>
> > > Thanks,
>
> > > Mark- Hide quoted text -
>
> - Show quoted text -


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



Is Signal multiple machine safe?

2007-03-12 Thread Alex Dong

Hi all,
I'm using post_save signal to send a "Your Account is Created" type of
email.  Since I have four machines, two django front end server
pointing to two MySQL cluster, I'm wondering is the post_save signal
multiple machine safe?

That is, if my signal is processed, is it possible that the "instance"
it receives is invalid because the model object was updated on another
machine?   Or, maybe django has already handled this so that as long
as the two front end django application server shares the same
database, it should be fine?

Thanks,
Alex


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



How to use Django session without browser cookies support

2007-03-12 Thread Sengtha

I am currently working on one project which needs to view page on
browser that doesn't support cookies.
By what I know, all Django sessions are based on browser cookies. And
Django sessions are save in django_session table. I wonder there is
any way to implement Django session like PHP session.use_trans_sid
without relying on client's browser cookies.

Please help

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: Duplicating model/view structure across several Django apps

2007-03-12 Thread Mark Engelberg

Well, as far as I can tell, for each entry in my INSTALLED_APPS (from
settings.py), it looks in that directory, and expects to find a
models.py there.  So I'm looking for an alternative to duplicating the
same models.py file in multiple directories.

--Mark

On 3/12/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> hello,
>
> but model.py is imported it as any module. what prevents you from just
> having it on the PYTHONPATH and not necessarily in the application
> directory?
>
> may be i misunderstood the question...
>
> konstantin
>
> On Mar 12, 9:37 pm, "Mark Engelberg" <[EMAIL PROTECTED]> wrote:
> > So I've got several applications which share the same model/view
> > structure.  I have kept the applications separate because conceptually
> > I want them separate in the admin interface, I want them to store
> > their respective info in separate tables in the database, and most
> > importantly, I want to retain the ability to tweak one without
> > affecting the others if it becomes necessary at a later time.
> >
> > But for now, they are all identical, and I want to avoid duplicating
> > the model/view code.  I think I understand how to keep the view code
> > in one place, routing the URLs from all the apps to the same views.py
> > and templates.
> >
> > However, it is less clear how to avoid duplicating the models.  It
> > appears that to install an app, you need to have a unique subdirectory
> > with its own model.py.  I tried having a fairly empty model.py that
> > merely imports everything from a master "model.py", but Django doesn't
> > seem to see the imported models (for example, syncdb doesn't seem to
> > be aware of the imported models).  I'm thinking that on Unix, it might
> > be possible to set up a symbolic link to a master model.py, so it
> > appears that there are multiple model.py files (one in each app
> > directory), but in fact, there is only one.  However, I'm testing this
> > on a Windows machine before deploying it, so I'd like to find a
> > solution that also works under Windows.
> >
> > Any suggestions?
> >
> > Thanks,
> >
> > Mark
>
>
> >
>

--~--~-~--~~~---~--~~
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: how to use .htc file in django

2007-03-12 Thread OudS



On 3月12日, 下午8时55分, Sam Morris <[EMAIL PROTECTED]> wrote:
> The fix is webserver specific. The Django built-in development web server
> will check /etc/mime.types on Unix, so editing that file is sufficient.

thanks to Sam Morris very much, you remind me, I look over the django
file, it seems that the Django development server does not have the
correct Multipurpose Internet Mail Extension (MIME) information for
the .htc files. The Apache Web server returns the .htc MIME type as
"www/unknown" as Apache server.

thank you again. :D


--~--~-~--~~~---~--~~
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: how to use .htc file in django

2007-03-12 Thread OudS



On 3月12日, 下午9时09分, "Benjamin Slavin" <[EMAIL PROTECTED]>
wrote:

> Also, in the future, please do -not- post this type of question to the
> Django-Dev mailing list.  That list is for use by developers of Django
> itself, not problems end-users are experiencing in their own
> applications (unless, of course, the problem is because of a bug in


I have deleted the topic in django developers. thank you.


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



Re: Trying to get fixtures working - problem with Site

2007-03-12 Thread Chris Moffitt

Russell Keith-Magee wrote:
> Can you provide a specific example? Like I said, I'm adding a unit
> test to cover all the edge cases of serialization - if you have a
> specific example that is failing, I'd like to make sure that your
> example is covered in the test.
>
>   
You hit it.  It was a One to One field that was causing the problem.

Now, I'm moving on to another problem when I try to load the data.  I 
have a place where it thinks there is a Null value but I don't know 
where it is having problems.  I'd suggest that it display a little more 
info about where the problem is, instead of this somewhat vague error-

 ['This field cannot be null.']

Since I have quite a few fields, it would be helpful if it told me what 
field or atleast which model it was getting stuck on.

Thanks,
Chris

--~--~-~--~~~---~--~~
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: Duplicating model/view structure across several Django apps

2007-03-12 Thread akonsu

hello,

but model.py is imported it as any module. what prevents you from just
having it on the PYTHONPATH and not necessarily in the application
directory?

may be i misunderstood the question...

konstantin

On Mar 12, 9:37 pm, "Mark Engelberg" <[EMAIL PROTECTED]> wrote:
> So I've got several applications which share the same model/view
> structure.  I have kept the applications separate because conceptually
> I want them separate in the admin interface, I want them to store
> their respective info in separate tables in the database, and most
> importantly, I want to retain the ability to tweak one without
> affecting the others if it becomes necessary at a later time.
>
> But for now, they are all identical, and I want to avoid duplicating
> the model/view code.  I think I understand how to keep the view code
> in one place, routing the URLs from all the apps to the same views.py
> and templates.
>
> However, it is less clear how to avoid duplicating the models.  It
> appears that to install an app, you need to have a unique subdirectory
> with its own model.py.  I tried having a fairly empty model.py that
> merely imports everything from a master "model.py", but Django doesn't
> seem to see the imported models (for example, syncdb doesn't seem to
> be aware of the imported models).  I'm thinking that on Unix, it might
> be possible to set up a symbolic link to a master model.py, so it
> appears that there are multiple model.py files (one in each app
> directory), but in fact, there is only one.  However, I'm testing this
> on a Windows machine before deploying it, so I'd like to find a
> solution that also works under Windows.
>
> Any suggestions?
>
> Thanks,
>
> Mark


--~--~-~--~~~---~--~~
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: Starting other processes in a view gives me some weird results.

2007-03-12 Thread akonsu

hello,

i do not know what causes this.

i am curious what happens if you replace

return HttpResponse(stdout or stderr)

with

return HttpResponse('hello world')

this is how i would debug
konstantin

On Mar 12, 10:03 pm, "Ino Pua" <[EMAIL PROTECTED]> wrote:
> Quick way of reproducing:
>
>1. Start a new project
>2. Replace urls.py with:
>
> from django.conf.urls.defaults import *
> from django.http import HttpResponse
> import subprocess
>
> def start(request):
> cmdname = request['cmd']
> p = subprocess.Popen([cmdname, 'start'], stdout=subprocess.PIPE)
> stdout, stderr = p.communicate()
> return HttpResponse(stdout or stderr)
>
> def stop(request):
> cmdname = request['cmd']
> p = subprocess.Popen([cmdname, 'stop'], stdout=subprocess.PIPE)
> stdout, stderr = p.communicate()
> return HttpResponse(stdout or stderr)
>
> urlpatterns = patterns('',
> (r'start/$', start),
> (r'stop/$', stop),
> )
>
>3. Start the django server (python manage.py runserver 8080)
>4. Access an url like:http://localhost:8080/start/?cmd=/etc/init.d/exim4,
> or any cmd= that starts a service (anything that daemonizes). You'll
> notice that the loading bar (in my firefox at least) never stops
> loading, even though the django web server is done with the request,
> and the page has been rendered.
>5. If you now stop the server and try to start it again, it wont be
> able to bind to its port:
>
> Validating models...
> 0 errors found.
>
> Django version 0.96-pre, using settings 'starter.settings'
> Development server is running athttp://127.0.0.1:8080/
> Quit the server with CONTROL-C.
> Error: (48, 'Address already in use')
>
> However, at this time, Im not sure whats causing this to happen. Any
> ideas would be appreciated.
>
> Shutting the started service down manually, or accessing the /stop/?
> cmd= url before stopping the django server fixes the problem.


--~--~-~--~~~---~--~~
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 art thou ImageField

2007-03-12 Thread akonsu

the view i think. on a form submission. new forms have save method
too.

konstantin

On Mar 12, 8:46 pm, "gorans" <[EMAIL PROTECTED]> wrote:
> Hmm.. I see the point there.
>
> But where would be the right place to generate the set of thumbs from
> the original image?
>
> On Mar 13, 1:04 am, "akonsu" <[EMAIL PROTECTED]> wrote:
>
>
>
> > hello,
>
> > regarding the last part of your post: i have an unconfirmed suspicion
> > that data validation should not be done in models but in the forms
> > that manipulate data. does anyone know if this is correct?
>
> > konstantin
>
> > On Mar 12, 9:56 am, "gorans" <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm trying to access the value of an image field which is uploaded in
> > > the django admin interface - prior to calling the save.
>
> > > I have a model called Photo with three attributes: large, medium and
> > > small. Each are ImageFields.
>
> > > I have overwritten the save( ) function in Photo so that I can check
> > > that the uploaded file is 800 x 600 px (and then proceed to generate
> > > medium and small) with PIL. However, when I call self.large I end up
> > > with an empty string.
>
> > > How would I access the filename of the uploaded image before the super
> > > (save) has been called? (* I think this problem is happening because I
> > > am using the admin *)
>
> > > Is overwriting the save method the best way to go about this? I am
> > > aware that I could create a custom Field but I would like to avoid
> > > that.
>
> > > Any direction will be greatly appreciated
>
> > > Goran- Hide quoted text -
>
> - Show quoted text -


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



Re: How much work has been done with newforms?

2007-03-12 Thread Rubic

Grupo Django:
> I'm programming a website in django and I'd
> like to know more about newfors, since I left
> the forms to the end, but now I have to start
> with them.

I think newforms is almost production-ready
and  would advise anyone starting a new project
to consider using it in favor of oldforms.

There are some good examples to follow in the
regression tests, in the documentation and at
the djangosnippets.org site.

enquest:
> I only find it hard solve problems as there
> arn't docs about it and I'm still beginning
> python!

enquest, your job is a little harder because
you're still learning Python.  But don't despair!
Try to work out small examples from the resources
above.  Post *small* coding problems here (perhaps
linked to your code posted on dpaste.com) and
you'll probably get answers to your questions.

Good luck. Have fun.

--
Jeff Bauer
Rubicon, Inc.


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



Duplicating model/view structure across several Django apps

2007-03-12 Thread Mark Engelberg

So I've got several applications which share the same model/view
structure.  I have kept the applications separate because conceptually
I want them separate in the admin interface, I want them to store
their respective info in separate tables in the database, and most
importantly, I want to retain the ability to tweak one without
affecting the others if it becomes necessary at a later time.

But for now, they are all identical, and I want to avoid duplicating
the model/view code.  I think I understand how to keep the view code
in one place, routing the URLs from all the apps to the same views.py
and templates.

However, it is less clear how to avoid duplicating the models.  It
appears that to install an app, you need to have a unique subdirectory
with its own model.py.  I tried having a fairly empty model.py that
merely imports everything from a master "model.py", but Django doesn't
seem to see the imported models (for example, syncdb doesn't seem to
be aware of the imported models).  I'm thinking that on Unix, it might
be possible to set up a symbolic link to a master model.py, so it
appears that there are multiple model.py files (one in each app
directory), but in fact, there is only one.  However, I'm testing this
on a Windows machine before deploying it, so I'd like to find a
solution that also works under Windows.

Any suggestions?

Thanks,

Mark

--~--~-~--~~~---~--~~
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: Apache2 displays django app as a file list

2007-03-12 Thread Mikey

That worked!

Thanks for your input - you've put me on the road to dumping 7 years
worth of Microsoft training to learn and use OpenSource!!

On Mar 12, 1:45 am, Daniel Hepper <[EMAIL PROTECTED]> wrote:
> Try to set PythonPath to the path where your project lives, not to your
> django installation:
>
> Replace :
> PythonPath "['/home/mike/downloads/trunk/'] + sys.path"
>
> with:
> PythonPath "['/home/mike/www'] + sys.path"
>
> I hope that does the trick.
>
> Am Sonntag, den 11.03.2007, 09:35 -0700 schrieb Mikey:
>
> > I have mod-python working - I got a test page to work, but I can't
> > seem to get apache to execute python code with in my django app. This
> > is what I get when browsing to the django app..http://www.mydom.net/python
>
> > [DIR] Parent Directory -
> > [   ] __init__.py 11-Mar-2007 08:230
> > [   ] __init__.pyc11-Mar-2007 08:25  123
> > [   ] manage.py   11-Mar-2007 08:23  546
> > [   ] settings.py 11-Mar-2007 08:25  2.8K
> > [   ] settings.pyc11-Mar-2007 08:25  1.8K
> > [DIR] test/   11-Mar-2007 08:54-
> > [   ] urls.py 11-Mar-2007 08:23  225
> > [   ] urls.pyc11-Mar-2007 08:55  220
>
> > I'm a new linux user and probably don't have something configured
> > properly.
>
> > I've followed as much of the online documentation and google help as I
> > can. I have this in a file under sites-enabled
>
> > 
> > ServerName surface
> > DocumentRoot /home/mike/www/
> > 
> > SetHandler python-program
> > PythonHandler django.core.handlers.modpython
> > PythonPath "['/home/mike/downloads/trunk/'] + sys.path"
> > SetEnv DJANGO_SETTINGS_MODULE python.settings
> > PythonDebug On
> > 
> > 
> > SetHandler None
> > 
> > 
>
> > Is is something in this file that I haven't configured properly? I did
> > a 'django-admin.py startproject python in the /home/mike/www/
> > directory
> > Does that mean my DJANGO_SETTINGS_MODULE is python.settings? Any help
> > would be greatly appreciated :)
>
> > Mike.


--~--~-~--~~~---~--~~
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: Playing with fixtures and django serializers -> Errors...

2007-03-12 Thread Russell Keith-Magee

On 3/13/07, Jens Diemer <[EMAIL PROTECTED]> wrote:
>
>
> I'm playing with django.core.serializers... so far with few success :(

Hi Jens,

I've just finished writing a new set of tests for the serializers,
which included fixing a number of bugs. These fixes have been checked
in as of [4719]. Can you retry your tests and see if you still have
problems?

Many Thanks,
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: QueryDict instance is immutable

2007-03-12 Thread limodou

On 3/13/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
> Hi!
> I have created a form using newforms, and one field is author which I
> want to fill using the current username, I did this:
> request.POST['author']="Username I want"
> and I got this error:
> "QueryDict instance is immutable"
> Ok, what should I do? I thought about create a hidden widget for this
> field, but that's not secure enough.
> Is there a way to do what I want?
>
> Thank you!
>
You can do like this:

old = request.POST._mutable
request.POST._mutable = True
for k, v in args.items():
request.POST[k] = v
request.POST._mutable = old

But except you have strong idea, I don't suggest that you do like
above. You can copy() it and the new instance can be changed.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 art thou ImageField

2007-03-12 Thread Jay Parlar

You may want to check out the 'stockphoto' app. Even if you don't use
it directly, it might give you ideas. It seems to handle thumbnails
quite well.

http://www.carcosa.net/jason/software/django/stockphoto/

Jay P.

--~--~-~--~~~---~--~~
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 art thou ImageField

2007-03-12 Thread gorans

Hmm.. I see the point there.

But where would be the right place to generate the set of thumbs from
the original image?

On Mar 13, 1:04 am, "akonsu" <[EMAIL PROTECTED]> wrote:
> hello,
>
> regarding the last part of your post: i have an unconfirmed suspicion
> that data validation should not be done in models but in the forms
> that manipulate data. does anyone know if this is correct?
>
> konstantin
>
> On Mar 12, 9:56 am, "gorans" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm trying to access the value of an image field which is uploaded in
> > the django admin interface - prior to calling the save.
>
> > I have a model called Photo with three attributes: large, medium and
> > small. Each are ImageFields.
>
> > I have overwritten the save( ) function in Photo so that I can check
> > that the uploaded file is 800 x 600 px (and then proceed to generate
> > medium and small) with PIL. However, when I call self.large I end up
> > with an empty string.
>
> > How would I access the filename of the uploaded image before the super
> > (save) has been called? (* I think this problem is happening because I
> > am using the admin *)
>
> > Is overwriting the save method the best way to go about this? I am
> > aware that I could create a custom Field but I would like to avoid
> > that.
>
> > Any direction will be greatly appreciated
>
> > Goran


--~--~-~--~~~---~--~~
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: Trying to get fixtures working - problem with Site

2007-03-12 Thread Russell Keith-Magee

On 3/12/07, Chris Moffitt <[EMAIL PROTECTED]> wrote:
>
> Installing xml fixture 'initial_data' from '/full/path/shop/fixtures'.
> Problem installing fixture '/full/path/shop/fixtures/initial_data.xml':
> Invalid value: 'site' should be a  'django.contrib.sites.models.Site'> instance, not a 
>
> Has anyone else seen this?

Yes, and I'm in the process of fixing it right now. I'm guessing you
have a non-integer primary key in the model that you are deserializing
(a OneToOneField is the most common example). I'm adding some fixes,
and a big whopping unit test to fix this kind of problem.

> I can not use the JSON serializer because it chokes on decimal types.  I
> don't think this is a model issue - it seems to be a problem with the
> serialized handling sites properly.

Can you provide a specific example? Like I said, I'm adding a unit
test to cover all the edge cases of serialization - if you have a
specific example that is failing, I'd like to make sure that your
example is covered in the test.

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: User id foreign key

2007-03-12 Thread Russell Keith-Magee

On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> You have to do something like this in your model:
> user_created = models.ForeignKey(User, related_name="user_created")
>
> Then instead of saying User.entry_set .. I think its just
> user_created_set ... but not positive on that.

Almost, but not quite. Details below.

> You have to do this normally when you have two ForeignKeys on the same
> class both referencing User  ( don't ask me why.. I haven't figured
> that part out yet )

To work out the reason, consider the following example:

class MyModel(models.Model):
user_created = models.ForeignKey(User)

Now, if I have an instance of MyModel, I can find the User instance
that is referenced using instance.user_created.

Following the relation from the other side, I can find out which
MyModel instances are related to a given User using the automatically
created descriptor. The automatically created descriptor takes its
name from the name of the model that created the reference (in this
case, MyModel), so you can reference myuser.mymodel_set, which will
return the set of MyModel instances that contain a foreign key
pointing to myuser.

Now, add a second reference to user:

class MyModel(models.Model):
user_created = models.ForeignKey(User)
other_users = models.ForeignKey(User)

With this defining, a mymodel instance can reference
instance.user_created and instance.other_users, and there are two
reverse descriptors, with the automatic names of mymodel_set and
mymodel_set.

Obviously, this is a name clash. Django can work out when a name clash
like this is going to happen, and forces you to provide an alternate
name when this is the case. The related_name argument is there to
allow you to provide an alternate name to avoid the clash. As a side
effect, it also allows you to provide more meaningful names than the
default 'modelname_set'. So...

class MyModel(models.Model):
user_created = models.ForeignKey(User)
other_users = models.ForeignKey(User, related_name='other_models')

would allow myuser.mymodel_set (instances related through
user_created) and myuser.other_models (instances related through
other_users).

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: Designing for Speed - conditionals inside the view versus the template

2007-03-12 Thread Ned Batchelder
And unless your application is extremely unusual, by far the biggest 
expense is database queries.  More than anything else, this is what 
governs the speed of your application.  So don't worry about where the 
conditionals are being evaluated: worry about how much data you are 
pulling from the database.

Keep in mind that Django's ORM has a lazy evaluation model, so your view 
code could load a context variable with a list of objects from the 
database, and if the template never uses the variable, then the database 
query is never executed.  This means that it can be difficult to 
determine how many queries are really executing unless you actually 
trace the database traffic.

--Ned.

John DeRosa wrote:
> Merric Mercer wrote:
>   
>> I have  view that returns a whole bunch of different variables and 
>> boolean flags.The state of these flags determine what the user 
>> actually sees on their screen.
>>
>>  From a design perspective I seem to have two options:-
>>
>>
>> 1.   Design a template with lots of {% if %} conditional statements to 
>> check the status of various flags, in order to display the appropriate 
>> information to the user.
>>
>> OR
>>
>> 2.   Do the bulk of the work in the view,  by doing something like:-
>> 
> [snip]
>   
>> 3.  Do a combination of the two above
>>
>> Option number 2 lacks the flexibility of doing stuff in the template, 
>> but would it make a big difference in speed?  I am concerned that having 
>> a lot of conditional statements in the template might be slower than 
>> doing the work in the view.
>>
>> Can anybody shed some light on this and the trade off (if any) of speed 
>> versus flexibility.
>> 
>
> A view is Python code, which is compiled into bytecode and then executed 
> by the Python interpreter.  Whereas a template is interpreted by the 
> Python template engine, which is Python code executed by the Python 
> interpreter.
>
> A template will will always have that extra layer of interpretation. 
> Think of it as a new language with a compiler written in Python.  (Which 
> it is...)  So from the smallest perspective, an if-else in a template 
> will always be slower than the equivalent {%if%}-{%else%}-{%endif%} in a 
> view.
>
> But before you pull out a stopwatch and move all of your application's 
> decisions into the views, think about the long-term maintainability, 
> likelihood of bugs, the goodness of separating of "what" code from "how" 
> code, etc.  The history of software is littered with code that was 
> extremely efficient but impossible to maintain or adapt to changing 
> requirements.  You can double your application's performance by buying 
> or leasing a new box + more memory next year.  What % improvement do you 
> think code shifting from template to view will get you?
>
> John
>
>
> >
>
>
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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: Designing for Speed - conditionals inside the view versus the template

2007-03-12 Thread James Bennett

On 3/12/07, Bill de hOra <[EMAIL PROTECTED]> wrote:
> Merric Mercer wrote:
>
> > 1.   Design a template with lots of {% if %} conditional statements
>  >
> > 2.   Do the bulk of the work in the view,  by doing something like:-
> >
> > 3.  Do a combination of the two above
>
> 4: Caching?

5. Start off with just the template, and see how it performs.
Optimizing before you know whether you need to is one of the deadly
sins :)

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



I18n not working

2007-03-12 Thread Christian Hoeppner

Hi there,

Actually, it's plainly that. It's just not working, and I don't really
know where to look for a flaw. It's just a blind guess, but maybe django
is not correctly locating my .mo files? I've triple-checked their
location and tried in every place stated in the documentation or the
django book (beta). Still, it just won't translate anything but the
admin.

Right now, the django.(mo|po) files are in
$PROJECTPATH/locale/es/LC_MESSAGES/

And also, I've tried some variants on the locale name (es, es-es,
es_ES...), although I'm setting the django_language session variable
using the LocaleMiddleware to exactly the same string I'm using for the
locale name on the filesystem.

You know, just to discard any stupid mistakes ;)

Anyone up with an idea?

-- 
Chris M. Hoeppner
Web design & consultancy.
Passionate about experience. Faithfull about copy.
 [EMAIL PROTECTED]
 www.chrishoeppner.com / 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
-~--~~~~--~~--~--~---



QueryDict instance is immutable

2007-03-12 Thread Grupo Django

Hi!
I have created a form using newforms, and one field is author which I
want to fill using the current username, I did this:
request.POST['author']="Username I want"
and I got this error:
"QueryDict instance is immutable"
Ok, what should I do? I thought about create a hidden widget for this
field, but that's not secure enough.
Is there a way to do what I want?

Thank you!


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



Re: Administration features in user pages - SOLVED

2007-03-12 Thread Gilhad


Thank you, so I will do it the same way.

If there is no easier way, this one should be sufficient for me.
At least I will have no bad feeling, that I am doing it by the difficult way, 
when there (maybe) exist another, better one.


On Monday 12 March 2007 16:20, Karen Tracey wrote:
> I don't know of any tutorial/doc that covers how the admin implements
> filters, etc.  When I wanted similar functionality on my user-visible pages
> I just read the admin souce to see how it did it...all in all it wasn't too
> tough to figure out.
>
> Karen
>
> On 3/12/07, Gilhad <[EMAIL PROTECTED]> wrote:
> > Is anywhere some simple tutorial, how to implement such features
> > (filters, sorting, pagination) into my views? Or is the fastest way try
> > to read and understand source of  django/contrib/admin ?
> >
> > Thanks for pointing me, where I should continue with study ...
> >
> > --
> > Zdravi
> >  Gilhad
> >  [EMAIL PROTECTED]
-- 
Zdravi
 Gilhad
 [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: Designing for Speed - conditionals inside the view versus the template

2007-03-12 Thread Bill de hOra

Merric Mercer wrote:

> 1.   Design a template with lots of {% if %} conditional statements
 >
> 2.   Do the bulk of the work in the view,  by doing something like:- 
> 
> 3.  Do a combination of the two above

4: Caching?

cheers
Bill


--~--~-~--~~~---~--~~
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: Filter "Dates"

2007-03-12 Thread Stephen Mizell

> Try doing the filtering first (since filter() returns a QuerySet) and
> then calling dates() on the result. So
>
> Model.objects.filter().dates()

Worked perfectly.  I would have bet money I had tried that earlier,
but it looks like I would have lost that bet.  Thanks for your help
Malcolm!

Stephen Mizell


--~--~-~--~~~---~--~~
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: Permalink decorator and generic views, revisited

2007-03-12 Thread James Bennett

On 3/12/07, dchandek <[EMAIL PROTECTED]> wrote:
> Am I missing something?

It's not that 'permalink' doesn't work with generic views -- it can.
As I understand it, the problem is a URLConf like this:

urlpatterns = patterns('django.views.generic.list_detail',
(r'^foo/(?P\d+)/$', 'object_detail', { 'queryset': Foo.objects.all() }),
(r'^bar/(?P\d+)/$', 'object_detail', { 'queryset': Bar.objects.all() }),
)

The 'get_absolute_url' methods for the 'Foo' and 'Bar' models will
probably be identical:

def get_absolute_url(self):
return ('django.views.generic.list_detail.object_detail', (), {
'id': str(self.id) })
get_absolute_url = permalink(get_absolute_url)

And this is where we get into trouble: we've got two distinct URL
patterns which point to the same view with the same argument signature
(django.views.generic.list_detail.object_detail(id=self.id)). As far
as I know, we currently only return the first matching URL, so in this
case 'get_absolute_url' for both 'Foo' and 'Bar' will return a
'/foo//' URL, because that's the first one it finds that matches.

I *think* that so long as you don't have multiple URLs pointing at the
same generic view you'll be OK, but otherwise there could be issues --
we're working on it.

-- 
"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: Administration features in user pages - newbie

2007-03-12 Thread Gilhad

I will, but there is a lot of documentation about django ... which file/page 
is related to the integration of this features into my code ?

(I can write my filtres and everything, but this is long and duplacate work, 
so I try to reuse the existing features from adminsite, but in my own views, 
which should be enhanced with different "do this" and "do that" links to 
another specialized viewes)

I want to do things in the good way, but I have more other work and some 
deadlines are approching ... and I did not found some obviosly named 
documents about this ... I read the tutorial*.txt legacy_databases.txt 
design_philosophies.txt django-admin.txt db-api.txt and so on, but now I need 
to go directly to the point, or try to program it myself (which is against 
logic and phylosofy of django ...)...


On Monday 12 March 2007 16:24, anders conbere wrote:
> Gilhad,
>
> just read the documentation.
>
> ~ Anders
>
> On 3/12/07, Gilhad <[EMAIL PROTECTED]> wrote:
> >  Is anywhere some simple tutorial, how to implement such features
> > (filters, sorting, pagination) into my views? Or is the fastest way try
> > to read and understand source of  django/contrib/admin ?
> >
> >  Thanks for pointing me, where I should continue with study ...
> >
> > --
> > Zdravi
> >  Gilhad
> >  [EMAIL PROTECTED]

-- 
Zdravi
 Gilhad
 [EMAIL PROTECTED]

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



Permalink decorator and generic views, revisited

2007-03-12 Thread dchandek

I posted previously about how it seemed to me that, while the
permalink decorator is useful in decoupling the get_absolute_url()
methods of an application's models from the site/project, it more or
less forces you to create dummy custom views where you would normally
simply use generic views. Here's what I find myself doing repeatedly:

In models.py:

from django.db.models import permalink
import views

class Item(models.Model):
...
def get_absolute_url(self):
return (views.item_detail, (str(self.id),))
get_absolute_url = permalink(get_absolute_url)


In urls.py (included in project URLconf):

from django.conf.urls.defaults import *
from views import *

urlpatterns = patterns('',
(r'^item/(?P\d+)/$', item_detail),
)


In views.py:

from django.views.generic.list_detail import object_detail,
object_list
import models

def item_detail(request, object_id=None):
return object_detail(request, queryset=models.Item.objects.all(),
object_id=object_id)


Am I missing something?

Thanks,
David


--~--~-~--~~~---~--~~
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: Reversed edit_inline?

2007-03-12 Thread jfagnani



On Mar 11, 8:43 pm, "chasfs" <[EMAIL PROTECTED]> wrote:
> ORM has been contentious for many years - for more background on the
> problems of
> ORM, check out Ted Neward's blog entry 
> -http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science...
>
> Peace,
> -chasfs

That for the link.

Not a bad article (once you wade through the Vietnam stuff). But the
author has only one paragraph on this topic:

"Inheritance mapping isn't the end of it; associations between
objects, the typical 1:n or m:n cardinality associations so commonly
used in both SQL and/or UML, are handled entirely differently: in
object systems, association is unidirectional, from the associator to
the associatee (meaning the associated object(s) have no idea they are
in fact associated unless an explicit bidirectional association is
established), whereas in relational systems the association is
actually reversed, from the associatee to the associator (via foreign
key columns). This turns out to be surprisingly important, as it means
that for m:n associations, a third table must be used to store the
actual relationship between associator and associatee, and even for
the simpler 1:n relationships the associator has no inherent knowledge
of the relations to which it associates--discovering that data
requires a JOIN against any or all associated tables at some point.
(When to actually retrieve that data is a subject of some debate--see
the Loading Paradox, below)."

We already know that associations are reversed between OO and
relational worlds, and it's not really that hard to accommodate,
especially in Django where the relational schema is completely based
off the OO schema.

All that really needs to be done is to either add an attribute to
model.ForeignKey to specify the direction of the association, or to
create a new class to represent this type of association. The DB
schema doesn't need to change at all, but some queries like
get_related() might.

I've heard the argument that Django is only making certain common use
cases simple, and that for any real project "scaffolding is meant to
be torn down". I can only assume that this particular use case
(basically just composition), being pretty elemental to OO design, is
very common. I also hope that newforms will mean that more of the
built-in forms functionality is going to usable in production. As
opposed to having everyone implement their own version, it'd benefit
everyone to have it standardized.

Simon, I hope to implement this also, once things calm down a little.
Feel free to contact me.

-Justin


--~--~-~--~~~---~--~~
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: Filter "Dates"

2007-03-12 Thread Malcolm Tredinnick

On Mon, 2007-03-12 at 19:37 +, Stephen Mizell wrote:
> I'm trying my hardest to make an archive list on our website.  I can
> pull them up fine with Model.objects.dates('pub_date','month') but I
> can't use .filter() on them for some reason.  We add things to the
> database sometimes with a pub_date > today's date so things are
> automatically published in the future.  Is there a way to use
> something to filter these out?
> 
> Model.objects.dates('pub_date','month',
> order='DESC').filter(pub_date__month__lte=date.month,
> pub_date__year__lte=date.year)
> 
> Note: To explain the "lte" on month and year, we want new articles to
> post the first day of each month.  This is why I don't use now().

The .dates() methods returns a DateQuerySet, not a QuerySet. It's
intended to be the last thing in the sequence of methods that you call.
A DateQuerySet is a subset of QuerySet, but because it's had the query
slightly altered to return only the dates, it doesn't have the full
flexibility for further actions that a QuerySet does. That might well be
biting you here.

Try doing the filtering first (since filter() returns a QuerySet) and
then calling dates() on the result. So

Model.objects.filter().dates()

Remember that method calls are evaluated left to right, so you can't
just put them in any order if they return slightly different results.

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: Accesing a property and methd in the admin site

2007-03-12 Thread Malcolm Tredinnick

On Mon, 2007-03-12 at 17:37 +, hass wrote:
> I just got my first django app up: http://brackets.bracketboy.net/ Not
> very impressive, but I'm still excited about it. anyway . . .
> 
> 
> I'm having trouble accesing a method through the admin interface as
> part of a choices list. It seems to work fine throughout the site and
> the admin interface, but not in choices selection. In the choices I
> get .  Any ideas?
> 
> Some of the relevant code:
> 
>   def _get_team_2(self):
>   if self.round == 1 :
> return
> Team.objects.filter(seed=self.seed_2).filter(region=self.region)
> [0].name
> 
>   else:
> prev_game =   Game.objects.get( id = self.id ).prev_game_2_id
> prev_winner = Game.objects.get( id = prev_game ).winner.id
> returnTeam.objects.get( id = prev_winner ).name
> 
>   team_2 = property( _get_team_2)
> 
>   winner = models.IntegerField(choices=((team_1.id, team_1),
> (team_2.id, team_2),),)

It's not completely clear what is going wrong here, but this
construction (of the "winner" attribute) looks dangerous. The "choices"
attribute is largely meant to take a sequence of static pairs, since it
is populated at import time. You seem to be trying to populate it with
something dynamic, which could fail in a number of interesting ways.

It is possible to use an iterator as the argument for the "choices"
attribute and maybe that is what you want to use (see the wiki for
details), but the way you are doing it at the moment looks like it's
bound to not work consistently.

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: Image and File Field hard coded sizes

2007-03-12 Thread Malcolm Tredinnick

On Mon, 2007-03-12 at 09:29 -0700, Brendon wrote:
> Hello folks,
> 
> I'm curious if there is a better way of changing File and Image Fields
> from "varchar(100)" to "varchar(%(maxlength)s)" than editing "django/
> db/backends/mysql/creation.py". Is there any particular reason why
> these are hard set? My relative paths seem to have exceeded the 100
> char limit which is why I'm asking!

A change to fix this (make the length longer) will be committed after
0.96. I'm intentionally not committing it beforehand because it is a
backwards incompatible change in the sense that every database using
such a field will need to alter the respective column in the database
(there is now the possibility of submitting a string longer than 100
chars, so it had better fit in the database column).

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



Study & Work in USA - These people are arranging everything for us.

2007-03-12 Thread Charles

Hi Friends,
Greetings!!

I was searching for information on Study & WORK IN USA & reached to
this very much informative site, www.sonal.coolgoose.in, I would like
to tell you more about STUDY & WORK IN USA.

There are so many universities waiting for us to join them for our
further studies and you know even we can get our studies SPONSORED too
& even we get 4 HOURS A DAY WORK PERMIT too if we go there to study.

Guys we have enough knowledge to study further & even work there... You
know this www.sonal.coolgoose.in people are ARRANGING EVERYTHING FOR
US to reach there with sponsorship, loans, accommodation, jobs & even
THEY ARE GUIDING FOR RE-ENTRY TOO.

I strongly recommend this site and even counselor is also very good
knowledgeable.

I'll keep you guys posted for more information if I'll have in future
& I would expect the same from you guys...

Till then cheers guys.

Thank you & Best regards...

Charles...


--~--~-~--~~~---~--~~
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 effects Python time/datetime and gives wrong time after DST update

2007-03-12 Thread Malcolm Tredinnick

On Mon, 2007-03-12 at 11:53 -0300, Ramiro Morales wrote:
> On 3/12/07, DavidA <[EMAIL PROTECTED]> wrote:
> >
> > I found a workaround but I'm not sure what the ramifications are. I
> > commented out this line in django.conf.__init__.py:
> >
> > os.environ['TZ'] = self.TIME_ZONE
> >
> 
> What version/revision of Django are you using?.
> 
> See ticket #2315 and changeset [4487] for some work donde
> in the Windows time zone stuff front.

By the way, if anybody wants a fun little side project and enjoys doing
Windows development, they could write some decent win32 timezone support
stuff for us. There are obviously ways to do it (although the idea would
be not to corrupt the whole server's idea of timezone -- just the
current process), but it's not the same as the Unix world and so some
specialist knowledge is required.

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: Any known issues with ChangeManipulators and large objects?

2007-03-12 Thread Malcolm Tredinnick

On Mon, 2007-03-12 at 10:27 -0700, Joseph Heck wrote:
> Kudo's to Ivan - It's a pretty good answer. I think the metaphor
> breaks down when you get to >1000 items that could pop up in a select
> field, but at least you don't get his when just using a plain-jane
> manipulator with this fix. 
> 
> I think I'll stick with the tendency towards using raw_id_admin=True
> myself, but then I don't need anything populated into a large
> pulldown. My case would have a pulldown of 30K+ items, which just
> doesn't make sense for a UI. 

I think that's the important thing here: we are currently paying a
performance penalty for retrieving all the related foreign key elements,
even in cases when it was impractical to display them. 

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



Filter "Dates"

2007-03-12 Thread Stephen Mizell

I'm trying my hardest to make an archive list on our website.  I can
pull them up fine with Model.objects.dates('pub_date','month') but I
can't use .filter() on them for some reason.  We add things to the
database sometimes with a pub_date > today's date so things are
automatically published in the future.  Is there a way to use
something to filter these out?

Model.objects.dates('pub_date','month',
order='DESC').filter(pub_date__month__lte=date.month,
pub_date__year__lte=date.year)

Note: To explain the "lte" on month and year, we want new articles to
post the first day of each month.  This is why I don't use now().

Thanks!

Stephen Mizell


--~--~-~--~~~---~--~~
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: How much work has been done with newforms?

2007-03-12 Thread Brendon

On Mar 12, 3:59 am, "Grupo Django" <[EMAIL PROTECTED]> wrote:
> Hello, I'd like to know how is the work going with newforms. I don't
> want a release date or something like this, just to know how is it
> going, and the documentation as well.
> I'm programming a website in django and I'd like to know more about
> newfors, since I left the forms to the end, but now I have to start
> with them.
> Thank you.

I just started using Django and chose to begin using newforms. I would
say that the code seems quite complete, however, the documentation is
not. You will probably have to figure them out as best you can using
previous posts to this group, the docs on the site and the newforms
test scripts:

http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py

This is what I've had to do but I think it has been worth it.


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



Re: Django keeps growing, performance keeps dropping

2007-03-12 Thread Joseph Heck
Take a shot at enabling the profiling (Jeremy provided a link a few msgs
back) - it'll give you a huge amount of detail.

-joe

On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Well crud. My host won't turn on slow query logging. So, if you know
> you've got a bunch of not-so-good queries (as shown above), how would
> one try to spot them?
>
>
>
> On Mar 10, 4:58 pm, "gilhad" <[EMAIL PROTECTED]> wrote:
> > On Mar 7, 4:26 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
> >
> > > My site just keeps getting bigger and bigger, and the performance has
> > > gotten excruciatingly slow.
> > > ...
> > > Problem is, I really don't know what to do about it, or even what I
> > > need to be looking at, really. I've gone through and looked at the
> > > views and removed imports I didn't need (I had a lot of import * type
> > > statements), but that only helped a little. I've tried figuring out
> > > select_all, but don't know if that would really help me or not.
> >
> > (-; Very simple test: copy this code to another diretory, attach it to
> > another nearly empty database and if it hugely speeds up thinks, then
> > the problem is not in including libraries, but in having big database
> > and/or bad algorithm for data manipulation. So there lies the way to
> > get more speed  ;-)
>
>
> >
>

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



Playing with fixtures and django serializers -> Errors...

2007-03-12 Thread Jens Diemer


I'm playing with django.core.serializers... so far with few success :(

With JSON i get the Error: "ContentType matching query does not exist."

If i use the "python" format, i get from serializers.serialize() a list. 
How should I to store these list in a file? With pickle, repr() or 
unicode()???

With pickle, i got the Error: "can't pickle array objects"

if i use "python" and store the result with repr() or unicode() in a 
file... I got an error, if i load the file and deserialize it:

   File ".\django\core\serializers\python.py", line 59, in Deserializer
 Model = _get_model(d["model"])
TypeError: string indices must be integers



If i use the "xml" format, i get an Error if i deserialize the 
serialized string:

   File "serializers_test.py", line 77, in test_xml
 for object in objects2:
   File ".\django\core\serializers\xml_serializer.py", line 115, in next
 return self._handle_object(node)
   File ".\django\core\serializers\xml_serializer.py", line 155, in 
_handle_object
 value = 
field.to_python(getInnerText(field_node).strip().encode(self.encoding))
   File ".\django\db\models\fields\__init__.py", line 525, in to_python
 raise validators.ValidationError, gettext('Enter a valid date/time 
in -MM-DD HH:MM format.')
django.core.validators.ValidationError: ['Enter a valid date/time in 
-MM-DD HH:MM format.']


I examined this. The XML file is correct. In the DB (the source) i have 
datetime fields with a NULL value.


XML file cutout:


   0
   managePages
   core
   blabla
   
   None
   




The Traceback is interesting (cutout):

.\django\core\serializers\xml_serializer.py in _handle_object line 155:

Model: 

data: {'description': 'This group is able to add/edit/delete pages.', 
'id': u'1', 'name': 'managePages', 'pluginID': '0', 'section': 'core'}

field: 
field_name: u'lastupdatetime'
field_node: 
m2m_data: {}
node: 
pk: u'1'
self:
value: 'blabla'


In 'data' i missing the keys 'lastupdatetime' and 'createtime'.
I find field_name == 'lastupdatetime', but value == 'blabla' also 
amusing. Because you can see from above: 'blabla' is the value for the 
key 'description' and not from 'lastupdatetime'

-- 
Mfg.

Jens Diemer



CMS in pure Python CGI: http://www.pylucid.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
-~--~~~~--~~--~--~---



Re: Chaining ManyToMany Filters Update

2007-03-12 Thread Gerard Whittey



Boris Smus wrote:
> On Mar 12, 6:56 am, Tim Chase <[EMAIL PROTECTED]>
> wrote:>
>> cs.filter(
>> Q(default_recipe__ingredients__ingredient__id=3) |
>> Q(default_recipe__ingredients__ingredient__id=1)
>> )
> 
> Just to clarify, I was trying to get AND functionality, as Konstantin
> suggested. I also tried with Q models, using the same expression as
> Tim gave, except s/|/,/. This gave the same erroneous result.
> 
> Thank you Tim for your custom SQL suggestion, I'll try to do something
> to that effect as a temporary solution. Something is still broken
> inside Django's m2m QuerySet filtering, however. Does anyone know the
> status of that?
> 
> 
> > 

--~--~-~--~~~---~--~~
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: Chaining ManyToMany Filters Update

2007-03-12 Thread Boris Smus

On Mar 12, 6:56 am, Tim Chase <[EMAIL PROTECTED]>
wrote:>
> cs.filter(
> Q(default_recipe__ingredients__ingredient__id=3) |
> Q(default_recipe__ingredients__ingredient__id=1)
> )

Just to clarify, I was trying to get AND functionality, as Konstantin
suggested. I also tried with Q models, using the same expression as
Tim gave, except s/|/,/. This gave the same erroneous result.

Thank you Tim for your custom SQL suggestion, I'll try to do something
to that effect as a temporary solution. Something is still broken
inside Django's m2m QuerySet filtering, however. Does anyone know the
status of that?


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



Accesing a property and methd in the admin site

2007-03-12 Thread hass

I just got my first django app up: http://brackets.bracketboy.net/ Not
very impressive, but I'm still excited about it. anyway . . .


I'm having trouble accesing a method through the admin interface as
part of a choices list. It seems to work fine throughout the site and
the admin interface, but not in choices selection. In the choices I
get .  Any ideas?

Some of the relevant code:

  def _get_team_2(self):
  if self.round == 1 :
return
Team.objects.filter(seed=self.seed_2).filter(region=self.region)
[0].name

  else:
prev_game =   Game.objects.get( id = self.id ).prev_game_2_id
prev_winner = Game.objects.get( id = prev_game ).winner.id
returnTeam.objects.get( id = prev_winner ).name

  team_2 = property( _get_team_2)

  winner = models.IntegerField(choices=((team_1.id, team_1),
(team_2.id, team_2),),)


(Since the winner field is just storing id's, I had initlaly hoped to
do it with a foreign key and limit_choices_to, but I wasn't able to
even get that close. But that's a question for another day, unless
somebody has the answer)


--~--~-~--~~~---~--~~
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: low performance of FastCGI deployment

2007-03-12 Thread Joseph Heck
Have you done any profiling to see where your bottlenecks are? There's a
decent set of notes on profiling Django at
http://code.djangoproject.com/wiki/ProfilingDjango and an even greater
writeup at
http://www.rkblog.rk.edu.pl/w/p/django-profiling-hotshot-and-kcachegrind/.

Apache+Mod_Python and Lighttpd+FastCGI have both rendered out (very simple)
pages in the sub 100ms range for me. I'd look to the code and see exactly
where the bottlenecks are happening.

-joe

On 3/12/07, Alexander Boldakov <[EMAIL PROTECTED]> wrote:
>
>
> Hello all,
>
> My django application runs slower under Apache+FastCGI or
> Lighttpd+FastCGI than under django development HTTP server. The
> approximate times for generating the page are 0.6 vs 1.0 seconds for
> FastCGI and development server correspondingly.
>
> I've tried different combinations of 'prefork' and 'threaded', unix
> domain socket and tcp socket, manually/web server started fastcgi
> server as described on django FastCGI documentation page, but nothing
> helped.
>
> If you have any idea of solving this problem, i will greatly
> appreciate it!
>
> Django version is 0.95. Python version is 2.4.4. Apache version is
> 2.2.3. Flup version is 0.5.
>
> Alexander Boldakov
>
>
> >
>

--~--~-~--~~~---~--~~
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: Any known issues with ChangeManipulators and large objects?

2007-03-12 Thread Joseph Heck
Kudo's to Ivan - It's a pretty good answer. I think the metaphor breaks down
when you get to >1000 items that could pop up in a select field, but at
least you don't get his when just using a plain-jane manipulator with this
fix.

I think I'll stick with the tendency towards using raw_id_admin=True myself,
but then I don't need anything populated into a large pulldown. My case
would have a pulldown of 30K+ items, which just doesn't make sense for a UI.

-joe

On 3/12/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
>
> On Mon, 2007-03-12 at 17:37 +1100, Malcolm Tredinnick wrote:
> > On Mon, 2007-03-12 at 05:00 +, [EMAIL PROTECTED] wrote:
> > > I was just wondering if there were any known issues regarding speed
> > > with ChangeManipulators and large objects?
> > >
> > > I'm using custom ChangeManipulators successfully on about 50 pages
> > > right now... but when I did an edit page for one of my largest
> > > database tables ( about 50 columns... and about 20 of them are foreign
> > > keys to other objects that also contain foreign keys ), my page load
> > > time shot up to about 30 seconds.
> > >
> > > If I comment out the line where I instantiate the custom change
> > > manipulator..and just pass None in for the Form ... it loaded fast
> > > (obviously blank forms load fast..heh).  So then I decided to rewrite
> > > the page using old fashioned forms where I set the values on each
> > > field in the template via the object...and it went really fast then
> > > too.
> > >
> > > I could paste the code in here..but I wasn't doing anything fancy.. I
> > > was just flattening the data from all of the objects...then loading
> > > the form...so thought I'd ask on the off chance if others had seen
> > > this happen?
> >
> > Unfortunately there is a problem in that case (foreign keys with lots of
> > related data). It is ticket #2638.
>
> It also looks like the patch in #3436 might be a solution for this. That
> has the sort of solution I was hoping for in #2638.
>
> 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
-~--~~~~--~~--~--~---



Jobs Vs Opportunity - The Movie

2007-03-12 Thread mike

Jobs Vs Opportunity - The Movie

www.thewealththeory.com/beyond-freedom

This is excellent!
If you haven't already watched, it check it out 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: django install on mac osx 10.4.8

2007-03-12 Thread Jay Parlar

On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> nope i do it from home, never had any problem before, not like i would
> really have known anyway got problem all the time :),
> problem isntalling this and that, problem installing rails and so on.
> shame i really want to give a try at django reviews looks good, better
> than rail for a designer like me.
>

I recommend staying away from DarwinPorts. It sometimes works very
nicely, other times, not so much.

I would instead install Python2.4 and sqlite2 from
http://pythonmac.org/packages/py24-fat/index.html

(As you're running Tiger, sqlite itself is already installed, you just
need the Python wrappers).

Then install subversion from
http://www.codingmonkeys.de/mbo/Subversion-1.4.3.pkg.zip

Then install Django via svn (the install document says how to do that).

Jay P.

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

2007-03-12 Thread theju

There is something called as Full text Search (i believe it is called
TSearch2...not sure of the name though) in postgresql. Google for
further info.
If you use some other database you might have to use:
1) Xapian http://www.xapian.org
2) pyLucene  http://pylucene.osafoundation.org/
3) Swish-E (I don't have the exact URL but remember seeing it
somewhere in the Python Cheeseshop).
Hope you find this information useful.

-Thejaswi Puthraya

On Mar 12, 4:09 pm, "Mary" <[EMAIL PROTECTED]> wrote:
> is there any search  functionality that has been implemented with
> Django for postgresql database
> As i need to add search in my website and i don't know from where i
> can start
> Any help will be very appreciated
>
> Thank you in advance;
> Mary Adel


--~--~-~--~~~---~--~~
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: High Fidelity Slugify : support for international characters

2007-03-12 Thread Aidas Bendoraitis

There were similar tryings to create international slugification before:
http://groups.google.com/group/django-users/browse_thread/thread/6942f87bed76a536/8d38392e25dd1974

But your approach seems to be more generic. You should certainly post
it on djangosnippets.org as a separate snippet or (maybe better) as an
extension suggestion for http://www.djangosnippets.org/snippets/98/

Regards,
Aidas Bendoraitis [aka Archatas]


On 3/12/07, Sam <[EMAIL PROTECTED]> wrote:
>
> I needed slugify to be more precise with accented characters and i
> couldn't find some code to do it, so here it is :
>
> http://amisphere.com/contrib/python-django/slughifi.py
>
> http://amisphere.com/contrib/python-django/ for a quick overview
>
> example :
> >>> text = "C'est déjà l'été."
> >>> slughifi(text, overwrite_char_map={u"'": "-",})
> 'c-est-deja-l-ete'
>
> Any comments ?
>
>
> >
>

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



error in django admin module

2007-03-12 Thread Paul Rauch

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I found an error in django.
I use python 2.5
the error occurs both in the actual official released version and in the
svn version.

as soon as I enter the adminpage I get following error, if I have a
sessioncookie.

without sessioncookie no error occurs, but I can't login, cause django
needs the cookie.

Traceback (most recent call last):
File "/usr/lib64/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File
"/usr/lib64/python2.5/site-packages/django/contrib/admin/views/decorators.py"
in _checklogin
  49. if request.user.is_authenticated() and request.user.is_staff:
File
"/usr/lib64/python2.5/site-packages/django/contrib/auth/__init__.py" in
get_user
  71. user_id = request.session[SESSION_KEY]
File
"/usr/lib64/python2.5/site-packages/django/contrib/sessions/middleware.py"
in __getitem__
  20. return self._session[key]
File
"/usr/lib64/python2.5/site-packages/django/contrib/sessions/middleware.py"
in _get_session
  60. self._session_cache = s.get_decoded()
File
"/usr/lib64/python2.5/site-packages/django/contrib/sessions/models.py"
in get_decoded
  61. encoded_data = base64.decodestring(self.session_data)
File "/usr/lib64/python2.5/base64.py" in decodestring
  321. return binascii.a2b_base64(s)

  TypeError at /test/admin/
  a2b_base64() argument 1 must be string or read-only character buffer,
not array.array
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iQIVAwUBRfV/7hG67lyyQrltAQLOyRAAiug7/lFdIXim4HVwhJnbY9EdAEv043Ad
fOt3HdKm4Seay9DwNSbPGo03zQrQSCjRGSYaeUpSsv0SEkL8I1+0+R8CeV3sQ5L6
yNH5NabNeGYWgaJdb7N8TqmHI9h4/AuyuPrUlxDPB/BuvzPQLn5CnqluuCfjjJoi
IThbVycndiXpPcK4oqUOXKTtgDToz0UjxICF6t3EocceKGQsEJVZkn/TChmGBjZS
jjE6Cnk7A1Unofa5RKQ1wufMbshBq9VEBDItOs4Secr+Z3k1gNjteMHkXt6efSxH
tmO3OZQxnDTS4oOLAuUcNQoaXTSX1YxI0T6rQANKQYDTVyKHPPngSmqq/jCGk9CR
CdC3KgugjKI2Teur2MUPK9qivSpiB+KbFM27tBO3FjYI7zCDe2l/i5mb/RCf24U7
TLqS/MuSJzCMqZG8oKd6ox/cNOx41OBTBPh0EXG/JyaTbIXYS9sUmQx4dhljVBEf
seYeMfaK3gCda67cxfkQAWI8TccB8GFMwflQMq+xmmDlej0jBVbxRBw0jSLYJZVb
kX+5Kvc9zB/jKzw5RrT7pX0xGEemeesUXaYXwXHlTyz3lYsAY+f3qXDjfzDHWG6p
bskPHXPr6ts3AbUorLs7VF2vTx7q4JGr1KyOdtr32IZYfAoudJChzK43bwhgLOs2
Sso1V2eCl8c=
=XRB8
-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
-~--~~~~--~~--~--~---



Image and File Field hard coded sizes

2007-03-12 Thread Brendon

Hello folks,

I'm curious if there is a better way of changing File and Image Fields
from "varchar(100)" to "varchar(%(maxlength)s)" than editing "django/
db/backends/mysql/creation.py". Is there any particular reason why
these are hard set? My relative paths seem to have exceeded the 100
char limit which is why I'm asking!

Brendon


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

2007-03-12 Thread akonsu

hello,

yes, there is search functionality called database API:

http://www.djangoproject.com/documentation/db_api/

do you have anything specific in mind?

konstantin

On Mar 12, 7:09 am, "Mary" <[EMAIL PROTECTED]> wrote:
> is there any search  functionality that has been implemented with
> Django for postgresql database
> As i need to add search in my website and i don't know from where i
> can start
> Any help will be very appreciated
>
> Thank you in advance;
> Mary Adel


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



mysql problems - guess not, but still :)

2007-03-12 Thread Michal Jedryszka

Hi.
We have some intresting situations in one of our environments.

1. When we generate request that causes object not found errors after
5 such requests we get info that we cannot connect DB. Looks like some
connection limitation but we cant reproduce it in other environments.

2. Occures when user has opened browser (opened session i guess)
during apache restart. After restart when user is refreshing page
content receives information that he can't connect to db.

We are using django.contrib.auth and django.contrib.sessions

Does anyone has similar issues, or maybe know origins of such behave.

Kind regards


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Designing for Speed - conditionals inside the view versus the template

2007-03-12 Thread John DeRosa

Merric Mercer wrote:
> I have  view that returns a whole bunch of different variables and 
> boolean flags.The state of these flags determine what the user 
> actually sees on their screen.
> 
>  From a design perspective I seem to have two options:-
> 
> 
> 1.   Design a template with lots of {% if %} conditional statements to 
> check the status of various flags, in order to display the appropriate 
> information to the user.
> 
> OR
> 
> 2.   Do the bulk of the work in the view,  by doing something like:-
[snip]
> 3.  Do a combination of the two above
> 
> Option number 2 lacks the flexibility of doing stuff in the template, 
> but would it make a big difference in speed?  I am concerned that having 
> a lot of conditional statements in the template might be slower than 
> doing the work in the view.
> 
> Can anybody shed some light on this and the trade off (if any) of speed 
> versus flexibility.

A view is Python code, which is compiled into bytecode and then executed 
by the Python interpreter.  Whereas a template is interpreted by the 
Python template engine, which is Python code executed by the Python 
interpreter.

A template will will always have that extra layer of interpretation. 
Think of it as a new language with a compiler written in Python.  (Which 
it is...)  So from the smallest perspective, an if-else in a template 
will always be slower than the equivalent {%if%}-{%else%}-{%endif%} in a 
view.

But before you pull out a stopwatch and move all of your application's 
decisions into the views, think about the long-term maintainability, 
likelihood of bugs, the goodness of separating of "what" code from "how" 
code, etc.  The history of software is littered with code that was 
extremely efficient but impossible to maintain or adapt to changing 
requirements.  You can double your application's performance by buying 
or leasing a new box + more memory next year.  What % improvement do you 
think code shifting from template to view will get you?

John


--~--~-~--~~~---~--~~
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: BooleanField won't update

2007-03-12 Thread [EMAIL PROTECTED]

Looks like some weird behavior.

I fixed it like this:

def update_snip(request):
u = User.objects.get(id=request.session['userid'])
snip = Snippet.objects.filter(id=snippet_id,user=u)
the_snip = snip[0]
the_snip.active = 0
the_snip.save()
print "Active = %s" % the_snip.active

If someone wants to explain that to me I would appreciate it.

david

On Mar 12, 10:10 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have a class call snippet:
>
> class Snippet(models.Model):
>
> user = models.ForeignKey(User)
> entry = models.ForeignKey(Entry)
> commentary = models.ForeignKey(Commentary)
> date_created = models.DateTimeField(auto_now_add=True)
> active = models.BooleanField(default=True)
> snippet = models.TextField()
> sortorder = models.IntegerField(blank=True)
>
> The active field is a Boolean. For some reason, I cannot ever update
> this to "False" or "0" - from my view function. from python it works.
>
> I also chnaged the BooleanField to an IntergerField with the same
> results.
>
> here is the view function:
>
> def update_snip(request):
> u = User.objects.get(id=request.session['userid'])
> snip = Snippet.objects.filter(id=snippet_id,user=u)
> snip[0].active = 0
> snip[0].save()
> print "Active = %s" % snip[0].active
>
> This NEVER works. What am I doing wrong?
>
> David


--~--~-~--~~~---~--~~
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 install on mac osx 10.4.8

2007-03-12 Thread [EMAIL PROTECTED]

nope i do it from home, never had any problem before, not like i would
really have known anyway got problem all the time :),
problem isntalling this and that, problem installing rails and so on.
shame i really want to give a try at django reviews looks good, better
than rail for a designer like me.

cheers Jay

On Mar 12, 3:58 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > well i tried with the forewall and offan it return the same error all
> > the time.
>
> Sorry, I misspoke. I didn't mean firewall, the firewall should have no
> effect. I actually meant proxy. Many corporate environments are behind
> proxies that screw up urllib until you configure things properly.
>
> Jay P.


--~--~-~--~~~---~--~~
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 install on mac osx 10.4.8

2007-03-12 Thread Jay Parlar

On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> well i tried with the forewall and offan it return the same error all
> the time.

Sorry, I misspoke. I didn't mean firewall, the firewall should have no
effect. I actually meant proxy. Many corporate environments are behind
proxies that screw up urllib until you configure things properly.

Jay P.

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



Jobs Vs Opportunity - The Movie

2007-03-12 Thread mike

Jobs Vs Opportunity - The Movie

www.thewealththeory.com/beyond-freedom.com

This is excellent!
If you haven't already watched, it check it out 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: Django effects Python time/datetime and gives wrong time after DST update

2007-03-12 Thread DavidA

Thanks. I am on trunk, 4227 so I don't have this fix.

On Mar 12, 10:53 am, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On 3/12/07, DavidA <[EMAIL PROTECTED]> wrote:
>
>
>
> > I found a workaround but I'm not sure what the ramifications are. I
> > commented out this line in django.conf.__init__.py:
>
> > os.environ['TZ'] = self.TIME_ZONE
>
> What version/revision of Django are you using?.
>
> See ticket #2315 and changeset [4487] for some work donde
> in the Windows time zone stuff front.
>
> Regards,
>
> --
>  Ramiro Morales


--~--~-~--~~~---~--~~
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: Multi-tenant database

2007-03-12 Thread James Bennett

On 3/12/07, zin <[EMAIL PROTECTED]> wrote:
> Is Django suitable for multi-tenant database application? i.e.
> combining username and company_id as primary key

Django does not currently have support for composite keys. You can
fake this to a certain extent with unique_together, but from Django's
point of view only one column will be treated as the primary key.

-- 
"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: Administration features in user pages - newbie

2007-03-12 Thread anders conbere

Gilhad,

just read the documentation.

~ Anders

On 3/12/07, Gilhad <[EMAIL PROTECTED]> wrote:
>
>
>  Is anywhere some simple tutorial, how to implement such features (filters,
> sorting, pagination) into my views? Or is the fastest way try to read and
> understand source of  django/contrib/admin ?
>
>  Thanks for pointing me, where I should continue with study ...
>
> --
> Zdravi
>  Gilhad
>  [EMAIL PROTECTED]
>
> >
>

--~--~-~--~~~---~--~~
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: Administration features in user pages - newbie

2007-03-12 Thread Karen Tracey
I don't know of any tutorial/doc that covers how the admin implements
filters, etc.  When I wanted similar functionality on my user-visible pages
I just read the admin souce to see how it did it...all in all it wasn't too
tough to figure out.

Karen

On 3/12/07, Gilhad <[EMAIL PROTECTED]> wrote:
>
>
>
> Is anywhere some simple tutorial, how to implement such features (filters,
> sorting, pagination) into my views? Or is the fastest way try to read and
> understand source of  django/contrib/admin ?
>
> Thanks for pointing me, where I should continue with study ...
>
> --
> Zdravi
>  Gilhad
>  [EMAIL PROTECTED]
>
> >
>

--~--~-~--~~~---~--~~
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: Unique_together question

2007-03-12 Thread Rob J Goedman

Thanks Ramiro,

Thanks for the pointer and hint. Next time I will search there first.

That indeed gets it through the validator.  The error seems to be  
caught by some
lower level (db?), but for now that works.

Thanks again,
Rob

On Mar 11, 2007, at 4:45 PM, Ramiro Morales wrote:

>
> On 3/11/07, Rob J Goedman <[EMAIL PROTECTED]> wrote:
>
>>
>> Any reason I can't combine these 2 fields to get a valid  
>> 'isUniqueday_sch'
>> in the AddManipulator? Full traceback at the end of the email.
>>
>
> This is a problem already reported. See tickets #526 and #2470,  
> there is a
> workaround described in the comments that involves changing the  
> order of the
> fields  in unique_together.
>
> Regards,
>
> -- 
>  Ramiro Morales
>
> >


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



BooleanField won't update

2007-03-12 Thread [EMAIL PROTECTED]

I have a class call snippet:

class Snippet(models.Model):

user = models.ForeignKey(User)
entry = models.ForeignKey(Entry)
commentary = models.ForeignKey(Commentary)
date_created = models.DateTimeField(auto_now_add=True)
active = models.BooleanField(default=True)
snippet = models.TextField()
sortorder = models.IntegerField(blank=True)


The active field is a Boolean. For some reason, I cannot ever update
this to "False" or "0" - from my view function. from python it works.

I also chnaged the BooleanField to an IntergerField with the same
results.

here is the view function:

def update_snip(request):
u = User.objects.get(id=request.session['userid'])
snip = Snippet.objects.filter(id=snippet_id,user=u)
snip[0].active = 0
snip[0].save()
print "Active = %s" % snip[0].active

This NEVER works. What am I doing wrong?

David


--~--~-~--~~~---~--~~
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: dict object is not callable (newforms/forms.py full_clean)

2007-03-12 Thread akonsu

hello,

i think render_to_response takes a Context object not a dict as the
second parameter.

konstantin

On Mar 12, 10:56 am, "DvD" <[EMAIL PROTECTED]> wrote:
> I got the same problem in a different context:
>
> 
> Exception Type: TypeError
> Exception Value:'dict' object is not callable
> Exception Location: /usr/lib/python2.4/site-packages/Django-0.95.1-
> py2.4.egg/django/newforms/forms.py in full_clean, line 180
> 
>
> Can someone help?
>
> On 5 Feb, 11:29, Antonio <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all,
>
> > I'm trying to use a ManyToManyField between two tables ... the models are
> > this:
>
> > class Rim(models.Model):
> > nome = models.CharField(maxlength=30)
>
> > def __str__(self):
> > return self.nome
>
> > class Previsione(models.Model):
> > nave = models.CharField(maxlength=50)
> > data = models.DateField()
> > grt = models.PositiveSmallIntegerField()
> > naz = models.CharField(maxlength=10)
> > h_inizio = models.TimeField()
> > rims = models.ManyToManyField(Rim)
>
> > into te views.py:
>
> > def previsione(req, varid=None):
> > if req.method == 'POST':
> > myform = nf.models.form_for_model(Previsione)(req.POST)
>
> > if myform.is_valid():
> > dati = Previsione(**myform.clean_data)
> > dati.save()
>
> > return HttpResponseRedirect('.')
> > else:
> > if varid is None:
> > myform = nf.models.form_for_model(Previsione)()
> > else:
> > instance = get_object_or_404(Previsione, pk=varid)
> > myform = nf.models.form_for_instance(instance)
>
> > return render_to_response('create_form.html', \
> > { 'titolo': 'Archivio Previsioni',
> > 'form': myform.as_table() })
>
> > when I'm trying to save the form (with one or many rims selected) I've this
> > error:
>
> > Exception Type: TypeError
> > Exception Value: 'dict' object is not callable
> > Exception Location: 
> > /usr/local/python2.5/site-packages/django/newforms/forms.py
> > infull_clean, line 167
>
> > [EMAIL PROTECTED]: django_src# svn update
> > At revision 4459.
>
> > can someone help me ?
>
> > tanks in advance ... and sorry for my english 
>
> > --
> > #include 
> > int main(void){char 
> > c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
> > 101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,­­101,
> > 116,46,105,116,62,10,10,0};printf("%s",c);return 0;}- Hide quoted text -
>
> - Show quoted text -


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



Trying to get fixtures working - problem with Site

2007-03-12 Thread Chris Moffitt

I've been trying to get the fixtures working in order to beef up the unit
tests with my app.  I'm running into an issue and wonder if anyone else
has seen this.

I can serialize the data just fin.  When I try to load the data, I get the
error below.  I've tried this with the XML and brand new PyYaml serializer
and get the same error:


Installing xml fixture 'initial_data' from '/full/path/shop/fixtures'.
Problem installing fixture '/full/path/shop/fixtures/initial_data.xml':
Invalid value: 'site' should be a  instance, not a 


Has anyone else seen this?

I can not use the JSON serializer because it chokes on decimal types.  I
don't think this is a model issue - it seems to be a problem with the
serialized handling sites properly.

-Chris

--~--~-~--~~~---~--~~
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: dict object is not callable (newforms/forms.py full_clean)

2007-03-12 Thread DvD

I got the same problem in a different context:


Exception Type: TypeError
Exception Value:'dict' object is not callable
Exception Location: /usr/lib/python2.4/site-packages/Django-0.95.1-
py2.4.egg/django/newforms/forms.py in full_clean, line 180


Can someone help?



On 5 Feb, 11:29, Antonio <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm trying to use a ManyToManyField between two tables ... the models are
> this:
>
> class Rim(models.Model):
> nome = models.CharField(maxlength=30)
>
> def __str__(self):
> return self.nome
>
> class Previsione(models.Model):
> nave = models.CharField(maxlength=50)
> data = models.DateField()
> grt = models.PositiveSmallIntegerField()
> naz = models.CharField(maxlength=10)
> h_inizio = models.TimeField()
> rims = models.ManyToManyField(Rim)
>
> into te views.py:
>
> def previsione(req, varid=None):
> if req.method == 'POST':
> myform = nf.models.form_for_model(Previsione)(req.POST)
>
> if myform.is_valid():
> dati = Previsione(**myform.clean_data)
> dati.save()
>
> return HttpResponseRedirect('.')
> else:
> if varid is None:
> myform = nf.models.form_for_model(Previsione)()
> else:
> instance = get_object_or_404(Previsione, pk=varid)
> myform = nf.models.form_for_instance(instance)
>
> return render_to_response('create_form.html', \
> { 'titolo': 'Archivio Previsioni',
> 'form': myform.as_table() })
>
> when I'm trying to save the form (with one or many rims selected) I've this
> error:
>
> Exception Type: TypeError
> Exception Value: 'dict' object is not callable
> Exception Location: 
> /usr/local/python2.5/site-packages/django/newforms/forms.py
> infull_clean, line 167
>
> [EMAIL PROTECTED]: django_src# svn update
> At revision 4459.
>
> can someone help me ?
>
> tanks in advance ... and sorry for my english 
>
> --
> #include 
> int main(void){char 
> c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
> 101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,­101,
> 116,46,105,116,62,10,10,0};printf("%s",c);return 0;}


--~--~-~--~~~---~--~~
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 effects Python time/datetime and gives wrong time after DST update

2007-03-12 Thread Ramiro Morales

On 3/12/07, DavidA <[EMAIL PROTECTED]> wrote:
>
> I found a workaround but I'm not sure what the ramifications are. I
> commented out this line in django.conf.__init__.py:
>
> os.environ['TZ'] = self.TIME_ZONE
>

What version/revision of Django are you using?.

See ticket #2315 and changeset [4487] for some work donde
in the Windows time zone stuff front.

Regards,

-- 
 Ramiro Morales

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

2007-03-12 Thread [EMAIL PROTECTED]

Thanks. It means I have to have Django source and copy admin media
files to Apache document root.

best regards,

On Mar 11, 1:15 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 3/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > When deploying site using apache + mod_python, how to make it can read
> > Django admin css? Let say I am using a share webhosting.
>
> This is covered in the "serving media files" and "serving the admin
> files" sections of the mod_python deployment documentation:
>
> http://www.djangoproject.com/documentation/modpython/#serving-media-f...
>
> --
> "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: Request for test confirmation

2007-03-12 Thread Ramiro Morales

On 3/12/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> Thanks, Ramiro. Although, interesting that you only had one failure and
> not two. *Shrug*.
>
> What database backend were you using here? SQLite?
>

Sorry for the incomplete report, I was in a hurry leaving for work. Yes I'm
using the sqlite backend.

$ dpkg -l libsqlite3-0  python-pysqlite2
[...]
ii  libsqlite3-0  3.3.5-0.1bpo1 SQLite
3 shared library
ii  python-pysqlite2  2.3.2-0bpo1   python
interface to SQLite 3

Regards,

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
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: Document type/Charset issues?

2007-03-12 Thread [EMAIL PROTECTED]

Did not know that setting. Thanks James!

On Mar 9, 11:04 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 3/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > also, google webmaster tools reports that the majority (about 80%, but
> > not all) of the site is US-ASCII, not UTF-8
>
> The 'meta' element is basically meaningless; it's used as a last
> resort when no other information is available.
>
> Your server is sending the following:
>
> Content-Type: text/html
>
> Notice that there's no character set specified here; per the relevant
> specifications (RFC 2854, RFC 2616 and RFC 2046 for those playing
> along at home), clients should assume a default of either us-ascii or
> iso-8859-1 in that case. Check that you have set DEFAULT_CHARSET to
> 'utf-8' in your settings file.
>
> --
> "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: django install on mac osx 10.4.8

2007-03-12 Thread [EMAIL PROTECTED]

well i tried with the forewall and offan it return the same error all
the time.
i tried agai to get darwin port running ( and the latest mac part as
well)
http://www.rhonabwy.com/wp/2006/07/20/installing-django-on-macos-x-development-version/

but once i downloaded either the dmg or the source file it trip on the
first line
>>> sudo port -d selfupdate
sudo port install subversion
sudo port install sqlite3 py-sqlite python24
sudo port install py-docutils py-mx

so i never get to see te rest



On Mar 12, 2:16 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi everybody,
>
> > i'm trying to install django, i followe dthe instruction on the django
> > web site but it doesn't work
> > been looking around and the only tutorial that i yet understand
> > ( sorry it's al a bit complicated for me ) require to install macport,
> > which i'm not really keen on ( tried earlier for other reasons and got
> > only trouble ).
>
> > playing around i installed the latest release of python 2.5
>
> > then i downloaded again the latest release of django but when i do the
> > install command
>
> > sudo python setup.py install
>
> > Downloadinghttp://cheeseshop.python.org/packages/2.5/s/setuptools/setuptools-0.6...
> > Traceback (most recent call last):
> >...
> > urllib2.HTTPError: HTTP Error 404: Not Found
>
> > And i can't do anything,
>
> > has anybody any idea how to solve this?
>
> Are you behind a firewall? urllib2 can't get through firewalls unless
> you've configured some environment variables.
>
> Jay P.


--~--~-~--~~~---~--~~
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 keeps growing, performance keeps dropping

2007-03-12 Thread [EMAIL PROTECTED]

Well crud. My host won't turn on slow query logging. So, if you know
you've got a bunch of not-so-good queries (as shown above), how would
one try to spot them?



On Mar 10, 4:58 pm, "gilhad" <[EMAIL PROTECTED]> wrote:
> On Mar 7, 4:26 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > My site just keeps getting bigger and bigger, and the performance has
> > gotten excruciatingly slow.
> > ...
> > Problem is, I really don't know what to do about it, or even what I
> > need to be looking at, really. I've gone through and looked at the
> > views and removed imports I didn't need (I had a lot of import * type
> > statements), but that only helped a little. I've tried figuring out
> > select_all, but don't know if that would really help me or not.
>
> (-; Very simple test: copy this code to another diretory, attach it to
> another nearly empty database and if it hugely speeds up thinks, then
> the problem is not in including libraries, but in having big database
> and/or bad algorithm for data manipulation. So there lies the way to
> get more speed  ;-)


--~--~-~--~~~---~--~~
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 effects Python time/datetime and gives wrong time after DST update

2007-03-12 Thread DavidA

I found a workaround but I'm not sure what the ramifications are. I
commented out this line in django.conf.__init__.py:

os.environ['TZ'] = self.TIME_ZONE

On Mar 12, 10:19 am, "DavidA" <[EMAIL PROTECTED]> wrote:
> I have some scripts that run tasks and use Django DB models. They have
> been running an hour late today after all the DST changes (here in the
> US). I've traced it down to any call to Django is shifting my time
> back an hour (like it was before this weekend's shift).
>
> So the time as reported by time.time() and datetime.datetime.now() are
> both correct _before_ this call:
>
>   task = Task.objects.get(pk=opts['--taskid'])
>
> where Task is a Django DB model. But immediately after this call both
> time.time() and datetime.datetime.now() return a time an hour earlier
> (after formatting using strftime).
>
> I'm running under Windows 2003 Server (patched for DST and verfied
> that the OS is patched). And I have TIME_ZONE set to 'EST5DT' in my
> Django settings file.
>
> I've tried manually setting the TIME_ZONE variable using
> django.conf.settings.configure so it wouldn't effect the
> os.environ['TZ'] setting, but then all python time seems to be based
> as UTC, not New York time.
>
> Has anyone seen anything similar? Can someone suggest a fix or at
> least a quick workaround?
>
> Thanks,
> -Dave


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



newforms: usage of smart_unicode breaks gettext?

2007-03-12 Thread Boris Erdmann

Hello group,

The __init__ method of the newforms.Field class normalizes labels and
help_text by using smart_unicode.

This seems to break gettext/gettext_lazy:

When accessing a newly started runserver with two browsers with
different accept-languages,
both get to see the translation of the first browser.

If I remove the usage of smart_unicode in fields.py everything works
as expected.


Am I doing something wrong???


Boris


--~--~-~--~~~---~--~~
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: Multi-tenant database

2007-03-12 Thread Kenneth Gonsalves


On 12-Mar-07, at 7:46 PM, Tim Chase wrote:

> As previously mentioned by Malcom, Django doesn't currently
> support multi-column keys.

their *is* unique_together, but will that suit your needs?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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 effects Python time/datetime and gives wrong time after DST update

2007-03-12 Thread DavidA

I have some scripts that run tasks and use Django DB models. They have
been running an hour late today after all the DST changes (here in the
US). I've traced it down to any call to Django is shifting my time
back an hour (like it was before this weekend's shift).

So the time as reported by time.time() and datetime.datetime.now() are
both correct _before_ this call:

  task = Task.objects.get(pk=opts['--taskid'])

where Task is a Django DB model. But immediately after this call both
time.time() and datetime.datetime.now() return a time an hour earlier
(after formatting using strftime).

I'm running under Windows 2003 Server (patched for DST and verfied
that the OS is patched). And I have TIME_ZONE set to 'EST5DT' in my
Django settings file.

I've tried manually setting the TIME_ZONE variable using
django.conf.settings.configure so it wouldn't effect the
os.environ['TZ'] setting, but then all python time seems to be based
as UTC, not New York time.

Has anyone seen anything similar? Can someone suggest a fix or at
least a quick workaround?

Thanks,
-Dave


--~--~-~--~~~---~--~~
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 install on mac osx 10.4.8

2007-03-12 Thread Jay Parlar

On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi everybody,
>
> i'm trying to install django, i followe dthe instruction on the django
> web site but it doesn't work
> been looking around and the only tutorial that i yet understand
> ( sorry it's al a bit complicated for me ) require to install macport,
> which i'm not really keen on ( tried earlier for other reasons and got
> only trouble ).
>
> playing around i installed the latest release of python 2.5
>
> then i downloaded again the latest release of django but when i do the
> install command
>
> sudo python setup.py install
>
> Downloading 
> http://cheeseshop.python.org/packages/2.5/s/setuptools/setuptools-0.6c1-py2.5.egg
> Traceback (most recent call last):
>...
> urllib2.HTTPError: HTTP Error 404: Not Found
>
> And i can't do anything,
>
> has anybody any idea how to solve this?
>

Are you behind a firewall? urllib2 can't get through firewalls unless
you've configured some environment variables.

Jay P.

--~--~-~--~~~---~--~~
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: Multi-tenant database

2007-03-12 Thread Tim Chase

> Is Django suitable for multi-tenant database application? i.e.
> combining username and company_id as primary key

You omit some key details:

-are the tenants writing data, or just reading data?

If they're just reading data, you can jockey your views based on 
the tenant.  We're currently doing that in our current Django app.

-do you want to use the default Admin?

If you want to use the default Admin, no.  You /can/ write your 
own admin.  This is a bit of a pain, but can be done.  This might 
be eased a bit in the newforms series.  I haven't dug into it a 
bit, but it sounds like it's designed to help here.  Fortunately, 
Django is just a framework, so it doesn't prevent you from doing 
this.  It just means that you can't take advantage of default 
scaffolding and have to roll some of your own.

As previously mentioned by Malcom, Django doesn't currently 
support multi-column keys.

Just a few ideas.

-tkc





--~--~-~--~~~---~--~~
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: HTTP Response returning 204

2007-03-12 Thread shevken

So i need to set USE_ETAGS=True in settings.py

And then

return response.status_code=204

Hmm..i'll try it tomorrow at work.

On Mar 12, 6:27 pm, "Horst Gutmann" <[EMAIL PROTECTED]> wrote:
> 2007/3/12, shevken <[EMAIL PROTECTED]>:
>
>
>
> > Anyway to return response code 204 from a view?
>
> > So that the request page do not get refreshed.
>
> I guess you could simply create a normal response object and set it's
> status_code attribute to 204 :-)


--~--~-~--~~~---~--~~
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 art thou ImageField

2007-03-12 Thread akonsu

hello,

regarding the last part of your post: i have an unconfirmed suspicion
that data validation should not be done in models but in the forms
that manipulate data. does anyone know if this is correct?

konstantin

On Mar 12, 9:56 am, "gorans" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to access the value of an image field which is uploaded in
> the django admin interface - prior to calling the save.
>
> I have a model called Photo with three attributes: large, medium and
> small. Each are ImageFields.
>
> I have overwritten the save( ) function in Photo so that I can check
> that the uploaded file is 800 x 600 px (and then proceed to generate
> medium and small) with PIL. However, when I call self.large I end up
> with an empty string.
>
> How would I access the filename of the uploaded image before the super
> (save) has been called? (* I think this problem is happening because I
> am using the admin *)
>
> Is overwriting the save method the best way to go about this? I am
> aware that I could create a custom Field but I would like to avoid
> that.
>
> Any direction will be greatly appreciated
>
> Goran


--~--~-~--~~~---~--~~
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: how to use .htc file in django

2007-03-12 Thread Sam Morris

On Mon, 12 Mar 2007 05:15:14 -0700, 骛之 张 wrote:

> hi everyone here, how to use .htc file in django
> 
> if in j2ee or nomal html file, i can define in table as  style="behavior:url(/htc_path/js/TableSort.htc) url(/htc_path/js/
> TableHL.htc) url(/htc_path/js/DragDrop.htc);">
> 
> but in django, I cannot do it correctly, help me, plz

What is your issue exactly? The only problem we ran into
was the one described at .

The fix is webserver specific. The Django built-in development web server
will check /etc/mime.types on Unix, so editing that file is sufficient.

On Windows, you have to do a bit more work (as usual): edit python's
mimetypes.py so that it searches for the mime.types file in a known
location, then create a mime.types file at that location with the correct
contents.

-- 
Sam Morris
http://robots.org.uk/

PGP key id 1024D/5EA01078
3412 EA18 1277 354B 991B  C869 B219 7FDB 5EA0 1078


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



multi-db branch and too many connections

2007-03-12 Thread [EMAIL PROTECTED]

Has anyone else using the multiple-database branch had problems with
'too many connections' errors?  The trunk was being merged into this
project until last fall I believe...so I think the mod_python bug that
existed early on is fixed...but when I get two or three QA ppl in my
system at the same time as me..I get this error..and I have 150
connections allowed for max right 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
-~--~~~~--~~--~--~---



Where art thou ImageField

2007-03-12 Thread gorans

Hi,

I'm trying to access the value of an image field which is uploaded in
the django admin interface - prior to calling the save.

I have a model called Photo with three attributes: large, medium and
small. Each are ImageFields.

I have overwritten the save( ) function in Photo so that I can check
that the uploaded file is 800 x 600 px (and then proceed to generate
medium and small) with PIL. However, when I call self.large I end up
with an empty string.

How would I access the filename of the uploaded image before the super
(save) has been called? (* I think this problem is happening because I
am using the admin *)

Is overwriting the save method the best way to go about this? I am
aware that I could create a custom Field but I would like to avoid
that.

Any direction will be greatly appreciated

Goran


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



High Fidelity Slugify : support for international characters

2007-03-12 Thread Sam

I needed slugify to be more precise with accented characters and i
couldn't find some code to do it, so here it is :

http://amisphere.com/contrib/python-django/slughifi.py

http://amisphere.com/contrib/python-django/ for a quick overview

example :
>>> text = "C'est déjà l'été."
>>> slughifi(text, overwrite_char_map={u"'": "-",})
'c-est-deja-l-ete'

Any comments ?


--~--~-~--~~~---~--~~
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: Chaining ManyToMany Filters Update

2007-03-12 Thread Tim Chase

>  
> >[56]:cs.filter(default_recipe__ingredients__ingredient__id=3).filter(default_recipe__ingredients__ingredient__id=1)
>> Out[56]:[]
> This would map to a Query that looks like this "... WHERE id=3 AND
> id=1".  that would most certainly return no results. 

Unless those ingredients were qbits ;)  That's my superposition, 
and I'm sticking with it! :)

> If you're trying to do OR, look into the DB API manual for Q
> objects, which are the way to express OR statements.

It looks like this might be what the OP was trying to do, which 
could be implemented with something like you describe:

cs.filter(
Q(default_recipe__ingredients__ingredient__id=3) |
Q(default_recipe__ingredients__ingredient__id=1)
)

This would return

[, ]

Alternatively, if it's a short list of IDs, one could also use 
Django's __in modifier, something like

cs.filter(default_recipe__ingredients__ingredient__in=[1,3])

(that might have to be

default_recipe__ingredients__ingredient__id__in=[1,3]

with both "id" and "in" rather than just "in"...YMMV)

Alternatively, the the OP may have been trying to do something 
I've struggled to do with my current app:  wanting to find all N 
with both a related X and Y from the same relation.  In the above 
example, it would be all Cocktail objects that contain both 
ingredient=1 and ingredient=3 which would be seen by a slightly 
more detailed set of sample data:

"""
In [54]:cs.filter(default_recipe__ingredients__ingredient__id=1)
Out[54]:[, ]

In [55]:cs.filter(default_recipe__ingredients__ingredient__id=3)
Out[55]:[, ]
"""

And you're  looking for Cocktail objects that have both 
ingredient#1 and ingredient#3 which is only the Bloody Mary 
[editor's aside:  they're all pretty vile drinks in my book].

To do this, I've had to resort to extra() calls, something like

##
ingredients = [1,3]
ingredient_clause = """EXISTS (
SELECT id
FROM app_cocktail_ingredients
WHERE
cocktail_id = app_cocktail.id
AND ingredient_id = %s
)
"""

for ingredient in ingredients:
cs = cs.extra(where=ingredient_clause,
params=[ingredient])
##

(not having your full model or DB schema, you'll likely have to 
adjust it for your "default_recipe"/"ingredients" interplay).

This will tack on a SQL EXISTS-clause for each ingredient that 
should ensure that the cocktail in question has the given 
ingredient, without excluding the possiblity of other ingredients.

Performance shouldn't be too bad, assuming you have a sane number 
of cocktails and ingredients.  I've had a few issues with 
performance using PostgreSQL+EXISTS() when the lookup table had 
nearly half a million records in it.  I'm working the kinks out 
of that today.   Switching to an IN query didn't help. 
Fortunately, I presume your ingredient list doesn't approach such 
absurdities.  Yippie :-S

Hope this gives you some ideas to work with.

-tkc




--~--~-~--~~~---~--~~
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: Chaining ManyToMany Filters Update

2007-03-12 Thread akonsu

Hello,

please allow me to disagree. the first two queries in the original
post return result sets which overlap. but they combined return the
empty set. this is the problem.

konstantin

On Mar 12, 9:13 am, Atilla <[EMAIL PROTECTED]> wrote:
> On 12/03/07, Boris Smus <[EMAIL PROTECTED]> wrote:
>  
> >[56]:cs.filter(default_recipe__ingredients__ingredient__id=3).filter(defau­lt_recipe__ingredients__ingredient__id=1)>
>  Out[56]:[]
>
> This would map to a Query that looks like this "... WHERE id=3 AND
> id=1".  that would most certainly return no results. If you're trying
> to do OR, look into the DB API manual for Q objects, which are the way
> to express OR statements.


--~--~-~--~~~---~--~~
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: newforms, choices and models

2007-03-12 Thread Massimiliano Ravelli

On 12 Mar, 11:31, enquest <[EMAIL PROTECTED]> wrote:
> However one question is still open!

Did you look at my previous post ?

Massimiliano


--~--~-~--~~~---~--~~
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: Allowing no value for a DateField

2007-03-12 Thread Jay Parlar

On 3/12/07, Roland Hedberg <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I have designed a model which contains among other things a couple of
> DateFields.
>
> Some, actually one, of these must have a value but the other may not.
>
> So, I tried to use the construct:
>
> done_planned = models.DateField(blank=True)
>
> But that doesn't work, because I get a exception with the error:
>
> "act_activity.done_planned may not be NULL"
>
> when trying to store a model instance where the optional dateField
> attributes are undefined.
>
> So, how should it be done ?


You want:

done_planned = models.DateField(blank=True, null=True)

'blank=True' is for the Admin, saying that at a validator level, the
field may be blank. 'null=True' is for the database constraints.

Jay P.

--~--~-~--~~~---~--~~
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: Multi-tenant database

2007-03-12 Thread Malcolm Tredinnick

On Mon, 2007-03-12 at 06:11 -0700, zin wrote:
> Is Django suitable for multi-tenant database application? i.e.
> combining username and company_id as primary key

We do not support multi-column primary keys at this point in time.

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: Allowing no value for a DateField

2007-03-12 Thread Jonathan Buchanan

On 3/12/07, Roland Hedberg <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I have designed a model which contains among other things a couple of
> DateFields.
>
> Some, actually one, of these must have a value but the other may not.
>
> So, I tried to use the construct:
>
> done_planned = models.DateField(blank=True)
>
> But that doesn't work, because I get a exception with the error:
>
> "act_activity.done_planned may not be NULL"
>
> when trying to store a model instance where the optional dateField
> attributes are undefined.
>
> So, how should it be done ?
>
> -- Roland

Use this and recreate your table:

done_planned = models.DateField(blank=True, null=True)

blank is for validation, null is for the database.

http://www.djangoproject.com/documentation/model_api/#null

Jonathan.

--~--~-~--~~~---~--~~
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: low performance of FastCGI deployment

2007-03-12 Thread Atilla

I am running a system with basically the same versions of all software
packages as you are. It is in production and under stress testing it
performed very very well and there've been no issues with performance
so far. I am using Apache + FastCGI, server-managed.

First thing you might want to look at is Apache configuration. What
MPM are you using for Apache - prefork or worker/threaded? Are you
loading too many apache mods that you might not need. Are the
MaxRequestsPerChild and other similar server directives set up
properly ? Note that the FCGI also has a finite number of requests to
serve, before being recycled, but unless you've changed the default
values you should be Ok.

On 12/03/07, Alexander Boldakov <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> My django application runs slower under Apache+FastCGI or
> Lighttpd+FastCGI than under django development HTTP server. The
> approximate times for generating the page are 0.6 vs 1.0 seconds for
> FastCGI and development server correspondingly.
>
> I've tried different combinations of 'prefork' and 'threaded', unix
> domain socket and tcp socket, manually/web server started fastcgi
> server as described on django FastCGI documentation page, but nothing
> helped.
>
> If you have any idea of solving this problem, i will greatly
> appreciate it!
>
> Django version is 0.95. Python version is 2.4.4. Apache version is
> 2.2.3. Flup version is 0.5.
>
> Alexander Boldakov
>
>
> >
>

--~--~-~--~~~---~--~~
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: how to use .htc file in django

2007-03-12 Thread Benjamin Slavin
It is not clear to me what you are asking.  You will need to provide
more information than "I cannot do it correctly".

However, your browser interprets the output of Django in the same way
as 'normal HTML' and J2EE application HTML output.  You should check
the HTML generated by your Django application and make sure that the
files you're referencing actually exist.  You may also need to see the
documentation at
http://www.djangoproject.com/documentation/static_files/

Also, in the future, please do -not- post this type of question to the
Django-Dev mailing list.  That list is for use by developers of Django
itself, not problems end-users are experiencing in their own
applications (unless, of course, the problem is because of a bug in
Django).

 - Ben

On 3/12/07, 骛之 张 <[EMAIL PROTECTED]> wrote:
>
> hi everyone here, how to use .htc file in django
>
> if in j2ee or nomal html file, i can define in table as  style="behavior:url(/htc_path/js/TableSort.htc) url(/htc_path/js/
> TableHL.htc) url(/htc_path/js/DragDrop.htc);">
>
> but in django, I cannot do it correctly, help me, plz
>
>
> >
>

--~--~-~--~~~---~--~~
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: Chaining ManyToMany Filters Update

2007-03-12 Thread Atilla

On 12/03/07, Boris Smus <[EMAIL PROTECTED]> wrote:
 >[56]:cs.filter(default_recipe__ingredients__ingredient__id=3).filter(default_recipe__ingredients__ingredient__id=1)
> Out[56]:[]
This would map to a Query that looks like this "... WHERE id=3 AND
id=1".  that would most certainly return no results. If you're trying
to do OR, look into the DB API manual for Q objects, which are the way
to express OR statements.

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



Multi-tenant database

2007-03-12 Thread zin

Is Django suitable for multi-tenant database application? i.e.
combining username and company_id as primary key


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



permissions in template

2007-03-12 Thread masuran

Hello everyone,

I've created a custom permission on one of my models and I've given a
user the custom permission.

When I go into the shell (manage.py shell), I can confirm that the
user has the custom permission. But when I use the perms object in one
of my templates, it simple doesn't work.

{% if perms.custom_perm %}
 do something
{% endif %}

According to the documentation, the perms object is included in the
template language. So I assume I don't have to create the object and
pass it to my template?
I've even tried the fix posted here http://code.djangoproject.com/ticket/2418
but to no avail. I still can't use the perms object in my template.


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



  1   2   >