Re: Integrating a chat application

2006-10-31 Thread James Bennett

On 11/1/06, Keith Mallory <[EMAIL PROTECTED]> wrote:
> How do I integrate a chat application in Django?

What chat application are you using that you want to "integrate"? What
exactly do you mean by "integrate"? Do you mean you want to rewrite an
existing application with Django? Do you mean you want to write a new
chat application from scratch? Do you mean you have an existing
application and you want to have it and Django share resources such as
a database?

Without specifics, this is an impossible question to answer.

> Has anyone already integrated a chat application?

I've worked on a chat application built with Django, but it's proprietary.

-- 
"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: looking for Django Contractors

2006-10-31 Thread John D'Agostino

Hi Benjamin,

http://www.gypsyjobs.com/ - is a forum setup by Django contributor Ian
Holsman, for django related jobs
and there is also -
http://code.djangoproject.com/wiki/DevelopersForHire

On Nov 1, 5:33 pm, Benjamin Ward <[EMAIL PROTECTED]> wrote:
> Hey good people,
>
> I'm wondering where i should post a Job availability? Is there a site
> that could be recommended?
>
> I'm wanting to find some talented Django developers to work on a site
> i'm building. It's a new site for the Record Label i work for - quite
> a big scope. I've managed to convince my Boss that Django is the way
> to go, but deadlines are pressing in and i'd like to get some more
> hands on deck. i don't mind tele-commuters, as long as time-zones are
> favourable etc. I'm in Sydney Australia.
>
> Is this list an appropriate forum for a Job listing?
> 
> cheers,
> ben


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: slowly losing my ming w/ a django error in command line on windows

2006-10-31 Thread Kenneth Gonsalves


On 01-Nov-06, at 10:03 AM, programguru wrote:

> ImportError: No module named MYSITE

why is it asking for caps? is it mysite or MYSITE?

-- 

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



Integrating a chat application

2006-10-31 Thread Keith Mallory
Hi,How do I integrate a chat application in Django? Has anyone already integrated a chat application?Is there any Ajax toolkit which can be integrated easily?ThanksKeith 

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


looking for Django Contractors

2006-10-31 Thread Benjamin Ward


Hey good people,

I'm wondering where i should post a Job availability? Is there a site  
that could be recommended?

I'm wanting to find some talented Django developers to work on a site  
i'm building. It's a new site for the Record Label i work for - quite  
a big scope. I've managed to convince my Boss that Django is the way  
to go, but deadlines are pressing in and i'd like to get some more  
hands on deck. i don't mind tele-commuters, as long as time-zones are  
favourable etc. I'm in Sydney Australia.

Is this list an appropriate forum for a Job listing?


cheers,
ben









--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: slowly losing my ming w/ a django error in command line on windows

2006-10-31 Thread James Bennett

On 10/31/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> I'm not sure how python on windows handles imports, since the native
> file system isn't case-sensitive, but try making MYSITE lowercase;
> python is case-sensitive.

The importing behavior on Windows and other case-insensitive
filesystems is defined in PEP 235[1]; if I'm reading it correctly,
trying 'import MYSITE' should work if 'MYSITE' (case-sensitively) is
the actual name of the directory.

I can't see anything in management.py which would normalize the path
before doing things (that *would* screw things up, since normalization
lowercases the names on Windows); can anyone else running Windows
verify this as a bug?


[1] http://www.python.org/dev/peps/pep-0235/


-- 
"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: slowly losing my ming w/ a django error in command line on windows

2006-10-31 Thread Jeremy Dunck

On 10/31/06, programguru <[EMAIL PROTECTED]> wrote:
...
> Directory of C:\MYDJANGO\MYSITE
...
> project_module = __import__(project_name, '', '', [''])
> ImportError: No module named MYSITE
> --

I'm not sure how python on windows handles imports, since the native
file system isn't case-sensitive, but try making MYSITE lowercase;
python is case-sensitive.

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



slowly losing my ming w/ a django error in command line on windows

2006-10-31 Thread programguru


#ive installed django on windows with the combination of several tutorials
and intstructs, and i am beggining lose all #will to eat, sleep, or do
anything else until i can resolve this.

#I simply did this: django-admin.py startproject mysite

#AND all was fine as these files were created:

Directory of C:\MYDJANGO\MYSITE

10/31/2006  08:16 PM  .
10/31/2006  08:16 PM  ..
10/31/2006  08:01 PM   557 manage.py
10/31/2006  08:01 PM 2,466 settings.py
10/31/2006  08:05 PM 1,716 settings.pyc
10/31/2006  08:01 PM   243 urls.py
10/31/2006  08:01 PM 0 __init__.py
10/31/2006  08:16 PM   127 __init__.pyc
   6 File(s)  5,109 bytes
   2 Dir(s)   6,622,806,016 bytes free

#then i went to test my development server like so:

manage.py runserver AND the below error continues to haunt me! please help
anyone!

django-admin.py startproject mysite

C:\MYDJANGO\MYSITE>manage.py
Traceback (most recent call last):
  File "C:\MYDJANGO\MYSITE\manage.py", line 11, in 
execute_manager(settings)
  File
"c:\python25\lib\site-packages\Django-0.95-py2.5.egg\django\core\manageme
nt.py", line 1299, in execute_manager
project_module = __import__(project_name, '', '', [''])
ImportError: No module named MYSITE
-- 
View this message in context: 
http://www.nabble.com/slowly-losing-my-ming-w--a-django-error-in-command-line-on-windows-tf2550223.html#a7107991
Sent from the django-users mailing list archive at Nabble.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: Index of an item in a QuerySet

2006-10-31 Thread samuel

> > I'm probably just not seeing it, but how do  I go about getting the
> > index of an item in a query set? I.E., this article is the Xth article
> > in this queryset of articles sorted by date.
>
> If you're looping through them in the template with the 'for' tag,
> each time through the loop you'll have access to a variable called
> 'forloop.counter' which has this information; the first time through
> it will be 1, the second time it will be 2, and so on.
>
> See http://www.djangoproject.com/documentation/templates/#for for details.
>

Thanks but I guess I'm looking for something a bit different. Here's
exactly what I'm trying to do: I have  articles that are chunked into
groups of 10 arbitrarily based on their date. So when a new article is
added the groups change. When you go to an article page, I want to
display the chunk that the article belongs to. So if the article is
19th, display a list of articles 11-20.

If I'm thinking through this correctly, I need to know the articles
location in the queryset before I get to the template and then slice
the queryset as necessary. How would I go about this? Just iterate
through and backtrack when I get there?

