Re: Keeping fields out of the Admin

2008-11-20 Thread Lars Stavholm

Epinephrine wrote:
> I have a field that should never be edited by hand.  It is basically
> date_letter_sent, and it should be filled in by a view function when
> it sends a letter.
> 
> How can I keep the field from being editable in the Admin edit page
> for that class?

editable = False in the model definition.
/L

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



Re: Custom Select widget choices - how to reuse choices?

2008-11-20 Thread urukay


easy way how to solve it is to put definition of your choices out of model
definition:

CHOICES=((u'1','one'), (u'2',u'two'))

class Movie( Relic ):
 disk_type = models.CharField( 'Type', max_length=8, choices=CHOICES)

and then you can import CHOICES whereever you want and reuse it
from ..models import CHOICES



Donn Ingle wrote:
> 
> 
> Hello,
> In my model, I define the choices for a charfield. I make a ModelForm of
> that 
> model but I want my own widget for that field. How can I pass-through the 
> choices I defined in my model?
> 
> Some code:
> 
> class Movie( Relic ):
>  disk_type = models.CharField( 'Type', max_length=8,
> choices=((u'1','one'), 
> (u'2',u'two')), default=u'1' )
> 
> class MovieForm( BasicRelicForm ):
>  disk_type = forms.CharField( widget = choicewidget( choices=?? )) 
>  class Meta:
>model = Movie
> 
> What would I put in the choices=?? line?
> 
> I have found this voodoo: 
> forminstance._meta.model.disk_type.choices
> But it needs an instance to work.
> 
> I could use a global var and repeat it twice, but I'd like to know if
> there's 
> a way to simply 'fetch' it from the model.
> 
> Any clues?
> \d
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Custom-Select-widget-choices---how-to-reuse-choices--tp20606743p20615699.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: ImportError: No module named psycopg2 on XP

2008-11-20 Thread Steve Holden

Steve Holden wrote:
> dj wrote:
>   
>> Hello All,
>>
>> I am trying to use PostgreSQL database and am I an stuck in the
>> install of psycopg2.
>> 
> [...]
>
> Hope this helps, though it may not ...
> regards
>  Steve
>   
PS: Binary installers available at
http://www.stickpeople.com/projects/python/win-psycopg/#Version2


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

2008-11-20 Thread Steve Holden

dj wrote:
> Hello All,
>
> I am trying to use PostgreSQL database and am I an stuck in the
> install of psycopg2.
> I downloaded the psycopg2-2.0.8.tar and extracted the file to C:
> \Python26\Lib\site-packages.
> I opened a cmd box and typed python setup.py install. The build
> completed without errors,
> however, when I try to import the library I get the following error:
>
>   
 import psycopg2
 
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: No module named psycopg2
>
> I went into the setup.cfg file and added these lines:
>
> # "pg_config" is the preferred method to locate PostgreSQL headers and
> # libraries needed to build psycopg2. If pg_config is not in the path
> or
> # is installed under a different name uncomment the following option
> and
> # set it to the pg_config full path.
> pg_config=C:/PostgreSQL/8.3/bin/pg_config.exe
>
> # If postgresql is installed somewhere weird (i.e., not in your
> runtime library
> # path like /usr/lib), just add the right path in "library_dirs" and
> any extra
> # libraries required to link in "libraries".
> library_dirs=C:/PostgreSQL/8.3/include/libpq-fe.h
> libraries=C:/PostgreSQL/8.3/lib/libpq/libpq-fs.h
>
> I ran the install command again. However, I continue to get the same
> error.
> Does anyone know what I am doing wrong ?
>   
Well, for a start you aren't supposed to put the install directory into
site-packages: the install process does that. So start with it somewhere
else, or it will install over itself, creating confusion and mayhem!

A psycopg2 install from source requires C compilation: do you have
Visual Studio or the free C toolchain installed? Are you *sure* there
were no build errors? This is what I get from

  python setup.py build

(a halfway house to avoid attempts to overwrite my working psycopg2
installation) on my Windows box:

C:\Users\sholden\Documents\psycopg2-2.0b8>python setup.py build
running build
running build_py
creating build
creating build\lib.win32-2.5
creating build\lib.win32-2.5\psycopg2
copying lib\extensions.py -> build\lib.win32-2.5\psycopg2
copying lib\extras.py -> build\lib.win32-2.5\psycopg2
copying lib\pool.py -> build\lib.win32-2.5\psycopg2
copying lib\psycopg1.py -> build\lib.win32-2.5\psycopg2
copying lib\tz.py -> build\lib.win32-2.5\psycopg2
copying lib\__init__.py -> build\lib.win32-2.5\psycopg2
running build_ext
Warning: 'pg_config' is not recognized as an internal or external command,
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible
binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin
installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

I believe for Python 2.6 you need a later version of Visual Studio: this
was a 2.5 build.

Hope this helps, though it may not ...
regards
 Steve


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

2008-11-20 Thread dj

Hello All,

I am trying to use PostgreSQL database and am I an stuck in the
install of psycopg2.
I downloaded the psycopg2-2.0.8.tar and extracted the file to C:
\Python26\Lib\site-packages.
I opened a cmd box and typed python setup.py install. The build
completed without errors,
however, when I try to import the library I get the following error:

>>> import psycopg2
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named psycopg2

I went into the setup.cfg file and added these lines:

# "pg_config" is the preferred method to locate PostgreSQL headers and
# libraries needed to build psycopg2. If pg_config is not in the path
or
# is installed under a different name uncomment the following option
and
# set it to the pg_config full path.
pg_config=C:/PostgreSQL/8.3/bin/pg_config.exe

# If postgresql is installed somewhere weird (i.e., not in your
runtime library
# path like /usr/lib), just add the right path in "library_dirs" and
any extra
# libraries required to link in "libraries".
library_dirs=C:/PostgreSQL/8.3/include/libpq-fe.h
libraries=C:/PostgreSQL/8.3/lib/libpq/libpq-fs.h

I ran the install command again. However, I continue to get the same
error.
Does anyone know what I am doing wrong ?

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

2008-11-20 Thread waltbrad



On Nov 20, 6:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
>, so check very carefully (for example,
> run tabnanny.py -- which is in the directory where Python is installed
> -- over your code to check)
>
Thanks for that, Malcolm. I'll have to remember that tool.



> > 1.1 pre-alpha
>
> Which is not 1.1. It is "1.1 pre-alpha". It is different from "1.1
> alpha", "1.1 beta" and "1.1" (the latter being the final 1.1 release and
> none of the latter three will exist for a few months yet).

Something I'll remember, thanks.

Hey, since I now have django installed in the Python25\Lib\site-
packages directory can I go ahead and delete the C:\django-trunk
directory Subversion installed?

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



Eclipse/Mylyn for Django Dev

2008-11-20 Thread Keyton Weissinger

This is a question for my fellow Eclipse/PyDev fans

Have any of you gone through the trouble to change your work flow to
take advantage of Mylyn?

