Re: group traffic

2006-08-29 Thread Kenneth Gonsalves


On 30-Aug-06, at 10:40 AM, Frank Stüss wrote:

> since this list is getting bigger day by day..
> Eam.. what about splitting this group up in say two or three lists?
>
> django.newbies  (like me :-)
> django.apps
> django.views

the only split I can see useful is to make a new list called django- 
projects where the people who are developing the projects for the  
proposed repository can post. Thus we have:

devel - developing django itself
projects - developing django applications for reuse
users - this list

-- 

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



Re: group traffic

2006-08-29 Thread limodou

On 8/30/06, Frank Stüss <[EMAIL PROTECTED]> wrote:
>
> Hi folks,
> since this list is getting bigger day by day..
> Eam.. what about splitting this group up in say two or three lists?
>
> django.newbies  (like me :-)
> django.apps
> django.views
>
> Looking for better names/categories.
>
> As all of you answerers are doing a great job helping, may be this would help
> even more. Does this make sense?
>
> Greetings,
> Frank
>
I don't think we need to split the maillist now, I don't think there
are too many emails in the maillist.

-1

-- 
I like python!
My Blog: http://www.donews.net/limodou
UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad
UliPad Maillist: http://groups.google.com/group/ulipad

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



group traffic

2006-08-29 Thread Frank Stüss

Hi folks,
since this list is getting bigger day by day..
Eam.. what about splitting this group up in say two or three lists?

django.newbies  (like me :-)
django.apps
django.views

Looking for better names/categories.

As all of you answerers are doing a great job helping, may be this would help 
even more. Does this make sense? 

Greetings,
Frank



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



Re: viewing generated SQL without running the query

2006-08-29 Thread Gary Wilson

Malcolm Tredinnick wrote:
> On Tue, 2006-08-29 at 03:53 +, Gary Wilson wrote:
> > I see that there is a _get_sql_clause() method, but is there a function
> > that will return the constructed query string?
>
> Deja vu. I tried to implement something like this a little while back.
> The thing that is hard about getting it to work is that we rely on the
> database backend to do some of the quoting and function substitution for
> us. As far as I know, there's no generic way to pull that information
> out of each backend. I wasn't really keen in duplicating the logic from
> the queryset stuff, however this may be easier with the query.py rewrite
> I'm doing (I just thought of that point now, so I really mean "may" --
> need to look into it).

Ah, I guess I didn't notice the using of the db backend to do some work
for us.  That does make things a bit harder.


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



Re: verbose_name option not working...

2006-08-29 Thread mediumgrade

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



Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread clee

Thank you. I've found django/test/client.py in svn.


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



Re: Multiple File Upload???

2006-08-29 Thread Russell Keith-Magee
On 8/29/06, cerealito <[EMAIL PROTECTED]
> wrote:
Is there anyway that i can catch those and pass them to djangoManipulator'sdo_html2python() and save() methods?Your request appears to have multiple files in it, which suggests that your template is working fine. As far as I can see, all that remains is to pass your request into the Description Manipulator to get_validation_errors, do_html2python, and save. This process should handle writing the files to disk.
BTW: Re _javascript_ - I was only suggesting _javascript_ that if you want a really fancy Gmail-esque UI. _javascript_ won't help you save multiple files, it will only make the interface for specifying them a little more Web 
2.0.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  -~--~~~~--~~--~--~---


models wierdness

2006-08-29 Thread Rob Hudson

I've got an app called page I've been working on.  Pages can contain
text, graphics, or media and each have their own table which refer back
to page (ForeignKey).  When I set up this model, only page_media has
the inlined SQL for the foreign key ("REFERENCES"), where as the others
do it with an ALTER TABLE syntax.  This seems odd to me that almost the
identicle table definition is output differently.  Should I be
concerned?  Should each table have similar SQL?

Thanks,
Rob

My models.py:

from django.db import models

class Template(models.Model):
name = models.CharField(maxlength=64, db_index=True,
unique=True)

def __str__(self):
return self.name

class Admin:
list_display = ('name')

class Page(models.Model):
name = models.CharField(maxlength=64, db_index=True,
unique=True)
template = models.ForeignKey(Template)

def __str__(self):
return self.name

class Admin:
list_display = ('name', 'template')

class Text(models.Model):
page = models.ForeignKey(Page, db_index=True,
edit_inline=models.STACKED)
position = models.CharField(maxlength=16, core=True)
content = models.TextField(core=True)

class Meta:
ordering = ['position']

class Graphic(models.Model):
page = models.ForeignKey(Page, db_index=True,
edit_inline=models.STACKED)
position = models.CharField(maxlength=16, core=True)
filename = models.CharField(maxlength=128, core=True)

class Meta:
ordering = ['position']

class Media(models.Model):
page = models.ForeignKey(Page, db_index=True,
edit_inline=models.STACKED)
position = models.CharField(maxlength=16, core=True)
filename = models.CharField(maxlength=128, core=True)

class Meta:
ordering = ['position']

The output of "./manage.py sql page":

BEGIN;
CREATE TABLE `page_text` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`page_id` integer NOT NULL,
`position` varchar(16) NOT NULL,
`content` longtext NOT NULL
);
CREATE TABLE `page_graphic` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`page_id` integer NOT NULL,
`position` varchar(16) NOT NULL,
`filename` varchar(128) NOT NULL
);
CREATE TABLE `page_page` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(64) NOT NULL UNIQUE,
`template_id` integer NOT NULL
);
ALTER TABLE `page_text` ADD CONSTRAINT page_id_refs_id_7038ecc2 FOREIGN
KEY (`page_id`) REFERENCES `page_page` (`id`);
ALTER TABLE `page_graphic` ADD CONSTRAINT page_id_refs_id_5fad2eb2
FOREIGN KEY (`page_id`) REFERENCES `page_page` (`id`);
CREATE TABLE `page_template` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(64) NOT NULL UNIQUE
);
ALTER TABLE `page_page` ADD CONSTRAINT template_id_refs_id_768003f7
FOREIGN KEY (`template_id`) REFERENCES `page_template` (`id`);
CREATE TABLE `page_media` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`page_id` integer NOT NULL REFERENCES `page_page` (`id`),
`position` varchar(16) NOT NULL,
`filename` varchar(128) NOT NULL
);
COMMIT;


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



Re: Directional Many-to-many