Thanks,
Sam


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Changing admin template for only certain models

2006-10-31 Thread iain duncan

On Tue, 2006-31-10 at 20:19 -0600, James Bennett wrote:
> On 10/31/06, iain duncan <[EMAIL PROTECTED]> wrote:
> > I would like to change the template ( or change behaviour ) for the
> > change list view, but only for one model. Can anyone tell me how one
> > could find out in the template which model we are representing? Or
> > alternately, where in the admin code one might add extra variables to
> > render to the template?
> 
> When Django renders the list, it looks for the following templates, in
> order, and uses the first one it finds:
> 
> admin/appname/modelname/change_list.html
> admin/appname/change_list.html
> admin/change_list.html
> 
> Where 'appname' and 'modelname' are the names of the application and
> the model, respectively. To override for a specific application, make
> a directory with the name of that application, and put a
> 'change_list.html' template in it. To override for a specific model,
> make the 'appname' directory, make a 'modelname' directory and put the
> 'change_list.html' template inside it.
> 

Looking in change_list.html I find this:

{% block result_list %}
{% result_list cl %}
{% endblock %}

I'm confused by the above, as I don't know how that middle tag is
working. It's not the same block inheritance as in the tutorial. Is
there a way to change how that tag is rendered on a per model basis?

Looking forward to that book ... ;)

Iain



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 password

2006-10-31 Thread Russell Keith-Magee

On 11/1/06, shidan <[EMAIL PROTECTED]> wrote:
>
> Hi how can I get a Users password after it has been hashed. Reseting it
> is not
> good enough due to the nature of the application and how it integrates
> with the
> rest of the system

You can't. Non-reversibility is the entire purpose of a password hash
- hashes are one way trapdoor functions.

Your only option would be to add a 'cleartext password' field to a
model somewhere, and keep the original password when the user submits
it. However, this is a bad idea from a security point of view, as it
introduces a point of weakness by which intruders can find the
password of other users, and thereby gain access as another user.

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: recovering password

2006-10-31 Thread James Bennett

On 10/31/06, shidan <[EMAIL PROTECTED]> wrote:
> Hi how can I get a Users password after it has been hashed.

The salted hash process Django uses is (deliberately, for security
purposes) a one-way procedure, so it's not possible to recover the
original password later.

-- 
"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: Changing admin template for only certain models

2006-10-31 Thread iain duncan


> When Django renders the list, it looks for the following templates, in
> order, and uses the first one it finds:
> 
> admin/appname/modelname/change_list.html
> admin/appname/change_list.html
> admin/change_list.html
> 
> Where 'appname' and 'modelname' are the names of the application and
> the model, respectively. To override for a specific application, make
> a directory with the name of that application, and put a
> 'change_list.html' template in it. To override for a specific model,
> make the 'appname' directory, make a 'modelname' directory and put the
> 'change_list.html' template inside it.

Trying the above suggestion I've run into one snag. I can change
change_list.html and it works for only the model in question, but I
don't seem to be able to get any results out of changing a copy of
change_list_results.html in the same directory, which has the part of
the template I actually want to edit. Any clue why this might be? I can
successfully change change_list_results.html in my main admin template
directory.

Thanks
Iain


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



recovering password

2006-10-31 Thread shidan

Hi how can I get a Users password after it has been hashed. Reseting it
is not
good enough due to the nature of the application and how it integrates
with the 
rest of the system


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Changing admin template for only certain models

2006-10-31 Thread iain duncan

On Tue, 2006-31-10 at 20:19 -0600, James Bennett wrote:
> On 10/31/06, iain duncan <[EMAIL PROTECTED]> wrote:
> > I would like to change the template ( or change behaviour ) for the
> > change list view, but only for one model. Can anyone tell me how one
> > could find out in the template which model we are representing? Or
> > alternately, where in the admin code one might add extra variables to
> > render to the template?
> 
> When Django renders the list, it looks for the following templates, in
> order, and uses the first one it finds:
> 
> admin/appname/modelname/change_list.html
> admin/appname/change_list.html
> admin/change_list.html
> 
> Where 'appname' and 'modelname' are the names of the application and
> the model, respectively. To override for a specific application, make
> a directory with the name of that application, and put a
> 'change_list.html' template in it. To override for a specific model,
> make the 'appname' directory, make a 'modelname' directory and put the
> 'change_list.html' template inside it.

Aha, ok, so instead of actually changing what goes to the template I can
route by model.

Now, I am also however interested in hacking on the admin views/models
themselves. Is there some way of replacing those much like one does for
templates? Would I make an entire copy of the admin interface and link
to my copy through the settings file? I would like to be able to send
more info through template variables to my extended templates.

Thanks for the tip!
Iain


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Changing admin template for only certain models

2006-10-31 Thread James Bennett

On 10/31/06, iain duncan <[EMAIL PROTECTED]> wrote:
> I would like to change the template ( or change behaviour ) for the
> change list view, but only for one model. Can anyone tell me how one
> could find out in the template which model we are representing? Or
> alternately, where in the admin code one might add extra variables to
> render to the template?

When Django renders the list, it looks for the following templates, in
order, and uses the first one it finds:

admin/appname/modelname/change_list.html
admin/appname/change_list.html
admin/change_list.html

Where 'appname' and 'modelname' are the names of the application and
the model, respectively. To override for a specific application, make
a directory with the name of that application, and put a
'change_list.html' template in it. To override for a specific model,
make the 'appname' directory, make a 'modelname' directory and put the
'change_list.html' template inside it.

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



Changing admin template for only certain models

2006-10-31 Thread iain duncan

I would like to change the template ( or change behaviour ) for the
change list view, but only for one model. Can anyone tell me how one
could find out in the template which model we are representing? Or
alternately, where in the admin code one might add extra variables to
render to the template?

I have been playing with what looks like the admin code, the stuff in my
/usr/local/src/django_src/django/contrib/admin
but I do not appear to be able to even break the admin interface. Is
there some sort of caching going on?

Thanks
iain


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



Need help deploying Django on shared host

2006-10-31 Thread Roboto

Hey guys,

I just need a little guidance here as I'm not all that awesome with
servers.  I'm currently being hosted on grokthis.net and a short while
after I received my account information I've been trying to get a quick
site up so that I can start making something significant

they've set it up such that my domain name is located in
/public_html/mydomain-org.net
and I've created my app inside /mydomain.org-net

jumping back into the server, I jump into my
etc/apache2/conf.d/sites-enabled/ directory
and I find mydomain-org.net

