Re: transaction commit

2007-07-24 Thread Andrey Khavryuchenko


 NAA> On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
 >> Yes, I read carefuly your question and thought the answer was
 >> straighforward.   I don't understand why you don't want decorators, but you
 >> could just check the decorator definition to read what it does and copy
 >> it's code.  All you need is decorator name and grep over django sources :)

 NAA> Aren't decorators usable only in views? 

Decorators are python feature.  Django views are regular functions, just as
any other.

 NAA> At least that's what I think.  I have a project that required a
 NAA> separately running process (running as daemon) that needed access to
 NAA> the Django models. Since the code in the daemon is not run in the
 NAA> context of a view (no triggering of TransactionMiddleware),
 NAA> transactions decorators do not work. I get:

 NAA> TransactionManagementError: This code isn't under transaction management

Not having read transaction code, can't say what haven't worked in your
case.  Definitely, something wasn't initialized :)

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua 
Call akhavr1975 on www.gizmoproject.com

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



Re: unbound method get_profile()

2007-07-24 Thread Jack Woods

Works!

New to Django/python, and you just solved an hour's worth of head
trauma.

Thanks Russ!

On Jul 25, 2:33 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > def profile(request):
> > template_name = 'user_profile.html'
> > obj_list = User.get_profile()
> ...
> > unbound method get_profile() must be called with User instance as
> > first argument (got nothing instead)
>
> Look closer at the code - the error message is telling you what is
> wrong. Heres a hint: which user instance are you calling get_profile()
> on?
>
> User is the name of the class; if you're looking for the instance of
> User that has made the request, you're looking for
> request.user.get_profile() (assuming you have the authentication
> middleware installed).
>
> Yours,
> Russ Magee %-)


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



Re: Shift a QuerySet?

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Oops, that should read "Cannot resolve keyword 'playlist_aggreation'
> into field", even though I am messing with song aggregations and
> playlist aggregations :)

Apologies - I got tied up in underscores :-)

Try:

Playlist.objects.filter(playlistaggreagation__count__gte=3)

Russ %-)

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



Re: unbound method get_profile()

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> def profile(request):
> template_name = 'user_profile.html'
> obj_list = User.get_profile()
...
> unbound method get_profile() must be called with User instance as
> first argument (got nothing instead)

Look closer at the code - the error message is telling you what is
wrong. Heres a hint: which user instance are you calling get_profile()
on?

User is the name of the class; if you're looking for the instance of
User that has made the request, you're looking for
request.user.get_profile() (assuming you have the authentication
middleware installed).

Yours,
Russ Magee %-)

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



Re: Shift a QuerySet?

2007-07-24 Thread [EMAIL PROTECTED]

Oops, that should read "Cannot resolve keyword 'playlist_aggreation'
into field", even though I am messing with song aggregations and
playlist aggregations :)

On Jul 24, 11:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thanks!
>
> All of your workarounds involving filter didn't work, erroring with
> "Cannot resolve keyword 'song_aggregation' into field", which makes
> sense since I really wanted to go the other way around, I think.
>
> Anyways, after some munging with 'extra', as per your suggestion, I
> got it working!
>
> Thanks again,
> Eric
>
> On Jul 24, 10:36 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > > An analogous operation would be:
> > > playlist_aggregates = PlaylistAggregation.objects.order_by('-count')
> > > playlists = [p.playlist for p in playlist_aggregates]
>
> > The query itself looks like it's just a query over Playlist objects
> > where all the query terms relate to Playlist_aggregate, e.g.,
>
> > Playlist.objects.filter(playlist_aggregation__count=3)
>
> > The ordering issue is a little more difficult. Ideally, it sounds like
> > you want to be able to write:
>
> > Playlist.objects.all().order_by('playlist_aggregation.count')
>
> > but the query syntax doesn't currently support this; order_by isn't
> > taken into account when the joins are determined. This is part of a
> > task that Malcolm is currently looking at.
>
> > In the interim, there are a few workarounds. In the end, the argument
> > to order_by is just the SQL name of the attribute; it just happens
> > that for attributes on a model, the SQL name matches the attribute
> > name. However, you can use this to cheat a bit. If you substitute the
> > SQL name for the joined column, you can order by joined attribute - as
> > long as the related table is actually joined in the SQL query.
>
> > A normal Playlist.objects.all() query won't join Playlist_aggregation
> > - so you'll need to fake it. Either add a meaningless filter, like
> > filter(playlist_aggregation__count__gte=0) (which will join the table,
> > but not reject any rows), or use the 'extra' clause to manually add
> > the join required.
>
> > Yours,
> > Russ Magee %-)


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



Re: Shift a QuerySet?

2007-07-24 Thread [EMAIL PROTECTED]

Thanks!

All of your workarounds involving filter didn't work, erroring with
"Cannot resolve keyword 'song_aggregation' into field", which makes
sense since I really wanted to go the other way around, I think.

Anyways, after some munging with 'extra', as per your suggestion, I
got it working!

Thanks again,
Eric

On Jul 24, 10:36 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > An analogous operation would be:
> > playlist_aggregates = PlaylistAggregation.objects.order_by('-count')
> > playlists = [p.playlist for p in playlist_aggregates]
>
> The query itself looks like it's just a query over Playlist objects
> where all the query terms relate to Playlist_aggregate, e.g.,
>
> Playlist.objects.filter(playlist_aggregation__count=3)
>
> The ordering issue is a little more difficult. Ideally, it sounds like
> you want to be able to write:
>
> Playlist.objects.all().order_by('playlist_aggregation.count')
>
> but the query syntax doesn't currently support this; order_by isn't
> taken into account when the joins are determined. This is part of a
> task that Malcolm is currently looking at.
>
> In the interim, there are a few workarounds. In the end, the argument
> to order_by is just the SQL name of the attribute; it just happens
> that for attributes on a model, the SQL name matches the attribute
> name. However, you can use this to cheat a bit. If you substitute the
> SQL name for the joined column, you can order by joined attribute - as
> long as the related table is actually joined in the SQL query.
>
> A normal Playlist.objects.all() query won't join Playlist_aggregation
> - so you'll need to fake it. Either add a meaningless filter, like
> filter(playlist_aggregation__count__gte=0) (which will join the table,
> but not reject any rows), or use the 'extra' clause to manually add
> the join required.
>
> Yours,
> Russ Magee %-)


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



Re: List with pagination, sorting and simple search interface

2007-07-24 Thread Przemek Gawronski

> Thanks. Finally I've used PaginatorPag from your link (with some
> changes) and
> Sortable Headers (from djangosnippets) with some changes too, newforms
> to create search form and generic list.
> Changes I had to do were necessary because each of those components -
> sort, filter and pagination should
> know about others parameters, eg. while sorting you shouldn't lost
> filter parameters etc.

Maybe you could put it at djangosnippets for others? I would be more
then happy to take a look at it :)

Przemek
-- 
AIKIDO TANREN DOJO  -   Poland - Warsaw - Mokotow - Ursynow - Natolin
info: http://www.tanren.pl/ phone: +4850151 email: [EMAIL PROTECTED]

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



unbound method get_profile()

2007-07-24 Thread [EMAIL PROTECTED]

Hey all,

I feel like I may be missing a small thing, but here it is.

from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib import auth

def profile(request):
template_name = 'user_profile.html'
obj_list = User.get_profile()
return render_to_response(template_name, locals(),
context_instance=RequestContext(request))

Simple enough.  But when I try to render the page, I get:

unbound method get_profile() must be called with User instance as
first argument (got nothing instead)

I have AUTH_PROFILE_MODULE set correctly, and I can pass normal user
data through to the page fine.  Any ideas?


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



Re: Shift a QuerySet?

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> An analogous operation would be:
> playlist_aggregates = PlaylistAggregation.objects.order_by('-count')
> playlists = [p.playlist for p in playlist_aggregates]

The query itself looks like it's just a query over Playlist objects
where all the query terms relate to Playlist_aggregate, e.g.,

Playlist.objects.filter(playlist_aggregation__count=3)

The ordering issue is a little more difficult. Ideally, it sounds like
you want to be able to write:

Playlist.objects.all().order_by('playlist_aggregation.count')

but the query syntax doesn't currently support this; order_by isn't
taken into account when the joins are determined. This is part of a
task that Malcolm is currently looking at.

In the interim, there are a few workarounds. In the end, the argument
to order_by is just the SQL name of the attribute; it just happens
that for attributes on a model, the SQL name matches the attribute
name. However, you can use this to cheat a bit. If you substitute the
SQL name for the joined column, you can order by joined attribute - as
long as the related table is actually joined in the SQL query.

A normal Playlist.objects.all() query won't join Playlist_aggregation
- so you'll need to fake it. Either add a meaningless filter, like
filter(playlist_aggregation__count__gte=0) (which will join the table,
but not reject any rows), or use the 'extra' clause to manually add
the join required.

Yours,
Russ Magee %-)

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



Re: Shift a QuerySet?

2007-07-24 Thread [EMAIL PROTECTED]

Good point, that's actually kind of embarassing.  I don't actually
expect to be able to use that syntax but I thought it would be
constructive.

Let me try again:
I have a QuerySet of PlaylistAggregation objects.  Each
PlaylistAggregation object is related to one Playlist object.  I want
to change my QuerySet to select only the related Playlist objects.

An analogous operation would be:
playlist_aggregates = PlaylistAggregation.objects.order_by('-count')
playlists = [p.playlist for p in playlist_aggregates]

But there are some significant downsides for doing that...namely, the
playlist_aggregates QuerySet is evaluated (if I want to paginate the
results, use generic views, etc. it becomes much harder).

Thanks for your help,
Eric

On Jul 24, 10:09 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > This may sound like a strange inquiry, but is there any way using
> > Django's ORM to "shift" a queryset?  To explain my question, I'll
> > provide an example.
> ...
> > Now, I want to "shift" my queryset to be a queryset of JUST the
> > related playlist objects:
> > playlists = playlist_aggregates.shift(playlist)
>
> This example doesn't explain anything - it just shows the syntax you
> expect to be able to use. What exactly is "shifting"? What behaviour
> do you expect "shift" to implement?
>
> Yours,
> Russ Magee %-)


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



Re: Shift a QuerySet?

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> This may sound like a strange inquiry, but is there any way using
> Django's ORM to "shift" a queryset?  To explain my question, I'll
> provide an example.
...
> Now, I want to "shift" my queryset to be a queryset of JUST the
> related playlist objects:
> playlists = playlist_aggregates.shift(playlist)

This example doesn't explain anything - it just shows the syntax you
expect to be able to use. What exactly is "shifting"? What behaviour
do you expect "shift" to implement?

Yours,
Russ Magee %-)

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