2006-08-29 Thread Russell Keith-Magee
On 8/30/06, Siah <[EMAIL PROTECTED]> wrote:
Somehow though, if I go to ChildObj and ask for its children, I willget the FatherObj as well. What am I doing wrong?By default, m2m fields are symmetrical - what you put in at one end, you can see from the other. 
If you want to make m2m fields non-symmetrical, add symmetrical=False to your m2m definition. See
http://www.djangoproject.com/documentation/models/m2m_recursive/for an example.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  -~--~~~~--~~--~--~---


Re: mod_python apache problems...

2006-08-29 Thread mediumgrade

Thanks, Ricardo. That was 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
-~--~~~~--~~--~--~---



Re: Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread James Bennett

On 8/29/06, clee <[EMAIL PROTECTED]> wrote:
> Thank you, I just downloaded firebug and it looks like a big step
> forward.

You might also want to look at the new testing support that went into
Django recently -- we've always had support for using doctest, but
unittest has just been added and there's a special-purpose class --
django.test.client.Client -- which will let you send test requests to
an application and compare the output against what you're expecting.
It's brand spanking new and not entirely documented, but the code is
pretty clean and well-commented, and official documentation will
hopefully be sorted out shortly.


-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

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



Re: AJAXWidgetComboBox in admin?

2006-08-29 Thread Matthew Flanagan

Hi,

I have a large revamp of this code that i've been meaning to upload to
the wiki for a while. I'll try to do it today or tomorrow. The new
code uses the newer dojo Select widget (which I wrote incidentally :).
I've also written a templatetag to make it easier to use the widget in
your templates.

As for integrating it into the admin: I haven't gotten too far with
that unfortunately. Please let me know if you are successful.

matthew

On 29/08/06, zenx <[EMAIL PROTECTED]> wrote:
>
> Just wanted to know if there are any implementations of the
> AJAXWidgetComboBox for the ForeignKey relationship inputs in the admin
> forms (instead of using raw_id_admin=True)
> http://code.djangoproject.com/wiki/AJAXWidgetComboBox
>
> 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
-~--~~~~--~~--~--~---



Re: python sets and objects returned in queries

2006-08-29 Thread Gary Wilson

Ivan Sagalaev wrote:
> Gary Wilson wrote:
> > Why can't objects be used in python sets?  Example:
> >
>  [u.username for u in User.objects.all()]
> > ['bar', 'foo', 'foobar']
>  a = User.objects.filter(username__contains='foo')
>  b = User.objects.filter(username__contains='bar')
>  set.intersection(set(a), set(b))
>
> May be set(..) doesn't cause a queryset to actually evaluate... Try:
>
>  set.intersection(set(list(a)), set(list(b)))

set() does eqvaluate the QuerySet:

>>> set(a)
set([, ])
>>> set(list(a))
set([, ])
>>> set(a) == set(list(a))
True


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



Re: ManyToManyField not populated in form

2006-08-29 Thread [EMAIL PROTECTED]

I have the same 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
-~--~~~~--~~--~--~---



Re: file upload = simple DoS possibility

2006-08-29 Thread Adrian Holovaty

On 8/29/06, Michael Samoylov <[EMAIL PROTECTED]> wrote:
> Is the any way to control upload process (max file size, etc.)? Great
> framework but file upload can couse DoS.
> [...]
> User can try to upload any size file and waste all server's cpu and
> memory and you can imagine situation with hundreds of uploads! I've
> patched django with
> 3581-streaming_uploads_and_uploadprogress_middleware_x_progress_id.diff
> but I see no performance  improvements :(

Hi Michael,

I'd recommend handling this at the Apache level. See the
LimitRequestBody directive:

http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread clee

Thank you, I just downloaded firebug and it looks like a big step
forward.
-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
-~--~~~~--~~--~--~---



ManyToManyField not populated in form

2006-08-29 Thread cyberco

In a form for changing a model instance all fields get correctly filled
with existing values except the ManyToManyField form fields (which
renders as a choice list in a form). It shows the correct list of
options, but none of the options is selected, even though the instance
of the model should have some values selected. Can this be changed?


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



Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread [EMAIL PROTECTED]

Firebug http://www.joehewitt.com/software/firebug/ has helped me out a
ton.  In it's console firebug shows every ajax request, and if there is
an http 500 error you can see the entire response.  So you don't see
the nicely formated django error page, but you see the html source of
the nicely formated django page.  So at least you can see the stack
trace.


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



advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread clee

Hello, I'm a long-time python user who is new to django, javascript,
and Mochikit. I'm very pleased with django so far but I'm having a bit
of a quandry as I start to mix in javascript and Mochikit.

One thing I like about django is that if I make an error in my python
code it send me that great debug/traceback page.  This works well if I
submit a form as well. However, I've stared to get more adventurous
with Mochikit and am trying to communicate with the server outside of a
form.

Of course, as I experiment, I make mistakes and I get back to my
javascript console (thank you mochikit) a status=500 error and an
xmlHttpRequest failed error.

I know I made a mistake in my python code in views.py, and I know that
django probably caught it and generated a traceback but I dont' know
how to look at it.

This has slowed down my coding cycle a great deal. Do others have
tricks to get at this? Is it stored in the failed response on the
javascript side? It seems if I could get access to it I could pop up a
window and display it or log it somewhere.

Many thanks for any help in advance. I will put a little code below to
give an idea of what I'm doing.

-chris


=== example ===
in my template I might have something like this in the 

Re: syncing with external BB database --- what would you do?

2006-08-29 Thread [EMAIL PROTECTED]

Register Django user in punBB:
##
- open register.php
- find:

// Add user

- after add:

$salt = substr(md5(base64_encode(time())), 0, 5);
$db->query('INSERT INTO auth_user (username, email, password,
is_active, date_joined) VALUES ("'.$db->escape($username).'",
"'.$email1.'", "sha1$'.$salt.'$'.sha1($salt.$password1).'", "1",
"2006-08-29 20:00:34")');

##
Register punBB user in Django:
- use this code:

import sha
user = 'piotr' # login
password = sha.new('piotr').hexdigest() # "piotr" is the password
email = '[EMAIL PROTECTED]' # user email
from django.db import connection
cursor = connection.cursor()
cursor.execute("INSERT INTO pun_users (group_id, username, password,
email, registered) VALUES ('4', '"+ user +"', '"+ password +"', '"+
email +"', '1156874672')")

- place it in your registration view and pass him user email, login and
password :)


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



Re: many to many problems

2006-08-29 Thread [EMAIL PROTECTED]

Somehow, I got this working. Nevermind...

I think I was trying too hard. I went back to the Django docs on
manipulators and copied the sample manipulator code (for your view) and
presto - it works.


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



Re: Finding entries with multiple tags

2006-08-29 Thread [EMAIL PROTECTED]