I've done the following code changes

   #ready is my app name
SetEnv DJANGO_SETTINGS_MODULE ready.settings

Made changes to the settings.py file to set DEBUG = FALSE
and I've setup my urls.py to link to a basic index.html

And I haven't been able to get my site up.

Right now, all I see is this light blue Django Debug page that tells me
to turn off debug and alter my urls.py file.

Any ideas?  Thanks

Rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: django for non-web apps?

2006-10-31 Thread Oliver Lavery
Hi,Yeah, it could be really useful if you want to build a your standard enterprise GUI database front-end, for example. Just discard the view and template layers, and use models to simplify interacting with the database. Django is so nicely decoupled that you can just as easily use the model layer with python GTK bindings as you can with the the web -oriented views and templates.
AJAXy (ugh) Web apps where a lot of the business logic resides in the client are similar to this in a sense. The real beauty of django resides in the model layer where you have easy to manage objects that present an abstraction of the database.
Cheers,~olOn 10/31/06, walterbyrd <[EMAIL PROTECTED]> wrote:
Django is called  "The Web framework . ."Does django also make sense for non-web apps?

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


Yup, two more 0.91 -> 0.95 questions ...

2006-10-31 Thread ZebZiggle


What is the format for __id in filters?

Does this code look correct (assuming characterDefinition is a member
of GameElement):

game.gameelement_set.filter(characterDefinition__id = characterId)

Note the two underscores. Also, I'm assuming gameElement_set gets
changed to lower-case "gameelement_set"?

Finally, can I safely do this the same as before?

player.user.id = None
player.save()


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



.delete() not called on related objects when 'parent' object is deleted

2006-10-31 Thread Jeff Forcier

Howdy folks,

I just ran across the problem mentioned in this older thread:


http://groups.google.com/group/django-users/browse_thread/thread/2d1dc42cea162c4b/

The issue is exactly as stated there and in my own subject line -
deletion of related objects, via
core/db/models/query.py::delete_objects(), bypasses the related
objects' .delete() method. This is problematic for anyone who overrides
that method and expects it to be called consistently.

I couldn't find a Trac bug entry for this, and neither could the
original poster--if one does exist, please let me know :) Otherwise, I
will file one myself--I just wanted to double check.

I'll note that delete_objects() *does* call the pre_delete and
post_delete signals, which I will likely use as a temporary
alternative, but even so, I still feel that this behavior is
sufficiently incorrect/misleading that it should be fixed at some point
(I can write a patch if/when I get the time to examine it further :)).

Thanks,
Jeff


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 with Intermediate Table - How to use built in admin?

2006-10-31 Thread Russell Keith-Magee

On 10/31/06, Vortexmind <[EMAIL PROTECTED]> wrote:
>
> Hi all
> I am currently developing a rather large data model, and I need to use
> Many-to-Many with Intermediate Table (as I need to stick some
> attributes within the association). I try to explain with the Django
> example about this issue:
>
> from django.db import models
>
> class Reporter(models.Model):
> first_name = models.CharField(maxlength=30)
> last_name = models.CharField(maxlength=30)
>
> class Article(models.Model):
> headline = models.CharField(maxlength=100)
> pub_date = models.DateField()
>
> class Writer(models.Model):
> reporter = models.ForeignKey(Reporter)
> article = models.ForeignKey(Article)
> position = models.CharField(maxlength=100)
>
> So far, if i add
>
> class Admin:
> pass
>
> to all the above I can edit them. But what if I want to have the inline
> admin to make the Writer relation when adding an Article or a Reporter?
> If I do as above, I must add Reporter, then Article, then I can finally
> go in the Writer admin interface and do the join. I hope you understand
> me :)

The admin application doesn't currently have any special handling for
m2m relations with intermediate tables, so the approach you describe
is the only way to do it.

The only way to do this would be to write your own view, and customize
the manipulator to represent m2m with intermediate tables.

That said, 'm2m with intermediate' is a relatively common use case, so
if you have any neat ideas on how to represent such a structure, feel
free to suggest them. The idea has been discussed before, but no
obvious solution has emerged (the real sticking point is querying the
intermediate table - check the archives for previous discussions).

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: X-View headers

2006-10-31 Thread Jeremy Dunck

On 10/31/06, Rob Hudson <[EMAIL PROTECTED]> wrote:
> When I send a GET request, I do get the right header:
>
> X-Object-Type: blog.post
> X-Object-Id: 1
>
> (Wait, those are actually two different things in two different places
> in Django.  Hmmm...)

Ah, it wasn't clear to me which X- headers you meant.

django.core.xheaders.populate_xheaders does the thing you're looking
for; grepping the tree shows it's called from generic views (which you
observed) and flatpages.

But there's no magic about it, just call that function with the
appropriate parameters.

See here for an example: ./django/views/generic/date_based.py
...
response = HttpResponse(t.render(c), mimetype=mimetype)
populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name))

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Displaying ManyToMany relation in template

2006-10-31 Thread Nikolaus Schlemm

hi,

try something like the following:

> {% if latest_posts %}
> {% for post in latest_posts %}
> 
> {{ post.title }}
> 
> publié le {{
> post.pub_date|date:"l d F Y à H:i" }}, dans la catégorie

{% for category in  post.category.all %}
{{ category.title }}
{% endfor %}

> 
> {{ post.summary }}
> 

{% for tag in post.tag.all %}
{{ tag }}
{% endfor %}

>  
> {% endfor %}
> {% else %}
> Aucun article ne correspond aux critères.
> {% endif %}

-> http://www.djangoproject.com/documentation/models/many_to_many/

> Thanks in advance,
> Nicolas
-- 
you're welcome!

Nikl

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



Adding a button to admin view?

2006-10-31 Thread iain duncan

Hi folks, I would like to add a custom form button to the admin
interface somehow and am not sure how to go about it. 

I want to add a "download now" button the list view for some file
entries, so it needs to be a link to file. Any idea how this should be
done? 

Thanks
Iain


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



Displaying ManyToMany relation in template

2006-10-31 Thread Nicolas Steinmetz

Hello,

I'm testing django with a blog and I have the following issue :

I have the following model :