Re: using javascript to update a ChoicesField: getting "not one of the available choices."

2007-07-24 Thread hotani

Ah nice. That will do the trick. Thanks!


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



Shift a QuerySet?

2007-07-24 Thread [EMAIL PROTECTED]

Hello,

This may sound like a strange inquiry, but is there any way using
Django's ORM to "shift" a queryset?  To explain my question, I'll
provide an example.

class Playlist(models.Model):
title = models.CharField(maxlength=256, null=True, blank=True)
user = models.ForeignKey(User)


class PlaylistAggregation(models.Model):
playlist = models.ForeignKey(Playlist)
count = models.IntegerField(default=0)

Now, on one of my pages I want to order by the count in
PlaylistAggregation, e.g.
playlist_aggregates = PlaylistAggregation.objects.order_by(u'-count')

Now, I want to "shift" my queryset to be a queryset of JUST the
related playlist objects:
playlists = playlist_aggregates.shift(playlist)

I'm baffled by this last step.  In the documentation, it says that it
should be possible to just do:
playlists = Playlist.objects.order_by('-
x_playlistaggregates.count')
but that throws errors.

Maybe I'm just overstepping the limits of the ORM?  Thanks in advance
for any comments/suggestions!

-Eric


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



Re: Customizing the settings configuration

2007-07-24 Thread gorans

Thanks for the help.

That's going to save me heaps and heaps of time.

Thanks again.

Goran

On Jul 25, 10:01 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/24/07, gorans <[EMAIL PROTECTED]> wrote:
>
>
>
> > I though that there could be a way to trick Django into reading
> > special development settings for me, something like having a settings
> > 'package' import separate settings files:
>
> No need for any special handling - just use the --settings option to
> manage.py, or the DJANGO_SETTINGS_MODULE environment variable.
>
> ./manage.py --settings=mysite.localsettings runserver
>
> or
>
> ./manage.py --settings=mysite.serversettings runserver
>
> If there are common elements in the two settings file, then put
>
> from mysite.commonsettings import *
>
> at the top of your localsettings/serversettings file. This will pull
> in all the settings from the common settings file.
>
> If putting your settings files into a package will make organization
> easier, go right ahead - just remember to put the extra path into your
> --settings. e.g.:
>
> ./manage.py --settings=mysite.settings.serversettings runserver
>
> Yours,
> Russ Magee %-)


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



Re: Instant Django

2007-07-24 Thread cjl

YML:

Thanks for the follow up bug report.  It looks like I was using
ExeMaker incorrectly.

In the utilities folder is a file named 'update.bat'. Change the
following line:

exemaker %CD%\Utilities\django-admin.py %CD%\Utilities

To read:

exemaker -i %CD%\Python25\python.exe %CD%\Utilities\django-admin.py %CD
%\Utilities

Then double-click start.bat, and type 'update' and the command prompt,
and press enter.  This should re-create django-admin.exe using the new
directives, which specify which python interpreter to use. I am
curious to see if this solves your problem.  If so, I will update the
download.

Thanks again,
cjlesh


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



learning django testing

2007-07-24 Thread james_027

hi,

Here's another newbie stupid question ... I've heard testing
everywhere from software development world, and the testing I know is
to run the application I am developing and do all the possibilities
that I user might do to make sure that the application behaves how it
should be.

I am studying this nice tutorial 
http://toys.jacobian.org/presentations/2007/oscon/tutorial/
And the first topic is testing. I don't have any idea what is the
testing all about. Is testing means writing a program that will
simulate the usage of an application? Could someone point me to a good
short introduction about testing that is somehow gear towards to
django or python?

Thanks
james


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



Re: Uploading 1 image...making multiple dimensions of that image?

2007-07-24 Thread John Shaffer

You might want to look at #4115, which adds a thumbnail filter:
http://code.djangoproject.com/ticket/4115

Using this, instead of making multiple copies of the image when you
upload it, you simply upload the original highest-quality image. When
the thumbnail filter is used in a template, it checks if an image
exists with the requested dimensions, and creates the image if it does
not already exist. It can also generate the image tag automatically
for you and avoid any distortion.

The patch places the files in "django.contrib.thumbnails", but you can
actually put the thumbnails directory anywhere. Just add it your
INSTALLED_APPS (that would be "myproject.thumbnails" if you placed it
in "myproject/thumbnails/") and {% load thumbnails %} will load the
filters. Do read the docs (the docs are the last file in the patch).

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



Re: Django - technology or magic?

2007-07-24 Thread to_see


Thank you all for the constructive, informative and supportive posts.
I think more time and study will put me right.


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



Re: transaction commit

2007-07-24 Thread Nimrod A. Abing

Hello everyone,

On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
> Yes, I read carefuly your question and thought the answer was
> straighforward.   I don't understand why you don't want decorators, but you
> could just check the decorator definition to read what it does and copy
> it's code.  All you need is decorator name and grep over django sources :)

Aren't decorators usable only in views? At least that's what I think.
I have a project that required  a separately running process (running
as daemon) that needed access to the Django models. Since the code in
the daemon is not run in the context of a view (no triggering of
TransactionMiddleware), transactions decorators do not work. I get:

TransactionManagementError: This code isn't under transaction management

So being able to use transactions manually would be useful.
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

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



Re: django.contrib.dataplot 0.3

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, Toby Dylan Hocking <[EMAIL PROTECTED]> wrote:

> However, I thought that the contrib/ subdirectory of the django
> distribution would be the most natural place to install it, since it is an
> add-on app that is meant to be used by other apps. Can you suggest another
> location that would be more appropriate and/or less "confusing"?

There's no need for the application to be in the Django source at all
- it just needs to be on the PYTHONPATH. Conventions here are little
less certain; putting your code in a 'django-databrowse' package would
be reasaonbly consistent with current practice.

Yours,
Russ Magee %-)

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



Re: Please Help with Namespace Issue.

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, Sebastian Macias <[EMAIL PROTECTED]> wrote:
>
> When I run the app with the development server everything is fine, I
> can go to http://localhost:8000/accounts/login/ and I get no errors
> but when I test it using apache/mod_python I get the following error.
>
> ImportError at /
> No module named registration.urls

Looks like a PYTHONPATH issue. In your apache configuration you need
to make sure that the PYTHONPATH that is defined allows you to import
the 'registration' application.

Yours,
Russ Magee %-)

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



Re: Auth framework - initials et of users/groups ?

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, Przemyslaw Wegrzyn <[EMAIL PROTECTED]> wrote:
>
> I'd like to use fixtures to initialize all my authentication data, so
> I'd like to disable this question as well:
...
> Is there any option to do it ? Well, I have not enough time to check the
> sources myself :-/

Yes. You can use the --noinput option. The noinput option is available
on a number of management commands, and exists to allow commands to
operate without human interaction. This means that any warnings on
data loss (like when you delete a table) and steps like the creation
of the superuser are ignored.

Yours,
Russ Magee %-)

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



Re: Auth framework - initials et of users/groups ?

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, Peter Melvyn <[EMAIL PROTECTED]> wrote:
>
> On 7/25/07, Przemyslaw Wegrzyn <[EMAIL PROTECTED]> wrote:
>
>
> > Thanks! I overlooked the 'fixtures' feature, I'll give it a try.
>
> I don't know wjhat kind of SQL server do you use, but If  I'm not
> mistaken, fixtures are not fully supported on MySQL with InnoDB
> engine.

Fixtures are supported under MySQL with InnoDB (i.e., fixtures will
load), but you may have difficulty loading complex fixtures. In
particular, any fixture with a foreign key/m2m field that has a
forward or circular reference will fail on load as a result of a
referential integrity error.

This is due to the fact that MySQL checks row integrity on the command
boundary, rather than the transaction boundary as it should. MyISAM
tables are not affected (as they don't have row referential
integrity).

Yours,
Russ Magee %-)

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



Re: Customizing the settings configuration

2007-07-24 Thread Russell Keith-Magee

On 7/24/07, gorans <[EMAIL PROTECTED]> wrote:
>
> I though that there could be a way to trick Django into reading
> special development settings for me, something like having a settings
> 'package' import separate settings files:

No need for any special handling - just use the --settings option to
manage.py, or the DJANGO_SETTINGS_MODULE environment variable.

./manage.py --settings=mysite.localsettings runserver

or

./manage.py --settings=mysite.serversettings runserver

If there are common elements in the two settings file, then put

from mysite.commonsettings import *

at the top of your localsettings/serversettings file. This will pull
in all the settings from the common settings file.

If putting your settings files into a package will make organization
easier, go right ahead - just remember to put the extra path into your
--settings. e.g.:

./manage.py --settings=mysite.settings.serversettings runserver

Yours,
Russ Magee %-)

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



Re: transaction commit

2007-07-24 Thread Russell Keith-Magee

On 7/25/07, Peter Melvyn <[EMAIL PROTECTED]> wrote:
>
> > Your example is correct, and you aren't violating any 'Django principles'.
>
> Really? Should not be there something like this?

Yes - this is a more complete example, and catching the rollback case
is a good idea. The point I was trying to make is that manually
invoking commit is both legal and encouraged when appropriate.

Yours,
Russ Magee %-)

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



Re: Best Practices to Make your Apps Portable

2007-07-24 Thread Collin Grady

apps are portable if you don't make them in a project directory - as
for copying them to another server, nothing stops you from making a
"3rd_party" or some such folder in there that you add to pythonpath,
so that they don't have to be referenced by project.app

Or maybe make an "apps" directory that you add to pythonpath, then put
any and all apps in there.


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



A convenient way to include images in a blog entry

2007-07-24 Thread Kai Kuehne

Hi list!
In the last past hours I've been thinking about how
to include images into my django blog application.

At first, I added a new field to my "Entry" django
model and named it "image". This worked but I decided that
(maybe) I want to include more than one image in a blog
entry. So I created an "Image" model and created
a relation between the "Entry" via the ManyToManyField.

Now I'm thinking about how I could include the images
into the 'Entry' without typing in the whole url on my one.

So I came up with this piece of code:

class Entry(models.Model):
images = models.ManyToManyField(Image)

def save(self):
"""Replace $imageX with the image url before saving."""
image_list = self.images.all()
for i in xrange(0, len(image_list)):
self.intro = self.intro.replace("$image%i" % i,
image_list[i].get_image_url())
self.body = self.body.replace("$image%i" % i,
image_list[i].get_image_url())

Now I can insert "$image0" to include the first image, "$image1"
for the second.. (or when using markdown, what I do: ![]($image0)]).

It works more or less but this is very ugly in my opion.
So has anybody of you came up with a better solution
to this problem?

Thanks!
Kai

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



Best Practices to Make your Apps Portable