> I am really close to finishing the rewrite work necessary to make this
> easy. It's a bug that it doesn't work already. You should be able to
> filter using
>
> Post.objects.filter(tag = 'django').filter(tag = 'python')

Yes! This is what I tried before but noticed it did not work (the
second filter would always return nothing). It's good to know this is a
bug but my thinking was still correct. Thanks for clarifying this

> (There have been other solutions to the same problem posted on this
> list, too).

I apologize for not noticing the other solutions. I searched the
archive with keywords that I thought would turn something up, but
couldn't find anything.

And everyone else, thank you for your input, too. My solution for the
now will be to keep the current Python code (as mentioned by Dave, it's
a tradeoff between the Python and SQL loop) until filter is fixed.

I appreciate everyone's input!


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



many to many problems

2006-08-29 Thread [EMAIL PROTECTED]

I would love to write up a howto for UPDATING a manyTOMany field, but I
cannot figure out how it is done. I would love to get the concept here:

I have a db model called "Projects" with a ManyToMany field called
"Team"

when updating the Project I want to also update the Team(s)

In the manipulator, I validate the data, etc:

manipulator = Project.ChangeManipulator(project_id)
errors = manipulator.get_validation_errors(new_data)
if not errors:
manipulator.do_html2python(new_data)
manipulator.save(new_data)

Does the manipulator call the "save" function in my Project model?

if so why do I get "TypeError at /projectlist/edit/2/   save() takes
exactly 2 arguments (1 given)"

In the Manipulator base class the save funciton's signature is: def
save(self, new_data):

In my Model.save():

super(Project,self).save()

and I try to save the related Objects:

self.team = data['team'] #ManyToMany
self.enduser = data['enduser'] #ForeignKey
self.rigorlevel = data['rigorlevel'] #ForeignKey


I wish the docs were more clear... What am I doing wrong?


Best,

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



Re: Finding entries with multiple tags

2006-08-29 Thread Chris Kelly
agreed with Malcom on this one:you should be splitting the url string at the top (removing the last blank entry) to get the array of tags.from there you can just iterate over the tags array until you hit the end in a for loop.
then in that for loop, just call a filter on the queryset, using the current tag as the param in the filter call.(note, I am not near a django install at the moment, so this is all untested, ymmv)
tags = url.split("/")[:-1]
posts = Post.objects.all()for tag in tags: posts.filter(posttag = tag)return render_to_response("blog/tags.html", {'posts': posts})if the filter call isn't working correctly, that's another story :)
good luck!-COn 8/29/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
On Tue, 2006-08-29 at 14:05 +, [EMAIL PROTECTED]
 wrote:> > > Yes, you are right.  I was not thinking straight.>> Not a problem. Help is always appreciated!>> > > Anyone know what the> > > best method for performing this in SQL would be?  Select all posts for
> > > each tag and use intersect?> >> > With ManyToMany relationships, you have to think of chasing the> > relationship backwards. Instead of finding the posts with a given tag,
> > start with the tag and find the related posts:> >> > >>> from danet.blog.models import Post, Tag> > >>> t = Tag.objects.get(pk='programming')> > >>> 
t.post_set.all()> > [ASP.NET 2.0>, ]> > > That works easily when you're just looking up one Tag. What I'm trying
> to figure out is the best way to search for multiple tags and return> only the Posts common to all of those tags:I am really close to finishing the rewrite work necessary to make thiseasy. It's a bug that it doesn't work already. You should be able to
filter usingPost.objects.filter(tag = 'django').filter(tag = 'python')and have it return Post instances that have both 'django' and'python' (and possibly other tags) associated with them. It sounds like
this is what you are after. Right now, like I said, it's a bug that thisdoesn't already work (since we say that concatenating filters should actlike "and"-ing them together). I'm going to get back to doing some
Django core dev work this week and this is top of my list.In the interim, you might like to try this solution, which also works,but is a little fiddlier:
http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/(There have been other solutions to the same problem posted on thislist, too).Cheers,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  -~--~~~~--~~--~--~---


Re: viewing generated SQL without running the query

2006-08-29 Thread Malcolm Tredinnick

On Tue, 2006-08-29 at 03:53 +, Gary Wilson wrote:
> I see that there is a _get_sql_clause() method, but is there a function
> that will return the constructed query string?

Deja vu. I tried to implement something like this a little while back.
The thing that is hard about getting it to work is that we rely on the
database backend to do some of the quoting and function substitution for
us. As far as I know, there's no generic way to pull that information
out of each backend. I wasn't really keen in duplicating the logic from
the queryset stuff, however this may be easier with the query.py rewrite
I'm doing (I just thought of that point now, so I really mean "may" --
need to look into it).

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



Re: Finding entries with multiple tags

2006-08-29 Thread Malcolm Tredinnick

On Tue, 2006-08-29 at 14:05 +, [EMAIL PROTECTED] wrote:
> > > Yes, you are right.  I was not thinking straight.
> 
> Not a problem. Help is always appreciated!
> 
> > > Anyone know what the
> > > best method for performing this in SQL would be?  Select all posts for
> > > each tag and use intersect?
> >
> > With ManyToMany relationships, you have to think of chasing the
> > relationship backwards. Instead of finding the posts with a given tag,
> > start with the tag and find the related posts:
> >
> > >>> from danet.blog.models import Post, Tag
> > >>> t = Tag.objects.get(pk='programming')
> > >>> t.post_set.all()
> > [, ]
> > >>>
> 
> That works easily when you're just looking up one Tag. What I'm trying
> to figure out is the best way to search for multiple tags and return
> only the Posts common to all of those tags:

I am really close to finishing the rewrite work necessary to make this
easy. It's a bug that it doesn't work already. You should be able to
filter using

Post.objects.filter(tag = 'django').filter(tag = 'python')

and have it return Post instances that have both 'django' and
'python' (and possibly other tags) associated with them. It sounds like
this is what you are after. Right now, like I said, it's a bug that this
doesn't already work (since we say that concatenating filters should act
like "and"-ing them together). I'm going to get back to doing some
Django core dev work this week and this is top of my list.

In the interim, you might like to try this solution, which also works,
but is a little fiddlier:
http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/

(There have been other solutions to the same problem posted on this
list, too).

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



Re: view.py as class not just methods

2006-08-29 Thread Malcolm Tredinnick