class Post(models.Model):
author = models.ForeignKey(User)
title = models.CharField(maxlength=50)
summary = models.TextField(blank=True)
message = models.TextField()
category = models.ManyToManyField(Category)
tag = models.ManyToManyField(Tag, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
pub_date = models.DateTimeField('Date de publication',
auto_now_add=True)
pub_status = models.BooleanField('Publie ?', default=True)

and the following template :

{% if latest_posts %}
{% for post in latest_posts %}

{{ post.title }}

publié le {{ post.pub_date|date:"l 
d F Y à H:i" }},
dans la catégorie {{ post.category }}
{{ post.summary }}
{{ post.tag }}
{% endfor %}
{% else %}
Aucun article ne correspond aux critères.
{% endif %}

I would like that post.category and post.tag display all tags or categories
linked to a postfor the related post.

I tried to use "cycle" and some "for" loops but it does not work (or I do
not handle it correctly).

Could someone explained how can I handle such an easy (?) thing ?

Thanks in advance,
Nicolas


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Error importing settings.py

2006-10-31 Thread sansmojo

On review, I guess the latter doesn't actually work.  So, please
ignore.  We have things running 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
-~--~~~~--~~--~--~---



Re: django for non-web apps?

2006-10-31 Thread Guillermo Fernandez Castellanos

Well... I'm not sure you need to mimic anything.

Let's take an example:
class Friend(models.Model):
name = models.CharField(maxlength=79)

Now suppose I do a function like this:
def names():
for friend in Friend.objects.all():
print friend.name
if '__main__'==__name__:
names()

Well... I will be able to use the database through python, and I will
not need any request nor http mimics.

What I will need, though, is something that sets my variables to the
correct values to use python. But I kind of remember Adrian announcing
in the mailing list a while ago that there's a function that allows to
automagically do this by adding it at the beginning of a program.

Hope it helps,

G

On 10/31/06, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
> I think the tricky part is what Guillermo is saying.  All views take a
> request object and return a response object.  You'd have something that
> would have to mimic HTTP requests and work with HTTP responses.  At
> that point it seems like you should just create your MVC pattern-based
> app using an ORM (sqlalchemy?) and tie it to whatever front-end your
> going for. (Just giving examples of what might be attractive in Django
> to have in a non-web app.)
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: X-View headers

2006-10-31 Thread Rob Hudson

Jeremy Dunck wrote:
> It has to be a HEAD request.

When I send a HEAD request to the one that was working, now it returns
this header (which looks like a bug, and probably relates to ticket
1840 (http://code.djangoproject.com/ticket/1840) which looks
complicated:

X-View: django.contrib.auth.decorators._checklogin

When I send a GET request, I do get the right header:

X-Object-Type: blog.post
X-Object-Id: 1

(Wait, those are actually two different things in two different places
in Django.  Hmmm...)

Both of those are using curl and using my cookies from Firefox using
the -b flag.

When I run it against another Django project (the one that wasn't
appearing to work in my other email) I see this...

HEAD:
X-View: myproject.page.views.load_page

GET:
No headers

But the view seems like that's as close as it's going to get without me
telling it how to look up which object ID it is and what object.  I
guess that's my original question:  How does it attempt to figure out
which content type and object ID to send back and if it can't, can I
help it figure it out.

One goal of this is to provide a link on the page direct to the admin
page for that object.  I suppose that could be done in the template and
when in DEBUG mode.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: django for non-web apps?

2006-10-31 Thread Rob Hudson

I think the tricky part is what Guillermo is saying.  All views take a
request object and return a response object.  You'd have something that
would have to mimic HTTP requests and work with HTTP responses.  At
that point it seems like you should just create your MVC pattern-based
app using an ORM (sqlalchemy?) and tie it to whatever front-end your
going for. (Just giving examples of what might be attractive in Django
to have in a non-web app.)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Error importing settings.py

2006-10-31 Thread sansmojo

Yay!

It worked with:

SetEnv DJANGO_SETTINGS_MODULE ce.settings
PythonPath "['/var/www/closed'] + sys.path"

Now, we have another question.  It also worked with:

SetEnv DJANGO_SETTINGS_MODULE settings
PythonPath "['/var/www/closed/ce'] + sys.path"

Is there any reason why we wouldn't want to go with the latter?

Thanks so much!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: django for non-web apps?

2006-10-31 Thread Guillermo Fernandez Castellanos

It's something I've often though about.

I've used databases in many projects, both web and not-web based. And
I am now sure that Django would have been a great help in those
non-web applications as well.

The problem would then be to strip Django of all those web-specific
libraries it's bundled with in order to lighten it and keep only the
SQL specific parts. Only if needed, of course.

Actualy, you can find examples about non-web applications where pdf
[1] or csv [2] are created dynamically in the Django doc, and even
using a template to send emails [3].

Enjoy,

G

[1] http://www.djangoproject.com/documentation/outputting_pdfs/
[2] http://www.djangoproject.com/documentation/outputting_csv/
[3] http://www.rossp.org/blog/2006/jul/11/sending-e-mails-templates/
On 10/31/06, walterbyrd <[EMAIL PROTECTED]> wrote:
>
> Django is called  "The Web framework . ."
>
> Does django also make sense for non-web apps?
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Storing images in the db

2006-10-31 Thread Jay Klehr

This is a huge religious debate that's probably not suited for this list.

I'd suggest reading the numerous topics available about this across the 
net.  Usually the best threads are in database specific lists, like 
lists.mysql.com

In those lists database admins usually jump in and speak their mind on 
the issue, which gives you another perspective on the issues at hand.

Jay


Panos Laganakos wrote:
> I'm going to work a small photo managment app for an LAN site here, and
> I wanted to hear some opinions.
>
> >From what I've seen people tend to store images outside the db and just
> keep their location field to grab em.
>
> What are the advantages/disadvantages of doing so? That way the httpd
> gets to serve them and if so, why is that important? Django keeps
> running, its not like it spawns something new like if I was doing so in
> PHP.
>
>
> >
>
>   


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



Storing images in the db

2006-10-31 Thread Panos Laganakos

I'm going to work a small photo managment app for an LAN site here, and
I wanted to hear some opinions.

>From what I've seen people tend to store images outside the db and just
keep their location field to grab em.

What are the advantages/disadvantages of doing so? That way the httpd
gets to serve them and if so, why is that important? Django keeps
running, its not like it spawns something new like if I was doing so in
PHP.


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



django for non-web apps?

2006-10-31 Thread walterbyrd

Django is called  "The Web framework . ."

Does django also make sense for non-web apps?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 do you nest two loops within a template?

2006-10-31 Thread MerMer

I found out that I needed to change the query set to a list, then I
could append new data to the end and return this.  The following is the
ammeded inclusion tag.

@register.inclusion_tag('cashtransfer.html')
def show_cash_transfer(username):
balance=[]
x=0
y=0
qs=CashTransfer.objects.filter(user=username)
item=list(qs) # convert the queery into a list
for cash in item:
x=item[y].credit+x
item[y].balance=x  #as a list we are able to append the data
y=y+1
return { 'transfers': item }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Error importing settings.py

2006-10-31 Thread Jorge Gajon

On 10/31/06, sansmojo <[EMAIL PROTECTED]> wrote:
>
> Hello all!  My server admin has set up an apache/mod_python server for
> me, but we keep getting the following error:
> http://paste.e-scribe.com/2490/
>
> Our apache config is here: http://paste.e-scribe.com/2491/
>

You probably only need to change this line in your apache config:
SetEnv DJANGO_SETTINGS_MODULE /var/www/closed/ce/settings.py

for this one:
SetEnv DJANGO_SETTINGS_MODULE ce.settings


Regards,
Jorge

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 do you nest two loops within a template?

2006-10-31 Thread MerMer

Joe,

My orginal code (see the inclusion tag below ) was returning a Query
Set and an interable list.   I can't understand how I can loop through
the Query set and append the data to the end - as there is no matching
attribute in the Query set.

 I am looking to return a query set and build a table from it.  The
last column in the table is the sum of the all the previous rows.
Here's an example.

credit   Balance
50  50
40  90
50140


Here's my orginal inclusion tag


@register.inclusion_tag('cashtransfer.html')
def show_cash_transfer(username):
balance=[]
x=0
qs=CashTransfer.objects.filter(user=username)
qs1=qs[0]
for cash in qs:
x=cash.credit+x
balance.append(x)
return { 'transfers': qs, 'balance': balance }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Field with null=True, blank unspecified, should allow null

2006-10-31 Thread yary


yary wrote:

> Do you have an example of any project in the wild, using the django
> admin, with a field "null=True, blank=False, editable=True"? I'm
> curious to know the use of such a beast in an actual implementation.

to clarify,I do think it is useful to have "null=True, blank=False,
editable=True" (ie "# of pregnancies in a population, so you don't have
men counting as 0" - I just haven't seen that combination actually
allow me to use it as I expect. When I try, it tells me the field can't
be blank. I don't want the admin to make it blank, I want it to make
the field null.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 do you nest two loops within a template?

2006-10-31 Thread Joseph Heck
This is one of those things that just isn't exceptionally straightfoward to accomplish.From within a template, and without extensions, I can't think of how you would do that immediately. It sounds like you have a relatively simple set of data, so I'd recommend instead on "tweaking" the data you have in the view prior to sending it to the template to be rendered.
Within the view, loop through your values for "b" that match up with each of the transfers, and assign a new variable (maybe "b") to each transfer as you go through the list - then you can reference it in the one loop:
{% for cash in transfers %}...{{ cash.credit }}{{ cash.debit }}
{{ cash.b }}{% endfor %}There are a couple of other references for how to display tabular data, both of which boil down to extending the tags - either with a TemplateTag or a Filter. 
-joeOn 10/31/06, Merric Mercer <[EMAIL PROTECTED]> wrote:
As a newbie to Python, I can't see how one can nest two loops within atemplate.  Taking the template below, I have an additional list which Ineed to iterate over  in order to display a single figure for the last
cell in each table row.Currently, if I add a for loop to the last cell (eg.  {% for b inbalance %} {{ b }} {% endfor %} ), I get all the values of the list inthe cell - which is not want I want.
The documentation mentions a forloop.parentloop but I'm not sure  how toapply this or whether it is the solution.   Can anybody help?MerMer{% for cash in transfers %}
{{ cash.date }}{{ cash.source }}{{ cash.credit }}{{ cash.debit }}  {{ b }} {% endfor %}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django users" group.  To post to this group, send email to django-users@googlegroups.com  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: Just when I think I've got Karma working

2006-10-31 Thread Guillermo Fernandez Castellanos

Maybe the bug is in KarmaScoreManager.vote():
karma = self.get(content_type=content_type,object_id=object_id)
might need to be:
karma = self.get(content_type__pk=content_type,object_id=object_id,
user__pk=user_id)
otherwise, you'll get a set of karma votes for a given object, instead
of the vote of a given person for a given object. Thus, you will
always go to the  except self.model.DoesNotExist part of the code.

And it seems that the KarmaScore class should have the fields
content_type and object_id named as such
(http://www.djangoproject.com/documentation/models/generic_relations/#c1876),
while you seems to call them content_type_id in here:
karma = self.model(None, user_id=user_id,
content_type_id=content_type, object_id=object_id, score=rating,
scored_date=datetime.datetime.now())

As well, if you add this field to the KarmaScore:
content_object = models.GenericForeignKey()
and pass the objecto to vote on in your vote function, you would be
able to create your karma objects like this:
karma = self.model(None, user_id=user_id, content_object=object,
score=rating, scored_date=datetime.datetime.now())
without needing to explicitely pass the content_type and object_id.

Oh... and in your KarmaScore model,
scored_date=datetime.datetime.now(), you might want to add the
auto_add=True option to DateTimeField.

Disclaimer: I have never used the Generic relations, and all my
conclusions come from the docs:
http://www.djangoproject.com/documentation/models/generic_relations/
and is sometimes difficult to answer such questions without the whole
code and some testing.

Hope it helps,

G


On 10/31/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Guillermo Fernandez Castellanos wrote:
> > Hi,
> >
> > Just guessing, but if I understood well the error you get, that's normal.
> >
> > The KarmaScoreManager is not the amount of karma of a coment (or in
> > your case an object). It keeps in the database the karma score that a
> > given user gave to a specific comment (or object). As there is a
> > single score per user and per object, you can only override the total
> > karma.
> >
> > The key point of the calculation of the karma is in the Comment model:
> > def _fill_karma_cache(self):
> > "Helper function that populates good/bad karma caches"
> > good, bad = 0, 0
> > for k in self.karmascore_set.all():
> > if k.score == -1:
> > bad +=1
> > elif k.score == 1:
> > good +=1
> > self._karma_total_good, self._karma_total_bad = good, bad
> >
> > For a given Comment, the function of the model will take all the
> > KarmaScore for the given comment (self.karmascore_set.all()) and
> > iterate over them to calculate the total karma of the Comment (self).
> >
> > If you want to do a generic karma, you might want to add a function to
> > the manipulator that will do just this, take an id and content_type,
> > get() the object, find all the KarmaScores that are related to this
> > object (self.karmascore_set.all()) and calculate the total karma by
> > iterating over those.
> >
> > Hope it helps,
> >
> > G
> >
> I thought I had taken care of that. Apparently not. I have:
>
> def _fill_karma_cache(self):
>good, bad = 0, 0
>from django.contrib.contenttypes.models import ContentType
>from gretschpages.karma.models import KarmaScore
>ctype = ContentType.objects.get(model='gpuser')
>
>for k in KarmaScore.objects.filter(content_type=ctype.id,
> object_id=self.id):
>if k.score == -1:
>bad +=1
>elif k.score == 1:
>good +=1
>self._karma_total_good, self._karma_total_bad = good, bad
>
> But something's going awry.
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 with Intermediate Table - How to use built in admin?

2006-10-31 Thread Vortexmind

Hi all
I am currently developing a rather large data model, and I need to use
Many-to-Many with Intermediate Table (as I need to stick some
attributes within the association). I try to explain with the Django
example about this issue:

from django.db import models

class Reporter(models.Model):
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=30)

class Article(models.Model):
headline = models.CharField(maxlength=100)
pub_date = models.DateField()

class Writer(models.Model):
reporter = models.ForeignKey(Reporter)
article = models.ForeignKey(Article)
position = models.CharField(maxlength=100)

So far, if i add

class Admin:
pass

to all the above I can edit them. But what if I want to have the inline
admin to make the Writer relation when adding an Article or a Reporter?
If I do as above, I must add Reporter, then Article, then I can finally
go in the Writer admin interface and do the join. I hope you understand
me :)

Thank to you all, so far Django is the framework that gave me less
problems ... I just started to look at it yesterday ^^


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Field with null=True, blank unspecified, should allow null

2006-10-31 Thread yary

James Bennett wrote:
> On 10/25/06, yary <[EMAIL PROTECTED]> wrote:
> > Seems that if someone says a field can be null, that implies the admin
> > interface should let it be null.
>
> I really, really, really don't like having a system assume that one
> thing I've done "implies" another thing it should do. I also don't
> like breaking the consistency of "blank defaults to False any time
> it's not specified".

Do you have an example of any project in the wild, using the django
admin, with a field "null=True, blank=False, editable=True"? I'm
curious to know the use of such a beast in an actual implementation.

null=True, blank=False breaks the admin UI, as it is in Django 0.95. It
doesn't let the user distinguish between a blank entry and a null
entry.

That combination does make sense if you have a char field that you
don't want blank, but would allow to be null. I changed the title of
this thread to reflect that. My updated request:

If a field has "null=True, blank=False, editable=True", the admin
should have a way to nullify the field (and it should work weather it
is numeric, character,foreign-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
-~--~~~~--~~--~--~---



How to take more control of HTML form elements generated by Manipulators?

2006-10-31 Thread [EMAIL PROTECTED]

Hi everyone,
The cool Manipulator feature in Django did save me lots of time while
developing forms, cheers for developers who wrote it first:-)
But as a CSS-aholic web developer, I find that I can not define or
modify form elements' attributes such as "id", "class", "style"
generated by default Manipulator with my hand!
I have tried to create a new Manipulator class myown but unluckily the
forms.xxxField stuff does not have any args like "id", "class",
"style".
I really need it because the attributes I listed above, I think, are
really important when you need to work with JavaScript...
Any ideas? 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
-~--~~~~--~~--~--~---



Filters on Foreign Key select boxes

2006-10-31 Thread Vortexmind

Hi
I was wondering about this. Is it possible to apply filters in prebuilt
admin application so that we can filter out the contents of the select
boxes from foreign keys, using a criteria defined by the user (a
text-pattern based match should be sufficient)?

Example

class Airplane(...)
name = ...
manufacturer = models.ForeignKey(Manufacturer)

class Admin:


class Manufacturer
name= ...
blah blah ...

With the above schema, I have in the Airplane admin a select box with
all the manufacturers to choose from. But what if the Manufacturer list
grows in size and the user must choose between hundreds of
manufacturers? Is there a way to filter them out without rewriting
entire parts of admin apps?

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



Poor man's model inheritance question.

2006-10-31 Thread medhat

Hi,

I am using OneToOneField to simulate model inheritance. I have all the
shared fields in a base model, and then for every specific case I have
a derived model that has a OneToOneField to that base model. That was
all working fine.

Recently I was trying to encapsulate some of the functionality that is
in all the derived models into a base class. So I have something
similar to the following:

---
class Base(models.Model):
   common_field = models.CharField()

class CommonFunc(models.Model):
   def save(self):
  do_common_thing()
  super(CommonFunc,self).save()

class DerivedModel(CommonFunc):
   base = models.OneToOneField(Base)
   specific_field = models.CharField()
---

The problem I am having is that for some reason it is not detecting
that the one-to-one field is a primary key and when I syncdb it gives
me an error that DerivedModel has two primary keys since django adds
the implicit id field.

Is this a bug? Is there a better way for me to achieve this? Or should
I just wait patiently until model inheritance is implemented?

-- 
Thanks,
Medhat


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



Per Server / Per Application threads?

2006-10-31 Thread ZebZiggle

Hey all!

I want to spawn a thread when Apache starts that will do some stuff in
the background. The thread will need to access the Django data model.
I'd really like the solution to work with the development environment
too (non-apache).

I was thinking about just using a singleton during a per-session/view
request, but this means that nothing will happen before the first
request comes in (also, there is the question of how safe it is to keep
a reference to the data model around from the view thread).

The actual problem is I want to clean up crud left around from inactive
users every 24 hours.

I don't really want to have to use cron to spawn my "cleanup" code.

Any suggestions on how to do this?

-S


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



for loop break

2006-10-31 Thread Henhiskan

Hi guys, I try it to do a break on a for loop (django template).
For example, iterates until find a element. How can I make it?

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: for loop break

2006-10-31 Thread James Bennett

On 10/31/06, Henhiskan <[EMAIL PROTECTED]> wrote:
> Hi guys, I try it to do a break on a for loop (django template).
> For example, iterates until find a element. How can I make it?

This really feels more like something that would belong in the view;
if you want a particular list or dictionary to only contain a subset
of elements, or just one specific element, then view is the place to
do that -- the template is meant more to render the data that's handed
to it, not to further manipulate the data.

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



Index of an item in a QuerySet

2006-10-31 Thread samuel

Hi all,

I'm probably just not seeing it, but how do  I go about getting the
index of an item in a query set? I.E., this article is the Xth article
in this queryset of articles sorted by date.

Thanks,
Sam


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Index of an item in a QuerySet

2006-10-31 Thread James Bennett

On 10/31/06, samuel <[EMAIL PROTECTED]> wrote:
> I'm probably just not seeing it, but how do  I go about getting the
> index of an item in a query set? I.E., this article is the Xth article
> in this queryset of articles sorted by date.

If you're looping through them in the template with the 'for' tag,
each time through the loop you'll have access to a variable called
'forloop.counter' which has this information; the first time through
it will be 1, the second time it will be 2, and so on.

See http://www.djangoproject.com/documentation/templates/#for for details.

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



Runserver reloads all over and over again

2006-10-31 Thread Pythoni

Is it nescessary to use runserver with the same Django version or is it
possible to mix them?
I use Django 0.91 and I somehow mixed Django  with a runserver (
probably version 0.95 and 0.90 or 0.91) and now runserver reloads
without any good reason.
Thank you for help
L.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 a Dynamic set of choices in Admin

2006-10-31 Thread patrickk

if you´re talking about the admin-interface, the one thing I can  
think of is:

copy change_form.html and use a js-framework (e.g. jquery):
1. on change dynamic-field-1 do ajax
2. get xml response
3. populate dynamic-field-2

patrick

Am 31.10.2006 um 12:41 schrieb MerMer:

>
> Is it possible to set up Dynamic set of choices.
>
> Suppose I have a Model which requires two additional fields.  The  
> first
> is a foreign key to USER.  The second field needs be dynamically
> populated depending on what is entered into the User Field.
>
> I cant see how this can be achieved.  Is there any way?
>
> MerMer
>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: is there any guide for creating custom Models Field?

2006-10-31 Thread Frankie Robertson

On 31/10/06, Enoch <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I have used Django for 2 months, and I really enjoy the rich features
> of django framework. Now I have a question and hope I can get help
> here.
>
> I'd like to write my own Models Field which likes EmailField, FileField
> integrated with Django. I read all the Models related documents but
> didn't get any clue how to start it. My basic requests may include
>
> 1) I hope my field can inherit from Django defualt Models, including
> "models.ManyToManyField" and "models.ForeignKey".
>
> For example now I need a MyForeignKey field inherit from ForeignKey, I
> will override the default "save()" functions and may add more functions
>
> 2) I hope the new Field that I created can still utilize the functions
> of "model", "admin", "generic view" etc
>
> 3) If it's possible I hope put the codes in a new app rather than hack
> the django original files
>
> I'm still a newbie of django framework, but I I'd like to learn it, use
> it more and more. This is my first post here, if there is anything
> already there which I can read please let me know, any suggestion
> appreciated.

Not much documentation on this area. (There could well be something on
the wiki) Luckily, some one has written about it here
(http://blog.tkbe.org/).

>
>
> >
>


-- 
http://grimboy.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: captcha problem

2006-10-31 Thread Dirk Eschler

Am Dienstag, 31. Oktober 2006 15:20 schrieb Dirk Eschler:
> In this case i would expect a TemplateSyntaxError. Since you don't get one,
> i suppose it is loaded.
>
> I tried to reproduce your error: i get empty captcha_* values when my
> captcha/urls.py is wrong. Judging from the code you have posted, i think it
> should look like:
>
> urlpatterns = patterns('anastas.apps.captcha.views',
> (r'^i/$', 'image'),
> (r'^json/$', 'json'),
> )

Uh wait, only the image is broken in this case.

Another thing to check, does pycaptcha write anything to your tmp dir? By 
default it seems to create the temporary image at /tmp/pycaptcha_1.

-- 
Dirk Eschler 
http://www.krusader.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
-~--~~~~--~~--~--~---



Re: Just when I think I've got Karma working

2006-10-31 Thread [EMAIL PROTECTED]

Guillermo Fernandez Castellanos wrote:
> Hi,
>
> Just guessing, but if I understood well the error you get, that's normal.
>
> The KarmaScoreManager is not the amount of karma of a coment (or in
> your case an object). It keeps in the database the karma score that a
> given user gave to a specific comment (or object). As there is a
> single score per user and per object, you can only override the total
> karma.
>
> The key point of the calculation of the karma is in the Comment model:
> def _fill_karma_cache(self):
> "Helper function that populates good/bad karma caches"
> good, bad = 0, 0
> for k in self.karmascore_set.all():
> if k.score == -1:
> bad +=1
> elif k.score == 1:
> good +=1
> self._karma_total_good, self._karma_total_bad = good, bad
>
> For a given Comment, the function of the model will take all the
> KarmaScore for the given comment (self.karmascore_set.all()) and
> iterate over them to calculate the total karma of the Comment (self).
>
> If you want to do a generic karma, you might want to add a function to
> the manipulator that will do just this, take an id and content_type,
> get() the object, find all the KarmaScores that are related to this
> object (self.karmascore_set.all()) and calculate the total karma by
> iterating over those.
>
> Hope it helps,
>
> G
>
I thought I had taken care of that. Apparently not. I have:

def _fill_karma_cache(self):
good, bad = 0, 0
from django.contrib.contenttypes.models import ContentType
from gretschpages.karma.models import KarmaScore
ctype = ContentType.objects.get(model='gpuser')

for k in KarmaScore.objects.filter(content_type=ctype.id,
object_id=self.id):
if k.score == -1:
bad +=1
elif k.score == 1:
good +=1
self._karma_total_good, self._karma_total_bad = good, bad

But something's going awry.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 does one pass a variable to a Custom Model Manager for use in an inclusion tag?

2006-10-31 Thread MerMer

Many thanks, Rajesh.  I'll take a look.

MerMer


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: captcha problem

2006-10-31 Thread Grigory Fateyev

Hello Dirk Eschler!
On Tue, 31 Oct 2006 15:32:03 +0100 you wrote:

> > urlpatterns = patterns('anastas.apps.captcha.views',
> > (r'^i/$', 'image'),
> > (r'^json/$', 'json'),
> > )
This is like mine.
 
> Uh wait, only the image is broken in this case.
> 
> Another thing to check, does pycaptcha write anything to your tmp
> dir? By default it seems to create the temporary image
> at /tmp/pycaptcha_1.

>>> tempfile.gettempdir()
'/tmp/.private/greg'

# ls -la /tmp/.private/greg/py*
-rw-r--r--  1 greg greg 12288 ïËÔ 30
18:36 /tmp/.private/greg/pycaptcha_1

It is right?

-- 
÷ÓÅÇÏ ÎÁÉÌÕÞÛÅÇÏ! çÒÉÇÏÒÉÊ
greg [at] anastasia [dot] ru
ðÉÓØÍÏ ÏÔÐÒÁ×ÌÅÎÏ: 2006/10/31 18:07

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: captcha problem

2006-10-31 Thread Dirk Eschler

Am Dienstag, 31. Oktober 2006 14:24 schrieb Grigory Fateyev:
> Hello Aidas Bendoraitis!
>
> On Tue, 31 Oct 2006 12:11:00 +0100 you wrote:
> > Maybe your captcha template tag is not loaded? Did you put it in the
> > right place?
>
> Thanks for replay!
>
> I am sure templsate is in the right place:
> anastas/
> apps/
> captcha/
> templatetags/
> captcha.py
> urls.py
> utils.py
> views.py
>
> How to check if it load?

In this case i would expect a TemplateSyntaxError. Since you don't get one, i 
suppose it is loaded.

I tried to reproduce your error: i get empty captcha_* values when my 
captcha/urls.py is wrong. Judging from the code you have posted, i think it 
should look like:

urlpatterns = patterns('anastas.apps.captcha.views',
(r'^i/$', 'image'),
(r'^json/$', 'json'),
)

-- 
Dirk Eschler 
http://www.krusader.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
-~--~~~~--~~--~--~---



Re: captcha problem

2006-10-31 Thread Grigory Fateyev

Hello Aidas Bendoraitis!
On Tue, 31 Oct 2006 12:11:00 +0100 you wrote:

> Maybe your captcha template tag is not loaded? Did you put it in the
> right place?

Thanks for replay!

I am sure templsate is in the right place:
anastas/
apps/
captcha/
templatetags/
captcha.py
urls.py
utils.py
views.py

How to check if it load?

-- 
÷ÓÅÇÏ ÎÁÉÌÕÞÛÅÇÏ! çÒÉÇÏÒÉÊ
greg [at] anastasia [dot] ru
ðÉÓØÍÏ ÏÔÐÒÁ×ÌÅÎÏ: 2006/10/31 16:19

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



is there any guide for creating custom Models Field?

2006-10-31 Thread Enoch

Hi

I have used Django for 2 months, and I really enjoy the rich features
of django framework. Now I have a question and hope I can get help
here.

I'd like to write my own Models Field which likes EmailField, FileField
integrated with Django. I read all the Models related documents but
didn't get any clue how to start it. My basic requests may include

1) I hope my field can inherit from Django defualt Models, including
"models.ManyToManyField" and "models.ForeignKey".

For example now I need a MyForeignKey field inherit from ForeignKey, I
will override the default "save()" functions and may add more functions

2) I hope the new Field that I created can still utilize the functions
of "model", "admin", "generic view" etc