2007-07-24 Thread Sebastian Macias

Today I had issues getting django registration to work in my django
project without having to modify every namespace inside django
registration. Basically what I ended up having to do is adding django
registration to my site-packages folder so I don't get errors like "No
module named registration.urls" and avoid having to change every
namespace in django registration to start with my project name This is
a pain for me as I'm making lots of changes to the django-registration
core. I also looked for help on IRC and was told that any third party
django apps are supposed to be added to the python path or put under
site-packages. This could end up being a tedious task as you would
have to remember what folders need to be copied to site-packages,
symlinked, etc when moving your project to a production server.
Wouldn't it be nice if you can just upload the project and all apps
(3rd party and your own) are inside of it?

My dilemma is... what is the point of having projects and apps if the
applications created for my project won't be portable in other
projects (becase the namespaces will always start with the project
name). I can't just copy and app from one project to another.

Basically what I see is that if I'm developing a web site (a django
project)  and three apps that will be used on it (i.e. a blog, a poll
system, a rating system) and if I want to re use any of these apps in
the future in other projects or make them opensource I need to have a
django project for each app.

I'm still new to python and django (and loving them) and maybe these
are concerns that are easily addressed by methods I'm still not aware
of.

Any thoughts will be greatly appreciated.

Thanks,

Sebastian Macias
digital-telepathy inc


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



Re: django.contrib.dataplot 0.3

2007-07-24 Thread James Bennett

On 7/24/07, Toby Dylan Hocking <[EMAIL PROTECTED]> wrote:
> Furthermore, is there a formal process for integrating into
> django.contrib? How has it worked in the past?

At the moment there isn't a formal process; when it's come up before,
the most common suggestion seems to have been that an application
should exist standalone for a while first; this is useful in a couple
of ways:

1. It lets you figure out if the app is useful/popular enough to
nominate for django.contrib.
2. It lets you respond to feedback without having to worry about
introducing backwards-incompatible changes to something that's being
distributed with Django.

It's true that in the past a couple of things have gone more or less
directly into django.contrib (databrowse and sitemaps), but that
process probably doesn't scale all that well ;)


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

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



Re: Why does direct_to_template require a db?

2007-07-24 Thread Jeremy Dunck

On 7/24/07, omat <[EMAIL PROTECTED]> wrote:
> Why does direct_to_template require a database at all?
>

It doesn't directly require it.  You must be using something that does.

Are you using sessions?

It does use RequestContext, which runs TEMPLATE_CONTEXT_PROCESSORS,
which includes django.core.context_processors.auth by default.

Which is to say, you should define TEMPLATE_CONTEXT_PROCESSORS without
that default processor.

If that doesn't work, please put your settings file and template
redacted) up on dpaste.com, then reply with that URL.

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



Re: django.contrib.dataplot 0.3

2007-07-24 Thread Toby Dylan Hocking

Hi Russ,

Thanks for the advice. I can certainly change the name to 
django-dataplot.

However, I thought that the contrib/ subdirectory of the django 
distribution would be the most natural place to install it, since it is an 
add-on app that is meant to be used by other apps. Can you suggest another 
location that would be more appropriate and/or less "confusing"?

Furthermore, is there a formal process for integrating into 
django.contrib? How has it worked in the past?

Sincerely,
Toby Dylan Hocking
http://www.ocf.berkeley.edu/~tdhock

On Tue, 24 Jul 2007, Russell Keith-Magee wrote:

>
> On 7/24/07, Toby Dylan Hocking <[EMAIL PROTECTED]> wrote:
>>
>> If any of you are interested in creating data graphics for your web apps,
>> try checking out the new version of my plotting framework,
>> django.contrib.dataplot. Here is an example of what it can do:
>
> Hi Toby,
>
> Looks like a great app! Plotting/charting is a feature that comes up
> regularly on the list - I'm sure many people will find this useful.
>
> However, if I could make a quick suggestion: django.contrib is the
> namespace used by Django applications that ship with Django. Promotion
> into django.contrib is something that occasionally happens when a
> popular application with general appeal becomes mature enough.
>
> It's potentially quite confusing if external applications with no
> formal affiliation with Django start using the same namespace.
>
> The informal convention being followed by other Django applications is
> to prefix your app name with 'django-'
>
> For example:
> http://code.google.com/p/django-registration/
> http://code.google.com/p/django-openid/
>
> Keep up the great work!
>
> Yours,
> Russ Magee %-)
>
> >

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



Why does direct_to_template require a db?

2007-07-24 Thread omat

Hi all,

I have an application that does not use a database at all. Thus, I
removed db specific settings from the settings file.

Everything works fine, except, when I try to use
'django.views.generic.simple.direct_to_template', it raises an
"Improperly Configured' exception, complaining that the database
configuration is missing. But, for the same request, when I call a
view function and return the same template, it works fine.

Why does direct_to_template require a database at all?

Thanks,
oMat


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



Re: newforms: default Model values

2007-07-24 Thread Patrick

Unfortunately, this doesn't work without a primary key needed for many-to-
many relations that are used in the model.

Previous tip with modifying base fields before instantiating a form 
object works better.


On Tue, 24 Jul 2007 22:37:06 +, Patrick wrote:

> Seems like an elegant and logical solution. Thanks, Michael!
> 
> On Tue, 24 Jul 2007 21:04:50 +, Michael wrote:
> 
>> When I came across the same issue (model default values not being
>> selected), I simply stopped using form_for_model for new forms and
>> instead created an instance of my model in memory then used
>> form_for_instance... for eg:
>> 
>> p = Post()
>> PostForm = form_for_instance(p)
>> 
>> That way the default values for the model are set when the new object
>> is created.
>> 
>> Hope that's relevant to your situation... not 100% sure.
>> 
>> On Jul 25, 6:19 am, Patrick <[EMAIL PROTECTED]> wrote:
>>> On Tue, 24 Jul 2007 11:51:36 -0700, Doug B wrote:
>>> > I don't know how others have approached it, but I have a 'settings'
>>> > file with defaults defined in one place and reference those values
>>> > via imports in the form file and model file.  For values specific
>>> > for the app, I stick them in the models file.
>>>
>>> > models.py
>>> > -
>>> > POST_DEFAULTS = {'status':'published'}
>>>
>>> > class Post(models.Model):
>>> > status  = models.CharField(
>>> > maxlength = 15,
>>> > choices = PUBLICATION_STATUS,
>>> > default = POST_DEFAULTS['status'])
>>>
>>> > forms.py
>>> > -
>>> > from app.models import POST_DEFAULTS,PUBLICATION_STATUS
>>>
>>> > class PostForm(forms.Form):
>>> > status =
>>> > forms.CharField(forms.CharField(widget=forms.Select
>>>
>>> (choices=PUBLICATION_STATUS,
>>>
>>> > initial = POST_DEFAULTS['status'])
>>>
>>> > ---or--- if you are doing form_for_* (I don't use those, but this
>>> > should be close)
>>>
>>> > views.py
>>> > -
>>> > PostForm = form_for_model(Post)
>>> > PostForm.base_fields['status'].initial = POST_DEFAULTS['status']
>>> > form = PostForm()
>>>
>>> > If you use the helpers, the important thing to remember is to modify
>>> > the base_fields dict before instantiating the form.  Yet another
>>> > option, is to create a callback function passed to form_for_model.
>>> > The callback function basically gets called for every field in the
>>> > model and you have the choice of making changes for each field. 
>>> > That method always felt cumbersome compared to just changing the
>>> > values you need changed, so I can't do it off the top of my head.  A
>>> > search for formfield callback should tell you how though.
>>>
>>> Thanks for this tip, Doug. It works.
>>>
>>> I somehow missed it in the docs.
>> 
>> 
>> 
>> 
> 
> 


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



Re: newforms: default Model values

2007-07-24 Thread Patrick

Seems like an elegant and logical solution. Thanks, Michael!

On Tue, 24 Jul 2007 21:04:50 +, Michael wrote:

> When I came across the same issue (model default values not being
> selected), I simply stopped using form_for_model for new forms and
> instead created an instance of my model in memory then used
> form_for_instance... for eg:
> 
> p = Post()
> PostForm = form_for_instance(p)
> 
> That way the default values for the model are set when the new object is
> created.
> 
> Hope that's relevant to your situation... not 100% sure.
> 
> On Jul 25, 6:19 am, Patrick <[EMAIL PROTECTED]> wrote:
>> On Tue, 24 Jul 2007 11:51:36 -0700, Doug B wrote:
>> > I don't know how others have approached it, but I have a 'settings'
>> > file with defaults defined in one place and reference those values
>> > via imports in the form file and model file.  For values specific for
>> > the app, I stick them in the models file.
>>
>> > models.py
>> > -
>> > POST_DEFAULTS = {'status':'published'}
>>
>> > class Post(models.Model):
>> > status  = models.CharField(
>> > maxlength = 15,
>> > choices = PUBLICATION_STATUS,
>> > default = POST_DEFAULTS['status'])
>>
>> > forms.py
>> > -
>> > from app.models import POST_DEFAULTS,PUBLICATION_STATUS
>>
>> > class PostForm(forms.Form):
>> > status =
>> > forms.CharField(forms.CharField(widget=forms.Select
>>
>> (choices=PUBLICATION_STATUS,
>>
>> > initial = POST_DEFAULTS['status'])
>>
>> > ---or--- if you are doing form_for_* (I don't use those, but this
>> > should be close)
>>
>> > views.py
>> > -
>> > PostForm = form_for_model(Post)
>> > PostForm.base_fields['status'].initial = POST_DEFAULTS['status'] form
>> > = PostForm()
>>
>> > If you use the helpers, the important thing to remember is to modify
>> > the base_fields dict before instantiating the form.  Yet another
>> > option, is to create a callback function passed to form_for_model.
>> > The callback function basically gets called for every field in the
>> > model and you have the choice of making changes for each field.  That
>> > method always felt cumbersome compared to just changing the values
>> > you need changed, so I can't do it off the top of my head.  A search
>> > for formfield callback should tell you how though.
>>
>> Thanks for this tip, Doug. It works.
>>
>> I somehow missed it in the docs.
> 
> 
> 


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



Re: DB-Lookup on dynamically created fieldname

2007-07-24 Thread Doug B

Maybe you could do something like this?

filterargs = {}
filterargs[fieldname] = some value
# or for other types of filtering
filterargs["%s__istartswith" % fieldname] = somevalue

mdl.objects.filter(**filterargs)

You might also want to take a look at the function get_model()

from django.db.models import get_model()

mdl = get_model('appname','modelname')



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



Please Help with Namespace Issue.

2007-07-24 Thread Sebastian Macias

Hello I'm having this strange problem and was wondering if anyone
knows what might be causing it.

I'm working on a django project called championsound. I integrated
django registration the "regular" way: copied the app folder to my
project folder and added (r'', include('marketing.urls')), to my
project URLs.

When I run the app with the development server everything is fine, I
can go to http://localhost:8000/accounts/login/ and I get no errors
but when I test it using apache/mod_python I get the following error.

ImportError at /
No module named registration.urls

I tried changing (r'', include('registration.urls')),  to (r'',
include('championsound.registration.urls')), and I got one step
further. Now the registration.urls is found but got the following
error.

ImportError at /accounts/login/
No module named registration.views

Then I opened registartion.urls and changed from registration.views
import activate, register, login_with_email with from
championsound.registration.views import activate, register,
login_with_email.

That solved the problem but of course that's not the way of doing
things as I would have to change the namespaces of every single app I
add to my project.

Any help will be 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?hl=en
-~--~~~~--~~--~--~---



Re: How do I know if fastcgi is installed correctly? (using dreamhost)

2007-07-24 Thread Horst Gutmann

walterbyrd wrote:
> 
> On Jul 19, 4:08 pm, FrankW <[EMAIL PROTECTED]> wrote:
>> in your shell, if you cd into /home/walterbyrd/django.niche-software/
>> django
>> and type ./dispatch.fcgi, what do you get?
>>
> 
> 
> ./dispatch.fcgi
> WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
> WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
> WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
> WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
> Status: 301 MOVED PERMANENTLY
> Content-Type: text/html; charset=utf-8
> Location: /
> 

Could you please also take a quick look into the error.log of your
domain right after accessing the test dispatch.fcgi which returned the
500 error? Perhaps there is something wrong with flup itself there :)

- Horst

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



Re: Auth framework - initials et of users/groups ?

2007-07-24 Thread Przemyslaw Wegrzyn

Peter Melvyn wrote:

>>Thanks! I overlooked the 'fixtures' feature, I'll give it a try.
>>
>>
>
>I don't know wjhat kind of SQL server do you use, but If  I'm not
>mistaken, fixtures are not fully supported on MySQL with InnoDB
>engine.
>  
>
Yes, I've found such warning in the documentation. Yet I'm on the safe
PostgreSQL side :-)

BR,
Przemyslaw


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



Re: Auth framework - initials et of users/groups ?

2007-07-24 Thread Peter Melvyn

On 7/25/07, Przemyslaw Wegrzyn <[EMAIL PROTECTED]> wrote:


> Thanks! I overlooked the 'fixtures' feature, I'll give it a try.

I don't know wjhat kind of SQL server do you use, but If  I'm not
mistaken, fixtures are not fully supported on MySQL with InnoDB
engine.

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



RE: Form_for multiple models

2007-07-24 Thread Chris Brand

> You can specify it upon form creation. Here is an example of how you
> could use prefixes for multiple model forms:

Thanks, Nathan.
That's very useful.

Chris




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



Re: Instant Django

2007-07-24 Thread yml

This is half solving the problem. with your fix in the start.bat now
when i launch python it start python on the memory stick  but for some
reasons dajngo-admin.exe call python installed on my computer not the
one in your package.
However this is working fine "E:\instant_django\django>python
Utilities/django-admin.py" but this is not working :
E:\instant_django\django>E:\instant_django\django\Utilities\django-
admin.py
Traceback (most recent call last):
  File "E:\instant_django\django\Utilities\django-admin.py", line 5,
in 
from django.core import management
ImportError: No module named django.core

It seems that django-admin.exe behave like "E:\instant_django\django
\Utilities\django-admin.py" instead of  "python Utilities/django-
admin.py"

Thank you for your effort in helping me.


On Jul 24, 8:45 pm, cjl <[EMAIL PROTECTED]> wrote:
> Thanks again for the bug report, I have found the problem.
>
> Change the 'path' section of start.bat to read:
>
> path = %CD%\Python25;%CD%\Utilities;%CD%\Utilities\svn-
> win32-1.4.4\bin;%CD%\Utilities\exemaker-1.2-20041012;%CD%\Utilities
> \npp.4.1.2.bin;%CD%\Utilities\sqlite-3_4_0;%PATH%
>
> I had %PATH% first, and it needs to come last, because order matters,
> and it needs to find my python before it finds the previously
> installed python.
>
> I will make the change, and upload a new version later.
>
> -cjlesh


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



DB-Lookup on dynamically created fieldname

2007-07-24 Thread Andreas Pfrengle

Hello group,

I have some models in my app that have several fields. First, my code
picks dynamically one of the models from a string-variable, sth. like:
mdl = eval(model_name), where model_name contains the name the model.
Then, I want to lookup a field in that model, but again I also only
got its name in a string-var.
So what I'm trying to do is sth. like:
mdl.objects.get(eval(field_name)=somevalue). Here I get of course a
syntax error (keyword can't be an expression), but I hope my problem
is made clear.
Does anyone have an idea how I could get around this? Any help is
appreciated :)

Regards,
Andreas


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



Re: Form_for multiple models

2007-07-24 Thread Nathan Ostgard

You can specify it upon form creation. Here is an example of how you
could use prefixes for multiple model forms:

In your views:

from django import newforms as forms
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from yourproject.yourapp.models import ModelClass1, ModelClass2

def some_form_view(request):
  form_classes = {ModelClass1: None, ModelClass2: None}
  for model in form_classes:
form_classes[model] = forms.form_for_model(model)
  form_objects = {}
  if request.method == 'POST':
prefix = 0
forms_are_valid = True
for model, form_class in form_classes.iteritems():
  form_objects[model] = form_class(request.POST, prefix='f' +
str(prefix))
  forms_are_valid = forms_are_valid and
form_objects[model].is_valid()
  prefix += 1
if forms_are_valid:
  for model, form in form_objects.iteritems():
form.save()
  return HttpResponseRedirect('/some/url')
  else:
prefix = 0
for model, form_class in form_classes.iteritems():
  form_objects[model] = form_class(prefix='f' + str(prefix))
  return render_to_response('blah.html', {'forms':
form_objects.values()})

In your template:


{% for form in forms %}
  {{ form.as_p }}
{% endfor %}




On Jul 24, 11:05 am, "Chris Brand" <[EMAIL PROTECTED]> wrote:
> >  - When you instantiate your form, pass in prefix='form1' as an
> > argument - all the fields on the form will get that prefix, which will
> > keep the two forms distinct in the POST dictionary. This will only be
> > an issue if there is an overlap in the field names on the two forms,
> > but it's better to be safe.
>
> I've seen this "prefix" mentioned before in this context. Is it in the
> documention yet (I couldn't find it) ? Do all forms accept it as an
> instantiation parameter, or is it specific to form_for_instance and
> form_for_model ? Is it in 0.96 or only in trunk ?
>
> A quick grep through the 0.96 source seems to indicate that it is a
> parameter to BaseForm.__init__(), but that's as far as I can get by myself
> at the moment...
>
> Thanks,
>
> Chris


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



Re: Auth framework - initials et of users/groups ?

2007-07-24 Thread Przemyslaw Wegrzyn

Andrey Khavryuchenko wrote:

> PW> One option I see is to add custom statements to one of SQL files used to
> PW> initialize my application's model. Yet it's a bit ugly, isn't it ?
>
>Create this data in console or in the script and then use 
>   manage.py dumpdata
>to save then in json format.   Use 
>   manage.py loaddata 
>as you need
>  
>
Thanks! I overlooked the 'fixtures' feature, I'll give it a try.

I'd like to use fixtures to initialize all my authentication data, so
I'd like to disable this question as well:

"You just installed Django's auth system, which means you don't have any
superusers defined.
Would you like to create one now? (yes/no):"

Is there any option to do it ? Well, I have not enough time to check the
sources myself :-/

BR,
Przemyslaw





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



Re: Blog engine

2007-07-24 Thread Chris Moffitt
I think I mentioned earlier in this thread, that I do have my take on
creating a blog here -
http://www.satchmoproject.com/trac/browser/satchmoproject.com/satchmo_website/apps

It's pretty full featured right now and makes use of the tagging and
comment_utils libraries.  It still needs the feeds but that should be pretty
simple.  It's BSD licensed so hopefully it will be useful to folks.

-Chris

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



Re: using javascript to update a ChoicesField: getting "not one of the available choices."

2007-07-24 Thread Doug B

Don't use a ChoiceField, but do use the select widget.

class TF(forms.Form):
blah=forms.IntegerField(widget=forms.Select(choices=((1,'one'),
(2,'two'))), initial = 2)


post = {'blah': 42}

form = TF(post)

form should validate.  It would be up to you to make sure that the
Integer value is in a range you expect though, and you could do that
with a clean_blah() method on the form.


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



Re: Should I give up on dreamhost?

2007-07-24 Thread walterbyrd

On Jul 23, 12:40 pm, Horst Gutmann <[EMAIL PROTECTED]> wrote:
> What exactly have you done so far? It took me quite some time but now
> Django is (so far) working veeery realiably on my Dreamhost account.
>

I have asked for, and recieved, help before, but I was still unable to
solve the problem.

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

I don't have to have django on my remote host right now. I just work
locally until I'm more comfortable with django. That is why I'm
wondering if I should just give up on dreamhost for now.


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



using javascript to update a ChoicesField: getting "not one of the available choices."

2007-07-24 Thread hotani

I have 'drop-down A' which, when changed, updates 'drop-down B' via an
AJAX call.

Problem is this: ChoicesField for drop-down B won't recognize any of
the choices and I can't submit the form. Is there a way to turn off
that piece of the validation?

Alternatively I could remove 'drop-down B' from the form class and
hand-build the form. That feels a little hacky though.


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



Uploading 1 image...making multiple dimensions of that image?

2007-07-24 Thread Greg

Hello,
In my admin interface I upload a picture of a product.  We'll in my
website I will show that picture in 3 separate pages.Each page
shows the picture with different dimensions.  I know that I can apply
a width and height attribute to my img tag.  However, that causes the
pictures to be distorted.  Can I have it to where when I upload my
original file:

1) Django (or anothe app) can create two new files of that image at
the dimensions that I want

or

2) Configure Django to where the image will show on the page with th
right dimensions without needing a width or height attribute for the
image tag?

Thanks for any advice


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



Re: from settings import *, non-django python script Error

2007-07-24 Thread Carl Karsten

johnny wrote:
> import re
> from BeautifulSoup import BeautifulSoup
> import urllib2
> from os import environ
> #from settings import *
> 
> def myfunction() :
> 
> environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
> from settings import *
> 
> I get an error:
> myscript.py:22: SyntaxWarning: import * only allowed at module level.

right. import creates a namespace (like a var name) which wouldn't be well 
defined there.

> 
> I have tried placing "from settings import *" above the "def
> myfunction()", then I get an error:
> raise EnvironmentError, "Could not import settings '%s' (Is it on
> sys.path?
> Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
> EnvironmentError: Could not import settings 'mysite.settings' (Is it
> on sys.path
> ? Does it have syntax errors?): No module named mysite.settings
> 
> If I don't do import *, what do I need to import in order to use
> django model in a python script?

Is it (settings.py) on sys.path ?

(be sure to answer this question if you are still having problems.)


> Import only the followings:
> 
> DATABASE_ENGINE
> DATABASE_NAME
> DATABASE_USER
> DATABASE_PASSWORD
> DATABASE_HOST
> DATABASE_PORT 
> 

you probably want something like this:

# nifty trick to get ../settings
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
apppath=os.path.abspath(BASE_DIR+'/../')
sys.path.insert(0, apppath )
import settings

"like" being a key word, cuz that code works for me, it expects settings.py to 
be in a dir above it.

Carl K

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



Re: newforms: default Model values

2007-07-24 Thread Michael

When I came across the same issue (model default values not being
selected), I simply stopped using form_for_model for new forms and
instead created an instance of my model in memory then used
form_for_instance... for eg:

p = Post()
PostForm = form_for_instance(p)

That way the default values for the model are set when the new object
is created.

Hope that's relevant to your situation... not 100% sure.

On Jul 25, 6:19 am, Patrick <[EMAIL PROTECTED]> wrote:
> On Tue, 24 Jul 2007 11:51:36 -0700, Doug B wrote:
> > I don't know how others have approached it, but I have a 'settings' file
> > with defaults defined in one place and reference those values via
> > imports in the form file and model file.  For values specific for the
> > app, I stick them in the models file.
>
> > models.py
> > -
> > POST_DEFAULTS = {'status':'published'}
>
> > class Post(models.Model):
> > status  = models.CharField(
> > maxlength = 15,
> > choices = PUBLICATION_STATUS,
> > default = POST_DEFAULTS['status'])
>
> > forms.py
> > -
> > from app.models import POST_DEFAULTS,PUBLICATION_STATUS
>
> > class PostForm(forms.Form):
> > status =
> > forms.CharField(forms.CharField(widget=forms.Select
>
> (choices=PUBLICATION_STATUS,
>
> > initial = POST_DEFAULTS['status'])
>
> > ---or--- if you are doing form_for_* (I don't use those, but this should
> > be close)
>
> > views.py
> > -
> > PostForm = form_for_model(Post)
> > PostForm.base_fields['status'].initial = POST_DEFAULTS['status'] form =
> > PostForm()
>
> > If you use the helpers, the important thing to remember is to modify the
> > base_fields dict before instantiating the form.  Yet another option, is
> > to create a callback function passed to form_for_model. The callback
> > function basically gets called for every field in the model and you have
> > the choice of making changes for each field.  That method always felt
> > cumbersome compared to just changing the values you need changed, so I
> > can't do it off the top of my head.  A search for formfield callback
> > should tell you how though.
>
> Thanks for this tip, Doug. It works.
>
> I somehow missed it in the docs.


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



Re: Auth framework - initials et of users/groups ?

2007-07-24 Thread Andrey Khavryuchenko

Przemyslaw,

 PW> I'm just trying to do is using django.contrib.auth framework.

 PW> What I'd need is the possibility to create initial set of groups, users
 PW> and user-group assignements, when 'syncdb' is performed.

 PW> One option I see is to add custom statements to one of SQL files used to
 PW> initialize my application's model. Yet it's a bit ugly, isn't it ?

Create this data in console or in the script and then use 
   manage.py dumpdata
to save then in json format.   Use 
   manage.py loaddata 
as you need

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua 
Call akhavr1975 on www.gizmoproject.com

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



Re: Blog engine

2007-07-24 Thread Henrik Lied

This sounds great. I created a project on Google Code:
http://code.google.com/p/django-blog-engine/


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



Re: django db models error

2007-07-24 Thread akk

Thanks a lot. I guess, I was not reading it well.

On Jul 24, 4:55 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 7/24/07, akk <[EMAIL PROTECTED]> wrote:
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
> > line 40, in __new__
> > model_module = sys.modules[new_class.__module__]
> > KeyError: '__console__'
>
> You'll need to actually put the model definition into a file and import it.
>
> If you know your way around the Django ORM's metasystem you can create
> model classes "on the fly" in the development version of Django
> (**not** in the 0.96 release -- you'll need a recent Subversion
> checkout), but there may not be a whole lot of use cases for that.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



Re: django db models error

2007-07-24 Thread James Bennett

On 7/24/07, akk <[EMAIL PROTECTED]> wrote:
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
> line 40, in __new__
> model_module = sys.modules[new_class.__module__]
> KeyError: '__console__'

You'll need to actually put the model definition into a file and import it.

If you know your way around the Django ORM's metasystem you can create
model classes "on the fly" in the development version of Django
(**not** in the 0.96 release -- you'll need a recent Subversion
checkout), but there may not be a whole lot of use cases for that.


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

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



from settings import *, non-django python script Error

2007-07-24 Thread johnny

import re
from BeautifulSoup import BeautifulSoup
import urllib2
from os import environ
#from settings import *

def myfunction() :

environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
from settings import *

I get an error:
myscript.py:22: SyntaxWarning: import * only allowed at module level.

I have tried placing "from settings import *" above the "def
myfunction()", then I get an error:
raise EnvironmentError, "Could not import settings '%s' (Is it on
sys.path?
Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'mysite.settings' (Is it
on sys.path
? Does it have syntax errors?): No module named mysite.settings

If I don't do import *, what do I need to import in order to use
django model in a python script?
Import only the followings:

DATABASE_ENGINE
DATABASE_NAME
DATABASE_USER
DATABASE_PASSWORD
DATABASE_HOST
DATABASE_PORT  ?


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



Re: Customizing the settings configuration

2007-07-24 Thread Shawn Allen

One solution is to add an extra import at the bottom of your  
settings.py:

try:
 from localsettings import *
except ImportError:
 pass

Then put localsettings.py in your svn:ignore, and override whatever  
settings you need to on a per-installation basis.

On Jul 24, 2007, at 8:41 AM, gorans wrote:
> I develop Django sites on my mac and then publish them to another web
> server. In between, they live in a happy SVN repository on my
> development server.
>
> Each time I make a change to the project's settings.py I have to then
> go over and modify the live file version (in respect to the database
> type / name, media directory etc.)
>
> I though that there could be a way to trick Django into reading
> special development settings for me, something like having a settings
> 'package' import separate settings files:
>
> e.g.
>
> myproject/
>
> manage.py
> ...
> settings/
> __init__.py
> coresettings.py
> localsettings.py
>
> so that we use the variable from coresettings first, and then try:
> import localsettings and if successful use those subsequent values.
>
> That way, I can have an un-versioned localsettings.py living on my
> mac, whilst keeping the live settings intact. Additionally, other
> developers on the project can do the same!
>
> Is this possible? (I'm sure it is but my Python just isn't good enough
> to know how to import all the variables from each module)
>
> Can anyone please give me directions / pointers as to how to do this?
> Or alternatively, how you deal with this task.
>
> Your help is very very much appreciated
>
> cheers
>
> Goran
>
>
> >


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



Auth framework - initials et of users/groups ?

2007-07-24 Thread Przemyslaw Wegrzyn

Hi!

I'm just trying to do is using django.contrib.auth framework.

What I'd need is the possibility to create initial set of groups, users
and user-group assignements, when 'syncdb' is performed.

One option I see is to add custom statements to one of SQL files used to
initialize my application's model. Yet it's a bit ugly, isn't it ?

BR,
Przemyslaw







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



django db models error

2007-07-24 Thread akk

Hi,

I started walking myself through exercises in django book. At chapter
V - Interacting with a database: Models. I keep getting error when I
try to create class. Otherwise my db connectivity seems fine. I can
run from
>>> django.db import connection
>>> cursor = connection.cursor()
(fine)

Here is the error I am getting:

$ python manage.py shell
>>> from django.db import models
>>> class Person(models.Model):
... first_name = models.CharField(maxlength=30)
... last_name = models.CharField(maxlength=30)
...
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 40, in __new__
model_module = sys.modules[new_class.__module__]
KeyError: '__console__'

Thanks a lot,
akk


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



Re: Django .91 issue

2007-07-24 Thread [EMAIL PROTECTED]

Awwh, Yes! Brainfart! Thank you so much.  I'm glad new django doesn't
use this method anymore.

Thanks again.


On Jul 24, 2:22 pm, oggie rob <[EMAIL PROTECTED]> wrote:
> With 0.91, you use the "magic" name for db-api operations, rather than
> the model name. For example:
>
> from django.models import my_model_module
> my_model_module.somemodels.get_object(...)
>
> I think sometime before 0.91 was finished, the directory structure
> changed, so you might access your models slightly differently, but you
> will still need a lower-case, pluralized name for the lookup.
>
>  -rob
>
> On Jul 24, 10:52 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Hi I have a csv file that I am reading in and I want to test to make
> > sure that there are no duplicate records so I do something like this:
>
> > # My Checker
>
> > from csv import reader
> > import datetime
> > import re
> > import time
> > from time import strptime
> > from django.models.somemodel import SomeModel
> > from some_site import settings
>
> > data = '../data/somefile.csv'
> > table = reader(open(data))
> > header = table.next()
>
> > for row in table:
>
> > company_name = len(row) > 3 and row[3] or ''
> > mailing_address = len(row) > 4 and row[4] or ''
> > print company_name
>
> > test = SomeModel.get_object(company_name__exact=company_name,
> > mailing_address__exact=mailing_address)
>
> > It crashes on the last line with this error:
>
> > AttributeError: 'module' object has no attribute 'get_object'
>
> > from what it look like to me is that it is trying to associate the
> > get_object with an attribute in the model class.
>
> > Is there an easier way to  test for existing attribute names on the
> > database.  There can be more than one company name but only one
> > address per company name is allowed in the table.
>
> > Any suggestions? Solutions?


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



Re: newforms: default Model values

2007-07-24 Thread Patrick

On Tue, 24 Jul 2007 11:51:36 -0700, Doug B wrote:

> I don't know how others have approached it, but I have a 'settings' file
> with defaults defined in one place and reference those values via
> imports in the form file and model file.  For values specific for the
> app, I stick them in the models file.
> 
> models.py
> -
> POST_DEFAULTS = {'status':'published'}
> 
> class Post(models.Model):
> status  = models.CharField(
> maxlength = 15,
> choices = PUBLICATION_STATUS,
> default = POST_DEFAULTS['status'])
> 
> forms.py
> -
> from app.models import POST_DEFAULTS,PUBLICATION_STATUS
> 
> class PostForm(forms.Form):
> status =
> forms.CharField(forms.CharField(widget=forms.Select
(choices=PUBLICATION_STATUS,
> initial = POST_DEFAULTS['status'])
> 
> ---or--- if you are doing form_for_* (I don't use those, but this should
> be close)
> 
> views.py
> -
> PostForm = form_for_model(Post)
> PostForm.base_fields['status'].initial = POST_DEFAULTS['status'] form =
> PostForm()
> 
> If you use the helpers, the important thing to remember is to modify the
> base_fields dict before instantiating the form.  Yet another option, is
> to create a callback function passed to form_for_model. The callback
> function basically gets called for every field in the model and you have
> the choice of making changes for each field.  That method always felt
> cumbersome compared to just changing the values you need changed, so I
> can't do it off the top of my head.  A search for formfield callback
> should tell you how though.
> 
> 
> 
Thanks for this tip, Doug. It works.

I somehow missed it in the docs.


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



Re: Insert vs. Update

2007-07-24 Thread James Bennett

On 7/24/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
> You're not the first to suggest insert() and update() methods that
> explicity do SQL INSERT and UPDATE calls. I have a vague recollection
> that a decision was made about adding these calls, but a quick search
> in the ticket database didn't find the ticket that related to this
> change. Feel free to do a more comprehensive search; the discussion
> should be archived there (or, at the very least, in the
> django-developers mailing list).

There was some discussion back when we were working around a
session-collision bug, because some folks claimed that implementing
separate INSERT and UPDATE methods would solve it, but at the time I
lobbied for fixing the session bug and waiting for the QuerySet
refactor to make a decision about INSERT/UPDATE :)


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

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



Re: Insert vs. Update

2007-07-24 Thread Peter Melvyn

On 7/24/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:

> You're not the first to suggest insert() and update() methods that
> explicity do SQL INSERT and UPDATE calls.

FYI: both, SQLite and MySQL support REPLACE statement to do this automatically.

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



Re: newforms: default Model values

2007-07-24 Thread Doug B

I don't know how others have approached it, but I have a 'settings'
file with defaults defined in one place and reference those values via
imports in the form file and model file.  For values specific for the
app, I stick them in the models file.

models.py
-
POST_DEFAULTS = {'status':'published'}

class Post(models.Model):
status  = models.CharField(
maxlength = 15,
choices = PUBLICATION_STATUS,
default = POST_DEFAULTS['status'])

forms.py
-
from app.models import POST_DEFAULTS,PUBLICATION_STATUS

class PostForm(forms.Form):
status =
forms.CharField(forms.CharField(widget=forms.Select(choices=PUBLICATION_STATUS,
initial = POST_DEFAULTS['status'])

---or--- if you are doing form_for_* (I don't use those, but this
should be close)

views.py
-
PostForm = form_for_model(Post)
PostForm.base_fields['status'].initial = POST_DEFAULTS['status']
form = PostForm()

If you use the helpers, the important thing to remember is to modify
the base_fields dict before instantiating the form.  Yet another
option, is to create a callback function passed to form_for_model.
The callback function basically gets called for every field in the
model and you have the choice of making changes for each field.  That
method always felt cumbersome compared to just changing the values you
need changed, so I can't do it off the top of my head.  A search for
formfield callback should tell you how though.


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



Re: Instant Django

2007-07-24 Thread cjl

Thanks again for the bug report, I have found the problem.

Change the 'path' section of start.bat to read:

path = %CD%\Python25;%CD%\Utilities;%CD%\Utilities\svn-
win32-1.4.4\bin;%CD%\Utilities\exemaker-1.2-20041012;%CD%\Utilities
\npp.4.1.2.bin;%CD%\Utilities\sqlite-3_4_0;%PATH%

I had %PATH% first, and it needs to come last, because order matters,
and it needs to find my python before it finds the previously
installed python.

I will make the change, and upload a new version later.

-cjlesh


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



Re: Django .91 issue

2007-07-24 Thread oggie rob

With 0.91, you use the "magic" name for db-api operations, rather than
the model name. For example:

from django.models import my_model_module
my_model_module.somemodels.get_object(...)

I think sometime before 0.91 was finished, the directory structure
changed, so you might access your models slightly differently, but you
will still need a lower-case, pluralized name for the lookup.

 -rob

On Jul 24, 10:52 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi I have a csv file that I am reading in and I want to test to make
> sure that there are no duplicate records so I do something like this:
>
> # My Checker
>
> from csv import reader
> import datetime
> import re
> import time
> from time import strptime
> from django.models.somemodel import SomeModel
> from some_site import settings
>
> data = '../data/somefile.csv'
> table = reader(open(data))
> header = table.next()
>
> for row in table:
>
> company_name = len(row) > 3 and row[3] or ''
> mailing_address = len(row) > 4 and row[4] or ''
> print company_name
>
> test = SomeModel.get_object(company_name__exact=company_name,
> mailing_address__exact=mailing_address)
>
> It crashes on the last line with this error:
>
> AttributeError: 'module' object has no attribute 'get_object'
>
> from what it look like to me is that it is trying to associate the
> get_object with an attribute in the model class.
>
> Is there an easier way to  test for existing attribute names on the
> database.  There can be more than one company name but only one
> address per company name is allowed in the table.
>
> Any suggestions? Solutions?


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



Re: share users across django projects?

2007-07-24 Thread hotani

I have considered it, but the first project is rather large and we
wanted to keep it on its own server with a separate database. I am
still at the high level design stage of the second project so it may
end up bundled with the first.


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



RE: select_related() bug

2007-07-24 Thread Chris Brand

> Maybe the problem is with the depth parameter, but since I have a self
> reference in the offer model, I have to use depth parameter. I have
> increased the depth prameter, but I get the same error.

Sounds like it could be bug 4789, which I recently tripped over myself.
Can you increase the depth to 3 ? If not, the bug does have a patch :
http://code.djangoproject.com/ticket/4789

Chris




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



RE: Form_for multiple models

2007-07-24 Thread Chris Brand

>  - When you instantiate your form, pass in prefix='form1' as an
> argument - all the fields on the form will get that prefix, which will
> keep the two forms distinct in the POST dictionary. This will only be
> an issue if there is an overlap in the field names on the two forms,
> but it's better to be safe.

I've seen this "prefix" mentioned before in this context. Is it in the
documention yet (I couldn't find it) ? Do all forms accept it as an
instantiation parameter, or is it specific to form_for_instance and
form_for_model ? Is it in 0.96 or only in trunk ?

A quick grep through the 0.96 source seems to indicate that it is a
parameter to BaseForm.__init__(), but that's as far as I can get by myself
at the moment...

Thanks,

Chris




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



Django .91 issue

2007-07-24 Thread [EMAIL PROTECTED]

Hi I have a csv file that I am reading in and I want to test to make
sure that there are no duplicate records so I do something like this:

# My Checker

from csv import reader
import datetime
import re
import time
from time import strptime
from django.models.somemodel import SomeModel
from some_site import settings

data = '../data/somefile.csv'
table = reader(open(data))
header = table.next()

for row in table:

company_name = len(row) > 3 and row[3] or ''
mailing_address = len(row) > 4 and row[4] or ''
print company_name

test = SomeModel.get_object(company_name__exact=company_name,
mailing_address__exact=mailing_address)


It crashes on the last line with this error:

AttributeError: 'module' object has no attribute 'get_object'

from what it look like to me is that it is trying to associate the
get_object with an attribute in the model class.

Is there an easier way to  test for existing attribute names on the
database.  There can be more than one company name but only one
address per company name is allowed in the table.

Any suggestions? Solutions?


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



Re: share users across django projects?

2007-07-24 Thread Carl Karsten

hotani wrote:
> I'm about to build a new project using django that will have the same
> users as a previous project. I would like to avoid duplicating the
> existing user table. Is there a way to authenticate into the new
> project with the current user list?

The users are in the db.  Unless you want to get on the multi-db bus, you will 
need to use the same db for both projects, witch is starting to sound like all 
one project.

Why not just make another app in the same project?

Carl K

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



Re: Django - technology or magic?

2007-07-24 Thread SH

That's one of the reasons I like django better than rails - Because
there's so little magic. It's all pretty straightforward.


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



Re: transaction commit

2007-07-24 Thread Andrey Khavryuchenko

Michal,

 MK> I suppose you read my question attentively and therefore you know that
 MK> I searched the web (and django documentation of course including the
 MK> transaction page). And I suppose you know that I was looking for
 MK> example how to use transactions without decorators.

 MK> The problem is that there's no example how to use transactions without
 MK> decorators in the documentation, there's no example here in this
 MK> mailing list... I found the example in
 MK> django.db.transaction.py

Yes, I read carefuly your question and thought the answer was
straighforward.   I don't understand why you don't want decorators, but you
could just check the decorator definition to read what it does and copy
it's code.  All you need is decorator name and grep over django sources :)

 MK> But thanks anyway ;-)

Luck!

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua 
Call akhavr1975 on www.gizmoproject.com

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



Re: transaction commit

2007-07-24 Thread Peter Melvyn

> Your example is correct, and you aren't violating any 'Django principles'.

Really? Should not be there something like this?

enter_transaction_management()
try:
managed(True)
 try:
 ...
 except:
   transaction.rollback()
   raise ...
 else:
   transaction.commit()
finally:
leave_transaction_management()

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



share users across django projects?

2007-07-24 Thread hotani

I'm about to build a new project using django that will have the same
users as a previous project. I would like to avoid duplicating the
existing user table. Is there a way to authenticate into the new
project with the current user list?


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



Re: List with pagination, sorting and simple search interface

2007-07-24 Thread Pigletto

> I don't think there are pre-made components that will provide you with
> all of those things, and being somewhat new to django I can only point
> you to one bit of documentation and code that I found helpful for
> pagination:
>
> http://code.djangoproject.com/wiki/PaginatorTag
Thanks. Finally I've used PaginatorPag from your link (with some
changes) and
Sortable Headers (from djangosnippets) with some changes too, newforms
to create search form and generic list.
Changes I had to do were necessary because each of those components -
sort, filter and pagination should
know about others parameters, eg. while sorting you shouldn't lost
filter parameters etc.


--
Pigletto


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



Re: How to communicate with Authorize.net?

2007-07-24 Thread Kevin Menard

On 7/22/07, Greg <[EMAIL PROTECTED]> wrote:
>
> Is there any documentation on how to send form data to a Authorize.net
> from within a Django view?

I've done this from a Java webapp we have here.  It's mostly just XML
datagram forming and parsing, using standard HTTP libs for POSTing.  I
don't think you'll run into anything in django that will help you out
or hold you back.

I'd check out the Authorize.net XML guide.  It's a pretty
straightforward, albeit klunky, process.

-- 
Kevin

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



Re: Trouble with last bit of Tutorial

2007-07-24 Thread Martin, Jared
I think my post got lost last night... So here's my question again:
 

- Original Message -
From: django-users@googlegroups.com 
To: Django users 
Sent: Mon Jul 23 20:53:49 2007
Subject: Trouble with last bit of Tutorial


I'm trying to put the last bit on the tutorial. I'm running django
0.96 on ubuntu, and I got stuck here:

Did I replace every instance of poll with object correctly in my
poll_detail.html template?
When I view it, it show the question, and the button below, but no
choices. Have I done something wrong?

{{ object.question }}
{% if error_message %}{{ error_message }}{%
endif %}

{% for choice in object.choice_set.all %}

{{ choice.choice }}
{% 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?hl=en
-~--~~~~--~~--~--~---



Customizing the settings configuration

2007-07-24 Thread gorans

Hi,

I develop Django sites on my mac and then publish them to another web
server. In between, they live in a happy SVN repository on my
development server.

Each time I make a change to the project's settings.py I have to then
go over and modify the live file version (in respect to the database
type / name, media directory etc.)

I though that there could be a way to trick Django into reading
special development settings for me, something like having a settings
'package' import separate settings files:

e.g.

myproject/

manage.py
...
settings/
__init__.py
coresettings.py
localsettings.py

so that we use the variable from coresettings first, and then try:
import localsettings and if successful use those subsequent values.

That way, I can have an un-versioned localsettings.py living on my
mac, whilst keeping the live settings intact. Additionally, other
developers on the project can do the same!

Is this possible? (I'm sure it is but my Python just isn't good enough
to know how to import all the variables from each module)

Can anyone please give me directions / pointers as to how to do this?
Or alternatively, how you deal with this task.

Your help is very very much appreciated

cheers

Goran


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



Re: Form_for multiple models

2007-07-24 Thread Chris Hoeppner
Russell Keith-Magee escribió:
> On 7/24/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> 
>> Well... Actually, what I need is the same as form_for_instance, but for
>> more than a single model.
> 
> Why not use multiple forms? There is nothing stopping you from putting
> multiple forms into a context, and populating multiple forms from a
> single POST dictionary. The only things to keep in mind are:
> 
>  - remember to check validity for both forms (form1.is_valid() and
> form2.is_valid())
> 
>  - When you instantiate your form, pass in prefix='form1' as an
> argument - all the fields on the form will get that prefix, which will
> keep the two forms distinct in the POST dictionary. This will only be
> an issue if there is an overlap in the field names on the two forms,
> but it's better to be safe.
> 
> Yours,
> Russ Magee %-)
> 

If I get this right, I might just throw fields from different models
together in one , and on the server side, call the save() method
on each form instance, and all the data gets where it belongs to?



signature.asc
Description: OpenPGP digital signature


Changing the "name" of a DB object & displaying the ID

2007-07-24 Thread Matt Williams

Dear All,

I have a simple question, but can' find the answer in the docs.

I have two classes, a & b,  in my model.py file, related via a OneToOne. 
When I create an a, I would like to display its UID in the admin interface.

I've tried adding

idNumber  = model.AutoField(primary_key=true)

and

class Admin:

def __str__(self.idNumber)

to the model, but it doesn't appear in the admin interface. Ideas?

Also, when I try and look at it, it just says "a (or b) Object created" 
- how do I get it to display the UID as its name?

Thanks a lot,

Matt

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



Re: Instant Django

2007-07-24 Thread cjl

YML:

Thank you for the bug report.

I thought I had tested this use case, but obviously I missed
something. I'll check into it, and get back to you with an answer.

Thanks again,
cjlesh


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



Re: Instant Django

2007-07-24 Thread yml

Hello,

I have downloaded your package and launch the start.bat
Then in that console I have entered: "django-admin startproject
test_admin"

Unfortunatly the system raises this error message:
"""
Traceback (most recent call last):
  File "E:\instant_django\django\Utilities\django-admin.py", line 5,
in 
from django.core import management
ImportError: No module named django.core
"""
It looks like the system is using my "installed" python and not the
one provided in your package.
Could you please let me know what need to be done to fix this error?

Thank you very much for your effort of making django moveable.
Regards,
yml




On Jul 23, 11:30 pm, cjl <[EMAIL PROTECTED]> wrote:
> Nathan: Thank you for the suggestion, I'm sure you're right. I'll add
> in a start-up message to 'start.bat' the next time I upload an update.
>
> Cam:  Thank you for the kind words. If you do get a change to play
> around with it, I would appreciate feedback and bug reports.
>
> Rob:  I see you read my 'disclaimer'.  I would argue that sipping wine
> in a nice club with a beautiful woman would make anything sound good,
> but I'll admit that I have never done it. I have pounded cheap beer in
> a dirty bar with slutty chicks while listening to AC/DC, and I would
> highly recommend it. By the way, I'm from Buffalo, too.
>
> Strangely enough, and slightly off-topic, I found a Japanese
> translation of my website:http://www.win-django.com/
>
> -cjlesh


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



newforms: default Model values

2007-07-24 Thread Patrick

Hi!

I'm starting to use newforms for most of my forms, but I run into a 
problem, which I'm hope has a DRY solution, but I haven't found it yet. 
Here's my model chunk:

class Post(models.Model):
status  = models.CharField(
maxlength = 15, 
choices = PUBLICATION_STATUS, 
default = 'published')

I use form_for_model and form_for_instance, to create form objects. I 
don't know if there is a way for the newforms to pick my default value 
and auto-select it in a form used to create a new Post.

I could probably hand-code it in the form template, but that will cause 
me to change the template if my default value changes in the model 
(perhaps this example will not change often, but some might).

I understand that newforms and its documentation is not finalized yet, 
but adding a capability to pick up default values from the model would be 
very beneficial. Maybe there are reasons why it's not done automatically, 
which I'm not aware of.

How do you do this in your applications?


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



Re: transaction commit

2007-07-24 Thread Michal Konvalinka

OK, I can try it but it will require a correction because I'm not a
native speaker.
Michal

On 24/07/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> On 7/24/07, Michal Konvalinka <[EMAIL PROTECTED]> wrote:
> >
> > The problem is that there's no example how to use transactions without
> > decorators in the documentation, there's no example here in this
> > mailing list... I found the example in
> > django.db.transaction.py
>
> This is a problem that should be fixed. Please log a ticket to report
> this lack of documentation. If you're feeling really adventurous, try
> your hand at writing the missing section. We welcome any contribution,
> and documentation from newcomers is often quite useful (since it
> highlights the areas that seem obvious to us, but aren't).
>
> Many thanks,
> Russ Magee %-)
>
> >
>

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



Cercasi Programmatori Python

2007-07-24 Thread Vittorino Parenti

La nosrta società cerca programmatori python con le seguenti conoscenze:

- Python2.4 o superiori
- Django
- PostgreSQL, MySQL, Ajax
- PHP (non indispensabile)

Coloro che fossero interessati possono inviare il CV al seguente indirizzo:

[EMAIL PROTECTED]

Saluti,
Vittorino.


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



Re: transaction commit

2007-07-24 Thread Russell Keith-Magee

On 7/24/07, Michal Konvalinka <[EMAIL PROTECTED]> wrote:
>
> The problem is that there's no example how to use transactions without
> decorators in the documentation, there's no example here in this
> mailing list... I found the example in
> django.db.transaction.py

This is a problem that should be fixed. Please log a ticket to report
this lack of documentation. If you're feeling really adventurous, try
your hand at writing the missing section. We welcome any contribution,
and documentation from newcomers is often quite useful (since it
highlights the areas that seem obvious to us, but aren't).

Many thanks,
Russ Magee %-)

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



Re: upload progress bar (ticket #4165)

2007-07-24 Thread Dirk van Oosterbosch, IR labs
I now believe this 'uncaught exception' just means that the return  
from the query http://mydomain.com/admin/upload_progress/?0 was not  
correctly parsable xml.
If I try http://mydomain.com/admin/upload_progress/?0 by hand it  
returns OperationalError at /admin/upload_progress/
(1048, "Column 'progress_id' cannot be null"). I guess this indicates  
again that the query needs a progress_id (32 random chars?). So my  
guess is it doesn't have this or it doesn't pass this along.

I see there is a 32 char sessionid. Should this be the progress_id?
Should there be a 32 char progress_id in the temp dir during an  
upload? (besides the temporarilily file being uploaded?)
What could cause this progress_id file not being there?
How to debug this further?

btw: is this mailing list the correct place to discuss this? Or  
should I post to the ticket page?

Best regards
dirk


On 23-jul-2007, at 19:11, Dirk van Oosterbosch, IR labs wrote:

> ...
> uncaught exception: [Exception... "Component returned failure code:
> 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]"
> nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS
> frame :: javascript: eval(__firebugTemp__); :: anonymous :: line 1"
> data: no]
>
> 1. My upload temp dir is empty, except for during a upload. Then is
> hold a file like this:
> -rw---1 apache   apache   7.6M Jul 22 23:08  
> tmpciyJoL.upload
>
> 2. The query string issued during the upload also does not contain 32
> random characters.
> It just calls: http://mydomain.com/admin/upload_progress/?0 (and
> following)
>>
>> 1. Check if your upload temp dir is contain file with 32 length  
>> random
>> character is created.
>> 2. If not, check you javascript that summit upload form, it should
>> have 32 random character as a query string.
>> 3. For firefox, use filebug extension to see if there are polling for
>> upload status, it occur every one second by default. For IE, use
>> fiddler to debug.
>>


-
Dirk van Oosterbosch
de Wittenstraat 225
1052 AT Amsterdam
the Netherlands

http://labs.ixopusada.com
-



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



Re: transaction commit

2007-07-24 Thread Michal Konvalinka

Hi Andrey,
I suppose you read my question attentively and therefore you know that
I searched the web (and django documentation of course including the
transaction page). And I suppose you know that I was looking for
example how to use transactions without decorators.

The problem is that there's no example how to use transactions without
decorators in the documentation, there's no example here in this
mailing list... I found the example in
django.db.transaction.py

But thanks anyway ;-)
Michal


On 24/07/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
>
>
>  MK> Hi,
>  MK> I would like to use transactions (in MySQL and InnoDB). I know there
>  MK> are decorators but I don't want to use them now. Is there any example
>  MK> how to use transactions without decorators? I couldn't find anything
>  MK> on django website, this user-group...
>
> Quick google on "django transactions" shows
> http://www.djangoproject.com/documentation/transactions/ as the first
> result.
>
> And it has a cut down example of manual commit usage.
>
> --
> Andrey V Khavryuchenko
> Django NewGate -  http://www.kds.com.ua/djiggit/
> Development - http://www.kds.com.ua
> Call akhavr1975 on www.gizmoproject.com
>
> >
>

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



Re: newforms: How to pass onchange="..." ?

2007-07-24 Thread [EMAIL PROTECTED]

Better yet, don't mix your js in with your other stuff, separate out
your script and say

document.getElementByID("id_whatever").onchange = do something

On Jul 24, 3:47 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Am Dienstag, 24. Juli 2007 10:32 schrieb Thomas Guettler:
>
> > Hi,
>
> > how can I pass the html attribute onchange="..." with newforms?
>
> I found one solution myself:
>
> http://code.djangoproject.com/attachment/ticket/4961/newforms.diff#pr...
>
> Adding HTML attributes to the widget
> 
>
> If you want to add HTML attributes to the widget of a field, you need add
> them to the dictionary ``attrs``::
>
> class ActionForm(forms.Form):
> action=forms.ChoiceField(choices=(
> ("", "---"),
> ("edit", "Bearbeiten"),
> ("delete", "Delete"))
> action.widget.attrs["onchange"]="this.form.submit()"
>
>  Thomas


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



select_related() bug

2007-07-24 Thread novice

Hello,
I have this following model structure
model category : name & description fields
model seller : name & some address fields...
model offer: category (FK to category table), name, picture, etc...
model offer_seller: offer (FK to offer), seller (FK to seller), price,
amount, etc

the seller has the string representation something like ,
and the offer_seller has a string representation something like


when I dont use select_related, I have no problem for example..
off_seller_1=OfferSeller.objects.filter(offer__in=[1, 2, 3])
off_seller_1[0].seller for example gives me the proper seller for that
offer...
and off_seller_1[0] ... gives me the _str representation something
like ""

now when I use select_related like this
off_seller_2=OfferSeller.objects.select_related(depth=2).filter(offer__in=[1,
2, 3])
off_seller_2[0].seller for example gives me the category instead of
the seller! 
and off_seller_2[0] ... gives me the _str representation something
like 

so the statment
off_seller_2[0].seller.shop_name   gives me "food" which is the
category name... instead of the shop_name, which was "aldi"

Maybe the problem is with the depth parameter, but since I have a self
reference in the offer model, I have to use depth parameter. I have
increased the depth prameter, but I get the same error.

Any ideas on how to solve this? Till then i will use the version
without select_related, and hence incurring database access whenever i
want to get info in related tables :-(

thanks in advance,
Oumer

class category(models.Model) :


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



Re: Form_for multiple models

2007-07-24 Thread Russell Keith-Magee

On 7/24/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote:

> Well... Actually, what I need is the same as form_for_instance, but for
> more than a single model.

Why not use multiple forms? There is nothing stopping you from putting
multiple forms into a context, and populating multiple forms from a
single POST dictionary. The only things to keep in mind are:

 - remember to check validity for both forms (form1.is_valid() and
form2.is_valid())

 - When you instantiate your form, pass in prefix='form1' as an
argument - all the fields on the form will get that prefix, which will
keep the two forms distinct in the POST dictionary. This will only be
an issue if there is an overlap in the field names on the two forms,
but it's better to be safe.

Yours,
Russ Magee %-)

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



Form_for multiple models

2007-07-24 Thread Chris Hoeppner
Hi there!

I need to get a form done. The 'long' way.

Well... Actually, what I need is the same as form_for_instance, but for
more than a single model.

The actual form_for_instance is a bit too advanced for my poor python
knowledge. Any way to get this a bit easier than creating the form by hand?



signature.asc
Description: OpenPGP digital signature


Re: Insert vs. Update

2007-07-24 Thread Russell Keith-Magee

On 7/24/07, PyMan <[EMAIL PROTECTED]> wrote:
>
> Can anyone tell me why Django do this while using save()? :

The behavior comes from the Object relational mapping (key word -
Object). Since save() is an operation on an Object relational mapper,
it was established as an unambiguous mechanism to get object instance
X onto the database. This means creating a row if one doesn't already
exist, and updating the existing row if it does.

> Am I wrong? What am I missing? Surely something, please tell me what.

You're not the first to suggest insert() and update() methods that
explicity do SQL INSERT and UPDATE calls. I have a vague recollection
that a decision was made about adding these calls, but a quick search
in the ticket database didn't find the ticket that related to this
change. Feel free to do a more comprehensive search; the discussion
should be archived there (or, at the very least, in the
django-developers mailing list).

Yours,
Russ Magee %-)

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



Re: Django - technology or magic?

2007-07-24 Thread Sam Morris

On Mon, 23 Jul 2007 16:57:42 -0700, to_see wrote:

> Snippet #26 solved my problem, essentially in two lines.  I could not
> write those lines for myself now, and I'm not certain I'll ever be able
> to do so.

I'm going to assume it's the Python code itself that is confusing you,
rather than the newforms API...

The lines you're talking about are the body of the constructor in the 
following code:

class AddSnippetForm (forms.Form):
  def __init__ (self, *args, **kwargs):
super (AddSnippetForm, self).__init__ (*args, **kwargs)
self.fields['language'].choices = [('', '--')] + [(lang.id, 
lang.name) for lang in Language.objects.all()]

The first line of the constructor is calling the constructor of the
AddSnippetForm's base class, which is forms.Form. This is necessary
so that the work done by the Form class's constructor is still
performed, even though the constructor was overridden by the child
class.

For details, see the definition of the super function in . I *think* (though I am
not certain) that this line could also be written as:

  forms.Form.__init__ (self, *args, **kwargs)

The funny *args and **kwargs arguments simply pass any positional
and keyword arguments that the constructor was called with through
to the constructor of the base class.

The second line is changing the 'choices' property of the 'language' 
field of the form. So far so good -- but what is that weird looking 
expression inside the second set of square brackets on the right hand 
side of the assignment?

Weel, it is a list comprehension. List Comprehensions are just a
concice way of evaluating an expression over each member of a list, and
returning a list of the results. That line could be written out in full 
as:

  x = [('', '--')]
  for lang in Language.objects.all ():
x.append ((lang.id, lang.name))
  self.fields['language'].choices = x

Or by using the map function, as:

  self.fields['language'].choices = [('', '--')] + map (lambda lang: 
(lang.id, lang.name), Language.objects.all ())

More details about List Comprehensions can be found:

 * in the Python tutorial
   
 * in the Python Language Reference
   
 * in PEP 202 (where List Comprehensions were originally defined)
   

When learning any new API/framework along with a language at the
same time, it is often difficult to determine whether something
that you find confusing is a feature of the language, or just an
artifact of the API/framework.

In my experience, once you break down the various little bits
(and know where to find the documentation!), code like this will
start to look a bit less magical and a bit more like, well, regular
code. :)

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

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


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



Re: transaction commit

2007-07-24 Thread Andrey Khavryuchenko


 MK> Hi,
 MK> I would like to use transactions (in MySQL and InnoDB). I know there
 MK> are decorators but I don't want to use them now. Is there any example
 MK> how to use transactions without decorators? I couldn't find anything
 MK> on django website, this user-group...

Quick google on "django transactions" shows
http://www.djangoproject.com/documentation/transactions/ as the first
result.

And it has a cut down example of manual commit usage.

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua 
Call akhavr1975 on www.gizmoproject.com

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



Re: transaction commit

2007-07-24 Thread Russell Keith-Magee

On 7/24/07, Michal Konvalinka <[EMAIL PROTECTED]> wrote:

> It works but I would like to ask If I am violating some Django
> principles or not.

Your example is correct, and you aren't violating any 'Django principles'.

Django provides decorators because it can be convenient to wrap a
whole function as a transaction. However, that's not the way _all_
code needs to work, so the manual mechanisms (which you have
discovered) also exist. Feel free to use whatever mechanism suits your
needs.

Yours,
Russ Magee %-)

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



Re: Template debugging

2007-07-24 Thread Russell Keith-Magee

On 7/23/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> I was wondering if this is even possible (perhaps, some middleware?).
> I'd like to have a closer look into the context that is getting rendered
> in each view, including the data I get from the RequestContext.

You might want to look at the {% debug %} template tag. Just drop {%
debug %} into your template, and you'll get a whole lot of debugging
data, including the current context.

> Maybe someone has used Symfony and has seen that cute debug bar you get
> when accessing through the dev controller.

Can't say I've looked at it. To save us all the effort of installing
another web framework, can you point us at a web site that
demonstrates this debug bar? Alternatively, can you  describe it in
more detail (or point at some documentation that explains it in more
detail)?

Yours,
Russ Magee %-)

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