On Sat, 2006-08-26 at 10:34 +, skink wrote:
> Hi,
> 
> I'm relatively new to django and maybe my question is stupid, but...
> 
> Is it possible to map in urls.py some url not to function in views.py
> (which has first argument with HttpRequest) but to some class methot?
> In that case each instance of such class would be created when session
> starts and for subsequnt calls would be served as self ?
> 
> I know, I know that HttpRequest has session member and I can use it.
> But maybe it would be good idea to have such url ==> class.method
> mapping.

Can you explain the use case for this a bit more?

I am wondering what you want to do that cannot be done by just creating
the class instance at import time and then calling the method (since you
can now put direct function and method references in URLConf calls). For
example,

my_class = MyClass(...)

urlpatterns = patterns('',
('foo/$', my_class.some_method),
)

The ability to put function references (and not just strings) inside
patterns(...) is something that was only added recently (after 0.95), so
you will need to be running a recent subversion checkout to use this.

I'm not sure that creating the class instance at call time (instead of
import time) gains you a lot that you cannot do otherwise. But I'd be
interested to hear what I've overlooked.

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



Re: included templates to load own objects

2006-08-29 Thread Malcolm Tredinnick

Hi Mae,

On Mon, 2006-08-28 at 14:53 +, Mae wrote:
> I want included-including templates to be able to act independently
> from each other.  I want the including template to not have to know
> anything about the particulars of the template it's including.
> 
> I want to be able to write {%include magic_template%} and
> magic_template would be a url that would get mapped to its own view
> function, which would do complex database access operations, open
> sockets, do business logic, whatever, before returning
> magic_template.html.
> 
> I have dozens of pages.  All of those pages are different from each
> other, but they all have one thing in common -- they include
> ticker.html.  Now this ticker.html requires certain variables to be
> pre-populated.  Right now, I have to manually attach every single one
> of those variables to every single view function for every single page.
>  If I need to add another variable, I'll have to paste its name into
> dozens of "render_to_response" statements.  This is a maintenance mess.
>  And every single page is obliged to know that it's including
> ticker.html, because it has to pass variables to it.  That's an
> architectural mess.

This can't be done with the {% include %} tag, but it is the ideal
example of when a custom template tag is useful. After writing the tag,
including the tag as 

{% ticker_data %}

wherever you needed it in your template (plus a "{% load ... %}" at the
top) is all you would need to do.

If your ticker data is best formatted via a small template fragment,
look at the inclusion_tag() shortcut for template tags ([1]). Otherwise,
you probably just need a simple_tag() template tag -- see [2] -- since
you are just returning a string from minimal (in fact, no) input
parameters.

[1]
http://www.djangoproject.com/documentation/templates_python/#inclusion-tags

[2]
http://www.djangoproject.com/documentation/templates_python/#shortcut-for-simple-tags

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



Re: How to handle person to person relationships

2006-08-29 Thread Jeremy Dunck

On 8/29/06, Mir Nazim <[EMAIL PROTECTED]> wrote:
>
> I have already gone through that. but problem is that I need to add
> some attributes to relationships like
>
> he is my best friend
> i have not met him
>
> something like orkut.

If you're going to attach view and template behavior based on the
different relationship types as you add them, then I think it makes
sense to just have a separate attribute field on the Person model for
each relationship type.

class Person(models.Model):
...
   contacts = models.ManyToManyField('self')
   friends = models.ManyToManyField('self')
   enemies = models.ManyToManyField('self')

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



Re: Finding entries with multiple tags

2006-08-29 Thread DavidA

[EMAIL PROTECTED] wrote:
> That works easily when you're just looking up one Tag. What I'm trying
> to figure out is the best way to search for multiple tags and return
> only the Posts common to all of those tags:

Joe,

My bad. I misunderstood your question. I think the only way to do this
(in SQL) is with a subselect or with multiple joins to the same table,
neither of which are possible in the direct DB API. But you can use the
extra() method to get around some of the constraints.

To solve your specific problem, I started with the custom SQL:

select slug from blog_post
where id in (select post_id from blog_post_tags
where tag_id in ('programming', 'finance'))

This can be implemented in Django as:

>>> from danet.blog.models import Post, Tag
>>> Post.objects.all().extra(where=["blog_post.id in (select post_id from 
>>> blog_post_tags where tag_id in ('programming', 'finance'))"])
[, , ]
>>>

So I've just copied the where-clause from the SQL (and explicitly
qualified the id column with 'blog_post.id').

Its debatable whether this is an improvement over direct SQL. You could
just as easily do