3) If it's possible I hope put the codes in a new app rather than hack
the django original files

I'm still a newbie of django framework, but I I'd like to learn it, use
it more and more. This is my first post here, if there is anything
already there which I can read please let me know, any suggestion
appreciated.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: SelectMultipleField without multiple fields in POST

2006-10-31 Thread [EMAIL PROTECTED]

wow thanks...that's it!
Thanks for your answer and the link to the doc.
I totally surveyed this part of the documentation. (sorry)

In the moment i am in the university. I will try your trick immediately
i arrived my job.


cu
Rafael


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: captcha problem

2006-10-31 Thread Aidas Bendoraitis
Maybe your captcha template tag is not loaded? Did you put it in the
right place?

Regards,
Aidas Bendoraitis aka Archatas


On 10/31/06, Grigory Fateyev <[EMAIL PROTECTED]> wrote:
>
> Hello Grigory Fateyev!
> On Mon, 30 Oct 2006 21:30:01 +0300 you wrote:
>
> > Why it can be, and how to fix it?
>
> Please, any suggestions?
>
> --
> ÷ÓÅÇÏ ÎÁÉÌÕÞÛÅÇÏ! çÒÉÇÏÒÉÊ
> greg [at] anastasia [dot] ru
> ðÉÓØÍÏ ÏÔÐÒÁ×ÌÅÎÏ: 2006/10/31 13:06
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: SelectMultipleField without multiple fields in POST