Re: Django - technology or magic?

2007-07-24 Thread Nis Jørgensen

to_see skrev:
> "Any sufficiently advanced technology is indistinguishable from
> magic."
> Arthur C. Clarke, "Profiles of The Future", 1961 (Clarke's third
> law)
>   

> Snippet #26 solved my problem, essentially in two lines.  I could not
> write those lines for myself now, and I'm not certain I'll ever be
> able to do so.
>
> Am I having a fairly normal introduction to a web framework?  I cannot
> see this as technology.  All I see is magic.
>   
FYI: I first looked at the Django source a year and a half ago. The
first time I saw (*args, **kwargs) I ran away screaming, deciding that I
would just try to use the magic, rather than understand it or control it.

Since then I learned some more python, and recognized this as a standard
python idiom.

Yesterday I ran into almost exactly the same problem as you - how to
populate my dropdown at the time of the request, rather than when the
module was loaded. I then went on to write exactly the same code as the
snippet, except for the identifiers and the "blank value" (with a bit of
trial and error).

So learn some python and you will be able to see how the magic works. Or
just lean back and enjoy the show ...

Nis


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



transaction commit

2007-07-24 Thread Michal Konvalinka

Hi,
I would like to use transactions (in MySQL and InnoDB). I know there
are decorators but I don't want to use them now. Is there any example
how to use transactions without decorators? I couldn't find anything
on django website, this user-group...

Is this correct?

def update_something(self, pairs):
from django.db import connection, transaction
transaction.enter_transaction_management()
cursor = connection.cursor()
for pair in pairs:
Q = '''UPDATE `table` SET `something` = %s WHERE  `id` = %s'''
cursor.execute(Q, (pair['something'], pair['id']))
transaction.commit()
transaction.leave_transaction_management()


It works but I would like to ask If I am violating some Django
principles or not.

Thank you,
Michal


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



  1   2   >