>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute("select post_id from blog_post_tags where tag_id in ('program
ming', 'finance')")
3L
>>> Post.objects.in_bulk([row[0] for row in cursor.fetchall()])
{16L: , 1L: , 6L:
}
>>>

In either case you've got about the same amount of custom SQL in your
Python code so its really a six-of-one situation.
-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
-~--~~~~--~~--~--~---



Re: Creating new apps

2006-08-29 Thread Guillermo Fernandez Castellanos

Hi,

> I have been on your SVN, but how do i tell Django that each little app has
> its own urls.py? is putting it in the directory enough to automatically let
> django know that each little app has its own urls.py?
Afterwards you can define a urls.py for each project.
Check for those urls.py in:
http://www.guindilla.eu:8000/www_guindilla_eu/
http://www.guindilla.eu:8000/www_haruki_eu/

> Also for authenticating users, do i use django.contrib.auth, which is the
> same as the admin system.
I do use django.contrib.auth and I'm very happy with it ;-)

> I dont want users to have access to my backend system.
Mmm... I don't really get what you mean here, but in admin, for each
user you have the "Staff Status" option in the "Permissions" section
that designates whether the user can log into the admin site. So just
uncheck it if you don't want users to access with the admin interface.
Of course, in the worse of the cases you can simply "desinstall" the
admin application, take it out of the urls.py or limit its access to
given IPs only (this is Apache magic though).

I hope I understood all your questions.

Enjoy,

G

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



Re: Directional Many-to-many

2006-08-29 Thread Corey Oordt
Take a look at: http://www.djangoproject.com/documentation/models/m2m_and_m2o/CoreyOn Aug 29, 2006, at 12:15 PM, Siah wrote:Hello,Given this model:class Person(models.Model):    name = models.CharField(maxlength=200)    children = models.ManyToManyField('self')I can do:    FatherObj.children.add(ChildObj)Somehow though, if I go to ChildObj and ask for its children, I willget the FatherObj as well. What am I doing wrong?In my real example, the childObj can have many parent nodes, thusmany-to-many is required.Thanks,Sia

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


Re: How to handle person to person relationships

2006-08-29 Thread Mir Nazim

I have already gone through that. but problem is that I need to add
some attributes to relationships like

he is my best friend
i have not met him

something like orkut.


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



Re: Creating new apps

2006-08-29 Thread Corey Oordt
Charles,I've always seen a Project as a Site. Although there are situations that that may not be true, for most of us, it probably is.I've seen an App as a grouping of functionality. Examples would be Blog, Forums, News, Gallery, etc.Good design practices should keep as much internal within each App as possible, so you can use the app with other projects. That is why you would have a urls.py and a views.py in each App directory.Each App is linked into the main project by: INSTALLED_APPS in settings.py and configuring a base url (eg. /blog ) that then references the App's urls.py.For authentication, you can use the contrib.auth. They don't have access to the admin unless they are a member of staff.Hope that helps,CoreyOn Aug 29, 2006, at 12:16 PM, charles sibbald wrote:Hi Guillermo,Thanks for the help.I have been on your SVN, but how do i tell Django that each little app has its own urls.py? is putting it in the directory enough to automatically let django know that each little app has its own urls.py?Also for authenticating users, do i use django.contrib.auth, which is the same as the admin system.I dont want users to have access to my backend system.RegardsCharles- Original Message From: Guillermo Fernandez Castellanos <[EMAIL PROTECTED]>To: django-users@googlegroups.comSent: Tuesday, August 29, 2006 3:47:51 PMSubject: Re: Creating new appsHi,I did my own homepage (www.haruki.eu) where I have several"applications" done together.As I understood after asking in the list and looking at severalproject svn trees, the 2nd way seems to be prefered for a sizableapplication. It allows modularity and reusability.What I do is have a name for the general project and all the appsthere. Each app has its own urls.py, and I let users define their ownurls.py that will include the urls.py of each application depending ofthe ones they want to add or use.You can have a look at the code here:http://www.guindilla.eu:8000/guindilla/trunk/Hope it helps.GOn 8/29/06, casibbald <[EMAIL PROTECTED]> wrote:>> I have been through the Django tutorial, but there is something it does> not clearly outline.>> After creating a project, I have to create my first App, which in the> tutorial it was Polls.>> I now want to start working on my own Application and wonder what the> best structure is for a sizable application which I hope it will grow> to as I learn more.>> So option 1.>> Project --- App -- Views (multiple views for my whole project)>> Option 2.>> Project --- App1 -- Views> Project --- App2 -- Views> Project --- App3 -- Views> Project --- App4 -- Views>> Multiple component apps to the whole project?>> and if option 2 is the better route to go, then for example would the> following be a good example.>>> Project --- Auth-- Views - Registration>  Login>  Pass-Reminder> Project --- Dashboard   -- Views - Welcome>  Report 1 + n> Project --- Account -- Views>  Address>  Credit Details> Project --- App + n -- Views>>> The issue I have been having is this, how best to then setup my URLs?,> as the tutorial does not explain how to have many apps in the same> urls.py file>>> >>

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


Re: Creating new apps

2006-08-29 Thread charles sibbald
Hi Guillermo,Thanks for the help.I have been on your SVN, but how do i tell Django that each little app has its own urls.py? is putting it in the directory enough to automatically let django know that each little app has its own urls.py?Also for authenticating users, do i use django.contrib.auth, which is the same as the admin system.I dont want users to have access to my backend system.RegardsCharles- Original Message From: Guillermo Fernandez Castellanos <[EMAIL PROTECTED]>To:
 django-users@googlegroups.comSent: Tuesday, August 29, 2006 3:47:51 PMSubject: Re: Creating new appsHi,I did my own homepage (www.haruki.eu) where I have several"applications" done together.As I understood after asking in the list and looking at severalproject svn trees, the 2nd way seems to be prefered for a sizableapplication. It allows modularity and reusability.What I do is have a name for the general project and all the appsthere. Each app has its own urls.py, and I let users define their ownurls.py that will include the urls.py of each application depending ofthe ones they want to add or use.You can have a look at the code here:http://www.guindilla.eu:8000/guindilla/trunk/Hope it helps.GOn 8/29/06, casibbald
 <[EMAIL PROTECTED]> wrote:>> I have been through the Django tutorial, but there is something it does> not clearly outline.>> After creating a project, I have to create my first App, which in the> tutorial it was Polls.>> I now want to start working on my own Application and wonder what the> best structure is for a sizable application which I hope it will grow> to as I learn more.>> So option 1.>> Project --- App -- Views (multiple views for my whole project)>> Option 2.>> Project --- App1 -- Views> Project --- App2 -- Views> Project --- App3 -- Views> Project --- App4 -- Views>> Multiple component apps to the whole project?>> and if option 2 is the better route to go, then for example would the> following be a good example.>>> Project ---
 Auth-- Views - Registration>  Login>  Pass-Reminder> Project --- Dashboard   -- Views -
 Welcome>  Report 1 + n> Project --- Account --
 Views>  Address>  Credit Details> Project --- App + n -- Views>>> The issue I have been having is this, how best to then setup my URLs?,> as the tutorial does not explain how to have many apps in the same> urls.py file>>> >>

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


Directional Many-to-many

2006-08-29 Thread Siah

Hello,

Given this model:

class Person(models.Model):
name = models.CharField(maxlength=200)
children = models.ManyToManyField('self')

I can do:
FatherObj.children.add(ChildObj)

Somehow though, if I go to ChildObj and ask for its children, I will
get the FatherObj as well. What am I doing wrong?

In my real example, the childObj can have many parent nodes, thus
many-to-many is required.

Thanks,
Sia


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



Re: Recovering from a server problem

2006-08-29 Thread keukaman


Kenneth Gonsalves wrote:
> On 29-Aug-06, at 6:58 AM, keukaman wrote:
>
> > Is there a way simple way to reestablish all of the relationships
> > between apps, etc, after a server outage?
>
> is it possible that your .pyc files have got out of sync? Maybe you
> could rm -rf the whole django tree and reinstall it? could help. Or
> remove all your .pyc files - both from django and the project.
>
> --
>
> regards
> kg
> http://lawgon.livejournal.com
> http://nrcfosshelpline.in/web/
I removed the .pyc files and it didn't help. I'll see if I can
reinstall Django.


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



Re: off-topic: why does it take so long for emails ...

2006-08-29 Thread Don Arbow

On Aug 29, 2006, at 3:36 AM, va:patrick.kranzlmueller wrote:
>
> I see. any chance to get me off the spam-list?


Adrian didn't say YOU were on a spam list, but that some MESSAGES may  
have been flagged by Google as potential spam.

Not much you can do about the time lag. There are times I've seen no  
emails come from Google Groups for 6 or 7 hours, then all of a sudden  
the logjam breaks. It's the Internet, sometimes its slow, sometimes not.

Don


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



Re: AJAXWidgetComboBox in admin?

2006-08-29 Thread Chris Long

Nothing right now. Currently the admin interface doesn't use any AJAX,
but it has been under discussion for a while to implement it.

If you did wish to use it, you could probably modify the admin
interface fairly easily to implement it (w/o changing the actual
django.contrib.admin) package. There are other threads and articles on
the wiki about doing this, but feel free to ask if they don't help.

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



Re: Creating new apps

2006-08-29 Thread Guillermo Fernandez Castellanos

Hi,

I did my own homepage (www.haruki.eu) where I have several
"applications" done together.

As I understood after asking in the list and looking at several
project svn trees, the 2nd way seems to be prefered for a sizable
application. It allows modularity and reusability.

What I do is have a name for the general project and all the apps
there. Each app has its own urls.py, and I let users define their own
urls.py that will include the urls.py of each application depending of
the ones they want to add or use.

You can have a look at the code here:
http://www.guindilla.eu:8000/guindilla/trunk/

Hope it helps.

G

On 8/29/06, casibbald <[EMAIL PROTECTED]> wrote:
>
> I have been through the Django tutorial, but there is something it does
> not clearly outline.
>
> After creating a project, I have to create my first App, which in the
> tutorial it was Polls.
>
> I now want to start working on my own Application and wonder what the
> best structure is for a sizable application which I hope it will grow
> to as I learn more.
>
> So option 1.
>
> Project --- App -- Views (multiple views for my whole project)
>
> Option 2.
>
> Project --- App1 -- Views
> Project --- App2 -- Views
> Project --- App3 -- Views
> Project --- App4 -- Views
>
> Multiple component apps to the whole project?
>
> and if option 2 is the better route to go, then for example would the
> following be a good example.
>
>
> Project --- Auth-- Views - Registration
>  Login
>  Pass-Reminder
> Project --- Dashboard   -- Views - Welcome
>  Report 1 + n
> Project --- Account -- Views
>  Address
>  Credit Details
> Project --- App + n -- Views
>
>
> The issue I have been having is this, how best to then setup my URLs?,
> as the tutorial does not explain how to have many apps in the same
> urls.py file
>
>
> >
>

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



Re: How to handle person to person relationships

2006-08-29 Thread Reinhard Knobelspies

http://www.djangoproject.com/documentation/models/m2m_recursive/


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



How to handle person to person relationships

2006-08-29 Thread Mir Nazim

How code the relationship like
"a person has many friends"

code so far.

class Person(models.Model):
full_name = models.CharField(maxlength=100)
nick_name = models.CharField(maxlength=20)
about = models.TextField(blank=True)
sex = models.CharField(maxlength=1, choices=SEXES)

# contact is also a person object so it is a reference to same
person
# more study needs to be done on how to add attributes to
ManyToMany relationship in Django
# e.g. we may need to define whether a contact is my friend etc.
# creating a separate class for Contact may not be the a good
solution, since a Contact is also a Person
contacts = models.ManyToManyField('self')


Or like this

class PersonRelation(models.Model):
person = models.ForeignKey(Person)
relations = models.ManyToManyField(Person, related_name =
'friends')
type = models.IntegerField(choices=FRIEND_TYPES)
group = models.IntegerField(choices=GROUP_TYPES)



please highlight pros and cons.


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



file upload = simple DoS possibility

2006-08-29 Thread Michael Samoylov

Hi all.

Is the any way to control upload process (max file size, etc.)? Great
framework but file upload can couse DoS.

For example:

class Account(models.Model):
user = models.OneToOneField(User)
birthday = models.DateField(blank=True, null=True)
icq = models.IntegerField(blank=True, null=True)
website = models.URLField(blank=True, null=True)
resume = models.TextField(blank=True, null=True)
userpic = PhotoField(upload_to='upload', width=100, height=100,
null=True, blank=True)

User can try to upload any size file and waste all server's cpu and
memory and you can imagine situation with hundreds of uploads! I've
patched django with
3581-streaming_uploads_and_uploadprogress_middleware_x_progress_id.diff
but I see no performance  improvements :(


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



AJAXWidgetComboBox in admin?

2006-08-29 Thread zenx

Just wanted to know if there are any implementations of the
AJAXWidgetComboBox for the ForeignKey relationship inputs in the admin
forms (instead of using raw_id_admin=True)
http://code.djangoproject.com/wiki/AJAXWidgetComboBox

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



Re: python syntax errors

2006-08-29 Thread Kenneth Gonsalves


On 29-Aug-06, at 6:46 PM, Jay Parlar wrote:

>> in idle). Even if it does compile, if some import errors are there,
>> again you will not get the error - just the script headers thing
>
> There are lots and lots of potential runtime errors that wouldn't be
> caught. Just running your stuff in IDLE is not enough.

it is not enough - but it is the first thing to do. Idle will allow  
errors within loops that are not executed for example. Next would be  
to run manage.py validate. This will take care of 95% of all newbie  
errors.

-- 

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



Re: Finding entries with multiple tags

2006-08-29 Thread DavidA

Gary Wilson wrote:
> [EMAIL PROTECTED] wrote:
> > > def tags(request, url):
> > > # Don't need the last item in the list since it will
> > > # always be an empty string since Django will append
> > > # a slash character to the end of URLs by default.
> > > tags = url.split('/')[:-1]
> > > posts = Post.objects.filter(tags__name__in=tags)
> > > return render_to_response("blog/tags.html", {'posts': posts})
> >
> > If I'm not mistaken, __in will return results that aren't tagged by all
> > tags. So using the original example:
> >
> > Post1: articles, python, django
> > Post2: articles, python
> > Post3: articles, music
> >
> > and tags has [articles, python, django], all 3 posts will be returned
> > since IN just OR's the values together, correct? That's why I came up
> > with that mess of a loop.
>
> Yes, you are right.  I was not thinking straight.  Anyone know what the
> best method for performing this in SQL would be?  Select all posts for
> each tag and use intersect?

With ManyToMany relationships, you have to think of chasing the
relationship backwards. Instead of finding the posts with a given tag,
start with the tag and find the related posts:

>>> from danet.blog.models import Post, Tag
>>> t = Tag.objects.get(pk='programming')
>>> t.post_set.all()
[, ]
>>>

My models look like this:

class Tag:
   ...
class Post:
tags = models.ManyToManyField(Tag)
...

Thus Post.tags is the set of tags for a given post and the reverse
relationship is created automatically as Tag.post_set (you can override
this with the 'related_name' arg to something like 'posts' if you
like).

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



Re: Multiple File Upload???

2006-08-29 Thread Russell Keith-Magee
On 8/29/06, cerealito <[EMAIL PROTECTED]> wrote:
Isn't there a way to upload as many files as i want to (much like gmailhandles attatchments)and then associating them to the descriptions?Try this:class Description(models.Model):
    text = models.CharField(maxlength=100)    class Admin:    pass        class Image(models.Model):    altText = models.CharField(maxlength=128, null=True, blank=True, core=True)    picture = 
models.FileField(upload_to='images', core=True)    description = models.ForeignKey(Description, edit_inline=True)and look at description in the admin view. Is that what you are after?By this model, every Image belongs to a single Description (so a description can have multiple images). Image is edited inline, so you get a list of images to add. It isn't quite as dynamic as GMail (you need some AJAX magic for that), but it's the functional part of the solution.
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  -~--~~~~--~~--~--~---


Re: python syntax errors

2006-08-29 Thread Jay Parlar

On 8/29/06, Ilia Kantor <[EMAIL PROTECTED]> wrote:
> And people here tell me set admin email.. So I will get emails with errors
> WHILE I DEVELOP on my home box!
> *rofl*
>
> Maybe django redirects stdout/stderr somewhere so the errors get consumed ?

It wouldn't be Django redirecting, it would be mod_python.

And yes, having to get emails while you develop is silly. That's why I
recommend using the dev server. Then you see the errors, immediately,
right on screen, without having to run 'tail' on an error log or
anything.

When you're 100% happy with how it runs with the dev server, start
testing with Apache.


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



Re: python syntax errors

2006-08-29 Thread Jay Parlar

On 8/28/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
 > if there are syntax errors, the file will not compile and the only
> error apache will give is incomplete script headers or something like
> that. So before running with apache, make sure the file compiles (F5
> in idle). Even if it does compile, if some import errors are there,
> again you will not get the error - just the script headers thing

There are lots and lots of potential runtime errors that wouldn't be
caught. Just running your stuff in IDLE is not enough.


> >
> > Save Apache for final deployment.
>
> no harm in using it for development - that way both devel and
> production are on identical platforms

I certainly wasn't advocating doing ALL your development *and* testing
with the Django server, and then switching to Apache for production.
My recommendation is to do all your main development with the Django
server. When you're completely happy with how it runs, start testing
with Apache. When you're happy with how that runs, switch to
production.

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



Re: Limit view to group members: what function for the @user_passes_test decorator?

2006-08-29 Thread cyberco

Great! Thanks for the excellent reply.


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



Re: viewing generated SQL without running the query

2006-08-29 Thread DavidA


Gary Wilson wrote:
> I see that there is a _get_sql_clause() method, but is there a function
> that will return the constructed query string?

You can just do the same construction that's done in
django/db/models/query.py:

>>> from danet.blog.models import Post, Tag
>>> qs = Tag.objects.filter(title__icontains='a', description__icontains='n')
>>> cols, sql, args = qs._get_sql_clause()
>>> "SELECT %s %s" % (', '.join(cols), sql % tuple(args))
'SELECT `blog_tag`.`slug`, `blog_tag`.`title`, `blog_tag`.`description`
 FROM `b
log_tag` WHERE (`blog_tag`.`description` LIKE %n% AND
`blog_tag`.`title` LIKE %a
%) ORDER BY `blog_tag`.`title` ASC'
>>>

There's some special handling for DISTINCT if you look at
django.db.models.query.iterator(), but the snippet above is close
enough. After a while you get used to just looking at the list from
_get_sql_clause() directly and can just add the "SELECT" and replace
the args in your head.
-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
-~--~~~~--~~--~--~---



Re: off-topic: why does it take so long for emails ...

2006-08-29 Thread va:patrick.kranzlmueller

I see. any chance to get me off the spam-list?

kenneth: I didn´t check that before. yesterday it was on the web  
interface immediately and I was waiting for the e-mail for about half  
an hour.

thanks,
patrick

Am 29.08.2006 um 05:14 schrieb Adrian Holovaty:

>
> On 8/28/06, patrickk <[EMAIL PROTECTED]> wrote:
>> when I send an email to the group, it takes about one hour for this
>> mail to show up on the list.
>> is that intended?
>
> Hi Patrick,
>
> Some django-users (and django-developers) messages are flagged
> automatically by Google Groups as potential spam. In that case, Google
> Groups e-mails the list admins for our confirmation that it's not
> spam. I think some of your messages may have gotten such false
> positives. In that case, the delay is just the time it takes for
> either Jacob or me to manually OK the message.
>
> Adrian
>
> -- 
> Adrian Holovaty
> holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Re: Additional Functionality to Admin Interface

2006-08-29 Thread chrisdo

Thanks, I'll try it at home, I don't have internet access for
subversion here.


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



Re: Additional Functionality to Admin Interface

2006-08-29 Thread Kenneth Gonsalves


On 29-Aug-06, at 2:55 PM, chrisdo wrote:

> I'm quite new to Django, and I couldn't find anything in the
> documentation.
> I want to develop a gallery system in Django, so if I add a new
> picture, I'm uploading it (the field is a ImageField).

you could use nesh's ImageWithThumbnail field:

http://djangoutils.python-hosting.com/wiki/Thumbnails

-- 

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



Additional Functionality to Admin Interface

2006-08-29 Thread chrisdo

Hi there

I'm quite new to Django, and I couldn't find anything in the
documentation.
I want to develop a gallery system in Django, so if I add a new
picture, I'm uploading it (the field is a ImageField).

But I don't want to set the height and witdh, I just want to upload the
image file (in the original size) and then generate some thumbnails and
also save them.

How can I do this? I think that I have to call another function from
within the administration area when I create another Image


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



edit_inline fails

2006-08-29 Thread Ilia Kantor

I have an object + edit_inline=stacked

I edit inline object and press save... But nothing changes.. 

How can I debug what's up ?

No errors, just doesn't work (trunk)

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



threadlocals with limit_choices_to in models

2006-08-29 Thread ibson

Hi,
I'm using the threadlocals hack
(http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser) in my
model to filter machines by group. But it's not stable at all. And most
of the time the filter return nothing because the usergroup is empty.

Here's a piece of my code :
usergroup = threadlocals.get_current_user().groups.all()[0]
machine = models.ForeignKey(Machine, limit_choices_to =
{'group':usergroup})

On the admin interface the list is empty, but after some browser
refreshing it comes, and then goes away. It's not stable at all.

Some help please? I'm facing this problem for weeks now in my
project!!! :|


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



Re: Multiple File Upload???

2006-08-29 Thread cerealito

Ok, the problem then is, that my model has just a single entity called
picture.
What I'm trying to do is asociate multiple image files to multiple
`descriptions'.
I'm doing this by a intermedaite table:

#Images to be used in descriptions
class Image(models.Model):
altText = models.CharField(maxlength = 128, null = True, blank =
True)
picture = models.ImageField(upload_to='img/%Y/%m')
...

# Replaces the Many-to-Many Relationship
class ImageInDescription(models.Model):
description = models.ForeignKey(Description,
edit_inline=models.TABULAR, num_in_admin=3)
image = models.ForeignKey(Image, core = True)
...

#Descriptions
class Description(models.Model):
lang = models.ForeignKey(Lang)
description = models.TextField(null = True, blank = True)
...

That's it. So as you can see in the first class, `Image' is itself an
element to be uploaded. I guess I could add more ImageFields to the
model but that would't make sense, would it?

Isn't there a way to upload as many files as i want to (much like gmail
handles attatchments)
and then associating them to the descriptions?