2006-10-31 Thread Frankie Robertson

On 31/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> in the last time i use django to create a gui for the internet. and it
> works fine.
> I have a lot of m2m relations. and they really work great.
> But there are one problem:
>
> In a custom manipulator:
>
> class AddRelationManipulator(forms.Manipulator):
>def __init__(self):
>self.fields = (
>forms.SelectMultipleField(field_name="r_client", size=10,
> choices=[(cl.id, cl.__str__()) for cl in Clients.objects.all()]),
>
>)
>
> I have a SelectMultipleField the show all clients from a model. If i
> use this manipulator i should select a piece of fields. Normally, as
> many fields should come back as i had selected. The problem is, that
> only comes ONE field (client object) back by POST.

If you are checking request.POST['r_client'] or something then you'll
only get the last of the POST'd objects. Try using
request.POST.getlist('r_client'), that returns a list of all the
things posted with that name. For more information see the
documentation of QueryDict
http://www.djangoproject.com/documentation/request_response/#querydict-objects

(Sorry if this isn't your problem, I'm poking about in the dark a bit.)

>
> thank,
>
> Rafael
>
>
> >
>


-- 
http://grimboy.co.uk

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



SelectMultipleField without multiple fields in POST

2006-10-31 Thread [EMAIL PROTECTED]

Hello,

in the last time i use django to create a gui for the internet. and it
works fine.
I have a lot of m2m relations. and they really work great.
But there are one problem:

In a custom manipulator:

class AddRelationManipulator(forms.Manipulator):
def __init__(self):
self.fields = (
forms.SelectMultipleField(field_name="r_client", size=10,
choices=[(cl.id, cl.__str__()) for cl in Clients.objects.all()]),

)

I have a SelectMultipleField the show all clients from a model. If i
use this manipulator i should select a piece of fields. Normally, as
many fields should come back as i had selected. The problem is, that
only comes ONE field (client object) back by POST. 

thank,

Rafael


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: captcha problem

2006-10-31 Thread Grigory Fateyev

Hello Grigory Fateyev!
On Mon, 30 Oct 2006 21:30:01 +0300 you wrote:

> Why it can be, and how to fix it?

Please, any suggestions?

-- 
Всего наилучшего! Григорий
greg [at] anastasia [dot] ru
Письмо отправлено: 2006/10/31 13:06

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