>From the Mylyn web page (http://www.eclipse.org/mylyn/):
"Mylyn is a task-focused interface for Eclipse that reduces
information overload and makes multi-tasking easy."

It seems like a really cool idea but I've not bothered to really give
it a go for a project (not wanting to take time to retool).

So I wanted to see if anyone out there had taken that leap and could
comment on their experience.

Keyton

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar

Thank you for the advise. I just started using Django and sometimes it
takes time to get used to do certain things.


Regards,

Arif

On Nov 20, 3:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-11-20 at 15:18 -0800, ayayalar wrote:
> > I understand, I wish it was possible to bind multiple view functions
> > to a single template through the urls...
>
> Why? It's the wrong level of coupling. Each URL patterns ends up
> resolving to a single view function. However that view function can (and
> should if there's any great level of processing involved) call other
> functions to do whatever it wants. So just move your multiple function
> calls down one layer. It retains the "view per URL" pattern and you can
> still have one function for each form. You just need to merge the
> results at the end, but since that's just a dictionary update, it's one
> line of code.
>
> You are trying to make this way too hard for yourself by getting hung up
> on one particular pattern of usage that you guessed might be possible
> without any supporting evidence. Since that isn't possible in Django and
> isn't ever likely to be possible, it's particularly counter-productive
> not to move on, especially as the way to do this is trivial.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Malcolm Tredinnick


On Thu, 2008-11-20 at 15:18 -0800, ayayalar wrote:
> I understand, I wish it was possible to bind multiple view functions
> to a single template through the urls...

Why? It's the wrong level of coupling. Each URL patterns ends up
resolving to a single view function. However that view function can (and
should if there's any great level of processing involved) call other
functions to do whatever it wants. So just move your multiple function
calls down one layer. It retains the "view per URL" pattern and you can
still have one function for each form. You just need to merge the
results at the end, but since that's just a dictionary update, it's one
line of code.

You are trying to make this way too hard for yourself by getting hung up
on one particular pattern of usage that you guessed might be possible
without any supporting evidence. Since that isn't possible in Django and
isn't ever likely to be possible, it's particularly counter-productive
not to move on, especially as the way to do this is trivial.

Regards,
Malcolm



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



Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar

As you can see I am trying to display a form that points to related
models/tables. Any suggestion where I can find a good documentation or
an article to accomplish this in "Django" way? I feel like I am not
taking the right path

On Nov 20, 3:23 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> I am able to do this, but this is pure ugly. Not a very elegant way of
> doing things.
>
> def product(request):
>     if not request.method == 'POST':
>         form1 = ProductForm()
>         form2 = ProductDetailForm()
>         return render_to_response('index.html', {'form1' : form1,
> 'form2' : form2})
>     else:
>         form1 = ProductForm(request.POST)
>         form2 = ProductDetailForm(request.POST)
>         if form1.is_valid():
>             form1.save()
>         if form2.is_valid():
>             form2.save()
>         return HttpResponseRedirect('/thanks.html')
>
> On Nov 20, 3:18 pm, ayayalar <[EMAIL PROTECTED]> wrote:
>
> > I understand, I wish it was possible to bind multiple view functions
> > to a single template through the urls...
>
> > Would something like this possible?
>
> > URLS
> > urlpatterns = patterns('',
>
> >     (r'^product/$', views.add_product, views.add_product_details),)
>
> > On Nov 20, 3:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Thu, 2008-11-20 at 14:03 -0800, ayayalar wrote:
>
> > > [...]
>
> > > > URLS
> > > > urlpatterns = patterns('',
>
> > > >     (r'^product/$', views.add_product),
> > > >     (r'^product/$', views.add_product_details),
>
> > > This has no chance of doing what you expect. Only one view function will
> > > be called for a single request. If you want to pass two form objects to
> > > the template, you need to do it from the same view function. You can
> > > still put the form creation pieces in separate functions, but your view
> > > function will have to call both of them and combine the results into a
> > > context to pass to a template.
>
> > > Regards,
> > > Malcolm
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



access current model id, for custom widget

2008-11-20 Thread yves_s

hi everybody
I'm making a custom form widget in the newforms admin and I want to
have access to the id of the current model instance (for already
existing data).
Can I get the id from the request object? Or any other solution?

I'm really going mad with this problem..

yves


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar

I am able to do this, but this is pure ugly. Not a very elegant way of
doing things.

def product(request):
if not request.method == 'POST':
form1 = ProductForm()
form2 = ProductDetailForm()
return render_to_response('index.html', {'form1' : form1,
'form2' : form2})
else:
form1 = ProductForm(request.POST)
form2 = ProductDetailForm(request.POST)
if form1.is_valid():
form1.save()
if form2.is_valid():
form2.save()
return HttpResponseRedirect('/thanks.html')

On Nov 20, 3:18 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> I understand, I wish it was possible to bind multiple view functions
> to a single template through the urls...
>
> Would something like this possible?
>
> URLS
> urlpatterns = patterns('',
>
>     (r'^product/$', views.add_product, views.add_product_details),)
>
> On Nov 20, 3:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Thu, 2008-11-20 at 14:03 -0800, ayayalar wrote:
>
> > [...]
>
> > > URLS
> > > urlpatterns = patterns('',
>
> > >     (r'^product/$', views.add_product),
> > >     (r'^product/$', views.add_product_details),
>
> > This has no chance of doing what you expect. Only one view function will
> > be called for a single request. If you want to pass two form objects to
> > the template, you need to do it from the same view function. You can
> > still put the form creation pieces in separate functions, but your view
> > function will have to call both of them and combine the results into a
> > context to pass to a template.
>
> > Regards,
> > Malcolm
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Brian Neal

On Nov 20, 4:50 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> And I do that. Here is my template:
>
No, you are not. Check the dictionary you are passing into your
render_to_response() calls again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar

I understand, I wish it was possible to bind multiple view functions
to a single template through the urls...

Would something like this possible?

URLS
urlpatterns = patterns('',

(r'^product/$', views.add_product, views.add_product_details),)



On Nov 20, 3:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-11-20 at 14:03 -0800, ayayalar wrote:
>
> [...]
>
> > URLS
> > urlpatterns = patterns('',
>
> >     (r'^product/$', views.add_product),
> >     (r'^product/$', views.add_product_details),
>
> This has no chance of doing what you expect. Only one view function will
> be called for a single request. If you want to pass two form objects to
> the template, you need to do it from the same view function. You can
> still put the form creation pieces in separate functions, but your view
> function will have to call both of them and combine the results into a
> context to pass to a template.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: indentation problem in file

2008-11-20 Thread waltbrad



On Nov 20, 6:07 pm, waltbrad <[EMAIL PROTECTED]> wrote:
> On Nov 20, 5:45 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
>
>
> > > Is there something wrong with this.  I am using django 1.1
>
> > Are you by any chance mixing spaces and tabs? The code *looks* OK. I
> > doubt you are using 1.1, however, since that hasn't been released yet.
>
> > regards
> >  Steve
>
> Thanks for the response Steve.  My code looks exactly as I posted it,
> spaces and all.
>
Sheesh. So, sorry. I didn't understand what you meant until after I
posted.

You were right, the return statements were not tabbed, I spaced them.

I corrected it and now the code works fine.

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

2008-11-20 Thread Malcolm Tredinnick


On Thu, 2008-11-20 at 15:07 -0800, waltbrad wrote:
[...]
> Thanks for the response Steve.  My code looks exactly as I posted it,
> spaces and all.

The error you posted also will have told you where the error was
occurring, not just the error message. That would certainly be a good
guide. It certainly sounds like you are mixing tabs and spaces in your
code if the alignment is as given, so check very carefully (for example,
run tabnanny.py -- which is in the directory where Python is installed
-- over your code to check)

> As far as the version, this is what I get with the following command:
> 
> C:\>django-admin.py --version
> 1.1 pre-alpha

Which is not 1.1. It is "1.1 pre-alpha". It is different from "1.1
alpha", "1.1 beta" and "1.1" (the latter being the final 1.1 release and
none of the latter three will exist for a few months yet). That might
sound like a minor point, but it really is significant in terms of what
version you are running, so getting into the right habits now will save
on confusion later on. It's the difference between "turn left" and "turn
left at the second lights" -- both start off the same way, and yet they
mean quite different things.

Regards,
Malcolm


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



Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Malcolm Tredinnick


On Thu, 2008-11-20 at 14:03 -0800, ayayalar wrote:
[...]
> URLS
> urlpatterns = patterns('',
> 
> (r'^product/$', views.add_product),
> (r'^product/$', views.add_product_details),

This has no chance of doing what you expect. Only one view function will
be called for a single request. If you want to pass two form objects to
the template, you need to do it from the same view function. You can
still put the form creation pieces in separate functions, but your view
function will have to call both of them and combine the results into a
context to pass to a template.

Regards,
Malcolm



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



Re: indentation problem in file

2008-11-20 Thread waltbrad



On Nov 20, 5:45 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> > Is there something wrong with this.  I am using django 1.1
>
> Are you by any chance mixing spaces and tabs? The code *looks* OK. I
> doubt you are using 1.1, however, since that hasn't been released yet.
>
> regards
>  Steve

Thanks for the response Steve.  My code looks exactly as I posted it,
spaces and all.

As far as the version, this is what I get with the following command:

C:\>django-admin.py --version
1.1 pre-alpha

Any help mightily appreciated. Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: del session variables

2008-11-20 Thread Malcolm Tredinnick


On Thu, 2008-11-20 at 14:06 -0800, Bobby Roberts wrote:
> is there a way to kill a session rather than running a del statement
> on each session variable?  I know in .asp you can simply say
> session.abandon.  Is there an equivalent with django?

Django has this really nifty feature (I believe ASP.NET has it too)
called "documentation". If you look at the documentation for the
sessions application, there's this section:

http://docs.djangoproject.com/en/dev/topics/http/sessions/#using-sessions-in-views

Have a look at the flush() method; I believe that might well be close to
what you are after.

Regards,
Malcolm


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



Re: del session variables

2008-11-20 Thread Andy McKay

On 20 Nov 2008, at 22:06, Bobby Roberts wrote:
> is there a way to kill a session rather than running a del statement
> on each session variable?  I know in .asp you can simply say
> session.abandon.  Is there an equivalent with django?


In the session documentation there are mentions of: clear() and flush()

http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-http-sessions

Sounds like one of those might be helpful.
--
   Andy McKay
   Clearwind Consulting

   Site: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Karen Tracey
On Thu, Nov 20, 2008 at 5:03 PM, ayayalar <[EMAIL PROTECTED]> wrote:

>
> VIEW:
>
> def add_product(request):
>if not request.method == 'POST':
>form1 = ProductForm()
>return render_to_response('index.html', {'form1' : form1})
>else:
>form1 = ProductForm(request.POST)
>if form1.is_valid():
>form1.save()
>return HttpResponseRedirect('/thanks.html')
>
>
> def add_product_details(request):
>if not request.method == 'POST':
>form2 = ProductDetailForm()
>return render_to_response('index.html', {'form2' : form2})
>else:
>if form2.is_valid():
>form2.save()
>return HttpResponseRedirect('/thanks.html')
>
> URLS
> urlpatterns = patterns('',
>
>(r'^product/$', views.add_product),
>(r'^product/$', views.add_product_details),
>
>
> Is this possible? For some reason the 2nd form never shows up
>

A request is going to match only one url pattern (assuming a match is
found).  You seem to be expecting that one request will first match the
first (add_product) view you have specified and then when that is done the
2nd (add_product_details) one will get called.  That's not how it works.  If
you wont both the code that is in add_product and add_product_details to be
called for your r'^product/$' url, then you need to combine their code into
one function that you specify in a single urlentry for r^product/$'.  In
that combined view you need to create both forms and pass both of them in
the context to your template.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Andy McKay

Yes but you never pass two forms to the template at the same time. In  
add_product you pass form1, in add_product_details you pass form2.

>>> (r'^product/$', views.add_product),
>>> (r'^product/$', views.add_product_details),

You have the same URL twice, only one of them will ever be active.

Remove one of those of URL's, then merge the two views together and  
pass both form1 and form2 to the template.
--
   Andy McKay
   Clearwind Consulting

   Site: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar

And I do that. Here is my template:









{{ form1.as_table }}






{{ form2.as_table }}







On Nov 20, 2:15 pm, Brian Neal <[EMAIL PROTECTED]> wrote:
> On Nov 20, 4:03 pm, ayayalar <[EMAIL PROTECTED]> wrote:
>
>
>
> > VIEW:
>
> > def add_product(request):
> >     if not request.method == 'POST':
> >         form1 = ProductForm()
> >         return render_to_response('index.html', {'form1' : form1})
> >     else:
> >         form1 = ProductForm(request.POST)
> >         if form1.is_valid():
> >             form1.save()
> >             return HttpResponseRedirect('/thanks.html')
>
> > def add_product_details(request):
> >     if not request.method == 'POST':
> >         form2 = ProductDetailForm()
> >         return render_to_response('index.html', {'form2' : form2})
> >     else:
> >         if form2.is_valid():
> >             form2.save()
> >             return HttpResponseRedirect('/thanks.html')
>
> > URLS
> > urlpatterns = patterns('',
>
> >     (r'^product/$', views.add_product),
> >     (r'^product/$', views.add_product_details),
>
> > Is this possible? For some reason the 2nd form never shows up
>
> Well you need to pass both forms to the template to get them both to
> show up.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: indentation problem in file

2008-11-20 Thread Steve Holden

waltbrad wrote:
> Hate to bother with this, I'm sure it's a small thing.  I'm going
> through the 1st django app tutorial in the  django documentation.  I'm
> doing okay until the Unicode statements they want inserted into the
> models.py file, for the representation of objects in the interpreter.
>
> On the website they show this:
> 
> class Poll(models.Model):
> # ...
> def __unicode__(self):
> return self.question
>
> class Choice(models.Model):
> # ...
> def __unicode__(self):
> return self.choice
> 
>
> But when I indent like that I get an error that reads:
>
> IndentationError: Expected an indented block.
>
> So, I take the indentations out of the def stmt.  But when I do that
> the representations are the same as they were before.  So, at present
> my models.py file looks like this:
> =
>
> # Create your models here.
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>   question = models.CharField(max_length=200)
>   pub_date = models.DateTimeField('date published')
>   def __unicode__(self):
> return self.question
>   def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
>
>
> class Choice(models.Model):
>
>   poll = models.ForeignKey(Poll)
>   choice = models.CharField(max_length=200)
>   votes = models.IntegerField()
>   def __unicode__(self):
>  return self.choice
> ==
>
> Is there something wrong with this.  I am using django 1.1
>   
Are you by any chance mixing spaces and tabs? The code *looks* OK. I
doubt you are using 1.1, however, since that hasn't been released yet.

regards
 Steve


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



Auto-notify outside/API services when instance Updated - Best Practices?

2008-11-20 Thread John.R

I'm working with an Event Model that, when saved (and possibly when
updated) needs to run some custom Python code to notify some outside
APIs - Twitter, Pownce, Google Calendar for instance.

I know enough to implement Signals so that I don't have to code
anything into the Event model itself if we change or add APIs later -
but what's the best approach to this, when handling things like:

What if one of several APIs is unavailable for update?
Best way to keep track of that, and update only the correct ones
later?

-
My initial thinking is to create a related Model that will store
information in properties, like "was_twittered",
"x_service_was_notified" that has a OneToOne relationship with the
Event Model. Then in Signals I would create a new instance of that,
related to the Event being saved/updated, and call a method on it that
would attempt to contact any services that don't have their related
"x_was_notified" property set to True.

But then, what about later? What if one doesn't respond? How do I go
back and tell it to retry later? Use cron? Implement a Django-based
cron app? I'd like to self-contain as much as possible with this, so
as to Not Repeat Myself, and to not go one a "wild goose chase" if
something acts buggy later.

Any ideas?

Thanks!

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



Help with GeoDjango and Google Maps, please...

2008-11-20 Thread ChrisK

I'm struggling to get django.contrib.gis.maps.google.gmap to do
something interesting. I have looked at the embedded examples, and as
far as they go, they're great. I would really like to display a
polygon using GPolygon, and for the life of me can't figure out the
right syntax to get the first argument (poly) to be accepted. I've
tried passing the points as a tuple, as an array, as a Polygon()
call ... they all fail in one way or another.

Can someone point me at a live example of the more complicated aspects
of this? The documentation is really pretty lacking... sad to say,
because this has a lot of potential.

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: Django development approach

2008-11-20 Thread John.R



On Nov 20, 3:54 pm, eldonp2 <[EMAIL PROTECTED]> wrote:
> I've spent some time getting comfortable with Django. I would like to
> try writing my first real app. I'd like to know whether I should go
> ahead to write everything from scratch, or whether...
> 1. Using pluggables can be easily integrated into an existing app
> 2. Whether it will be easy to change the look and feel (with CSS)
> afterwards. I want to concentrate on functionality right now.
> 3. Models, urls, views, forms and templates should be created as
> needed manually - and whether using a CMS would make this task easier.
>
> Thanks


It depends on what you want your First Real App to do. Check out as
many 'pluggables' as possible, but since you're coding, feel free to
code yourself, and see how you compare. Also check out Pinax, if
you're implementing any of the functionality that it brings as a base,
and you can build on top of that.

The look/feel is "no biggie". Django's template system, and it's
inheritance, makes doing that sort of thing super easy.

I'm sure others will have more to say than me.

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

2008-11-20 Thread Brian Neal

On Nov 20, 3:54 pm, eldonp2 <[EMAIL PROTECTED]> wrote:
> I've spent some time getting comfortable with Django. I would like to
> try writing my first real app. I'd like to know whether I should go
> ahead to write everything from scratch, or whether...
> 1. Using pluggables can be easily integrated into an existing app

Just depends on whether these 3rd party apps fit your use-cases or
not.

> 2. Whether it will be easy to change the look and feel (with CSS)
> afterwards. I want to concentrate on functionality right now.

Well...yes, in my experience it is easy to add CSS later to change the
site. Just sprinkle in some classes and ids in your HTML templates so
you can easily style things later.

> 3. Models, urls, views, forms and templates should be created as
> needed manually - and whether using a CMS would make this task easier.

Not sure what you mean here.

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



Re: Using Email for Username

2008-11-20 Thread Michael Newman



On Nov 20, 1:30 pm, Justin <[EMAIL PROTECTED]> wrote:
> We want to use email addresses as our site's login username, not just
> as an alternative authentication method. I figured a quick way to do
> this would be just changing the auth user model's username field to an
> EmailField instead of a CharField (I know this isn't the most robust
> solution). Nonetheless, the change is reflected in the manage.py
> sqlall output, and I took the appropriate steps to update the sql
> table. However, the changes are not reflected in the admin interface.
> When I try to Add User, it still won't accept an email string and
> displays the old help_text.
>
> How to make my change to the auth user model take effect?
>
> Thanks!

No need to reinvent the wheel and create a whole auth framework just
to enable e-mail. This is an extension of Django Registration that I
wrote that allows a user to just register entering in a email address.
The username is then auto created. Teamed up with authentication
backend from this comment: http://www.djangosnippets.org/snippets/74/#c195
you have a full user system without needing usernames at all. Easy as
pie.

Let me know if you have any questions,
Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Brian Neal

On Nov 20, 4:03 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> VIEW:
>
> def add_product(request):
>     if not request.method == 'POST':
>         form1 = ProductForm()
>         return render_to_response('index.html', {'form1' : form1})
>     else:
>         form1 = ProductForm(request.POST)
>         if form1.is_valid():
>             form1.save()
>             return HttpResponseRedirect('/thanks.html')
>
> def add_product_details(request):
>     if not request.method == 'POST':
>         form2 = ProductDetailForm()
>         return render_to_response('index.html', {'form2' : form2})
>     else:
>         if form2.is_valid():
>             form2.save()
>             return HttpResponseRedirect('/thanks.html')
>
> URLS
> urlpatterns = patterns('',
>
>     (r'^product/$', views.add_product),
>     (r'^product/$', views.add_product_details),
>
> Is this possible? For some reason the 2nd form never shows up

Well you need to pass both forms to the template to get them both to
show up.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



indentation problem in file

2008-11-20 Thread waltbrad

Hate to bother with this, I'm sure it's a small thing.  I'm going
through the 1st django app tutorial in the  django documentation.  I'm
doing okay until the Unicode statements they want inserted into the
models.py file, for the representation of objects in the interpreter.

On the website they show this:

class Poll(models.Model):
# ...
def __unicode__(self):
return self.question

class Choice(models.Model):
# ...
def __unicode__(self):
return self.choice


But when I indent like that I get an error that reads:

IndentationError: Expected an indented block.

So, I take the indentations out of the def stmt.  But when I do that
the representations are the same as they were before.  So, at present
my models.py file looks like this:
=

# Create your models here.
from django.db import models
import datetime

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()


class Choice(models.Model):

poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
 return self.choice
==

Is there something wrong with this.  I am using django 1.1





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



del session variables

2008-11-20 Thread Bobby Roberts

is there a way to kill a session rather than running a del statement
on each session variable?  I know in .asp you can simply say
session.abandon.  Is there an equivalent with django?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is it possible to display multiple forms in a single template file?

2008-11-20 Thread ayayalar

VIEW:

def add_product(request):
if not request.method == 'POST':
form1 = ProductForm()
return render_to_response('index.html', {'form1' : form1})
else:
form1 = ProductForm(request.POST)
if form1.is_valid():
form1.save()
return HttpResponseRedirect('/thanks.html')


def add_product_details(request):
if not request.method == 'POST':
form2 = ProductDetailForm()
return render_to_response('index.html', {'form2' : form2})
else:
if form2.is_valid():
form2.save()
return HttpResponseRedirect('/thanks.html')





URLS
urlpatterns = patterns('',

(r'^product/$', views.add_product),
(r'^product/$', views.add_product_details),


Is this possible? For some reason the 2nd form never shows up
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 development approach

2008-11-20 Thread eldonp2

I've spent some time getting comfortable with Django. I would like to
try writing my first real app. I'd like to know whether I should go
ahead to write everything from scratch, or whether...
1. Using pluggables can be easily integrated into an existing app
2. Whether it will be easy to change the look and feel (with CSS)
afterwards. I want to concentrate on functionality right now.
3. Models, urls, views, forms and templates should be created as
needed manually - and whether using a CMS would make this task easier.

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



Re: Caching an image in Django

2008-11-20 Thread bfrederi

My apologies, those tickets are exactly what I was looking for.
Thanks!

http://code.djangoproject.com/ticket/9180
http://code.djangoproject.com/ticket/5589

On Nov 20, 2:40 pm, bfrederi <[EMAIL PROTECTED]> wrote:
> I don't think those ticket numbers are correct. Those are dealing with
> forms... not caching.
>
> On Nov 20, 2:13 pm, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
>
> > On Thu, Nov 20, 2008 at 6:00 PM, bfrederi <[EMAIL PROTECTED]> wrote:
>
> > > I am trying to cache a small thumbnail image. The code is a bit
> > > extensive, but the part this is breaking is that I am opening the
> > > image file, then this:
>
> > > cache.set('thumbnail_file', image_file.read())
>
> > > when I go to retrieve the image with:
>
> > > cache.get('thumbnail_file')
>
> > > I get this traceback:
>
> > > Traceback (most recent call last):
> > >  File "/home/django-code/aubrey_ark/tests.py", line 48, in
> > > testResourceObject
> > >    ro = ResourceObject(self.meta_id)
> > >  File "/home/django-code/aubrey_ark/resource_handler.py", line 102,
> > > in __init__
> > >    cache.get(self.meta_id+'_thumbnail')
> > >  File "/usr/lib/python2.5/site-packages/django/core/cache/backends/
> > > memcached.py", line 30, in get
> > >    return smart_unicode(val)
> > >  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
> > > line 35, in smart_unicode
> > >    return force_unicode(s, encoding, strings_only, errors)
> > >  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
> > > line 70, in force_unicode
> > >    raise DjangoUnicodeDecodeError(s, *e.args)
> > > DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xff in
> > > position 0: unexpected code byte. You passed in '\xff\xd8\xff...
> > > [...]
>
> > > Any clue on how to fix this. Should I be doing a special encoding/
> > > compression before placing the image file into the cache?
>
> > See tickets #9180 and #5589 for related reports and proposed 
> > workarounds/fixes
> > when using the memcache backend.
>
> > Regards,
>
> > --
> >  Ramiro Morales
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it possible to bind two forms to a single method?

2008-11-20 Thread Steve Holden

ayayalar wrote:
> I have the following forms:
>
> from django.forms.models import ModelForm
> from demo.home.models import Product, ProductDetail
>
> class ProductForm(ModelForm):
> class Meta:
> model = Product
>
>
> class ProductDetailForm(ModelForm):
> class Meta:
> model = ProductDetail
>
>
> I am trying to handle the submission of these forms in a single
> method.
>
> def add_product(request):
> if not request.method == 'POST':
> form1 = ProductForm();
> form2 = ProductDetailForm()
> return render_to_response('index.html', {'form1' : form1,
> 'form2' : form2})
> else:
> #Need to process the forms here.
>
>
>
> How do I know which form is submitted?
>   
Well, that really depends on the HTML you have put around the forms. One
possible way would be to have two different submit buttons with the same
name and different values, then use the value to distinguish between them.

This presumes you only want to action the form whose submit button is
clicked?

A further, and even easier, way is to give each form a different action
attribute. Then they will trigger different views!

regards
 Steve


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



Is it possible to bind two forms to a single method?

2008-11-20 Thread ayayalar

I have the following forms:

from django.forms.models import ModelForm
from demo.home.models import Product, ProductDetail

class ProductForm(ModelForm):
class Meta:
model = Product


class ProductDetailForm(ModelForm):
class Meta:
model = ProductDetail


I am trying to handle the submission of these forms in a single
method.

def add_product(request):
if not request.method == 'POST':
form1 = ProductForm();
form2 = ProductDetailForm()
return render_to_response('index.html', {'form1' : form1,
'form2' : form2})
else:
#Need to process the forms here.



How do I know which form is submitted?


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



Re: Caching an image in Django

2008-11-20 Thread bfrederi

I don't think those ticket numbers are correct. Those are dealing with
forms... not caching.

On Nov 20, 2:13 pm, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On Thu, Nov 20, 2008 at 6:00 PM, bfrederi <[EMAIL PROTECTED]> wrote:
>
> > I am trying to cache a small thumbnail image. The code is a bit
> > extensive, but the part this is breaking is that I am opening the
> > image file, then this:
>
> > cache.set('thumbnail_file', image_file.read())
>
> > when I go to retrieve the image with:
>
> > cache.get('thumbnail_file')
>
> > I get this traceback:
>
> > Traceback (most recent call last):
> >  File "/home/django-code/aubrey_ark/tests.py", line 48, in
> > testResourceObject
> >    ro = ResourceObject(self.meta_id)
> >  File "/home/django-code/aubrey_ark/resource_handler.py", line 102,
> > in __init__
> >    cache.get(self.meta_id+'_thumbnail')
> >  File "/usr/lib/python2.5/site-packages/django/core/cache/backends/
> > memcached.py", line 30, in get
> >    return smart_unicode(val)
> >  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
> > line 35, in smart_unicode
> >    return force_unicode(s, encoding, strings_only, errors)
> >  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
> > line 70, in force_unicode
> >    raise DjangoUnicodeDecodeError(s, *e.args)
> > DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xff in
> > position 0: unexpected code byte. You passed in '\xff\xd8\xff...
> > [...]
>
> > Any clue on how to fix this. Should I be doing a special encoding/
> > compression before placing the image file into the cache?
>
> See tickets #9180 and #5589 for related reports and proposed workarounds/fixes
> when using the memcache backend.
>
> Regards,
>
> --
>  Ramiro Morales
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching an image in Django

2008-11-20 Thread Ramiro Morales

On Thu, Nov 20, 2008 at 6:00 PM, bfrederi <[EMAIL PROTECTED]> wrote:
>
> I am trying to cache a small thumbnail image. The code is a bit
> extensive, but the part this is breaking is that I am opening the
> image file, then this:
>
> cache.set('thumbnail_file', image_file.read())
>
> when I go to retrieve the image with:
>
> cache.get('thumbnail_file')
>
> I get this traceback:
>
> Traceback (most recent call last):
>  File "/home/django-code/aubrey_ark/tests.py", line 48, in
> testResourceObject
>ro = ResourceObject(self.meta_id)
>  File "/home/django-code/aubrey_ark/resource_handler.py", line 102,
> in __init__
>cache.get(self.meta_id+'_thumbnail')
>  File "/usr/lib/python2.5/site-packages/django/core/cache/backends/
> memcached.py", line 30, in get
>return smart_unicode(val)
>  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
> line 35, in smart_unicode
>return force_unicode(s, encoding, strings_only, errors)
>  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
> line 70, in force_unicode
>raise DjangoUnicodeDecodeError(s, *e.args)
> DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xff in
> position 0: unexpected code byte. You passed in '\xff\xd8\xff...
> [...]
>
> Any clue on how to fix this. Should I be doing a special encoding/
> compression before placing the image file into the cache?
>

See tickets #9180 and #5589 for related reports and proposed workarounds/fixes
when using the memcache backend.

Regards,

-- 
 Ramiro Morales

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



Re: Keeping fields out of the Admin

2008-11-20 Thread James Bennett

On Thu, Nov 20, 2008 at 2:02 PM, Epinephrine <[EMAIL PROTECTED]> wrote:
> How can I keep the field from being editable in the Admin edit page
> for that class?

I don't really mean to sound rude in saying this, but your best bet is
probably to read through the documentation for the admin:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/

It contains a full reference for the various options you'd most likely
want to use in your admin declarations, and is a great source for
being able to find information immediately rather than wait around for
someone on a mailing list to answer your question. It also contains
the answer to the question you've asked.


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



Keeping fields out of the Admin

2008-11-20 Thread Epinephrine

I have a field that should never be edited by hand.  It is basically
date_letter_sent, and it should be filled in by a view function when
it sends a letter.

How can I keep the field from being editable in the Admin edit page
for that class?

Thanks in advance!


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



Caching an image in Django

2008-11-20 Thread bfrederi

I am trying to cache a small thumbnail image. The code is a bit
extensive, but the part this is breaking is that I am opening the
image file, then this:

cache.set('thumbnail_file', image_file.read())

when I go to retrieve the image with:

cache.get('thumbnail_file')

I get this traceback:

Traceback (most recent call last):
  File "/home/django-code/aubrey_ark/tests.py", line 48, in
testResourceObject
ro = ResourceObject(self.meta_id)
  File "/home/django-code/aubrey_ark/resource_handler.py", line 102,
in __init__
cache.get(self.meta_id+'_thumbnail')
  File "/usr/lib/python2.5/site-packages/django/core/cache/backends/
memcached.py", line 30, in get
return smart_unicode(val)
  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
line 35, in smart_unicode
return force_unicode(s, encoding, strings_only, errors)
  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py",
line 70, in force_unicode
raise DjangoUnicodeDecodeError(s, *e.args)
DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xff in
position 0: unexpected code byte. You passed in '\xff\xd8\xff
\xe0\x00\x10JFIF\x00\x01\x01\x01\x01,\x01,\x00\x00\xff\xfe\x00
{FWv4-47_1, Tue Jul 18, 2006,  2:37:50 PM,  8G, 7710x10590,
(1578+1912), 125%, Repro 2.2 v2, 1/100 s, R63.1, G54.9, B68.2\xff\xdb
\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r
\x0c\x0b\x0b\x0c\x19\x12\x13\x0f\x14\x1d\x1a\x1f\x1e\x1d\x1a\x1c\x1c $.
\' ",#\x1c\x1c(7),01444\x1f\'9=82<.342\xff\xc0\x00\x0b\x08\x00Z\x00=
\x01\x01\x11\x00\xff\xc4\x00\x1a
\x00\x00\x02\x03\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x03\x01\x05\x06\x04\x00\xff
\xc4\x00A\x10\x00\x01\x03\x02\x04\x01\x07\t
\x04\x08\x07\x00\x00\x00\x00\x00\x01\x02\x03\x11\x00\x04\x05\x12!1A
\x06\x13Qaq\xc2\xd1\x14\x15"#2B\x83\x91\xa13\xb2\xc1\xf0$DRSr
\x81\xe1\xf1bct\x82\x92\x93\xb1\xff\xda\x00\x08\x01\x01\x00\x00?
\x00\xbf\xc4\xb1\xccM\x9b\xfb\xa8\xbeu\x08\x0f-)JN\x83S\x02\xb8\xd1\xca
\x0can\x04\xaa\xea\xe4\x08\x9c\xc1\x7f\xd2\x8b\xcf\xb8\x8a\x94\x13\xe7+
\x82\xa3\xc0:I\xfaR\\\xc6\xf12\xe1Joo\x08N\xe7\xca\x145\xa6\'\x14\xbfX
\x91\x88_\x1d?~\xaf\x1a\x95__+\xf5\xcb\xc3\xd3\xeb\xd5\xe3I]\xe3\xceBM
\xed\xc9\xcc`E\xc2\x8e\xb1<[EMAIL PROTECTED]
[EMAIL PROTECTED]'@
\'\xe7\xd94L\xd8)\xb6\xc9Y\xcf1\xb0\xe2

Admin generic inlines don't handle multi-table inherited models

2008-11-20 Thread Mike Hurt

Hi all,

Just wondering if anyone has come across the following problem, and if
there is a way around it...

I'm using both multi-table inheritance and generic relations to
maintain a central repository of both general files, and display
images in the following, simplified, way,:

#
# models.py
#
class File(models.Model):
"""
This base class defines the generic relationship
and all properties common to all files
"""
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
title = models.CharField(max_length=100)
file = models.FileField(upload_to='files/%Y/%m/%d')


class Image(File):
"""
Override the base class file field to access
image specific properties of the ImageField
"""
file = models.ImageField(upload_to='files/%Y/%m%d')


#
# admin.py
#
class FileInline(generic.GenericStackedInline):
model = File
extra = 1

class ImageInline(generic.GenericStackedInline):
model = Image
extra = 1

The generic inlines above are then imported into the admin.py of any
app which needs them and are referenced via the ModelAdmin's inlines
as you'd expect.

Now here's the problem... saving a File object via the generic inline
works as expected, but saving an Image via it's generic inline raises
the following error:

Cannot assign None: "Image.file_ptr" does not allow null values.

django/db/models/fields/related.py in __set__
253. if instance is None:
254. raise AttributeError, "%s must be accessed via instance" %
self._field.name
255.
256. # If null=True, we can assign null here, but otherwise the
value needs
257. # to be an instance of the related class.
258. if value is None and self.field.null == False:
259. raise ValueError('Cannot assign None: "%s.%s" does not allow
null values.' %
>>> 260. (instance._meta.object_name, self.field.name))
261. elif value is not None and not isinstance(value,
self.field.rel.to):
262. raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s"
instance.' %
263. (value, instance._meta.object_name,
264. self.field.name, self.field.rel.to._meta.object_name))
265.
266. # Set the value of the related field

I'm running on SVN trunk as of changeset #9506, BTW.

It seems to me that the generic inline is not correctly handling the
_ptr foreign-key connecting the Image instance to it's parent File
instance.

If anyone can shed light on this, even if it's just a link to the
appropriate ticket number that would be greatly appreciated. If you
need additional info please let me know.

With best regards

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



Re: Filtered choices list for a m2m field from an m2m field within another model.

2008-11-20 Thread Silvano

Thanks for the answer Malcolm.

Maybe I was unclear where I put the line "related_contacts =
Contact.objects.filter(projects_involved__title__startswith=title)".
Sorry for that.
It was in the "Project" model, not in a view. When I validate the code
as follows I get the described error no matter if I use starts_with or
startswith.

class Contact(models.Model):
projects_involved = models.ManyToManyField('Project', blank=True)

class Project(models.Model):
title = models.CharField(max_length=100)
related_contacts = Contact.objects.filter
(projects_involved__title__startswith=title)
client = models.ManyToManyField(Contact,
related_name='client',blank=True, limit_choices_to=related_contacts)
collaborators = models.ManyToManyField
(Contact,related_name='collaborators', blank=True,
limit_choices_to=related_contacts)

Now I already see a second problem myself. In the docs it says
"limit_choices_to has no effect when used on a ManyToManyField with an
intermediate table". So my choices list would have no effect if it
worked.

Maybe you could give me some general advice on how to approach what I
had mind.

Thanks - Silvan



On Nov 20, 2:10 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2008-11-19 at 13:35 -0800, Silvano wrote:
> > Dear all
>
> > I'm completely stuck with the following problem.
>
> > What I'm trying to accomplish is: I have an app with the model
> > "Project" and another model "Contacts". In "Contacts" I have a m2m
> > field called "projects_involved" relating to the "Project" model which
> > allows to select projects the contact is involved with.
> > In my "Project" model I have some m2m fields like "client" and
> > "collaborators" where I want to store a relation to some of the
> > contacts. In the admin interface the user should be provided with
> > contacts related to the actual "Project" only.
>
> > class Contact(models.Model):
> > projects_involved = models.ManyToManyField('Project', blank=True)
>
> > class Project(models.Model):
> > title = models.CharField(max_length=100)
> > client = models.ManyToManyField(Contact, related_name='client',
> > blank=True)
> > collaborators = models.ManyToManyField(Contact,
> > related_name='collaborators', blank=True)
>
> > What I tried so far is to use a filter for constructing a choices list
> > within the “Project” model.
>
> > related_contacts = Contact.objects.filter
> > (projects_involved__title__starts_with=title)
>
> But that isn't really what you have in your view. The lookup type in
> Django is "startswith" (no underscore). If you wrote the above, it would
> complain that "title" is not a joinable field.
>
> > This gives me the following error in
> > "/django/db/models/fields/__init__.py" line 102, in __cmp__
> > return cmp(self.creation_counter, other.creation_counter)
> > AttributeError: 'str' object has no attribute 'creation_counter'
>
> That error message is normally related to model creation, not filtering.
> So what happens when you run "manage.py validate"? I suspect it will
> report that same error. In which case, you've left something out of your
> example code, because when I cut-and-paste exactly what you've written,
> I don't see that error.
>
> So run "manage.py validate" and make sure the same error is reported.
> Then look at your code carefully to work out what is different between
> what you have and what you've pasted here (start by pasting exactly what
> you have here into a new project and verify it doesn't raise an error;
> then slowly build up to what you have in the case that is causing the
> error).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NetBeans IDE for Python

2008-11-20 Thread ohmi

Same results here although other sorts of autocomplete to seem to be
somewhat functional.
No django-specific documentation yet, like how to set up the debugging
environment.
It looks like this stuff is being done according to their roadmap.

Could be a great platform, esp. considering the price.

O

On Nov 20, 5:01 am, lig <[EMAIL PROTECTED]> wrote:
> On 19 нояб, 21:22, Delta20 <[EMAIL PROTECTED]> wrote:
>
> > NetBeans for Python has been released and based on the NB Python
> > roadmap, it looks interesting for those of us working with Django. I
> > haven't had much of a chance to play with it yet since it just came
> > out today, but here's the info for anyone interested:
>
> > NetBeans IDE for Python:http://download.netbeans.org/netbeans/6.5/python/ea/
> > NB Python Roadmap:http://wiki.netbeans.org/Python
>
> from django.db import models
>
> class Page(models.Model):
>     name    = models. # hitting Ctrl+Space here don't show field type
> suggestions or anything from imported models package

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Custom middleware only works when debugging is on

2008-11-20 Thread jwpeddle

Oh my god the stupidity.

The error was in my 500.html template. NOTHING to do with my
middleware.

Sigh.

On Nov 20, 1:54 pm, jwpeddle <[EMAIL PROTECTED]> wrote:
> I've got a custom middleware class (nearly identical in function to
> the flat page fallback middleware). When I have DEBUG = True, it works
> as expected. When I have DEBUG = False, I get errors stemming from
> variables set by the middleware not existing for the templates. After
> investigating, the only progress I've made is confirming that the
> class is called somehow (a print statement just inside the class will
> print) but the process_response never is.
>
> Again, this works when debugging is on. Perfectly. Not at all when
> it's off. Not on apache and not on the dev server. I apologize for the
> lack of errors, but I haven't narrowed it down enough yet to get any
> relevant errors.
>
> class PageFallbackMiddleware():
>     def process_response(self, request, response):
>         if response.status_code != 404:
>             return response # No need to check for a flatpage for
> non-404 responses.
>         try:
>             return page(request, request.path)
>         # Return the original response if any errors happened. Because
> this
>         # is a middleware, we can't assume the errors will be caught
> elsewhere.
>         except Http404:
>             return response
>         except:
>             if settings.DEBUG:
>                 raise
>             return response
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django install

2008-11-20 Thread waltbrad



On Nov 20, 1:22 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
>
> On Windows systems, the same result can be achieved by copying the file
> django-trunk/django/bin/django-admin.py to somewhere on your system
> path, for example C:\Python24\Scripts.
>
>

Hello Steve. Yes, I did that. Actually I just ran that script from the
trunk directory. It installed.

So, I'm good to go. The tutorial seems to indicate that I don't have
to install Apache until I embark on production, so I've left that out.

Solved my environment variable problem; I realized included the
program name in the variable path. Once I removed that I could run
django-admin.py from any directory.

Thanks.

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



Re: Django install

2008-11-20 Thread Steve Holden

waltbrad wrote:
>
> On Nov 20, 1:20 pm, Sahil R Cooner <[EMAIL PROTECTED]> wrote:
>   
>> Have you tried checking out the django documentation, it's gotten a lot
>> better than a year ago.
>>
>> You can find what you're looking for there 
>> at:http://docs.djangoproject.com/en/dev/topics/install/?from=olddocs
>>
>>
>> 
> Hello Sahil. Well, yes. I got lazy there. I was just real resistant to
> installing SVN because I was afraid it was going to gunk up my
> system.  But, after I last posted, I swallowed hard and installed Silk
> Subversion. Then I used that to do download the django-trunk and I
> installed django using the setup.py script.
>
> So, I think I have django installed fine now, (haven't continued with
> the tutorial yet.)
>
> As I went through the docs I see they want you to install Apache. I
> did that last year, so I guess I'll have to do that again. This is
> where I get really confused because I don't understand why I need
> Apache. Should I install Apache before I continue with the tutorial?
>   
You don't need Apache to run the test server, only for production (and
there are options even then).

regards
 Steve


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

2008-11-20 Thread Carl Meyer

On Nov 20, 10:21 am, Huy Dinh <[EMAIL PROTECTED]> wrote:
> Each user is allowed to make new posts and edit their own posts. They
> are not allowed to create a post for a region that's not their own.

The admin has hooks to allow you to do this sort of thing.  This
snippet[1] demonstrates the basic technique; you should be able to
modify it to your needs.

Carl

[1] http://www.djangosnippets.org/snippets/1054/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Importing standalone apps in a project

2008-11-20 Thread Carl Meyer

On Nov 20, 10:22 am, "Saurabh Agrawal" <[EMAIL PROTECTED]> wrote:
> Using the Python IDLE, I am able to issue command "import coltrane" without
> problem. (coltrane is the name of standalone app)
>
> However, I am not able to do so using Django configured shell "python
> manage.py shell".

It would seem that Django is using a different Python path than IDLE
for some reason (two different versions of Python installed?).  Try
the following once under IDLE and once under django shell and examine
for differences:

>>> import sys; sys.path

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

2008-11-20 Thread Carl Meyer

Please stop the excessive top-posting; it makes reading the list
digest painful.  Quote only what you need to, and locate the quotes
appropriately in your response.  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django install

2008-11-20 Thread Steve Holden

waltbrad wrote:

> Hi folks.  I'm trying to install on my pc Django without success. I
> was using instantdjango, but I'm told that there is some danger
> because of it's internal webserver?
> Anyway, I downloaded django and put the folder into C:\Python25\Lib
> \site-packages. I also put the path to django-admin.py in my
> environment variables.  When I start up the interpreter I can import
> django fine.  But when I try to run django-admin.py from the command
> line it's not recognized.
> I actually installed django and got it working on another computer
> about a year ago. But, had no time to really get into it. So, now I've
> got time and this computer but can't remember what I did. I wish I
> could just use instantdjango but it seems it would be better to figure
> out a proper installation of django.
> I'm just using SQLite.  I don't want to make this anymore complicated
> than I have to.
It looks like you missed out step 4 from the install instructions at

  http://docs.djangoproject.com/en/dev/topics/install/

"""

On Unix-like systems, create a symbolic link to the file
django-trunk/django/bin/django-admin.py in a directory on your system
path, such as /usr/local/bin. For example:

ln -s `pwd`/django-trunk/django/bin/django-admin.py /usr/local/bin

This simply lets you type django-admin.py from within any directory,
rather than having to qualify the command with the full path to the file.

On Windows systems, the same result can be achieved by copying the file
django-trunk/django/bin/django-admin.py to somewhere on your system
path, for example C:\Python24\Scripts.

"""



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

2008-11-20 Thread Justin

We want to use email addresses as our site's login username, not just
as an alternative authentication method. I figured a quick way to do
this would be just changing the auth user model's username field to an
EmailField instead of a CharField (I know this isn't the most robust
solution). Nonetheless, the change is reflected in the manage.py
sqlall output, and I took the appropriate steps to update the sql
table. However, the changes are not reflected in the admin interface.
When I try to Add User, it still won't accept an email string and
displays the old help_text.

How to make my change to the auth user model take effect?

Thanks!

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



Re: Django install

2008-11-20 Thread waltbrad



On Nov 20, 1:20 pm, Sahil R Cooner <[EMAIL PROTECTED]> wrote:
> Have you tried checking out the django documentation, it's gotten a lot
> better than a year ago.
>
> You can find what you're looking for there 
> at:http://docs.djangoproject.com/en/dev/topics/install/?from=olddocs
>
>
Hello Sahil. Well, yes. I got lazy there. I was just real resistant to
installing SVN because I was afraid it was going to gunk up my
system.  But, after I last posted, I swallowed hard and installed Silk
Subversion. Then I used that to do download the django-trunk and I
installed django using the setup.py script.

So, I think I have django installed fine now, (haven't continued with
the tutorial yet.)

As I went through the docs I see they want you to install Apache. I
did that last year, so I guess I'll have to do that again. This is
where I get really confused because I don't understand why I need
Apache. Should I install Apache before I continue with the tutorial?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django install

2008-11-20 Thread Sahil R Cooner


Have you tried checking out the django documentation, it's gotten a lot
better than a year ago.

You can find what you're looking for there at:
http://docs.djangoproject.com/en/dev/topics/install/?from=olddocs

On Thu, Nov 20, 2008 at 10:01:20AM -0800, waltbrad wrote:
> 
> Hi folks.  I'm trying to install on my pc Django without success. I
> was using instantdjango, but I'm told that there is some danger
> because of it's internal webserver?
> 
> Anyway, I downloaded django and put the folder into C:\Python25\Lib
> \site-packages. I also put the path to django-admin.py in my
> environment variables.  When I start up the interpreter I can import
> django fine.  But when I try to run django-admin.py from the command
> line it's not recognized.
> 
> I actually installed django and got it working on another computer
> about a year ago. But, had no time to really get into it. So, now I've
> got time and this computer but can't remember what I did. I wish I
> could just use instantdjango but it seems it would be better to figure
> out a proper installation of django.
> 
> I'm just using SQLite.  I don't want to make this anymore complicated
> than I have to.
> > 

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

2008-11-20 Thread waltbrad

Hi folks.  I'm trying to install on my pc Django without success. I
was using instantdjango, but I'm told that there is some danger
because of it's internal webserver?

Anyway, I downloaded django and put the folder into C:\Python25\Lib
\site-packages. I also put the path to django-admin.py in my
environment variables.  When I start up the interpreter I can import
django fine.  But when I try to run django-admin.py from the command
line it's not recognized.

I actually installed django and got it working on another computer
about a year ago. But, had no time to really get into it. So, now I've
got time and this computer but can't remember what I did. I wish I
could just use instantdjango but it seems it would be better to figure
out a proper installation of django.

I'm just using SQLite.  I don't want to make this anymore complicated
than I have to.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Custom Select widget choices - how to reuse choices?

2008-11-20 Thread Donn

Hello,
In my model, I define the choices for a charfield. I make a ModelForm of that 
model but I want my own widget for that field. How can I pass-through the 
choices I defined in my model?

Some code:

class Movie( Relic ):
 disk_type = models.CharField( 'Type', max_length=8, choices=((u'1','one'), 
(u'2',u'two')), default=u'1' )

class MovieForm( BasicRelicForm ):
 disk_type = forms.CharField( widget = choicewidget( choices=?? )) 
 class Meta:
   model = Movie

What would I put in the choices=?? line?

I have found this voodoo: 
forminstance._meta.model.disk_type.choices
But it needs an instance to work.

I could use a global var and repeat it twice, but I'd like to know if there's 
a way to simply 'fetch' it from the model.

Any clues?
\d

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



Re: Custom middleware only works when debugging is on

2008-11-20 Thread jwpeddle

Eliminated any possible issues in my urls conf. Even removing
everything from it doesn't change the situation.

On Nov 20, 1:54 pm, jwpeddle <[EMAIL PROTECTED]> wrote:
> I've got a custom middleware class (nearly identical in function to
> the flat page fallback middleware). When I have DEBUG = True, it works
> as expected. When I have DEBUG = False, I get errors stemming from
> variables set by the middleware not existing for the templates. After
> investigating, the only progress I've made is confirming that the
> class is called somehow (a print statement just inside the class will
> print) but the process_response never is.
>
> Again, this works when debugging is on. Perfectly. Not at all when
> it's off. Not on apache and not on the dev server. I apologize for the
> lack of errors, but I haven't narrowed it down enough yet to get any
> relevant errors.
>
> class PageFallbackMiddleware():
>     def process_response(self, request, response):
>         if response.status_code != 404:
>             return response # No need to check for a flatpage for
> non-404 responses.
>         try:
>             return page(request, request.path)
>         # Return the original response if any errors happened. Because
> this
>         # is a middleware, we can't assume the errors will be caught
> elsewhere.
>         except Http404:
>             return response
>         except:
>             if settings.DEBUG:
>                 raise
>             return response
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Custom middleware only works when debugging is on

2008-11-20 Thread jwpeddle

Ok, I've tried to dumb things down, and it turns out the built-in
flatpage fallback middleware ALSO doesn't have it's process_response
called. I can only assume a response is sent before the middleware is
reached, but I've got a pretty standard setup:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'applecore.main.middleware.PageFallbackMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
)

On Nov 20, 1:54 pm, jwpeddle <[EMAIL PROTECTED]> wrote:
> I've got a custom middleware class (nearly identical in function to
> the flat page fallback middleware). When I have DEBUG = True, it works
> as expected. When I have DEBUG = False, I get errors stemming from
> variables set by the middleware not existing for the templates. After
> investigating, the only progress I've made is confirming that the
> class is called somehow (a print statement just inside the class will
> print) but the process_response never is.
>
> Again, this works when debugging is on. Perfectly. Not at all when
> it's off. Not on apache and not on the dev server. I apologize for the
> lack of errors, but I haven't narrowed it down enough yet to get any
> relevant errors.
>
> class PageFallbackMiddleware():
>     def process_response(self, request, response):
>         if response.status_code != 404:
>             return response # No need to check for a flatpage for
> non-404 responses.
>         try:
>             return page(request, request.path)
>         # Return the original response if any errors happened. Because
> this
>         # is a middleware, we can't assume the errors will be caught
> elsewhere.
>         except Http404:
>             return response
>         except:
>             if settings.DEBUG:
>                 raise
>             return response
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Help for crontab

2008-11-20 Thread Ben Eliott

recommend you check out django-extensions jobs.
http://code.google.com/p/django-command-extensions/


On 20 Nov 2008, at 12:53, laspal wrote:

>
> hi,
> I am writing cron job for my application but run into problem
>
> from django.core.management import setup_environ
> import settings
> setup_environ(settings)
>
> from test.crm.models import CronEmail
>
> Basically the problem is I am not able to import any model.
>
> I tried this too:
> pathname = os.path.dirname(sys.argv[0])
> sys.path.append(os.path.abspath(pathname))
> sys.path.append(os.path.normpath(os.path.join(os.path.abspath
> (pathname), '../')))
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> but still can import any model.
>
> 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
-~--~~~~--~~--~--~---



Custom middleware only works when debugging is on

2008-11-20 Thread jwpeddle

I've got a custom middleware class (nearly identical in function to
the flat page fallback middleware). When I have DEBUG = True, it works
as expected. When I have DEBUG = False, I get errors stemming from
variables set by the middleware not existing for the templates. After
investigating, the only progress I've made is confirming that the
class is called somehow (a print statement just inside the class will
print) but the process_response never is.

Again, this works when debugging is on. Perfectly. Not at all when
it's off. Not on apache and not on the dev server. I apologize for the
lack of errors, but I haven't narrowed it down enough yet to get any
relevant errors.

class PageFallbackMiddleware():
def process_response(self, request, response):
if response.status_code != 404:
return response # No need to check for a flatpage for
non-404 responses.
try:
return page(request, request.path)
# Return the original response if any errors happened. Because
this
# is a middleware, we can't assume the errors will be caught
elsewhere.
except Http404:
return response
except:
if settings.DEBUG:
raise
return response
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Media and putting javascript last

2008-11-20 Thread Wes Winham

> Any reason this wouldn't work for you as well?

The problem with that is that when I do {{ form.media.js }} (or
whatever media output stuff I need to do) at the bottom, I'm going to
have included jquery twice since jquery is a requirement in the Media
class of any widgets/forms that need it. The trick is trying to not
have jquery in there twice.

-wes

On Nov 18, 5:59 pm, Justin Lilly <[EMAIL PROTECTED]> wrote:
> The way I structure this is I put my jquery include at at the top with  
> the css. At the bottom of my script, I add an {% block extra_script %}
> {% endblock %} block just before the  tag which is where excess  
> javascript goes. Any reason this wouldn't work for you as well?
>
>   -justin
>
> On Nov 18, 2008, at 5:19 PM,WesWinhamwrote:
>
>
>
> > == Quick summary ==
>
> > I want to find a consistent way of putting media.css at the top and
> > media.js at the bottom while still allowing jquery stuff in the
> > document body.
>
> > == Reason I want the JS at the the bottom ==
>
> > I'm a big fan of the yslow (http://developer.yahoo.com/yslow/) addon
> > and Yahoo's recommendations for improving user experience in regard to
> > page load time and responsiveness. One of the recommendations I've
> > personally found most useful is that CSS should go at the top and JS
> > should go at the bottom to improve rendering speed and allow your page
> > to be "loaded" as quickly as possible (even if there's still some JS
> > stuff going on, your users likely won't notice it).
>
> > == Reason I need the jquery include at the top ==
>
> > For several jquery widgets I use (a wymeditor widget, autocomplete
> > widget, jquery calendar widget), I've written the django widget such
> > that it does any initialization and setting up using $
> > (document).onLoad
> > () so that I don't have to worry about adding any javascript for
> > specific widgets in the template. It's all handled through python so
> > that the designer side doesn't have to worry about it. Because of the
> > onLoad() usage, I need jquery at the top (so that all of the stuff in
> > the body can use it).
>
> > == Problems with re-usable widgets and class Media ==
>
> > All of my widgets obviously have the Media.js element set with jquery
> > and their required libraries (my favorite Django 1.0ish feature, btw)
> > which works wonderfully except for the fact that if I was to do
> > {{ media.js }} after I've already included jquery at the top of the
> > page, I get lots of problems for having jquery included twice. I'd
> > like to go the Pinax route and include jquery in my base.html so that
> > it's on every page (since I use it on almost every page), but then I
> > need a method of extracting out any jquery includes for any of my
> > media elements. I could do that in every view, but it seems like there
> > must be easier way to do it from one location.
>
> > == Ideas for removing jquery includes from all media objects ==
> > 1. I first looked in to a context processor, but then I realized that
> > you could only add/overwrite context and not alter it.
> > 2. Now I'm considering some kind of form subclass that will strip out
> > the jquery stuff
>
> > Does anyone have any suggestions on a better way to keep my jquery
> > include and my css at the top and all the rest of my javascript at the
> > bottom while avoiding including jquery twice?
>
> > thanks
> > -Wes
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Help with Abstract class and admin.py

2008-11-20 Thread Karen Tracey
On Thu, Nov 20, 2008 at 10:15 AM, JimR <[EMAIL PROTECTED]> wrote:

>
> Karen,
>
> Thanks for your help.  Here's what I've done:
>
> I've commented out the list_display for GameAdmin and defined a
> __unicode__ for game as:
>
>def __unicode__(self):
>return '%s vs. %s' %  (self.team.name, self.opponent)
>
> That returns values in the admin display as "Team 1 vs. Team 2", etc.,
> as we would have hoped.
>
> Uncommenting the list_display as so:
> class GameAdmin(admin.ModelAdmin):
>list_display = ('team', 'opponent',)
> search_fields = ('team__name','opponent',)
>
> results in the strange behavior (non-zero count but showing no rows)
>
> changing list display to team__name results in the following error:
> 'team__name' is not a callable or an attribute of 'GameAdmin' or found
> in the model 'Game'.
>
> So now that I copied that and pasted that error message here, I have a
> thought: make a callable for Game as:
>def _team_name(self):
> return (self.team.name)
>team_name = property(_team_name)
>
> class GameAdmin(admin.ModelAdmin):
>list_display = ('team_name', 'opponent',)
>search_fields = ('team__name','opponent',)
>
> Everything now displays correctly.  Reading the documentation on
> list_display and Abstract classes, I assumed that I could reference
> Team elements through the AbstractEvent model.  Apparently, that is
> not the case. The callable seems to have solved my problem.
>

I am glad you found something that works, but this should not have been
necessary.  As I said earlier, cut-and-pasting the models & admin def you
posted into a new project (commenting out all the foreign keys in Team
pointing to models not provided) on one of my machines gives an admin that
properly displays the team and opponent in the change list.  So, there's
something not quite right in your other code or possibly the data in your
DB, though I have no clue what since I've never heard this symptom reported
before.

It will probably be best for you to figure out what it is sooner rather than
later -- I'd be surprised if whatever it is doesn't cause other weird
problems down the road.  I'd start with what you posted, in a new project
with a test sqlite db that can be reset at will, adding things from your
real project bit by bit until you see what it is, exactly, that is causing
this.  It is really not normal or expected behavior.

Karen

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

2008-11-20 Thread John M

Ian,

Thanks for the reply, yes I've verified via the db.connections option
that something is definitely wrong.

John

On Nov 19, 6:33 pm, "Ian Lewis" <[EMAIL PROTECTED]> wrote:
> John,
>
> Try checking the log output of the database server to see what is
> different about the SQL. Perhaps some kind of caching is going on
> where the manager is caching the results of it's queries?
>
> On Thu, Nov 20, 2008 at 11:21 AM, John M <[EMAIL PROTECTED]> wrote:
>
> > I have a model with a custom model manager used for related set
> > filtering, but it's not working as expected.
>
> > See my models and test athttp://dpaste.com/92327/
>
> > Can someone explain why my manager isn't doing what I think it should?
>
> > Thanks
>
> > John
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Regional administrator

2008-11-20 Thread Huy Dinh

Hi,

I'm creating a website to allow 1 admin from each region to post news
articles. Supposing the system has 3 users: 'eu', 'us' and 'asia' -
one for each region.

Each user is allowed to make new posts and edit their own posts. They
are not allowed to create a post for a region that's not their own.

Anonymous users get the option to display post by region or all on one
page.

Is it possible to do this without rewriting the admin? How would I go
about it?


Thanks

Huy Dinh

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

2008-11-20 Thread goblue0311

yeah, it was definitley the __init__.py issue, which I will strive to
never forget again.

Thanks!

On Nov 19, 3:52 pm, Ben Eliott <[EMAIL PROTECTED]> wrote:
> what happens when you go into the python interpreter and write
> import basic
>
> On 19 Nov 2008, at 16:58, goblue0311 wrote:
>
>
>
> > I'm implementing the popular basic.blog application, which requires
> > the inclusion of the basic.inlines project. However, I cannot seem to
> > get my application to locate the basic.inlines project. I have asked
> > this question in the basic.apps group, but I think it's generic enough
> > to be posted here as well.
>
> > I have installed the module in my site-packages directory, which is on
> > my PYTHONPATH. The basic.inlines module is located in a folder called
> > 'basic' as per the installation instructions, and basic.inlines is
> > included in INSTALLED_APPS.
>
> > However, while trying to run syncdb, I get an error stating "no module
> > named basic". The question is, how is Django trying to locate this
> > package? I was assuming it used PYTHONPATH in conjunction with some
> > generic paths, but perhaps I'm missing a step here. Any hints or
> > suggestions on how to resolve this?
>
> > 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
-~--~~~~--~~--~--~---



[Novice]Importing standalone apps in a project

2008-11-20 Thread Saurabh Agrawal
Hi,

I am following Practial Django Projects book. In Chapter 4, Django Powered
Weblog, James talks about standalone apps.

The basic premise seems to be to include the app in the python path. I have
done that.

Using the Python IDLE, I am able to issue command "import coltrane" without
problem. (coltrane is the name of standalone app)

However, I am not able to do so using Django configured shell "python
manage.py shell".

Also after adding the app in INSTALLED_APPS in settings.py of the project, I
am unable to use it.

What am I doing wrong? Does Django by itself needs its path set?

I hope this is not a very stupid question.

Thanks for reading.

Regards,
Saurabh.

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



Regional administrator

2008-11-20 Thread Huy Dinh

Hi,

I'm creating a website to allow 1 admin from each region to post news
articles. Supposing the system has 3 users: 'eu', 'us' and 'asia' -
one for each region.

Each user is allowed to make new posts and edit their own posts. They
are not allowed to create a post for a region that's not their own.

Anonymous users get the option to display post by region or all on one
page.

Is it possible to do this without rewriting the admin? How would I go
about it?


Thanks

Huy Dinh

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

2008-11-20 Thread Karen Tracey
On Thu, Nov 20, 2008 at 9:15 AM, Serdar T. <[EMAIL PROTECTED]> wrote:

>
> ok. so that fix workedkind of.
>
> I now get the properly formatted admin login page when I visit
> http://mysite.org/admin/
>
> But when I log in,  the following 500 Internal Server Error appears:
> "I'm sorry, that page is currently unavailable due to a server
> misconfiguration."
>
> That is actually a custom error page I placed in my django project's
> template directory. When I clear the cache, cookies and authenticated
> sessions, I can hit refresh on the admin URL and once again call up
> the admin login page (complete with the stylesheets etc.). But then I
> get an error stating that cookies appear to not be enabled. And when I
> click login, I'm right back where I started: 500 error.
>
> Any ideas on how to proceed?
>

Since you don't appear to be in production mode, set DEBUG=True in your
settings file so that you get a debug page instead of the bare 500.html
rendering.  For production, you'll want to set up ADMINS, EMAIL_HOST,
EMAIL_HOST_USER, etc. in settings.py so that tracebacks from uncaught
exceptions (what's likely causing your  500) get mailed to you.  You don't
want to expose that information to end users, but you do need it in order to
track down what's going on without having to make wild guesses in the
presence of no information.

Karen

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

2008-11-20 Thread [EMAIL PROTECTED]

On 20 nov, 14:31, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On 20 nov, 06:54, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Wed, Nov 19, 2008 at 10:23 PM, [EMAIL PROTECTED]
>
> > <[EMAIL PROTECTED]> wrote:
>
> > > On 20 nov, 06:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> > >> On Wed, Nov 19, 2008 at 9:53 PM, [EMAIL PROTECTED]
>
> > >> <[EMAIL PROTECTED]> wrote:
>
> > >> > I use a fake queryset because it's the only way that I found to
> > >> > populate the formset (using a real queryset would lead to the same
> > >> > problem anyway), hence I wonder if there is a cleaner way to do what I
> > >> > want without reinventing modelforms, or using separate form classes
> > >> > for saving and creating my dynamic formsets.
>
> > >> I think from what I gather you are looking to create an "add"-only
> > >> model formset? If so take a look 
> > >> athttp://code.djangoproject.com/ticket/9538. I have written some
> > >> information on that ticket that may be of use to you.
>
> > > Yes I tried the approach you're talking about in the ticket:
>
> > > FormSet = modelformset_factory(SomeModel, extra=3)
>
> > > This creates 3 blank forms with INITIAL_FORMS=0, which is fine. But
> > > then how can I populate this formset with some initial data instead of
> > > the model's default values ?
>
> > Can you file a ticket about this? The fundamental issue here is that
> > formsets use initial data to populate the forms, but model formsets
> > make no distinction between initial data being passed in and initial
> > data it makes via the queryset. It sounds worth fixing.
>
> I think I misunderstood your first post, sorry. I tried to use
> formset_factory with my ModelForm based form :
>
> FormSet = formset_factory(SomeModelForm, extra=0)
> forms = FormSet(initial=[{"field": 1}, {"field": 2}, {"field": 3}])
>
> It works (I thought you _had_ to use modelformset_factory to create
> ModelForm formsets). But then again, I get INITIAL_FORMS=3 in the
> output. If I set extra to 3, I still get INITIAL_FORMS=3, and 3
> additional blank forms, there seems to be no way to populate the extra
> forms with initial data.
>
> So I think a new keyword argument is needed for formset_factory to
> solve this particular issue, perhaps extra_initial ?

Looking closer at the details, the 'id' field is missing when using
formset_factory, which prevents django from saving the formset (I
still use a modelformset_factory based formset on the form's target
view to save the models). Using modelformset_factory is what gives the
closest result to what I want, but something like extra_initial would
make the whole thing way less hackish.

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



Re: Help with Abstract class and admin.py

2008-11-20 Thread JimR

Karen,

Thanks for your help.  Here's what I've done:

I've commented out the list_display for GameAdmin and defined a
__unicode__ for game as:

def __unicode__(self):
return '%s vs. %s' %  (self.team.name, self.opponent)

That returns values in the admin display as "Team 1 vs. Team 2", etc.,
as we would have hoped.

Uncommenting the list_display as so:
class GameAdmin(admin.ModelAdmin):
list_display = ('team', 'opponent',)
search_fields = ('team__name','opponent',)

results in the strange behavior (non-zero count but showing no rows)

changing list display to team__name results in the following error:
'team__name' is not a callable or an attribute of 'GameAdmin' or found
in the model 'Game'.

So now that I copied that and pasted that error message here, I have a
thought: make a callable for Game as:
def _team_name(self):
 return (self.team.name)
team_name = property(_team_name)

class GameAdmin(admin.ModelAdmin):
list_display = ('team_name', 'opponent',)
search_fields = ('team__name','opponent',)

Everything now displays correctly.  Reading the documentation on
list_display and Abstract classes, I assumed that I could reference
Team elements through the AbstractEvent model.  Apparently, that is
not the case. The callable seems to have solved my problem.

Thanks for your help!
Jim



On Nov 19, 10:01 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 9:30 PM, JimR <[EMAIL PROTECTED]> wrote:
>
> > Karen,
>
> > Thanks for the quick response, and sorry, I do have quotes around
> > them, I just mistyped when I added them back in for the purposes of
> > this post.
>
> > Here's the abbreviated Team model, and the corrected Admin Manager.
> > We do not have a __unicode__ method defined for the Team model.
>
> > I've reposted everything for easier reading.
>
> > class Team(models.Model):
> >        name = models.CharField(max_length=50)
> >        org = models.ForeignKey(Organization, related_name='teams')
> >        level = models.CharField(choices=COMPETITIVE_LEVEL, max_length=20)
> >        activity = models.ForeignKey(ActivityDetail)
> >        headcoach = models.ForeignKey(Coach, related_name='teams',
> > blank=True, null=True)
> >        coaches = models.ManyToManyField(Coach, blank=True, null=True)
> >        season = models.ForeignKey(Season, related_name='teams')
> >        is_archive = models.BooleanField(default=False)
> >        division = models.ForeignKey(Division, related_name='teams)
> >       ...
>
> > class AbstractEvent(models.Model):
> >        team = models.ForeignKey(Team)
> >        description = models.TextField(null=True, blank=True)
> >        description_rendered = models.TextField(null=True, blank=True)
> >        when = models.DateTimeField()
> >        where = models.ForeignKey(Address)
> >        created_at = models.DateTimeField(default=datetime.today)
> >        created_by = models.ForeignKey(User)
> >       ...
> >        class Meta:
> >                abstract = True
>
> > class Game(AbstractEvent):
> >        opponent = models.CharField(max_length=128)
> >        minutes_early = models.PositiveIntegerField(null=True,
> > blank=True)
> >        counts_towards_record = models.BooleanField(default=True)
> >        points_for = models.IntegerField(null=True, blank=True)
> >        points_against = models.IntegerField(null=True, blank=True)
> >        ...
>
> > The AdminManager for the Game model is as follows:
>
> > class GameAdmin(admin.ModelAdmin):
> >        list_display = ('team', 'opponent',)
> >        search_fields = ('team', 'opponent',)
> >       ...
>
> Cut and pasting your models & admin def, commenting out all the ForeignKeys
> for models not included, and putting them in a project yields an admin
> change list for Game that shows both the Team (unhelpfully identified as
> "Team object" in the absence of a __unicode__ method in Team) and opponent.
> So, there's something else involved here. I'd advise starting with what
> you've posted here -- since that does display a correct admin, and adding
> things bit by bit to match the full setup you actually have that is not
> working, to see what is leading to the problem.  I've never seen anything
> like what you describe (change list giving a non-zero count but showing no
> rows) so I really have no idea what is causing it for you.
>
> You will need to change the 'team' in search_fields to specify the field of
> Team that you want to search on (such as' team__name').  As you have it an
> attempt to search will likely produce an exception.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Bug? Related manager not working for custom manager?

2008-11-20 Thread John M

Malcom,

Thank you so much for taking the time to look over this, and you're
right, looking back, I should have trimmed down the problem for all to
see.

I've come up with a work-around for now, but will watch the ticket to
see when it's fixed.

I suspect it's something to do with the fact it's a related manager,
cause working with the records as Tasks directly, doesn't seem to have
the problem.

Thanks again

John

On Nov 19, 11:52 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2008-11-19 at 18:21 -0800, John M wrote:
> > I have a model with a custom model manager used for related set
> > filtering, but it's not working as expected.
>
> > See my models and test athttp://dpaste.com/92327/
>
> > Can someone explain why my manager isn't doing what I think it should?
>
> This would have been a good situation to really trim down your example
> to, say, one extra field plus the ForeignKey in each model. It took a
> fair amount of work to untangle your test lines that didn't have any
> explanation of what you expected to see and work out what the problem
> was that you were actually seeing. Remember that you're always going to
> be more familiar with the problem than the people reading it anew.
>
> After trimming down the example, we end up with ticket #9643. It's a
> clearbug. My guess is that it will be easy to fix when I get a few
> minutes to look at it.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with file upload and model forms

2008-11-20 Thread Alex Koshelev
Do you use `enctype` attribute[1] of form tag?

[1]:
http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form


On Thu, Nov 20, 2008 at 16:59, Marc Barranco <[EMAIL PROTECTED]> wrote:

>
> Hi!
> I'm trying to upload a file like the example in documentation in
> Django (http://docs.djangoproject.com/en/dev/topics/http/file-
> uploads/ )
> with the "Forms from Models".
> But I can't upload the file because the form always return the error
> "this field is required" although selecting a file before submitting
> the form.
> The fact is that I can do it with the django admin site, but with the
> the my own form I don't find where's the problem.
>
> Here is the code:
>
> ---models.py-
> from django import forms
> from django.forms import ModelForm
> from django.db import models
>
> class UploadFile(models.Model):
>title   = models.CharField(max_length=50)
>file= models.FileField(upload_to="pdf/")
>
> class UploadFileForm(forms.Form):
>title = forms.CharField(max_length=50)
>file  = forms.FileField()
>
>
> views.py---
> from django.http import HttpResponseRedirect
> from django.shortcuts import render_to_response
> from llunes.files.models import *
>
> def upload(request):
>if request.method == 'POST':
>form = UploadFileForm(request.POST, request.FILES)
>if form.is_valid():
>handle_uploaded_file(request.FILES['file']) # <--In
> fact it never
> entries here
>
>#'cause it seems that the
>
>#form is not valid
>return HttpResponseRedirect('/files/upload/')
>else:
>form = UploadFileForm()
>return render_to_response('files/upload.html', {'form': form})
>
> def handle_uploaded_file(f):
>destination = open('tmp.pdf', 'wb+')
>for chunk in f.chunks():
>destination.write(chunk)
>destination.close()
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 generic view to insert a simple model in the DB

2008-11-20 Thread John M

django writes about 90% of the form part for you.  This was also an
area for me (being new to HTML apps) that was confusing.

You have two choices, you can use the {{form}} object in your html, or
you can setup each field from the form individually.
(http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-
generic-create-update-create-object).  If you want to do individual
fields, like the example:


{{ form.name.label_tag }} {{ form.name }}
{{ form.address.label_tag }} {{ form.address }}


of if you wanted to have django do the whole thing for your:


((form))


That's about as simple as it gets.

Other than the above code IN YOUR TEMPLATE, you'll need to have the
basic HTML  and  sections, you can find those on the web
somewhere for examples.

Once you have the above setup and happy, you should have what you're
looking for to get started.

HTH

John


On Nov 19, 3:57 am, maury <[EMAIL PROTECTED]> wrote:
> Updates:
>
> I found some documentation and I added a code to urls.py like this :
>
> (r'^poll/add$', create_update.create_object, {'model' : Poll}),
>
> and the problem is that I have to write a template (I know where the
> file should be and how it should be named from the error message I
> got) and I don't know how to write it, yet. I have no special needs,
> is it possible to let django supply one default template constructed
> from the model definition ?
>
> Thanks a lot
> Maury
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: configuring production server for static media

2008-11-20 Thread Serdar T.

ok. so that fix workedkind of.

I now get the properly formatted admin login page when I visit
http://mysite.org/admin/

But when I log in,  the following 500 Internal Server Error appears:
"I'm sorry, that page is currently unavailable due to a server
misconfiguration."

That is actually a custom error page I placed in my django project's
template directory. When I clear the cache, cookies and authenticated
sessions, I can hit refresh on the admin URL and once again call up
the admin login page (complete with the stylesheets etc.). But then I
get an error stating that cookies appear to not be enabled. And when I
click login, I'm right back where I started: 500 error.

Any ideas on how to proceed?


On Nov 20, 12:06 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> Try:
>
>   ADMIN_MEDIA_PREFIX = 'http://media.mysite.org/media/'
>
> Web site example always show just a path and not a site name, but
> source code shows it can be  full URL with site name.
>
> # URL prefix for admin media -- CSS, JavaScript and images. Make sure
> to use a
> # trailing slash.
> # Examples: "http://foo.com/media/;, "/media/".
> ADMIN_MEDIA_PREFIX = '/media/'
>
> I guess I'd always assumed that this prefix was added on top of
> MEDIA_URL, but apparently not. Thus if on different site, looks like
> you need to state host as well.
>
> Graham
>
> On Nov 20, 3:06 pm, "Serdar T." <[EMAIL PROTECTED]> wrote:
>
> > I think my prior response missed the mark in terms of sample html and
> > url.
>
> > To be precise:
>
> >http://mysite.org/admin/
>
> > yields the below html:
>
> >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
> > http://www.w3.org/1999/xhtml; lang="en-us" xml:lang="en-
> > us" >
> > 
> > Log in | Django site admin
> > 
> > 
>
> > 
> > 
>
> > 
>
> > 
>
> > 
>
> > 
> > 
> > 
>
> > <<<>>>
>
> > On Nov 19, 10:58 pm, "Serdar T." <[EMAIL PROTECTED]> wrote:
>
> > > On Nov 19, 10:32 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > On Nov 20, 2:10 pm, "Serdar T." <[EMAIL PROTECTED]> wrote:
>
> > > > > hmm...I modified the root as you suggested but still the same results:
> > > > > I get the admin page minus any stylesheets, etc.
>
> > > > > I'm confused though: what exactly is the ADMIN_MEDIA_PREFIX prefixing?
>
> > > > >  It seems that the setting tacks "/media" to the end of root path as a
> > > > > way of defining where the server should search for media.
>
> > > > > But if the "media" directory is being appended to the end of the path,
> > > > > why is it called a prefix?
>
> > > > Please provide a snippet of the HTML pages being served which show the
> > > > actual URLs which are generated in the response.
>
> > >  > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
> > > 2http://www.w3.org/1999/xhtml; lang="en-us" xml:lang="en-
> > > us" >
> > > 3
> > > 4Log in | Django site admin
> > > 5
> > > 6
> > > 7
> > > 8
> > > 9
> > > 10
> > > 11
> > > 12
> > > 13
> > > 14
> > > 15
> > > 16
> > > 17
> > > 18
> > > 19
> > > 20 
> > > 21 
> > > 22 
> > > 23
> > > 24Django administration
> > > 25
> > > 26 
> > > 27
> > > 28
> > > 29 
> > > 30 
> > > <<>>
>
> > > > Also indicate whether you have validated that you can access the
> > > > static media files from nginx media site and exactly what the URLs you
> > > > have managed to successfully access them using are.
>
> > > Yup, when I turn indexing on in nginx configs, I'm able to view the
> > > media files at the following URL subdomain:
>
> > >http://media.mysite.org/
>
> > > gives acess the following directory heirarchy:
>
> > > ../
> > > media/
> > >   ../
> > >   css/   10-
> > > Nov-2008 14:05   -
> > >   img/   10-
> > > Nov-2008 14:05   -
> > >   js/
> > >  <>
>
> > > > A directory list of what is actually in:
>
> > > >   /home/user/public_html/mysite/public
>
> > > the "/media" directory is the only thing in this directory.
> > > It is a symlink to django's admin media file, located in the following
> > > directory:
>
> > > /home/user/python/django-trunk/django/contrib/admin/media
>
> > > >   /home/user/public_html/mysite/public/media
>
> > > media, as stated above, is a symlink to django's admin/media directory
>
> > > > would be useful as well.
>
> > > > Graham
>
> > > > > On Nov 19, 7:43 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > > > > wrote:
>
> > > > > > If:
>
> > > > > >   ADMIN_MEDIA_PREFIX = '/media/'
>
> > > > > > means that static media URLs will all be prefixed with that, then
> > > > > > wouldn't:
>
> > > > > >   root /home/user/public_html/mysite/public/media;
>
> > > > > > need to be:
>
> > > > > >   root /home/user/public_html/mysite/public;
>
> > > > > > This is because you have location '/' on nginx mapped to this
> > > > > > directory.
>
> > > > > > Graham
>
> > > > > > On Nov 20, 10:45 am, "Serdar T." <[EMAIL PROTECTED]> wrote:
>
> > > > > > > 

Re: django site within 7 hours (a day)

2008-11-20 Thread Kenneth Gonsalves

On Thursday 20 November 2008 06:12:36 pm Masklinn wrote:
> I don't think there's a problem on whether it's appropriate for the  
> group, but there's already Django Pluggables (http://djangoplugables.com/
> ) as a "django applications hotspot" so the project is a bit redundant  
> isn't it?

but was that written in 7 hours??

-- 
regards
KG
http://lawgon.livejournal.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
-~--~~~~--~~--~--~---



Problems with file upload and model forms

2008-11-20 Thread Marc Barranco

Hi!
I'm trying to upload a file like the example in documentation in
Django (http://docs.djangoproject.com/en/dev/topics/http/file-
uploads/)
with the "Forms from Models".
But I can't upload the file because the form always return the error
"this field is required" although selecting a file before submitting
the form.
The fact is that I can do it with the django admin site, but with the
the my own form I don't find where's the problem.

Here is the code:

---models.py-
from django import forms
from django.forms import ModelForm
from django.db import models

class UploadFile(models.Model):
title   = models.CharField(max_length=50)
file= models.FileField(upload_to="pdf/")

class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file  = forms.FileField()


views.py---
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from llunes.files.models import *

def upload(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
handle_uploaded_file(request.FILES['file']) # <--In 
fact it never
entries here

#'cause it seems that the

#form is not valid
return HttpResponseRedirect('/files/upload/')
else:
form = UploadFileForm()
return render_to_response('files/upload.html', {'form': form})

def handle_uploaded_file(f):
destination = open('tmp.pdf', 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()


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

2008-11-20 Thread David Christiansen

Pranav,

Have you considered just writing a view that returns the data in the
file with the appropriate headers? That's very easy to do and doesn't
require loading the whole static serve method.  You can then also put
whatever tracking you wanted in that view function.

If you want, I can send you a sample of something where I do something
similar.

-David Christiansen


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

2008-11-20 Thread dash86no

I had another go at this one (can never sleep on a problem)

Fixed it: The problem was my lack of test data.

If you only have one record in the table related to your foreign key,
then the filter list will not show up at the side of the admin screen.
If you add another record then the filter list will start showing up.


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

2008-11-20 Thread Ramiro Morales

On Thu, Nov 20, 2008 at 11:23 AM, dash86no <[EMAIL PROTECTED]> wrote:
>
> Having reread that documentation I can see it says "ForeignKey" as
> plain as day.
>
> Sorry I'm an idiot. I'll work on this again tomorrow, time for sleep I
> think
>
>
>
> On Nov 20, 10:19 pm, dash86no <[EMAIL PROTECTED]> wrote:
>> Karen,
>>
>> Most people I know say "hey guys" to refer to mixed groups. I'm 27 and
>> mostly spending time with Americans nowadays so I don't know if that
>> has anything to do with it.
>>
>> Anyway, I did try it, and I found whenever I tried to specify a
>> foreign key it was simply ignored. I.e. no error message the filter
>> table just didn't come up.
>>
>> I got my info about it not working here:
>>
>> http://groups.google.com/group/django-users/browse_thread/thread/cb18...
>>

Note that in the referenced thread I understood [1]you were [2]asking
for being able
to filter on fields of the FK-related model instead of by the FK iself.

Regards,

-- 
 Ramiro Morales

1. If you are effectively the same person as "caio ariede"
2. It could be me but re-reading your original message there I keep
doing the same interpretation.

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

2008-11-20 Thread [EMAIL PROTECTED]

On 20 nov, 06:54, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 10:23 PM, [EMAIL PROTECTED]
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > On 20 nov, 06:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> >> On Wed, Nov 19, 2008 at 9:53 PM, [EMAIL PROTECTED]
>
> >> <[EMAIL PROTECTED]> wrote:
>
> >> > I use a fake queryset because it's the only way that I found to
> >> > populate the formset (using a real queryset would lead to the same
> >> > problem anyway), hence I wonder if there is a cleaner way to do what I
> >> > want without reinventing modelforms, or using separate form classes
> >> > for saving and creating my dynamic formsets.
>
> >> I think from what I gather you are looking to create an "add"-only
> >> model formset? If so take a look 
> >> athttp://code.djangoproject.com/ticket/9538. I have written some
> >> information on that ticket that may be of use to you.
>
> > Yes I tried the approach you're talking about in the ticket:
>
> > FormSet = modelformset_factory(SomeModel, extra=3)
>
> > This creates 3 blank forms with INITIAL_FORMS=0, which is fine. But
> > then how can I populate this formset with some initial data instead of
> > the model's default values ?
>
> Can you file a ticket about this? The fundamental issue here is that
> formsets use initial data to populate the forms, but model formsets
> make no distinction between initial data being passed in and initial
> data it makes via the queryset. It sounds worth fixing.

I think I misunderstood your first post, sorry. I tried to use
formset_factory with my ModelForm based form :

FormSet = formset_factory(SomeModelForm, extra=0)
forms = FormSet(initial=[{"field": 1}, {"field": 2}, {"field": 3}])

It works (I thought you _had_ to use modelformset_factory to create
ModelForm formsets). But then again, I get INITIAL_FORMS=3 in the
output. If I set extra to 3, I still get INITIAL_FORMS=3, and 3
additional blank forms, there seems to be no way to populate the extra
forms with initial data.

So I think a new keyword argument is needed for formset_factory to
solve this particular issue, perhaps extra_initial ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 list_filter with a foreign key field in the Admin

2008-11-20 Thread dash86no

Having reread that documentation I can see it says "ForeignKey" as
plain as day.

Sorry I'm an idiot. I'll work on this again tomorrow, time for sleep I
think



On Nov 20, 10:19 pm, dash86no <[EMAIL PROTECTED]> wrote:
> Karen,
>
> Most people I know say "hey guys" to refer to mixed groups. I'm 27 and
> mostly spending time with Americans nowadays so I don't know if that
> has anything to do with it.
>
> Anyway, I did try it, and I found whenever I tried to specify a
> foreign key it was simply ignored. I.e. no error message the filter
> table just didn't come up.
>
> I got my info about it not working here:
>
> http://groups.google.com/group/django-users/browse_thread/thread/cb18...
>
> On Nov 20, 9:50 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Thu, Nov 20, 2008 at 7:33 AM, Dominic Ashton <[EMAIL PROTECTED]>wrote:
>
> > > Guys,
>
> > > A brief google search has led me to conclude that it's not possible to
> > > filter on a foreign key field in the Admin.
>
> > Did you try it?  I have foreign key fields specified in my filters and they
> > work.  What happens when you put the foreign key field name in list_filter?
>
> > Karen,
> > not a guy but guessing you didn't mean that to be exclusive
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 list_filter with a foreign key field in the Admin

2008-11-20 Thread dash86no

Karen,

Most people I know say "hey guys" to refer to mixed groups. I'm 27 and
mostly spending time with Americans nowadays so I don't know if that
has anything to do with it.

Anyway, I did try it, and I found whenever I tried to specify a
foreign key it was simply ignored. I.e. no error message the filter
table just didn't come up.

I got my info about it not working here:

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



On Nov 20, 9:50 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Nov 20, 2008 at 7:33 AM, Dominic Ashton <[EMAIL PROTECTED]>wrote:
>
> > Guys,
>
> > A brief google search has led me to conclude that it's not possible to
> > filter on a foreign key field in the Admin.
>
> Did you try it?  I have foreign key fields specified in my filters and they
> work.  What happens when you put the foreign key field name in list_filter?
>
> Karen,
> not a guy but guessing you didn't mean that to be exclusive
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Help for crontab

2008-11-20 Thread Horst Gutmann

For things like that it's IMO still the best approach to write a
custom command for the manage.py, which handles all this for you :-)

http://docs.djangoproject.com/en/dev/howto/custom-management-commands/#howto-custom-management-commands

-- Horst

On Thu, Nov 20, 2008 at 1:53 PM, laspal <[EMAIL PROTECTED]> wrote:
> hi,
> I am writing cron job for my application but run into problem
>
> from django.core.management import setup_environ
> import settings
> setup_environ(settings)
>
> from test.crm.models import CronEmail
>
> Basically the problem is I am not able to import any model.
>
> I tried this too:
> pathname = os.path.dirname(sys.argv[0])
> sys.path.append(os.path.abspath(pathname))
> sys.path.append(os.path.normpath(os.path.join(os.path.abspath
> (pathname), '../')))
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> but still can import any model.
>
> Thanks
> >
>

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



Re: Using list_filter with a foreign key field in the Admin

2008-11-20 Thread Daniel Roseman

On Nov 20, 12:33 pm, "Dominic Ashton" <[EMAIL PROTECTED]>
wrote:
> Guys,
>
> A brief google search has led me to conclude that it's not possible to
> filter on a foreign key field in the Admin.
>
> Can anyone explain the design rationale around that? Filtering by anything
> but a foreign key value is usuless in many of my models. To give you a
> concrete example: I have a Products model, with one to many links to:
> Suppliers and categories. Without being able to filter by supplier or
> category i'm left being able to filter by product name, price or product
> number. This is next to useless.
>
> I'm sure i'm missing something obvious here, so I'd really appreciate it if
> somebody could point me to a resource by which I could cure my ignorance.
>
> Cheers,

Don't know why you think you can't filter on a ForeignKey. The
documentation says this:

Set list_filter to activate filters in the right sidebar of the change
list page of the admin. This should be a list of field names, and each
specified field should be either a BooleanField, CharField, DateField,
DateTimeField, IntegerField or ForeignKey.

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-filter

There's a whole class in django.contrib.admin.filterspecs devoted to
filtering on related items.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Help for crontab

2008-11-20 Thread laspal

hi,
I am writing cron job for my application but run into problem

from django.core.management import setup_environ
import settings
setup_environ(settings)

from test.crm.models import CronEmail

Basically the problem is I am not able to import any model.

I tried this too:
pathname = os.path.dirname(sys.argv[0])
sys.path.append(os.path.abspath(pathname))
sys.path.append(os.path.normpath(os.path.join(os.path.abspath
(pathname), '../')))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

but still can import any model.

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



Re: Using list_filter with a foreign key field in the Admin

2008-11-20 Thread Karen Tracey
On Thu, Nov 20, 2008 at 7:33 AM, Dominic Ashton <[EMAIL PROTECTED]>wrote:

> Guys,
>
> A brief google search has led me to conclude that it's not possible to
> filter on a foreign key field in the Admin.
>

Did you try it?  I have foreign key fields specified in my filters and they
work.  What happens when you put the foreign key field name in list_filter?

Karen,
not a guy but guessing you didn't mean that to be exclusive

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

2008-11-20 Thread [EMAIL PROTECTED]

> I don't think there's a problem on whether it's appropriate for the
> group, but there's already Django Pluggables (http://djangoplugables.com/
> ) as a "django applications hotspot" so the project is a bit redundant
> isn't it?

Django pluggables is ok, but I can't get my applications listed on it
and I can't do releases of applications (version 1.0) of it etc. I was
toying with writing my own thing the other day, so more than happy to
see an alternative. Since I can submit to this application listing, I
welcome it.

Although the submit button at the top doesn't seem to work...


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



Re: django site within 7 hours (a day)

2008-11-20 Thread Masklinn


On 20 Nov 2008, at 13:22 , tom wrote:

>
> Hi,
>
> don't know if this is the right place or not. Please let me know if
> not. :)
>
> On the 18th of November in 2008 I was already working with django for
> about one and a half year, writing several applications either for
> customers or for myself. On this special day I thought it would be
> nice to demonstrate the power of django and write an application
> within one day. This was one goal, but the second goal was to give
> something back to the django community, by creating a hot spot for
> django applications.
>
> And this is what i have done:
> + selected a free design template
> + re-used a number of available applications (registration, profile,
> tagging, rating)
> + combined those to one project
> + and updated the templates accordingly
>
> I set myself a time box of 7 hours for getting as much done as
> possible. This site is now available under :
>
> http://www.django-apps.com/
>
> As mentioned, please delete this post if it is not appropriate for
> this group.
>
> Please don't hesitate to contact me, if there are questions.
>
> cheers, Tom
>

I don't think there's a problem on whether it's appropriate for the  
group, but there's already Django Pluggables (http://djangoplugables.com/ 
) as a "django applications hotspot" so the project is a bit redundant  
isn't it?

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



Re: Using list_filter with a foreign key field in the Admin

2008-11-20 Thread tom

Hi Dominic,

do you may have a code sample?

-tom

On 20 Nov., 13:33, "Dominic Ashton" <[EMAIL PROTECTED]> wrote:
> Guys,
>
> A brief google search has led me to conclude that it's not possible to
> filter on a foreign key field in the Admin.
>
> Can anyone explain the design rationale around that? Filtering by anything
> but a foreign key value is usuless in many of my models. To give you a
> concrete example: I have a Products model, with one to many links to:
> Suppliers and categories. Without being able to filter by supplier or
> category i'm left being able to filter by product name, price or product
> number. This is next to useless.
>
> I'm sure i'm missing something obvious here, so I'd really appreciate it if
> somebody could point me to a resource by which I could cure my ignorance.
>
> Cheers,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 list_filter with a foreign key field in the Admin

2008-11-20 Thread Dominic Ashton
Guys,

A brief google search has led me to conclude that it's not possible to
filter on a foreign key field in the Admin.

Can anyone explain the design rationale around that? Filtering by anything
but a foreign key value is usuless in many of my models. To give you a
concrete example: I have a Products model, with one to many links to:
Suppliers and categories. Without being able to filter by supplier or
category i'm left being able to filter by product name, price or product
number. This is next to useless.

I'm sure i'm missing something obvious here, so I'd really appreciate it if
somebody could point me to a resource by which I could cure my ignorance.

Cheers,

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

2008-11-20 Thread tom

Hi,

don't know if this is the right place or not. Please let me know if
not. :)

On the 18th of November in 2008 I was already working with django for
about one and a half year, writing several applications either for
customers or for myself. On this special day I thought it would be
nice to demonstrate the power of django and write an application
within one day. This was one goal, but the second goal was to give
something back to the django community, by creating a hot spot for
django applications.

And this is what i have done:
+ selected a free design template
+ re-used a number of available applications (registration, profile,
tagging, rating)
+ combined those to one project
+ and updated the templates accordingly

I set myself a time box of 7 hours for getting as much done as
possible. This site is now available under :

http://www.django-apps.com/

As mentioned, please delete this post if it is not appropriate for
this group.

Please don't hesitate to contact me, if there are questions.

cheers, Tom


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

2008-11-20 Thread lig

On 19 нояб, 21:22, Delta20 <[EMAIL PROTECTED]> wrote:
> NetBeans for Python has been released and based on the NB Python
> roadmap, it looks interesting for those of us working with Django. I
> haven't had much of a chance to play with it yet since it just came
> out today, but here's the info for anyone interested:
>
> NetBeans IDE for Python:http://download.netbeans.org/netbeans/6.5/python/ea/
> NB Python Roadmap:http://wiki.netbeans.org/Python

from django.db import models

class Page(models.Model):
name= models. # hitting Ctrl+Space here don't show field type
suggestions or anything from imported models package

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

2008-11-20 Thread huw_at1

OK I'll give it a go when I get some time to try mod_wsgi. Thanks for
all the help regarding this matter.

On Nov 17, 10:30 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> Can you try building mod_wsgi instead and see if it picks up the
> correct library?
>
> If it doesn't work, post the output from running 'configure' script
> and running 'make' for mod_wsgi.
>
> I trust mod_wsgi build process more than I do mod_python.
>
> Graham
>
> On Nov 17, 9:04 pm, huw_at1 <[EMAIL PROTECTED]> wrote:
>
> > ls -ltr /usr/local/lib/python2.5/config/libpython2.5.so
>
> > lrwxrwxrwx 1 root root 21 Nov 12 10:48 /usr/local/lib/python2.5/config/
> > libpython2.5.so -> ../../libpython2.5.so
>
> > ls -ltr /usr/local/lib
>
> > -r-xr-xr-x  1 root root  4806649 Nov 11 11:22 libpython2.5.a
> > -r-xr-xr-x  1 root root  4806649 Nov 12 12:49 libpython2.5.so.1.0
> > lrwxrwxrwx  1 root root       19 Nov 12 12:49 libpython2.5.so ->
> > libpython2.5.so.1.0
> > drwxr-xr-x 21 root root    20480 Nov 12 12:50 python2.5
>
> > ldd /usr/local/apache2/modules/mod_python.so
>
> >         libpthread.so.0 => /lib64/libpthread.so.0 (0x2b2d9e698000)
> >         libdl.so.2 => /lib64/libdl.so.2 (0x2b2d9e8b2000)
> >         libutil.so.1 => /lib64/libutil.so.1 (0x2b2d9eab6000)
> >         libm.so.6 => /lib64/libm.so.6 (0x2b2d9ecba000)
> >         libc.so.6 => /lib64/libc.so.6 (0x2b2d9ef3d000)
> >         /lib64/ld-linux-x86-64.so.2 (0x0039a2c0)
>
> > echo $LD_LIBRARY_PATH
>
> > /usr/local/lib
>
> > On Nov 14, 5:17 am, Graham Dumpleton <[EMAIL PROTECTED]>
> > wrote:
>
> > > Did you do a 'ls -L' on the symlink to validate it pointed at
> > > something?
>
> > > The relative location of where the .so will be is more a hint as for
> > > different systems it may not be in same relative location.
>
> > > Graham
>
> > > On Nov 13, 10:44 pm, huw_at1 <[EMAIL PROTECTED]> wrote:
>
> > > > My apologies. I forgot to mention that I already tried what was
> > > > suggested in the article you pointed me at. I created a symlink in /
> > > > usr/local/lib/python2.5/config as directed however recompiling
> > > > mod_python still links to the library statically. Unless I missed a
> > > > step in the article I am starting to wonder if mod_python just
> > > > includes this library statically by default. Still, thanks for all the
> > > > help so far. I really appreciate it.
>
> > > > On Nov 13, 9:55 am, Graham Dumpleton <[EMAIL PROTECTED]>
> > > > wrote:
>
> > > > > Because you have created the symlink for the .so file so it appears
> > > > > next to the static library. It is arguably a a failing of standard
> > > > > Python installer that it doesn't do this. What to do is explained in
> > > > > document I previously pointed you at:
>
> > > > >  http://code.google.com/p/modwsgi/wiki/InstallationIssues
>
> > > > > Yes I know this is for mod_wsgi but same applies to mod_python.
>
> > > > > Graham
>
> > > > > On Nov 13, 8:44 pm, huw_at1 <[EMAIL PROTECTED]> wrote:
>
> > > > > > ls -ltr /usr/local/lib
>
> > > > > > -r-xr-xr-x     1 root root  4806649 Nov 11 11:22 libpython2.5.a
> > > > > > -r-xr-xr-x     1 root root  4806649 Nov 12 12:49 libpython2.5.so.1.0
> > > > > > lrwxrwxrwx  1 root root            19 Nov 12 12:49 libpython2.5.so 
> > > > > > ->
> > > > > > libpython2.5.so.1.0
>
> > > > > > echo $LD_LIBRARY_PATH
>
> > > > > > /usr/local/lib
>
> > > > > > ldd /usr/local/bin/python
>
> > > > > >         libpython2.5.so.1.0 => /usr/local/lib/libpython2.5.so.1.0
> > > > > > (0x2b6d8efc5000)
> > > > > >         libpthread.so.0 => /lib64/libpthread.so.0 
> > > > > > (0x0039a4a0)
> > > > > >         libdl.so.2 => /lib64/libdl.so.2 (0x0039a460)
> > > > > >         libutil.so.1 => /lib64/libutil.so.1 (0x0039b340)
> > > > > >         libm.so.6 => /lib64/libm.so.6 (0x0039a420)
> > > > > >         libc.so.6 => /lib64/libc.so.6 (0x0039a3e0)
> > > > > >         /lib64/ld-linux-x86-64.so.2 (0x0039a2c0)
>
> > > > > > recompile mod_python and do ldd /usr/local/apache2/modules/
> > > > > > mod_python.so
>
> > > > > >         libpthread.so.0 => /lib64/libpthread.so.0 
> > > > > > (0x2b74c34f7000)
> > > > > >         libdl.so.2 => /lib64/libdl.so.2 (0x2b74c3711000)
> > > > > >         libutil.so.1 => /lib64/libutil.so.1 (0x2b74c3915000)
> > > > > >         libm.so.6 => /lib64/libm.so.6 (0x2b74c3b19000)
> > > > > >         libc.so.6 => /lib64/libc.so.6 (0x2b74c3d9c000)
> > > > > >         /lib64/ld-linux-x86-64.so.2 (0x0039a2c0)
>
> > > > > > I still don't get why the library is being compiled in statically.
>
> > > > > > On Nov 13, 12:11 am, Graham Dumpleton <[EMAIL PROTECTED]>
> > > > > > wrote:
>
> > > > > > > On Nov 12, 11:44 pm, huw_at1 <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > echo '/usr/local/lib' >> /etc/ld.so.conf
>
> > > > > > > > more /etc/ld.so.conf
>
> > > > > > > > include ld.so.conf.d/*.conf
> > > > > > > > /usr/local/lib
>
> > > > > > > > ldd /usr/local/bin/python
>
> > 

Using a HTML to fire off a data processing script on the server (REST or SOAP)

2008-11-20 Thread Shao

Dear ALL,

I am very much interested in using a HTML to fire off a data
processing script to run over the internet.

I will be very grateful if you can advise me on passing parameters
from an HTML form to a script and fire the script off to carry out
full execution, monitor its progress and return an innerHTML with link
(a name string of) the file generated back to allow user to download
the result.

The script run over a period of 2 to 3 minutes.


Necessary are  the following steps:
* user submits data to the server from a web page using an HTML form;
server redirects the browser to a status page that says "script is
running";
* in the background, the server fires off a worker script that does
the job; the server monitors the script to see when it's done (this
monitoring can be tied to the status page: when the user reloads the
status page, the server looks at the script to check if it's done);
* user refreshes the page (or the page refreshes itself) until script
is finished, and the page says "script finished; here are the results"
* some kind of cleanup of data, either with a cron job or manually by
the user

Regards.

Shao

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

2008-11-20 Thread Antoni Aloy

2008/11/20 Malcolm Tredinnick <[EMAIL PROTECTED]>:
>

>
> Andrew's final comment on that ticket is accurate. Removing the code
> duplication is pretty easy there and following the examples in
> tests/regressiontests/middleware/tests.py to create some tests for it
> should be fairly straightforward as well. So it looks close.
>
> Regards,
> Malcolm

Anybody on this thread is going to take the ticket? I could take a
look at it and make the tests.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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

2008-11-20 Thread Malcolm Tredinnick


On Thu, 2008-11-20 at 07:17 -0200, Ramiro Morales wrote:
> On Sun, Nov 16, 2008 at 10:14 PM, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
> >
> > Hello Ramiro,
> >
> > thanks for your reply. According to the docs, the Locale and Session
> > middlewares should set the Vary-On headers accordingly, and indeed
> > they are:
> >
> > Date: Sun, 16 Nov 2008 23:49:29 GMT
> > Server: WSGIServer/0.1 Python/2.5.2
> > Vary: Accept-Language, Cookie
> > Content-Type: text/html; charset=utf-8
> > Content-Language: de
> >
> > 200 OK
> >
> > I'm lost. Maybe Beegee from the other thread found a solution in the
> > meantime.
> 
> I asked Antoni Aloy that was the OP in one of these threads.
> He pointed me to [1]ticket 5691 he opened back then. You might want to take
> a look at it (to know propossed solutions, code devs opinions and
> perhaps to post feedback and enhance the patch si it can be applied?).

That ticket was mostly just waiting until we sorted out the whole
problem with cache middleware ordering with respect to almost everything
else (especially sessions). That's ticket #730 that is referred to
there. We fixed that properly in time for 1.0, so that ticket can now
move ahead.

Andrew's final comment on that ticket is accurate. Removing the code
duplication is pretty easy there and following the examples in
tests/regressiontests/middleware/tests.py to create some tests for it
should be fairly straightforward as well. So it looks close.

Regards,
Malcolm



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



Re: Caching and I18n

2008-11-20 Thread Ramiro Morales

On Sun, Nov 16, 2008 at 10:14 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hello Ramiro,
>
> thanks for your reply. According to the docs, the Locale and Session
> middlewares should set the Vary-On headers accordingly, and indeed
> they are:
>
> Date: Sun, 16 Nov 2008 23:49:29 GMT
> Server: WSGIServer/0.1 Python/2.5.2
> Vary: Accept-Language, Cookie
> Content-Type: text/html; charset=utf-8
> Content-Language: de
>
> 200 OK
>
> I'm lost. Maybe Beegee from the other thread found a solution in the
> meantime.

I asked Antoni Aloy that was the OP in one of these threads.
He pointed me to [1]ticket 5691 he opened back then. You might want to take
a look at it (to know propossed solutions, code devs opinions and
perhaps to post feedback and enhance the patch si it can be applied?).

HTH

-- 
 Ramiro Morales

1. http://code.djangoproject.com/ticket/5691

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

2008-11-20 Thread Steve Holden

Graham Dumpleton wrote:
> 
> 
> On Nov 20, 1:41 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
[...]
>> The drawbacks are that the Django web servers aren't designed to the
>> same rigorous security standards that are applied to production web
>> servers like Apache and lighthttpd,
> 
> I really scratch my head when I keep seeing this argument about
> security. It doesn't really matter whether you use Apache or Django,
> it is possible to screw up in configuring either such that you could
> expose more of the file system than you intended.
> 
Perhaps we need a documentation change.

>From http://docs.djangoproject.com/en/dev/howto/static-files/

"""
The big, fat disclaimer

Using this method is inefficient and insecure. Do not use this in a
production setting. Use this only for development.
"""

So it's true I was parroting the documentation, and that your rather
more nuanced advice is probably more useful in the general case.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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: many to many matrix

2008-11-20 Thread Malcolm Tredinnick


On Thu, 2008-11-20 at 00:19 -0800, frans wrote:
> Hi, I was wondering if there is some way to create a "matrix display"
> for viewing/editing many to many relationships between objects ?
> 
> I've been thinking to use django for network documentation. My idea is
> to put all the networks we host or talk with in a matrix. Where you
> see all the networks on the left, and on the top.
> In the "cells" we could then define if traffic is allowed or not. And
> maybe the direction.
> 
> It should be possible with the django admin framework right ? 

Not easily. It would require a reasonable amount of customisation and if
you're not a programmer, would probably be quite difficult. Since there
could be dozens or hundreds of objects on each axis, which makes a table
that scrolls horizontally and vertically. You end up needing to develop
something equivalent to a spreadsheet display.

It would be possible to do something like this, since there are existing
Javascript widgets -- such as YUI's DataTable -- which allow that sort
of scrollable display. But it's not an out-of-the-box, flick-a-switch
option.

Regards,
Malcolm



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



  1   2   >