Russell Keith-Magee wrote:
> On 8/29/06, cerealito <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi everyone,
> >
> > I am trying to upload multiple image files in one of my projects.
> > Single-File upload works fine, but how do I Get to upload many files in
> > the same form?
>
> ...
>
> > But my question is... How do I "save" them?
> >
> > imageManipulator.do_html2python(new_data)
> > imageManipulator.save(new_data)
> >
> > Wouldn't work...
>
>
> It should do. As long as your model contains multiple FileField entries, the
> manipulator should quite happily save the files, one file per file field per
> form. Can you share your actual model, view and template (or pruned versions
> of them)?
>
> Yours,
> Russ Magee %-)
>
> --=_Part_61688_22258181.1156811004015
> Content-Type: text/html; charset=ISO-8859-1
> X-Google-AttachSize: 1132
>
> On 8/29/06,  class="gmail_sendername">cerealito mailto:[EMAIL 
> PROTECTED]">[EMAIL PROTECTED] wrote: class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 
> 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> Hi everyone,I am trying to upload 
> multiple image files in one of my projects.Single-File upload works fine, 
> but how do I Get to upload many files inthe same 
> form?...
> But my question is... How do I save 
> them?imageManipulator.do_html2python(new_data)imageManipulator.save(new_data)Wouldn't
>  work...It should do.  As long as your model contains 
> multiple FileField entries, the manipulator should quite happily save the 
> files, one file per file field per form. Can you share your actual model, 
> view and template (or pruned versions of them)?
> Yours,Russ Magee %-)
> 
> --=_Part_61688_22258181.1156811004015--


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



Problem accessing users and groups in Admin

2006-08-29 Thread Luis P. Mendes

Hi,

I posted this on Saturday, but since I had no replies, I'm reposting it.

What should I look for to solve this problem:

When I access http://127.0.0.1:8000/admin/ I get
Groups
Users
in the Autho Fieldset.


If I click on Users  http://127.0.0.1:8000/admin/auth/user/ I get a list
of all the users.

When I click on any of them:  http://127.0.0.1:8000/admin/auth/user/1/
like the superuser in this case:

Page not found (404)
Request Method:
GET
  Request URL:
http://127.0.0.1:8000/admin/auth/user/1/

Or starting again from admin:   http://127.0.0.1:8000/admin/
I click in the +Add shortcut for Users:
http://127.0.0.1:8000/admin/auth/user/add/
.
DoesNotExist at /admin/auth/user/add/
Request Method:
GET
  Request URL:
http://127.0.0.1:8000/admin/auth/user/add/
  Exception Type:
DoesNotExist
  Exception Value:
Exception Location:
/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py
in __get__, line 163

Traceback (most recent call last):
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py"
in get_response
   74. response = callback(request, *callback_args, **callback_kwargs)
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/decorators.py"
in _checklogin
   55. return view_func(request, *args, **kwargs)
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/views/decorators/cache.py"
in _wrapped_view_func
   39. response = view_func(request, *args, **kwargs)
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/main.py"
in add_stage
   243. manipulator = model.AddManipulator()
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/manipulators.py"
in __init__
   69. self.fields.extend(f.get_manipulator_fields(self.opts, self,
self.change))
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py"
in get_manipulator_fields
   226. field_objs, params =
self.prepare_field_objs_and_params(manipulator, name_prefix)
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py"
in prepare_field_objs_and_params
   215. field_objs = self.get_manipulator_field_objs()
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py"
in get_manipulator_field_objs
   627. choices = self.get_choices_default()
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py"
in get_choices_default
   631. return Field.get_choices(self, include_blank=False)
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py"
in get_choices
   292. return first_choice + [(x._get_pk_val(), str(x))
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/auth/models.py"
in __str__
   48. return "%s | %s" % (self.content_type, self.name)
 File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py"
in __get__
   163. raise self.field.rel.to.DoesNotExist

   DoesNotExist at /admin/auth/user/add/

Request information
GET
No GET data
POST
No POST data
.

What should I try to look for to solve this problem?

Luis P. Mendes


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



Re: python syntax errors

2006-08-29 Thread Ilia Kantor


> if there are syntax errors, the file will not compile and the only
> error apache will give is incomplete script headers or something like
> that. So before running with apache, make sure the file compiles (F5
> in idle). Even if it does compile, if some import errors are there,
> again you will not get the error - just the script headers thing

Wait, wait.. When the error occurs, message is GENERATED.
it should not be consumed, but saved somewhere.
Better go apache log...

And people here tell me set admin email.. So I will get emails with errors 
WHILE I DEVELOP on my home box!
*rofl*

Maybe django redirects stdout/stderr somewhere so the errors get consumed ?


>
> > Save Apache for final deployment.
>
> no harm in using it for development - that way both devel and
> production are on identical platforms

I too can't understand why I shouldn't develop on apache.

Usually people recommend use same env for development and production.
Less weak points.

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



Re: python sets and objects returned in queries

2006-08-29 Thread Ivan Sagalaev

Gary Wilson wrote:
> Why can't objects be used in python sets?  Example:
> 
 [u.username for u in User.objects.all()]
> ['bar', 'foo', 'foobar']
 a = User.objects.filter(username__contains='foo')
 b = User.objects.filter(username__contains='bar')
 set.intersection(set(a), set(b))

May be set(..) doesn't cause a queryset to actually evaluate... Try:

 set.intersection(set(list(a)), set(list(b)))

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