Processing multiple forms on one page

2009-06-23 Thread Oleg Oltar

Hi!

I am writing a small application for user profile management.

I need to display and to process output from 2 form on the page of own
profile. How can I do it?

1. Form if to change avatar. (Contains browse and upload buttons)
2. Form is for changing user details, e.g. info field, or maybe emails

I want these form to be processed independently. E.g. user can submit
one without filling another.

I have read a post about similar problem here:
http://groups.google.com/group/django-users/browse_thread/thread/1ff0909af4e0cdfe
but didn't find a solution for me.

e.g. if we have following code:
if request.method == 'POST':
form1 = RegistrationForm(request.POST)
form2 = ...(request.POST)

How to process them? Mean one of them will be empty, and it means I
don't need to return an error in that case.
Actually,  I need to understand which of them is in post. But how?


Thanks,
Oleg

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



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread Steve Howell

The child should either win semantically or fail syntactically.  You
seem to have some sympathy for the latter position.  I think the
current behavior is less than ideal but I have no passion to fix it.
It might be something worth documenting more clearly.  Without
researching tracker I suspect that most folks who encounter this
gotcha either work around it or go to a different templating system.
The OP is using generics so will probably be wise to stick with django
templates and slightly repetitive code.

On Jun 23, 9:16 pm, Karen Tracey  wrote:
> On Tue, Jun 23, 2009 at 11:05 PM, Steve Howell  wrote:
> > > {% extends "base_form.html" %}
> > > {% with form.instance as object %}
>
> > I understand why tags outside the block would not render anything
> > within the parent but it is not as clear to me why the with statement
> > would not change the context for template code that it lexically
> > encloses.  It seems like this code should either dwim or raise an
> > exception.
>
> It doesn't lexically enclose anything if it is inside a child template and
> not inside a {% block %}.
>
> Consider:
>
> parent.html:
>
> {% with something as x %}
> {% block b1 %} {{ x }} in parent b1{% endblock %}
> {% block b2 %} {{ x }} in parent b2{% endblock %}
> {% endwith %}
> {% with something_else as x %}
> {% block b3 %}{{ x }} in parent b3{% endblock %}
> {% endwith %}
>
> child.html:
>
> {% extends "parent.html" %}
> {% with something_else_again as x %}
> {% block b3 %}{{ x }} in child b3{% endblock %}
> {% block b2 %}{{ x }} in child b2{% endblock %}
> {% endwith %}
> {% with yet_even_something_else as x %}
> {% block b1 %}{{ x }} in child b1{% endblock %}
> {% endwith %}
>
> If those with/endwiths in child.html were to have some effect, what would it
> be?  Where would you place them in the fully-block-substituted parent
> template?  something_else_again being x encloses blocks b3 and b2 in
> child.html, yet in the parent template these blocks are found in a different
> order and have different with's enclosing them...which withs win?  I just
> don't see any sensible way to make this "work".
>
> Raising some sort of error for child template content found outside of a {%
> block %} seems like a more reasonable idea.  I have no idea if it's been
> asked for/considered/rejected/etc., nor how hard it would be to do.  If you
> are really interested in pursuing that idea I'd first search the tracker and
> archives of this list to see if it hasn't already been discussed.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 11:05 PM, Steve Howell  wrote:

> > {% extends "base_form.html" %}
> > {% with form.instance as object %}
> >
>
> I understand why tags outside the block would not render anything
> within the parent but it is not as clear to me why the with statement
> would not change the context for template code that it lexically
> encloses.  It seems like this code should either dwim or raise an
> exception.


It doesn't lexically enclose anything if it is inside a child template and
not inside a {% block %}.

Consider:

parent.html:

{% with something as x %}
{% block b1 %} {{ x }} in parent b1{% endblock %}
{% block b2 %} {{ x }} in parent b2{% endblock %}
{% endwith %}
{% with something_else as x %}
{% block b3 %}{{ x }} in parent b3{% endblock %}
{% endwith %}

child.html:

{% extends "parent.html" %}
{% with something_else_again as x %}
{% block b3 %}{{ x }} in child b3{% endblock %}
{% block b2 %}{{ x }} in child b2{% endblock %}
{% endwith %}
{% with yet_even_something_else as x %}
{% block b1 %}{{ x }} in child b1{% endblock %}
{% endwith %}

If those with/endwiths in child.html were to have some effect, what would it
be?  Where would you place them in the fully-block-substituted parent
template?  something_else_again being x encloses blocks b3 and b2 in
child.html, yet in the parent template these blocks are found in a different
order and have different with's enclosing them...which withs win?  I just
don't see any sensible way to make this "work".

Raising some sort of error for child template content found outside of a {%
block %} seems like a more reasonable idea.  I have no idea if it's been
asked for/considered/rejected/etc., nor how hard it would be to do.  If you
are really interested in pursuing that idea I'd first search the tracker and
archives of this list to see if it hasn't already been discussed.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



TinyMCE django admin

2009-06-23 Thread Dhruv Adhia

Hello All,

I have following under models.py

from django.db import models
from django.contrib import admin
from tinymce import models as tinymce_models


class BlogPost(models.Model):

title = models.CharField(max_length=150)
body = models.TextField() #observe, thats how you get big
character field
timestamp = models.DateTimeField()

class Meta:
ordering = ('-timestamp',)
class Admin:
list_display = ('title', 'timestamp')
js = ['tiny_mce/tiny_mce.js', 'js/textareas.js']

class BlogPostAdmin(admin.ModelAdmin):
pass

class MyModel(models.Model):
my_field = tinymce_models.HTMLField()

admin.site.register(MyModel)
admin.site.register(BlogPost, BlogPostAdmin)

As you can see I have followed all the settings. But I dont get the
editor for the textfield and also I HTMLfield does not work. Though I
am able to edit content inside HTML field and then in the front end
side I am not able to view it. It shows me all the tags.

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



Re: psycopg2.OperationalError: fe_sendauth: no password supplied

2009-06-23 Thread Dhruv Adhia
I think combo of these links should help you,

http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804
find out where pg_hba.conf

should be under your 8.3/main/ , I am not sure just find it out. This file
has all the permission stuff.

Also otherwise look at docs
http://www.postgresql.org/docs/current/static/libpq-pgpass.html

Happy debugging :)


On Tue, Jun 23, 2009 at 7:09 PM, Chris Haynes  wrote:

>
> I've just installed postgresql and psycopg2. I supplied a password in
> the postgres install, but don't know how to supply it to psycopg2:
>
>  ~/s/sd$ manage.py syncdb
> Traceback (most recent call last):
>  File "./manage.py", line 11, in 
>execute_manager(settings)
>  File "/users/home/system/lib/djangotrunk/django/core/management/
> __init__.py", line 347, in execute_manager
>utility.execute()
>  File "/users/home/system/lib/djangotrunk/django/core/management/
> __init__.py", line 295, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/users/home/system/lib/djangotrunk/django/core/management/
> base.py", line 195, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/users/home/system/lib/djangotrunk/django/core/management/
> base.py", line 222, in execute
>output = self.handle(*args, **options)
>  File "/users/home/system/lib/djangotrunk/django/core/management/
> base.py", line 351, in handle
>return self.handle_noargs(**options)
>  File "/users/home/system/lib/djangotrunk/django/core/management/
> commands/syncdb.py", line 48, in handle_noargs
>cursor = connection.cursor()
>  File "/users/home/system/lib/djangotrunk/django/db/backends/
> __init__.py", line 62, in cursor
>cursor = self._cursor(settings)
>  File "/users/home/system/lib/djangotrunk/django/db/backends/
> postgresql_psycopg2/base.py", line 84, in _cursor
>self.connection = Database.connect(conn_string, **self.options)
> psycopg2.OperationalError: fe_sendauth: no password supplied
> >
>


-- 
Dhruv Adhia
http://thirdimension.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread buttman

On Jun 23, 11:03 pm, Karen Tracey  wrote:
> On Tue, Jun 23, 2009 at 10:22 PM, buttman  wrote:
>
> You seem to have left out of your options the choice of putting the {% with
> %} block in the parent template?  Or passing your variables in the context
> with the names you'd like to use in the template blocks?
>
> Karen

I have a "base_form.html" template that is used for many different
kinds of forms. Sometimes "form.instance" is a "Position" object,
sometimes it's a "Company" object, etc. Each child template needs to
access "form.instance", but each child template doesn't use that
"form.instance" the same way. I can't use a context variable either
because a lot of these templates are being called from the
"create_update.update_object" generic view, where I'm kind of limited
to which extra variables I can give to the template. This is why I'm
kind of forced to use "form.instance" in the first place. I could
write wrapper functions for these generic views, but there are a ton
of them and it would take a long time :/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread Steve Howell



On Jun 23, 7:29 pm, Karen Tracey  wrote:
> On Tue, Jun 23, 2009 at 10:16 PM, Steve Howell  wrote:
>
> > Nothing posted is outside a block but it could be that the parent has
> > no title block?
>
> I can't parse this sentence.  The part of the original post where things
> didn't work is here:
>
> {% extends "base_form.html" %}
> {% with form.instance as object %}
>

I understand why tags outside the block would not render anything
within the parent but it is not as clear to me why the with statement
would not change the context for template code that it lexically
encloses.  It seems like this code should either dwim or raise an
exception.
> {% block title%}
>    {{object.title}} <- not displayed :(
> {% endblock %}
>
> {% with %} is not inside a block, so there is no place for it to go in the
> parent template.  That's why {{ object.titlte }} won't work inside the
> over-ridden title block -- without the {% with %}, object hasn't been
> assigned a value.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 10:22 PM, buttman  wrote:

>
> Yes, but {% with %} isn't placing anything anywhere. It's just
> creating a new variable "object" from "form.instance". My only options
> seems to be either stuck using form.instance, or place a {% with %}
> tag inside each and every {% block %} that needs it (which is just
> about every one). I don't like either option :(
>

It may not be placing anything anywhere but it itself has to be placed
somewhere and if it is not inside a block there is no place for it to go.
All that happens with child templates is that the defined blocks are
substituted into the parent template to over-ride whatever may have been
specified there.  Then the ultimate parent template, after all over-ridden
blocks have been substituted, is rendered.  (I do not know if that is
exactly how it is implemented, but that is how it works conceptually.)
Anything outside of a {% block %} in a child template has no place to go in
the ultimately rendered template.

You seem to have left out of your options the choice of putting the {% with
%} block in the parent template?  Or passing your variables in the context
with the names you'd like to use in the template blocks?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 10:16 PM, Steve Howell  wrote:

>
> Nothing posted is outside a block but it could be that the parent has
> no title block?
>

I can't parse this sentence.  The part of the original post where things
didn't work is here:

{% extends "base_form.html" %}
{% with form.instance as object %}

{% block title%}
   {{object.title}} <- not displayed :(
{% endblock %}

{% with %} is not inside a block, so there is no place for it to go in the
parent template.  That's why {{ object.titlte }} won't work inside the
over-ridden title block -- without the {% with %}, object hasn't been
assigned a value.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread buttman

On Jun 23, 9:47 pm, Karen Tracey  wrote:
> On Tue, Jun 23, 2009 at 8:34 PM, nbv4  wrote:
>
> > I'm trying to set up a template for all my forms, but I'm having
> > trouble using the {% with %} block:
>
> > {% extends "base_form.html" %}
> > {% with form.instance as object %}
>
> > {% block title%}
> >    {{object.title}} <- not displayed :(
> > {% endblock %}
>
> > {% block body %}
> > {% with form.instance as object %}
> >    {{object.title}} <- now it is displayed
> > {% endwith%}
> > {% endblock %}
>
> > {% endwith %}
>
> > The 'with' tag works, but only within other blocks. Is there any way
> > to get around this without wrapping a hundred 'with' blocks around
> > each block in my template?
>
> I don't think what you're describing has anything to do with the {% with %}
> tag specifically.  You're dealing with a child template here -- one that
> starts with an {% extends %} tag.  Nothing placed outside of {% block %}
> tags in a child template has any effect on the rendered template.  A child
> template simply supplies block contents to override what has been specified
> in the parent template, so everything in a child template must be included
> inside {% block %} tags. (If it is not specified inside a {% block %}, where
> should it go in the parent template?)  See:
>
> http://docs.djangoproject.com/en/dev/topics/templates/#id1
>
> Karen

Yes, but {% with %} isn't placing anything anywhere. It's just
creating a new variable "object" from "form.instance". My only options
seems to be either stuck using form.instance, or place a {% with %}
tag inside each and every {% block %} that needs it (which is just
about every one). I don't like either option :(
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread Steve Howell

Nothing posted is outside a block but it could be that the parent has
no title block?

On Jun 23, 6:47 pm, Karen Tracey  wrote:
> On Tue, Jun 23, 2009 at 8:34 PM, nbv4  wrote:
>
> > I'm trying to set up a template for all my forms, but I'm having
> > trouble using the {% with %} block:
>
> > {% extends "base_form.html" %}
> > {% with form.instance as object %}
>
> > {% block title%}
> >    {{object.title}} <- not displayed :(
> > {% endblock %}
>
> > {% block body %}
> > {% with form.instance as object %}
> >    {{object.title}} <- now it is displayed
> > {% endwith%}
> > {% endblock %}
>
> > {% endwith %}
>
> > The 'with' tag works, but only within other blocks. Is there any way
> > to get around this without wrapping a hundred 'with' blocks around
> > each block in my template?
>
> I don't think what you're describing has anything to do with the {% with %}
> tag specifically.  You're dealing with a child template here -- one that
> starts with an {% extends %} tag.  Nothing placed outside of {% block %}
> tags in a child template has any effect on the rendered template.  A child
> template simply supplies block contents to override what has been specified
> in the parent template, so everything in a child template must be included
> inside {% block %} tags. (If it is not specified inside a {% block %}, where
> should it go in the parent template?)  See:
>
> http://docs.djangoproject.com/en/dev/topics/templates/#id1
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopyg setup error: no build_ext

2009-06-23 Thread Dhruv Adhia
I got my copy from the following site

http://www.initd.org/pub/software/psycopg/
and got it working smoothly for the purpose of geodjango app
the version I installed was
psycopg2-2.0.11.tar.gz

Cheers,

On Tue, Jun 23, 2009 at 6:47 PM, Chris Haynes  wrote:

>
> /opt/local/bin$ sudo port install py26-psycopg2
>
> worked, after an incredible number of (presumably dependent) installs.
>
> Now I'm getting a password error, but I'll post that separately as it
> deserves a different title.
>
> thanks
> Chris
>
>
> On Jun 23, 8:33 pm, James Martin  wrote:
> > I was never able to get psycopg2 to compile on osx I recommend
> > using sqlite for development or another database.  If you must use
> > psycopg2, you may want to try to get it through something like
> > darwinports.
> >
> > On Tue, Jun 23, 2009 at 1:19 PM, Chris Haynes
> wrote:
> >
> > > Using what I believe is the latest version of psycopyg, I get:
> >
> > > 509 ~/Desktop/psycopg2-2.0.9$ python setup.py build
> > > running build
> > > running build_py
> > > creating build
> > > creating build/lib.macosx-10.3-fat-2.6
> > > creating build/lib.macosx-10.3-fat-2.6/psycopg2
> > > copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > > copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > > copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > > copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > > copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > > copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > > copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > > running build_ext
> > > error: No such file or directory
> >
> > > and easy_install doesn't work either (seems like the same problem):
> >
> > > 510 ~/Desktop/psycopg2-2.0.9$ easy_install .
> > > Processing .
> > > Running setup.py -q bdist_egg --dist-dir /Users/home/Desktop/
> > > psycopg2-2.0.9/egg-dist-tmp-mYsMSq
> > > error: Setup script exited with error: No such file or directory
> >
>


-- 
Dhruv Adhia
http://thirdimension.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



psycopg2.OperationalError: fe_sendauth: no password supplied

2009-06-23 Thread Chris Haynes

I've just installed postgresql and psycopg2. I supplied a password in
the postgres install, but don't know how to supply it to psycopg2:

 ~/s/sd$ manage.py syncdb
Traceback (most recent call last):
  File "./manage.py", line 11, in 
execute_manager(settings)
  File "/users/home/system/lib/djangotrunk/django/core/management/
__init__.py", line 347, in execute_manager
utility.execute()
  File "/users/home/system/lib/djangotrunk/django/core/management/
__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/users/home/system/lib/djangotrunk/django/core/management/
base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/users/home/system/lib/djangotrunk/django/core/management/
base.py", line 222, in execute
output = self.handle(*args, **options)
  File "/users/home/system/lib/djangotrunk/django/core/management/
base.py", line 351, in handle
return self.handle_noargs(**options)
  File "/users/home/system/lib/djangotrunk/django/core/management/
commands/syncdb.py", line 48, in handle_noargs
cursor = connection.cursor()
  File "/users/home/system/lib/djangotrunk/django/db/backends/
__init__.py", line 62, in cursor
cursor = self._cursor(settings)
  File "/users/home/system/lib/djangotrunk/django/db/backends/
postgresql_psycopg2/base.py", line 84, in _cursor
self.connection = Database.connect(conn_string, **self.options)
psycopg2.OperationalError: fe_sendauth: no password supplied
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using pluralize with floats?

2009-06-23 Thread Tim Chase

> Has anyone tried to use pluralize template tag with a float value? I
> am thinking of submitting a patch to support this functionality.
> 
> For instance, using the value 1.5 returns a singular suffix from
> pluralize. I am implementing a real estate web application where a
> house could have 1.5 bathrooms, for example.

I suspect the pluralize filter is casting to an int which throws 
away the fractional part.  I'd clone the pluralize filter and 
make a custom one that uses a "floating point 
equals-within-epsilon" comparison:

   EPSILON = 0.001 # some arbitrarily small precision
   def floats_equal(f1, f2):
 return abs(f1-f2) < EPSILON

   register = template.Library()
   @register.filter(name="oneish")
   def oneish(value):
 return floats_equal(1.0, float(value))

...
   #  template #
   This house has
   {{ house.bathrooms }}
bathroom{{ house.bathrooms|oneish|pluralize }}
   

The above is off-the-cuff & untested, but should be fairly close 
to an accurate implementation.  It also abuses the fact that 
"True == 1" which might be nice to make a little more explicit.

-tim







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



Re: debugging

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 9:04 PM, db_333  wrote:

>
> Hi I'm trying to figure out why a record I am trying to save from a
> form will not commit.  The form seems to be working fine, and I wanted
> to know if there were any specific debugging statements I could use to
> see where this is failing.
>
> The following is what I have:
>
> 1. model:
>
> class Units(models.Model):
>serial_number = models.CharField(max_length=25, primary_key=True)
>build = models.CharField(max_length=50, blank=True)
>model = models.CharField(max_length=20, blank=True)
>create_date = models.DateField(null=True, blank=True)
>source = models.CharField(max_length=20, blank=True)
>class Meta:
>db_table = u'units'
>
> 2. form:
>
> class UnitFormSave(forms.Form):
>serial_number = forms.CharField(max_length=50)
>build = forms.CharField(max_length=50)
>model = forms.CharField(max_length=10)
>source = forms.CharField(max_length=10)
>
> 3. view:
>
> def save_unit(request):
>if request.method == 'POST':
>form = UnitFormSave(request.POST)
>if form.is_valid():
>unit = Units.objects.create(
>serial_number = form.cleaned_data['serial_number'],
>build = form.cleaned_data['build'],
>model = form.cleaned_data['model'],
>source = form.cleaned_data['source'])
>unit.save()
>return HttpResponseRedirect('/search/')
>else:
>form = UnitFormSave()
>
>variables = RequestContext(request, {
>'form': form
>})
>return render_to_response('unit_save.html', variables)
>

Is this actually the way you have the save_unit function indented? You've
got everything indented under "if request.method == 'POST'" with nothing for
the GET case.  It rather looks like from the "else" currently paired with
"if form.is_valid():" through the end of the funciton should be out-dented
one level.  That way if form is not valid what will happen is that the form
annotated with error messages about what is incorrect will be re-displayed.
What is happening with the code you have posted is that the error-annotated
form is being tossed away and replaced with a new blank form.  As it is,
though, I don't see how you are getting anything valid on a GET to begin
with, so I am not even sure this is the code you are actually running.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopyg setup error: no build_ext

2009-06-23 Thread Chris Haynes

/opt/local/bin$ sudo port install py26-psycopg2

worked, after an incredible number of (presumably dependent) installs.

Now I'm getting a password error, but I'll post that separately as it
deserves a different title.

thanks
Chris


On Jun 23, 8:33 pm, James Martin  wrote:
> I was never able to get psycopg2 to compile on osx I recommend
> using sqlite for development or another database.  If you must use
> psycopg2, you may want to try to get it through something like
> darwinports.
>
> On Tue, Jun 23, 2009 at 1:19 PM, Chris Haynes wrote:
>
> > Using what I believe is the latest version of psycopyg, I get:
>
> > 509 ~/Desktop/psycopg2-2.0.9$ python setup.py build
> > running build
> > running build_py
> > creating build
> > creating build/lib.macosx-10.3-fat-2.6
> > creating build/lib.macosx-10.3-fat-2.6/psycopg2
> > copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> > running build_ext
> > error: No such file or directory
>
> > and easy_install doesn't work either (seems like the same problem):
>
> > 510 ~/Desktop/psycopg2-2.0.9$ easy_install .
> > Processing .
> > Running setup.py -q bdist_egg --dist-dir /Users/home/Desktop/
> > psycopg2-2.0.9/egg-dist-tmp-mYsMSq
> > error: Setup script exited with error: No such file or directory
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 8:34 PM, nbv4  wrote:

>
> I'm trying to set up a template for all my forms, but I'm having
> trouble using the {% with %} block:
>
> {% extends "base_form.html" %}
> {% with form.instance as object %}
>
> {% block title%}
>{{object.title}} <- not displayed :(
> {% endblock %}
>
> {% block body %}
> {% with form.instance as object %}
>{{object.title}} <- now it is displayed
> {% endwith%}
> {% endblock %}
>
> {% endwith %}
>
> The 'with' tag works, but only within other blocks. Is there any way
> to get around this without wrapping a hundred 'with' blocks around
> each block in my template?


I don't think what you're describing has anything to do with the {% with %}
tag specifically.  You're dealing with a child template here -- one that
starts with an {% extends %} tag.  Nothing placed outside of {% block %}
tags in a child template has any effect on the rendered template.  A child
template simply supplies block contents to override what has been specified
in the parent template, so everything in a child template must be included
inside {% block %} tags. (If it is not specified inside a {% block %}, where
should it go in the parent template?)  See:

http://docs.djangoproject.com/en/dev/topics/templates/#id1

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: null values should work here but don't

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 4:14 PM, K.C. Smith  wrote:

>
> I want to (optionally) leave some fields in a model/table NULL.  I've
> set the options "null=True" and "blank=True" for the fields in
> question.  I know it's working because the admin site add form greyed
> out the "blank=True" fields.  But, I still can't add an object with
> these fields blank/NULL.  I get this error (in part):
>
> Exception Type: DataError
> Exception Value:invalid input syntax for type inet: ""
> Exception Location: /usr/local/lib/python2.5/site-packages/django/db/
> backends/util.py in execute, line 19
> Python Executable:  /usr/local/bin/python
> Python Version: 2.5.4
>
> I'm using Postgres and the psycopg2-2.0.9 module. And other models/
> tables without null values are working fine.
>

Looks like:

http://code.djangoproject.com/ticket/5622

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error -- 'str' object has no attribute 'creation_counter'

2009-06-23 Thread Phil

> OK thanks Karen, so the patch is the cause, foreign key filters now
> work fine with the 1.0.2 main release. Of course, once again I have
> the problem that tables with composite primary keys are not working...

Whoops, I just described a different problem (foreign key filters)
that was caused by the patch. But reverting to the base release also
fixed the Inlines issue that I raised in the first place. It seems the
composite foreign key patch needs some work

Phil

On Jun 24, 11:07 am, Phil  wrote:
> OK thanks Karen, so the patch is the cause, foreign key filters now
> work fine with the 1.0.2 main release. Of course, once again I have
> the problem that tables with composite primary keys are not working...
>
> I still don't understand why though. The class CompositePrimaryKey is
> not present in the main release. However, as neither my main table or
> the foreign key table had composite primary keys, why did the code use
> this class?
>
> Phil
>
> On Jun 24, 1:02 am, Karen Tracey  wrote:
>
> > On Tue, Jun 23, 2009 at 2:02 AM, Phil  wrote:
> > > I'm sure I had this working before, but since then I have installed
> > > the composite primary key patch and I notice the 2nd to last traceback
> > > is in class CompositePrimaryKey... Could this be something to do with
> > > it?? All ideas appreciated
>
> > Certainly if you see code from the patch in the traceback then I'd be
> > inclined to suspect the patch as the cause.  Next step would be to try to
> > recreate the error without the patch -- if you can't, that would be more
> > evidence there is some situation the patch isn't handling properly.
>
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error -- 'str' object has no attribute 'creation_counter'

2009-06-23 Thread Phil

OK thanks Karen, so the patch is the cause, foreign key filters now
work fine with the 1.0.2 main release. Of course, once again I have
the problem that tables with composite primary keys are not working...

I still don't understand why though. The class CompositePrimaryKey is
not present in the main release. However, as neither my main table or
the foreign key table had composite primary keys, why did the code use
this class?

Phil

On Jun 24, 1:02 am, Karen Tracey  wrote:
> On Tue, Jun 23, 2009 at 2:02 AM, Phil  wrote:
> > I'm sure I had this working before, but since then I have installed
> > the composite primary key patch and I notice the 2nd to last traceback
> > is in class CompositePrimaryKey... Could this be something to do with
> > it?? All ideas appreciated
>
> Certainly if you see code from the patch in the traceback then I'd be
> inclined to suspect the patch as the cause.  Next step would be to try to
> recreate the error without the patch -- if you can't, that would be more
> evidence there is some situation the patch isn't handling properly.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



debugging

2009-06-23 Thread db_333

Hi I'm trying to figure out why a record I am trying to save from a
form will not commit.  The form seems to be working fine, and I wanted
to know if there were any specific debugging statements I could use to
see where this is failing.

The following is what I have:

1. model:

class Units(models.Model):
serial_number = models.CharField(max_length=25, primary_key=True)
build = models.CharField(max_length=50, blank=True)
model = models.CharField(max_length=20, blank=True)
create_date = models.DateField(null=True, blank=True)
source = models.CharField(max_length=20, blank=True)
class Meta:
db_table = u'units'

2. form:

class UnitFormSave(forms.Form):
serial_number = forms.CharField(max_length=50)
build = forms.CharField(max_length=50)
model = forms.CharField(max_length=10)
source = forms.CharField(max_length=10)

3. view:

def save_unit(request):
if request.method == 'POST':
form = UnitFormSave(request.POST)
if form.is_valid():
unit = Units.objects.create(
serial_number = form.cleaned_data['serial_number'],
build = form.cleaned_data['build'],
model = form.cleaned_data['model'],
source = form.cleaned_data['source'])
unit.save()
return HttpResponseRedirect('/search/')
else:
form = UnitFormSave()

variables = RequestContext(request, {
'form': form
})
return render_to_response('unit_save.html', variables)


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



why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread nbv4

I'm trying to set up a template for all my forms, but I'm having
trouble using the {% with %} block:

{% extends "base_form.html" %}
{% with form.instance as object %}

{% block title%}
{{object.title}} <- not displayed :(
{% endblock %}

{% block body %}
{% with form.instance as object %}
{{object.title}} <- now it is displayed
{% endwith%}
{% endblock %}

{% endwith %}

The 'with' tag works, but only within other blocks. Is there any way
to get around this without wrapping a hundred 'with' blocks around
each block in my template?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TypeError: 'module' object is not callable

2009-06-23 Thread Paula Leuzzi
Is there any way to tell through debugging if there's an issue with saving a
record?  This form seems to work fine, but the record does not save.  I'm
lost as to why it's not committing.  Any pointers on debug statements for
this kind of issue?

On Fri, Jun 19, 2009 at 4:32 PM, db_333  wrote:

>
> I wanted to later implement a login based on a user session, and I got
> some guidance from pretty decent Django book on learning to build
> websites with Django.  However, I can see that I need to better
> understand how the middleware APIs work before I jump ahead.
> I appreciate your quick responses
>
> On Jun 19, 4:25 pm, Alex Gaynor  wrote:
> > On Fri, Jun 19, 2009 at 6:24 PM, db_333  wrote:
> >
> > > here's what I have for the Middleware:
> >
> > > MIDDLEWARE_CLASSES = (
> > >'django.middleware.common.CommonMiddleware',
> > >'django.contrib.sessions.middleware.SessionMiddleware',
> > >'django.contrib.auth.middleware.AuthenticationMiddleware',
> > >'django.contrib.auth.models'
> > > )
> > > I'm searching the APIs to see what I might be missing...  any
> > > pointers?
> >
> > > On Jun 19, 4:20 pm, Andy McKay  wrote:
> > > > On 19-Jun-09, at 3:38 PM, db_333 wrote:
> >
> > > > >  File "/Library/Python/2.5/site-packages/django/core/handlers/
> > > > > wsgi.py", line 228, in __call__
> > > > >self.load_middleware()
> > > > >  File "/Library/Python/2.5/site-packages/django/core/handlers/
> > > > > base.py", line 47, in load_middleware
> > > > >mw_instance = mw_class()
> > > > > TypeError: 'module' object is not callable
> > > > > [19/Jun/2009 14:09:22] "GET / HTTP/1.1" 500 644
> >
> > > > But what Middleware do you have installed - whats the settings.py
> > > > value for middleware?
> >
> > > > It looks like that might be problem, none of the above code.
> >
> > Why did you add 'django.contrib.auth.models' to your middleware?  That's
> > whats causing your issue, but what were you hoping to accomplish?
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>

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



django-registration not reflecting changes to forms and views

2009-06-23 Thread neri...@gmail.com

I'm using django-registration and don't understand why changes made to
form and views are not reflected in the browser, even after deleting
the referenced forms and views. I tried adding more form fields to the
registration form and the changes would never show with touch
dispatch.fcgi, so I tried deleting the forms and views files for the
app and the app still works as if nothing was changed! I'm not sure
what I'm missing, if you can help me out I would appreciate it.

Thanks,

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



Odd ModelForm problem

2009-06-23 Thread saxon75

I'm having a strange problem with my site wherein a ModelForm doesn't
appear to recognize that it has an attribute that it ought to.  I
should preface this by saying that I recently moved my codebase to a
new server--everything had been working fine on the old server and I
haven't made any changes to the code since then, so that seems like
the only thing that could have changed, but I have no idea what the
problem is.

In any case, here are the relevant bits of code:

==
article/forms.py:

from models import Article
from django import forms

[snip]

class AddArticleForm(forms.ModelForm):
  body = forms.CharField(widget=forms.Textarea(attrs={'rows': '25',
'cols': '80'}))
  slug = forms.CharField(max_length=25,required=False)

  class Meta:
model = Article
exclude = ('node_ptr','archetype','created','author','section')

==
article/models.py:

from django.db import models
from sake.node.models import Node
from sake.misc import blurbify

class Article(Node):
  body = models.TextField()
  blurb = property(lambda self: blurbify(self.body, 100))

  def __str__(self):
return self.title

==
node/models.py:

from django.db import models
from django.contrib.auth.models import User, Group
import re
from sake.misc import slugrepl
from tagging.models import Tag

# Create your models here.

class Section(models.Model):
  section = models.CharField(max_length=50)
  keyword = models.CharField(max_length=15)
  sort_reverse = models.BooleanField()

  def __str__(self):
return self.section

  def get_absolute_url(self):
return ('sake.node.views.node_section_all', (), {'sect':
self.keyword})
  get_absolute_url = models.permalink(get_absolute_url)

  def save(self):
#g = Group.objects.create(name=self.keyword)
#g.save()
super(Section,self).save()

class Archetype(models.Model):
  classname = models.CharField(max_length=15)

  def __str__(self):
return self.classname

class Node(models.Model):
  author = models.ForeignKey(User)
  created = models.DateTimeField()
  published = models.BooleanField()
  promoted = models.BooleanField()
  section = models.ForeignKey(Section)
  archetype = models.ForeignKey(Archetype)
  title = models.CharField(max_length=255)
  slug = models.SlugField(max_length=25)
  comments_enabled = models.BooleanField()
  tag_list = models.CharField(max_length=255)

  def _get_tags(self):
return Tag.objects.get_for_object(self)

  def _set_tags(self, tag_list):
Tag.objects.update_tags(self, tag_list)

  tags = property(_get_tags, _set_tags)

  def _blurb(self):
if self.archetype.classname is not "Node":
  return getattr(self, self.archetype.classname.lower()).blurb
else:
  return u"Created by %s" % (self.author.username,)

  blurb = property(_blurb)

  def __str__(self):
return self.title

  def get_absolute_url(self):
return ('sake.node.views.node_detail', (), {
'sect': self.section.keyword,
'yr': self.created.year,
'mo': self.created.strftime('%m'),
'slg': self.slug})
  get_absolute_url = models.permalink(get_absolute_url)

  def save(self):
self.archetype = Archetype.objects.get(classname=type
(self).__name__)
if len(self.slug) == 0:
  self.slug = re.sub('\W', slugrepl, self.title.lower().strip())[:
25]
super(Node,self).save()
self.tags = self.tag_list

==
article/views.py:

from forms import ArticleForm, AddArticleForm
from django.shortcuts import render_to_response
from datetime import datetime
from sake.node.models import Section
from sake.article.models import Article
from django.core.paginator import Paginator
from django.template import RequestContext
from django.template.defaultfilters import slugify

def add_article(request, sect):
  if request.user.is_authenticated():
if request.user.is_superuser or request.user.groups.filter
(name=sect).count():
  if request.method == 'POST':
form = AddArticleForm(request.POST)
if not form.slug:
  form.slug = slugify(form.title)
if form.is_valid():
  article = form.save(commit=False)
  article.author = request.user
  article.created = datetime.now()
  article.section = Section.objects.get(keyword=sect)
  article.save()
  return render_to_response('thanks.html',
context_instance=RequestContext(request))
  else:
form = AddArticleForm()
  return render_to_response('article/add_article.html', {'form':
form}, context_instance=RequestContext(request))
  return render_to_response('needperms.html',
context_instance=RequestContext(request))

==

The error comes up in views.py from the add_article() method, the line
"if not form.slug:"  The error itself is: 'AddArticleForm' object has
no attribute 'slug'

This is pretty odd to me, since it seems clear to me from the
declaration that AddArticleForm does have that attribute.  Further,
this used to work.

I am in the HEAD revision of django as of a few minutes ago, 

Re: Limit the number of forms in a Formset.

2009-06-23 Thread Sonal Breed

Thanks a lot Karen,
I cannot thank you enough.. The solution worked and solved many of my
problems.

Thanks a ton!
Sonal.

On Jun 19, 7:46 pm, Karen Tracey  wrote:
> On Fri, Jun 19, 2009 at 5:01 PM, Sonal Breed  wrote:
>
> > Hi all,
> > I am trying to display a formset in my application such that it only
> > contains number of forms equal to number of database instances.
>
> > My models are as below:
> > class Card(models.Model):
> >  name = models.CharField(max_length=20, blank=False, null=False,
> > unique=True)
> >   def __str__(self):
> >    return self.name + " Card"
>
> > class CardRow(models.Model):
> >  card = models.ForeignKey(ContactCard, related_name='data')
>
> >  name = models.CharField(max_length=22, blank=False, null=False)
> >  phone1 = models.CharField(max_length=20, blank=True)
> >  relation=models.CharField(max_length=30, blank=True)
> >  location=models.CharField(max_length=30, blank=True)
>
> > My forms are:
> > class CardForm(forms.ModelForm):
> >  class Meta:
> >    model = Card
>
> > class CardRowForm(forms.ModelForm):
> >  class Meta:
> >    model = CardRow
> >    exclude = ('card',)
>
> > CardRowFormSet = inlineformset_factory(Card, CardRow,max_num=10,
> > extra=10)
>
> (Note the forms you mention above aren't being used when you create
> CardRowFormSet. As they are no different from what you're going to get by
> default that's no problem but I'm not sure why you have created these forms
> at all?)
>
>
>
> > I want in the formset, the number of forms to be equal to number of
> > rows per card.
> > I have tried many combinations for max_num and extra fields, but in
> > vain.
>
> > Can somebody throw light on this issue??
>
> Specify extra=0, since you don't want any extra forms and extra defaults to
> 3.  You don't need to specify anything for max_num as by default the number
> of inline forms will be determined by the number of CardRows that exist for
> the Card instance you specify when you instantiate the formset.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changes to views and forms are not reflected in browser

2009-06-23 Thread neridaj

I'm new to django, so I'm not sure how to do that. I'm on shared
hosting, is that normally allowed?

On Jun 17, 11:34 pm, Thomas Guettler  wrote:
> Hi,
>
> Does restarting apache or fast cgi server help? Do you access the page
> through a proxy?
>
>  Thomas
>
> neri...@gmail.com schrieb:
>
> > Hello,
>
> > I'm trying to makechangesto views and forms but when I refresh the
> > browser to view/try thechangesnothing seems to have changed. I
> > normally do "touch dispatch.fcgi" which is working with templates and
> > urls but with views and forms I get nothing different. I tried other
> > browsers and cleared my cache as well.
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



makemessages .. not all translations found or commented out

2009-06-23 Thread Niels

I have text  (in .html, .py an .txt) that should be translated.

When I use this command
./manage.py makemessages -l nl   --
pythonpath=apps_pinax,templates_pinax

It finds translations in the html file like:
#: templates_pinax/tribes/topics.html:11
msgid "Discussion Topics for Tribe"
msgstr "Discussies van groep"

when I use this command
./manage.py makemessages -l nl  -e=html,txt,py --
pythonpath=apps_pinax,templates_pinax

It finds also text in the txt files.. but it also comments out parts
of translations I found with the first command like

#~ msgid "Discussion Topics for Tribe"
#~ msgstr "Discussies van groep"

any suggestions would be helpful.









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



can't adapt error

2009-06-23 Thread sico

Hey,

I was getting a weird can't adapt error when saving a record.
Previous posts talked about charset conversions, unicode, etc...

The problem I had turned out to be trying to write an object reference
where I should have put the key value instead.

e.g.

rec["myfk"] = myObj

changed to:

rec["myfk"] = myObj.pk

and it fixed it.

Just posting incase anyone else encounters the same problem!

Regards,
Si

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



Re: psycopyg setup error: no build_ext

2009-06-23 Thread James Bennett

On Tue, Jun 23, 2009 at 2:33 PM, James
Martin wrote:
> I was never able to get psycopg2 to compile on osx I recommend
> using sqlite for development or another database.  If you must use
> psycopg2, you may want to try to get it through something like
> darwinports.

I've gotten it to compile cleanly a couple of times, but generally the
easiest method is to grab a pre-built package from here (versions for
Python 2.4 are also available on the same site):

http://pythonmac.org/packages/py25-fat/


-- 
"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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Uploading Images

2009-06-23 Thread Roboto

{% if form.is_multipart %}

{% else %}

{% endif %}
{{ form }}


http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files

On Jun 15, 12:59 am, Oleg Oltar  wrote:
> I made a mistake in view.py.
> Corrected version is
> def handleUploadedFile(file):
>     destination = open('usermedia/new.jpg', 'wb+')
>     for chunk in file.chunks():
>         destination.write(chunk)
>     destination.close()
>     return destination
>
> def user_profile(request, profile_name):
>     owner = get_object_or_404(User, username = profile_name)
>     ownersProfile =get_object_or_404(UserProfile, user = owner)
>     form = ProfileEdit(request.POST)
>     if request.method == 'POST':
>
>         if form.is_valid():
>             ownersProfile.about = form.cleaned_data['about']
>             ownersProfile.avatar = handleUploadedFile(request.FILES['file'])
>             ownersProfile.save()
>             return HttpResponseRedirect("/")
>         else:
>             form = ProfileEdit()
>
> Also changed a little bit template:
> 
>   {{ form.as_p }}
>   
> 
>
> But I am getting:
> MultiValueDictKeyError at /account/profile/test
>
> "Key 'file' not found in "
>
> :(
>
>
>
> On Mon, Jun 15, 2009 at 6:54 AM, Oleg Oltar wrote:
> > Hi!
>
> > I know that the problem probably was discussed many times already, but
> > I really can't make it working.
>
> > I read the documentation and prepared the following code:
>
> > model:
>
> > class UserProfile(models.Model):
> >    """
> >    User profile model, cintains a Foreign Key, which links it to the
> >    user profile.
> >    """
> >    about = models.TextField(blank=True)
> >    user = models.ForeignKey(User, unique=True)
> >    ranking = models.IntegerField(default = 1)
> >    avatar = models.ImageField(upload_to="usermedia", default = 
> > 'images/js.jpg')
>
> >    def __unicode__(self):
> >        return u"%s profile" %self.user
>
> > form:
>
> > class ProfileEdit(forms.Form):
> >    about = forms.CharField(label = 'About', max_length = 1000, 
> > required=False)
> >    avtar = forms.ImageField()
>
> > view:
> > def handleUploadedFile(file):
> >    destination = open('usermedia/new.jpg', 'wb+')
> >    for chunk in file.chunks():
> >        destination.write(chunk)
> >    destination.close()
> >    return True
>
> > def user_profile(request, profile_name):
> >    owner = get_object_or_404(User, username = profile_name)
> >    ownersProfile =get_object_or_404(UserProfile, user = owner)
> >    form = ProfileEdit(request.POST)
> >    if request.method == 'POST':
> >        form = ProfileEdit(request.POST, request.FILES)
> >        if form.is_valid():
> >            handleUploadedFile(request.FILES['file'])
> >        else:
> >            form = ProfileEdit()
>
> >    data = RequestContext(request,
> >                          {
> >            'owner' : owner,
> >            'ownersProfile' : ownersProfile,
> >            'form' : form
> >            }
> >                          )
> >    return render_to_response('registration/profile.html', data)
>
> > And part of template:
>
> > 
> >  {{ form.as_p }}
> >  
> > 
>
> > After trying this code in browser I am getting a text field with
> > browse button, so when I chose file to upload, and finally click
> > upload I am getting 404 Error.
> > Not sure what I might doing wrong.
> > Please help
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: application scope objects? (maybe need cherrypy instead)

2009-06-23 Thread qwcode

2 examples of where you'd want this:
  1) storing a compiled xslt template (which is thread safe) that will
be used repeatedly
  2) storing a pylucene IndexSearcher object (which is thread safe)
which are expensive to recreate

from searching the archive, this question is coming up a lot (usually
with the words "global variable") but with no real answers

it makes me think cherrypy (or a java app running in a servlet
container) would be a better choice than django if you need
application scope.  cherrypy is a server that doesn't live and die
with the request
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopyg setup error: no build_ext

2009-06-23 Thread James Martin

I was never able to get psycopg2 to compile on osx I recommend
using sqlite for development or another database.  If you must use
psycopg2, you may want to try to get it through something like
darwinports.

On Tue, Jun 23, 2009 at 1:19 PM, Chris Haynes wrote:
>
> Using what I believe is the latest version of psycopyg, I get:
>
> 509 ~/Desktop/psycopg2-2.0.9$ python setup.py build
> running build
> running build_py
> creating build
> creating build/lib.macosx-10.3-fat-2.6
> creating build/lib.macosx-10.3-fat-2.6/psycopg2
> copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
> running build_ext
> error: No such file or directory
>
> and easy_install doesn't work either (seems like the same problem):
>
> 510 ~/Desktop/psycopg2-2.0.9$ easy_install .
> Processing .
> Running setup.py -q bdist_egg --dist-dir /Users/home/Desktop/
> psycopg2-2.0.9/egg-dist-tmp-mYsMSq
> error: Setup script exited with error: No such file or directory
> >
>

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



Re: NoReverseMatch error during Django 1.0 tutorial

2009-06-23 Thread Rafa Muñoz Cárdenas

return HttpResponseRedirect(reverse
('mysite.polls.vews.results', args=(p.id,)))

As you see, there is a mistake in "vews".
return HttpResponseRedirect(reverse
('mysite.polls.views.results', args=(p.id,)))

Now it should work :)

On 21 jun, 19:11, ebbnormal  wrote:
> Hello,
>
> I am still working on the Django 1.0 tutorial (http://
> docs.djangoproject.com/en/1.0/intro/tutorial04/) and
> got the following error after voting on my poll ( which simply makes a
> call to the Django reverse function which is supposed to give control
> to my results function in polls.views).
>
> The error is the following:
>
> NoReverseMatch at /polls/1/vote/
> Reverse for 'mysite.polls.vews.results' with arguments '(1,)' and
> keyword arguments '{}' not found.
>
> and my views.py is the following:
>
> from mysite.polls.models import  Choice, Poll
> from django.shortcuts import get_object_or_404, render_to_response
> from django.core.urlresolvers import reverse
> from django.http import HttpResponseRedirect
>
> # ...
>
> def vote(request, poll_id):
>     p = get_object_or_404(Poll, pk=poll_id)
>     try:
>         selected_choice = p.choice_set.get(pk=request.POST['choice'])
>     except (KeyError, Choice.DoesNotExist):
>         return render_to_response('detail.html', {
>             'poll': p,
>             'error_message': "You didnt select a choice.",
>         })
>
>     else:
>         selected_choice.votes += 1
>         selected_choice.save()
>         return HttpResponseRedirect(reverse
> ('mysite.polls.vews.results', args=(p.id,)))
>
> def results(request, poll_id):
>     p = get_object_or_404(Poll, pk=poll_id)
>     return render_to_response('results.html', {'poll': p})

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



null values should work here but don't

2009-06-23 Thread K.C. Smith

I want to (optionally) leave some fields in a model/table NULL.  I've
set the options "null=True" and "blank=True" for the fields in
question.  I know it's working because the admin site add form greyed
out the "blank=True" fields.  But, I still can't add an object with
these fields blank/NULL.  I get this error (in part):

Exception Type: DataError
Exception Value:invalid input syntax for type inet: ""
Exception Location: /usr/local/lib/python2.5/site-packages/django/db/
backends/util.py in execute, line 19
Python Executable:  /usr/local/bin/python
Python Version: 2.5.4

I'm using Postgres and the psycopg2-2.0.9 module. And other models/
tables without null values are working fine.

I did check the DB to make sure that "not null" wasn't set.  I even
dropped the table and then did another syncdb.  But, I still keep
getting this same error.

To try to test whether the error was coming from the DB or Django, I
inserted a couple of rows manually: once specifying the columns (and
omitting the nulls), and once by using the NULLs explicitly).
Succeeded both times, so I'm inclined to believe that this error is
coming from Django and not the database. Any ideas?  Thanks.

K.C.

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



Re: learning django

2009-06-23 Thread virgo

thank u very much..

On Jun 2, 4:52 pm, Hernan Olivera  wrote:
> 2009/6/2virgo:
>
>
>
> > I am very new to this field..got a job as python programmer and was
> > asked to use django for web developmentHow do u think I should
> > start learning...I dont have much time left before they kick me
> > out!!
>
> You must follow the tutorial, and the django book, first.
>
> It is really easy. Do it yourself, not just reading or cut & paste.
>
> Familiarize yourself with Django's documentation, and look for
> available Django books.
> Look for Django code, and try to see how it works.
>
> Good luck!!
>
> --
> Hernan Olivera

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



Re: Using pluralize with floats?

2009-06-23 Thread Adam V.

Float is an inexact numeric type, so this sort of thing gets
problematic.

For a "number of bathrooms" field, why not use a CharField with a
limited set of choices or custom validation?

On Jun 23, 12:19 pm, Peter Schroeder 
wrote:
> Hello,
>
> Has anyone tried to use pluralize template tag with a float value? I
> am thinking of submitting a patch to support this functionality.
>
> For instance, using the value 1.5 returns a singular suffix from
> pluralize. I am implementing a real estate web application where a
> house could have 1.5 bathrooms, for example.
>
> Thanks,
>
> Pete
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using pluralize with floats?

2009-06-23 Thread Peter Schroeder

Hello,

Has anyone tried to use pluralize template tag with a float value? I
am thinking of submitting a patch to support this functionality.

For instance, using the value 1.5 returns a singular suffix from
pluralize. I am implementing a real estate web application where a
house could have 1.5 bathrooms, for example.

Thanks,

Pete

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



upload_to ignored outside of admin?

2009-06-23 Thread ryan

class Creative(models.Model):
creative = models.FileField(upload_to='creative')
element = models.ForeignKey(Element)

#views.py(1)
attachment = request.FILES[attachment_num]
element.creative_set.create(creative=attachment)

#views.py(2)
attachment = request.FILES[attachment_num]
Creative.objects.create(creative=attachment,element=new_element)

Both of these make an entry in the database 'filename.txt'
But doing so from the admin results in 'creative/filename.txt' which
is what i want

Can anyone spot an error?
Do I have to pass upload_to to create function in views.py?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Passing a param in __init__ of an inlineformset

2009-06-23 Thread martyn

Hi,

I was looking for solutions to pass a param into forms created with
inlineformset.
Basicaly, I want to prepopulate a ChoiceField of my form with datas
which comes from parent.parent.instance

I've pasted the entire code (models / forms / views) here
http://friendpaste.com/2Rtzh6wOiUMQA0aRJTpC0Q

The only thing I need to do is to pass a param into a Form.__init__
which is used with inlineformset

Thank you for helping 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to not saving models

2009-06-23 Thread Matías Costa
This gets ugglier at each step, think twice before doing this.
Django uses thread storage for django.db.connection, so what seems a simple
object is unique to the request and safe. The quick and dirty way is to
place a middleware after auth, and set something in django.db.connection.

PD: django.db.connection is the name I recall from memory. May be
django.models.db.connection or django.core.db.connection or ... etc

On Tue, Jun 23, 2009 at 3:42 PM, ReneMarxis  wrote:

>
> Hey Matias.
>
> Many thanks for your answer. This is what my 'new' manage.py looks
> like:
>
> http://dpaste.com/58713/
>
> and it seems to work. At least no data is saved any longer :)
>
> But next question is not far away:
> I can use pass or return forig(self) according to if i'd like to save
> or not (is this ok at all?), but how can i check session data. There
> is no request/response loop right?
>
> PS: Monkey patching... very nice this :)
>
> On 23 Jun., 13:38, Matías Costa  wrote:
> > Monkey patch django.db.model.save
> > Where? in manage.py?
> >
> > On Tue, Jun 23, 2009 at 12:56 PM, ReneMarxis 
> wrote:
> >
> > > what i forgot to say: Of course i don't like to change all models-
> > > code. Some 'global' solution is what i am looking for.
> >
>

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



Re: Template tag testing

2009-06-23 Thread brianmac44


On Jun 23, 12:00 pm, Michael  wrote:
> On Tue, Jun 23, 2009 at 11:53 AM, brianmac44  wrote:
> I don't know if this is best practice, but here is the way I test my
> template tags essentially by rendering the templates:
>
> http://bitbucket.org/newmaniese/newmanutils/src/tip/newmanutils/tests.py

Thanks Michael.

That was a good start for me.  My tag needed some context from the
testing client.
http://dpaste.com/58833/

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



psycopyg setup error: no build_ext

2009-06-23 Thread Chris Haynes

Using what I believe is the latest version of psycopyg, I get:

509 ~/Desktop/psycopg2-2.0.9$ python setup.py build
running build
running build_py
creating build
creating build/lib.macosx-10.3-fat-2.6
creating build/lib.macosx-10.3-fat-2.6/psycopg2
copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
running build_ext
error: No such file or directory

and easy_install doesn't work either (seems like the same problem):

510 ~/Desktop/psycopg2-2.0.9$ easy_install .
Processing .
Running setup.py -q bdist_egg --dist-dir /Users/home/Desktop/
psycopg2-2.0.9/egg-dist-tmp-mYsMSq
error: Setup script exited with error: No such file or directory
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



currying variables into ModelForm subclasses

2009-06-23 Thread Steve Howell

I have an application with a single method called member_create that
presents a form to collect membership information and save it to the
database.  Depending on the project configuration and user I have
different membership forms, so I have a line of code like this in
member_create():

member_edit_form_class = get_member_edit_form_class
(membership_type)

Up until recently, get_member_edit_form would return either
GenericMemberEditForm or SpecialMemberEditForm, where the latter
inherited from the former.  All of that was relatively
straightforward.  Just to be clear, get_member_edit_form_class was
returning a class, not an instance, since member_create would
instantiate the class later as needed:

if request.method == 'POST':
form = member_edit_form_class(request.POST, request.FILES)
...
else:
form = member_edit_form_class()


Things got a little more interesting, though, when our "Special"
customer wanted further refinements in the form's behavior based on
membership type.  Trying to keep member_create() generic, I put logic
like this in the SpecialMemberEditForm class:

def __init__(self, *args, **kwargs):
membership_type = kwargs.pop('membership_type', None)
super(SpecialMemberEditForm, self).__init__(*args, **kwargs)
if membership_type.name == 'whatever':
 self.fields['options'].queryset = ...
else:
 self.fields['options'].queryset = ...

I wanted the member_create() method not to have any knowledge of this
extra parameter, for a few reasons:

  1) I wanted to keep member_create() as generic as possible.
  2) I already had a factory method called get_member_edit_form_class
(), so I wanted the factory method to configure the classes as
needed.  (I am using "factory" in the loose sense--I don't know the
exact terminology for a method that returns a class, not an instance.)
  3) I didn't want member_create() to pass in the extra parameter to
any class other than SpecialMemberEditForm, since
GenericMemberEditForm had no use for that parameter, and it would be
brittle to have all member edit forms follow the contract of popping
off unused parameters.
  4) To elaborate on the prior point, the forms all have BaseModelForm
as an ancestor, and BaseModelForm's __init__ method cannot deal
gracefully with extraneous keyword arguments, perhaps for good reason.

In order to allow get_member_edit_form_class to configure
SpecialMemberEditForm as needed, I wrote code like this:

def special_get_member_edit_form_class(membership_type):
# we curry membership_type here so that other code never needs
to
# deal with extra parms
def curry(*args, **kwargs):
kwargs['membership_type'] = membership_type
return SpecialMemberEditForm(*args, **kwargs)
return curry

Essentially, the method above is not returning a class--instead it's
returning a method, but that method generally provides the illusion of
being a class in a pythonic sort of way, since it has the same
behavior when used as a callable (it returns an instance).

This worked exactly as expected in member_create(), but then I got
around to updating member_update(), which works like this:

member_edit_form_class = get_member_edit_form_class
(membership_type)

return create_update.update_object(request,
   post_save_redirect=...,
 
form_class=member_edit_form_class,
 
template_name='member_form.html',
   **kwargs)

Here is where the illusion broke down.  The update_object method
really wants member_edit_form_class to be a subclass of Form, not just
a callable that produces a Form subclass instance.

In particular, this line of code fails inside get_model_and_form_class
(), which gets called by update_object():

return form_class._meta.model, form_class

Basically what is happening at this point is that form_class is the
same as curry above, and curry does not have an attribute called
_meta, since curry is not exactly a subclass of Form; instead, it is a
method that returns an instance of Form.  So I added one line of code
to solve the problem:

curry._meta = SpecialMemberEditForm._meta

So now everything works, but it still feels a little dirty and
brittle, and I'm wondering if others have solved similar problems
using different design patterns.  The situation is not as esoteric as
perhaps it looks--really, it's just a scenario where we are trying to
keep one method DRY with a couple different forms that can be plugged
in, and one form class needs to be configured before instantiation.

I know that django has some helpers related to partial functions, but
I haven't had luck tracking down documentation, so any pointers there
are welcome, even if they don't exactly solve my problem.  I think I
am doing something a little different from the normal partial/currying
use case, but I also bet somebody has solved my problem before.


Re: Empty [] using objects.all() on legacy database

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 12:04 PM, Greg Corey  wrote:

> Ok. I will work on opening a ticket based on your recommendation, though I
> will not have your depth of analysis on the problem. Mind if I quote your
> most recent explanation if needed?
>

Sure, but it's probably not necessary, though you could include a pointer to
this thread in the Google group's archive for the group for reference
purposes.  For the ticket description all you need to do is describe the
problem from the user's level.  You've got an existing database with a table
that has a column name with a % in it.  Unless you double the % when you
specify it in db_column for the associated Django model field, you cannot
access data in this table via your Django model.  Needing to double the % in
this parameter is entirely non-obvious and (I'm assuming -- you might want
to verify this) not documented, so it either should not be necessary or
needs to be documented.  (If in fact you find that the description of
db_column somewhere says %s in column names need to be doubled, then never
mind about a ticket...but I'd be surprised if that were the case.)

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django admin interface for Web service

2009-06-23 Thread Kusako

Hi-

I need to access an XMLRPC web service from the Django admin
interface. Basically what I need is some create forms that will send
data to the web service instead of storing to a database.
As I'm  somewhat new to Django I'm wondering about the best way to
accomplish this. Should I just create custom views for the create
forms and link them to the admin site? Or is there a way to use
models, but instead of storing them in the database, send them to the
web service?

Thanks for any help,

-markus

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



Re: CSS admin panel when deploy django application on Apache2

2009-06-23 Thread jose antunes
usually that problem is resolved by creating a .htaccess file in the
directory were the css resides with AddType /text/css .css because otherwise
the server transfers the css as text/html.

In the case of django the problem may be also because the css file for the
admin panel is outside of the server "jurisdiction" in
../../django/contrib/admin/media/css. For this problem I also would like to
find a solution.

2009/6/23 kiwi 

>
> Hi, I've a problem with CSS of admin panel of Django when I deploy my
> web application on Apache2. Everything works, only Css of admin's
> panel do not works correctely... Someone can help me?
>
> Thanks
>
> This is my httpd.conf file
>
>
> #WSGIDaemonProcess sds user=utente group=utente threads=25
> #WSGIProcessGroup utente
>
> #Module mod_python#
> #LoadModule python_module /usr/lib/apache2/modules/mod_python.so
>
> #Module mod_wsgi#
> LoadModule wsgi_module modules/mod_wsgi.so
>
> ServerName /etc/apache2/sites-available/default
>
> #Dico ad apache di prendere le configurazioni da un file esterno
> definito all'interno della mia applicazione
> #Include "/home/utente/www/python/sds/apache/django_wsgi.conf"
>
> #basta eseguire solo un alias per specificare al server che deve
> gestire i media
> Alias /media_admin/ /home/utente/www/python/sds/media/contrib/admin/
> media
> Alias /media /home/utente/www/python/sds/media/
>
> #permessi per la directory media
> 
> Order deny,allow
> Allow from all
> 
>
> #specifica file per il deploy
> WSGIScriptAlias / /home/utente/www/python/sds/apache/django.wsgi
>
> #permessi per la directory apache
> 
> Order deny,allow
> Allow from all
> 
> >
>

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



Re: Empty [] using objects.all() on legacy database

2009-06-23 Thread Greg Corey
Ok. I will work on opening a ticket based on your recommendation, though I
will not have your depth of analysis on the problem. Mind if I quote your
most recent explanation if needed?

Greg

On Tue, Jun 23, 2009 at 8:41 AM, Karen Tracey  wrote:

> On Mon, Jun 22, 2009 at 2:19 PM, Erik Vorhes  wrote:
>
>>
>> On Mon, Jun 22, 2009 at 12:52 PM, Greg Corey wrote:
>> > Karen, the double % ( i.e. 'discount%%') worked. Is this a big enough
>> bug
>> > that it should be reported? I'm not sure what is a bug and what is just
>> my
>> > ignorance. Thank you sooo much for the help.
>>
>> The first % escapes the second % sign, and thus allows for the actual
>> symbol to display. This is because Python uses % to include variables,
>> etc., into a string. So it's not a bug at all.
>>
>
> But we're talking about the the db_column parameter for a model field
> definition here.  I don't see that it's at all obvious that one should need
> to escape % symbols there.  I see how down in the depths of passing SQL to
> the database (for the one backend I looked at, MySQL) it needs to have been
> done, when args are being passed with the SQL, because the DB backend is
> going to use string interpolation to place the args into the SQL and if the
> % in the column name hasn't been escaped there won't be enough actual passed
> args  for the interpolation.
>
> But I don't know if that code is the same for all backends, nor do I know
> if Django consistently uses and empty tuple for the no-args case vs. passing
> None for args.  If it ever does the latter, doubling the % in the db_column
> specification won't work because when None is passed for args string
> interpolation isn't done, and the doubled % would be passed as the column
> name.
>
> All in all I think it would be good to open a ticket to track this.  I
> don't have time to look into it any more deeply right now.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template tag testing

2009-06-23 Thread Michael
On Tue, Jun 23, 2009 at 11:53 AM, brianmac44  wrote:

>
> I tried to test template tags with doctests and unittests but I'm not
> sure what token and/or context to use. What's the best practice for
> testing template tags?
>

I don't know if this is best practice, but here is the way I test my
template tags essentially by rendering the templates:

http://bitbucket.org/newmaniese/newmanutils/src/tip/newmanutils/tests.py

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



Template tag testing

2009-06-23 Thread brianmac44

I tried to test template tags with doctests and unittests but I'm not
sure what token and/or context to use. What's the best practice for
testing template tags?

Thanks,

Brian

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



Re: CSS admin panel when deploy django application on Apache2

2009-06-23 Thread Daniel Roseman

On Jun 23, 4:08 pm, kiwi  wrote:
> Hi, I've a problem with CSS of admin panel of Django when I deploy my
> web application on Apache2. Everything works, only Css of admin's
> panel do not works correctely... Someone can help me?
>
> Thanks
>


> Alias /media_admin/ /home/utente/www/python/sds/media/contrib/admin/
> media

Does this line match the value of ADMIN_MEDIA_PREFIX in your
settings.py? Usually it's set to '/media/', so unless you've changed
it that would explain why your admin CSS isn't being loaded.
--
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



CSS admin panel when deploy django application on Apache2

2009-06-23 Thread kiwi

Hi, I've a problem with CSS of admin panel of Django when I deploy my
web application on Apache2. Everything works, only Css of admin's
panel do not works correctely... Someone can help me?

Thanks

This is my httpd.conf file


#WSGIDaemonProcess sds user=utente group=utente threads=25
#WSGIProcessGroup utente

#Module mod_python#
#LoadModule python_module /usr/lib/apache2/modules/mod_python.so

#Module mod_wsgi#
LoadModule wsgi_module modules/mod_wsgi.so

ServerName /etc/apache2/sites-available/default

#Dico ad apache di prendere le configurazioni da un file esterno
definito all'interno della mia applicazione
#Include "/home/utente/www/python/sds/apache/django_wsgi.conf"

#basta eseguire solo un alias per specificare al server che deve
gestire i media
Alias /media_admin/ /home/utente/www/python/sds/media/contrib/admin/
media
Alias /media /home/utente/www/python/sds/media/

#permessi per la directory media

Order deny,allow
Allow from all


#specifica file per il deploy
WSGIScriptAlias / /home/utente/www/python/sds/apache/django.wsgi

#permessi per la directory apache

Order deny,allow
Allow from all

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



Re: Diffents admin sites into the same project

2009-06-23 Thread KrcK

Hi again!

My problem was that I thought that I've to create a class that inheritance 
from AdminSite and then used it to register my models, so when I wanted to 
hook MyAdminSite in my urls I didn't know how I could do that...

After read your answer I've got to do it. And now I've my three different 
admin sites. I didn't know this behavior but I like a lot! I want to learn 
about the Django Admin Site capabilities.

Thanks Rusell!

On Tuesday, 23 de June de 2009 14:06:24 Russell Keith-Magee wrote:
> On Tue, Jun 23, 2009 at 5:55 AM, KrcK wrote:
> > Hi group!
> >
> > I've a problem with AdminSite. I don't know how can I get 3 admin sites
> > differents and if it's posible to do it.
>
> It is certainly possible, and it's documented:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adminsite-objects
>
> You mention that you've read this but you don't understand it - the
> docs give a complete worked example for how to hook two admin sites
> into your URL patterns - all that is left is to instantiate a new
> AdminStite object.
>
> django.contrib.admin.site is just an instance of AdminSite(); you can
> create your own instance by calling
>
> myadmin = AdminSite()
>
> Then register you apps with the new site instance:
>
> myadmin.register(MyModel)
>
> and hook myadmin into your urls.py.
>
> If you require any more help than this, you will need to be a little
> more specific about what is causing you difficulties - what you have
> tried, why you tried it, what happens when you tried, etc. Without
> knowing the source of your confusion, it's very hard to provide
> assistance.
>
> Yours,
> Russ Magee %-)
>
> 

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



Re: Error -- 'str' object has no attribute 'creation_counter'

2009-06-23 Thread Karen Tracey
On Tue, Jun 23, 2009 at 2:02 AM, Phil  wrote:

> I'm sure I had this working before, but since then I have installed
> the composite primary key patch and I notice the 2nd to last traceback
> is in class CompositePrimaryKey... Could this be something to do with
> it?? All ideas appreciated
>

Certainly if you see code from the patch in the traceback then I'd be
inclined to suspect the patch as the cause.  Next step would be to try to
recreate the error without the patch -- if you can't, that would be more
evidence there is some situation the patch isn't handling properly.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Empty [] using objects.all() on legacy database

2009-06-23 Thread Karen Tracey
On Mon, Jun 22, 2009 at 2:19 PM, Erik Vorhes  wrote:

>
> On Mon, Jun 22, 2009 at 12:52 PM, Greg Corey wrote:
> > Karen, the double % ( i.e. 'discount%%') worked. Is this a big enough bug
> > that it should be reported? I'm not sure what is a bug and what is just
> my
> > ignorance. Thank you sooo much for the help.
>
> The first % escapes the second % sign, and thus allows for the actual
> symbol to display. This is because Python uses % to include variables,
> etc., into a string. So it's not a bug at all.
>

But we're talking about the the db_column parameter for a model field
definition here.  I don't see that it's at all obvious that one should need
to escape % symbols there.  I see how down in the depths of passing SQL to
the database (for the one backend I looked at, MySQL) it needs to have been
done, when args are being passed with the SQL, because the DB backend is
going to use string interpolation to place the args into the SQL and if the
% in the column name hasn't been escaped there won't be enough actual passed
args  for the interpolation.

But I don't know if that code is the same for all backends, nor do I know if
Django consistently uses and empty tuple for the no-args case vs. passing
None for args.  If it ever does the latter, doubling the % in the db_column
specification won't work because when None is passed for args string
interpolation isn't done, and the doubled % would be passed as the column
name.

All in all I think it would be good to open a ticket to track this.  I don't
have time to look into it any more deeply right now.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django - how to work with Ajax requests?

2009-06-23 Thread Joshua Russo

On Jun 23, 12:49 pm, "http://groups.google.com/group/django-users/;
 wrote:
> Hello everyone,
> i got a problem with working with Ajax requests @ the Admin models.
> How can i get requests from Ajax to the AdminModel to get 4 example
> from a dropdownmenu my manytomanyfield changed.
> its tricky! Have not found something @ the docu or something else...
>
> Thanks 4 reading,
> Chris

This is what I did: http://www.djangosnippets.org/snippets/1588/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to use Sum function with expression

2009-06-23 Thread Alex Gaynor
On Tue, Jun 23, 2009 at 7:31 AM, Russell Keith-Magee  wrote:

>
> On Tue, Jun 23, 2009 at 2:36 AM, pr wrote:
> >
> > Hi,
> >
> > I want to get total price (quantity*price) in this example for objest
> > list (not one) of A class
> >
> > class A(models.Model)
> >  name = models.CharField(max_length=255)
> >
> > class B(models.Model)
> >  quantity = models.PositiveIntegerField()
> >  price = models.DecimalField(max_digits=10, decimal_places=2)
> >  a = models.ForeignKey(A)
> >
> > I try:
> > A.objects.all().select_related().annotate(my_sum=Sum
> > ('b__price*b__quantity'))
> > but it doesn't work...
>
> You can't currently annotate a computed expression onto a model (at
> least, not using the annotate() clause). You can only annotate an
> aggregate, which must be a Sum/max/min etc of a single field.
>
> For the moment, if you want to do something like this, you will need
> to look into using extra(select=...), or using custom SQL.
>
> Annotating computed fields is something that I would like to add in
> the future, but probably it probably won't get done until at least
> Django v1.2, probably later (unless someone else volunteers to do the
> work).
>
> Yours,
> Russ Magee %-)
>
> >
>
It's actually possible if you write you're own custom aggregate (and I feel
confident that writing an aggregate that could work with F() objects
wouldn't be overly difficult, and even if it is writing one that ahrd codes
your expression would be near trivial).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Django - how to work with Ajax requests?

2009-06-23 Thread http://groups.google.com/group/django-users/

Hello everyone,
i got a problem with working with Ajax requests @ the Admin models.
How can i get requests from Ajax to the AdminModel to get 4 example
from a dropdownmenu my manytomanyfield changed.
its tricky! Have not found something @ the docu or something else...

Thanks 4 reading,
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Encryption question

2009-06-23 Thread Brian Neal

On Jun 23, 8:39 am, daniel  wrote:
> Good morning,
>
> I have a MySQL (version 5.0.5 running on Ubuntu 8.04) database
> containing encrypted fields (the encryption was done using mysql's
> AES_ENCRYPT). The database is normally accessed by an application
> written in C++ and Qt. However, I also need to access the database
> thru a web server and I am getting started with django  (1.0).
>
[snip]
> Any suggestions on how I can mix the encryption/decryption of values
> using these two applications?
> Or is it possible for django to use MySQL functions such as
> AES_ENCRYPT/AES_DECRYPT in a query?
>

I don't know about the first part of your question, but you can use
raw SQL in Django:

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

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



Re: how to not saving models

2009-06-23 Thread ReneMarxis

Hey Matias.

Many thanks for your answer. This is what my 'new' manage.py looks
like:

http://dpaste.com/58713/

and it seems to work. At least no data is saved any longer :)

But next question is not far away:
I can use pass or return forig(self) according to if i'd like to save
or not (is this ok at all?), but how can i check session data. There
is no request/response loop right?

PS: Monkey patching... very nice this :)

On 23 Jun., 13:38, Matías Costa  wrote:
> Monkey patch django.db.model.save
> Where? in manage.py?
>
> On Tue, Jun 23, 2009 at 12:56 PM, ReneMarxis  wrote:
>
> > what i forgot to say: Of course i don't like to change all models-
> > code. Some 'global' solution is what i am looking for.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Encryption question

2009-06-23 Thread daniel

Good morning,

I have a MySQL (version 5.0.5 running on Ubuntu 8.04) database
containing encrypted fields (the encryption was done using mysql's
AES_ENCRYPT). The database is normally accessed by an application
written in C++ and Qt. However, I also need to access the database
thru a web server and I am getting started with django  (1.0).

The encryption key is 16 characters long, and the encrypted fields are
defined as VARBINARY(64) in MySQL.

I have a djando view where I want to display the decrypted data. The
decryption is performed by Python (version 2.5.2) using the library
Crypto.Cipher (from Crypto.Cipher import AES).
Of course I use the same key in both applications.
I do have the following issues:
- It appears that I can only effectively encypt/decrypt the data using
the paired method, ie. using AES_DECRYPT() where data was encrypted
using the MySQL method, and decrypt the data where the encryption was
done by Python. If I tried to use AES_DECRYPT on data encrypted by the
python code, AES_DECRYPT() returns NULL.
- Decrypting data (read from MySQL) using the library Crypto.Cipher
(from Crypto.Cipher import AES), the decrypted sting is padded to a
length of 16 (or multiple of). For example

decryptString: decryptedStr = Deborah, length of string = 16
Subject's firstName = Deborah
Character (i = 0) 68
Character (i = 1) 101
Character (i = 2) 98
Character (i = 3) 111
Character (i = 4) 114
Character (i = 5) 97
Character (i = 6) 104
Character (i = 7) 9
Character (i = 8) 9
Character (i = 9) 9
Character (i = 10) 9
Character (i = 11) 9
Character (i = 12) 9
Character (i = 13) 9
Character (i = 14) 9
Character (i = 15) 9

In the case above, the string is padded with chr(9), but other strings
are padded with LF, or something else. The python code is listed here

def decryptString( strToDecrypt):
aesObject = AES.new( 'Example of a key', AES.MODE_ECB)
decryptedStr = aesObject.decrypt( strToDecrypt)
print "decryptString: decryptedStr = ", decryptedStr, " length of
string = ", len( decryptedStr);
return decryptedStr

Any suggestions on how I can mix the encryption/decryption of values
using these two applications?
Or is it possible for django to use MySQL functions such as
AES_ENCRYPT/AES_DECRYPT in a query?

Thanks
Daniel

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



Re: Question IMAGE in Django

2009-06-23 Thread Brian Neal

Also check the permissions on your images. I had set the
FILE_UPLOAD_PERMISSIONS to 0640 in development, but this wasn't
correct for my production server. Ensure that Apache or whatever user
the webserver is running has read access to your images.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Apache 2.2 >> Forbidden You don't have a permission to access /static_media on this server

2009-06-23 Thread Brian Neal

On Jun 23, 5:29 am, MarcoCanali  wrote:
> I have this error message from apache 2.2 server when i try to access
> at mine static_media for my django project. Apache serve my project in
> django without static file such as css or image ...

Check your file permissions. Can the apache process read them?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Apache 2.2 >> Forbidden You don't have a permission to access /static_media on this server

2009-06-23 Thread MarcoCanali


I have this error message from apache 2.2 server when i try to access
at mine static_media for my django project. Apache serve my project in
django without static file such as css or image ...


Post the main file did use:
Cartella Media : c:/python25/scripts/calculus/calculusdb/media
Directori Progetto: c:/python25/scripts/calculus/
Directori File Admin Django: c:/Django-1.0.2/Django/contrib/admin/
media
setting.py
BASE_DIR = '%s/' % os.path.abspath(os.path.dirname(locals()
['__file__'])).replace('\\', '/')
MEDIA_ROOT = BASE_DIR +'/statis_media/'
MEDIA_URL = '/static_media/'
ADMIN_MEDIA_PREFIX = '/media/'
urls.py
... +
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root),
if settings.DEBUG:
urlpatterns += patterns('django.views.static',
(r'^static_media/(?P.*)$',
'serve', {
'document_root': 'bvvgptdb/media',
'show_indexes': True }),)
httpd  Apache

SetHandler python-program
PythonPath "['C:/Python25/Scripts','C:/Python25/Scripts/
calculus'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE calculus.settings
PythonDebug On

Alias /static_media/ "C:/Python25/Scripts/calculus/calculus/media/"

SetHandler None


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



How to use F() expression to flip the boolean field

2009-06-23 Thread jay.sh...@gmail.com

Hi there,
I'm using django 1.1 beta now. There is a boolean column in my table.
I want to filp all the value, that is True to False and False to
True.
I found the F() expression in django 1.1 beta, and tried to use to to
satisfy my request but failed.
Here is my usage:
= code start =
class SomeModel(models.Model):
  display = models.BooleanField('display', default = False)

SomeModel.objects.update(display = not F('display'))
== code end ==

Did I make something wrong in the query? If so, how to fix it?
Many 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



application scope objects?

2009-06-23 Thread qwcode

coming from the java/servlet world, objects can be placed in the
"ServletContext",  thereby making their scope *application* level, not
per request.   Yes, you have to be conscious of thread safety in
putting an object there, but atleast you have this option.  There's
something similar for .Net apps

I guess this is not possible in a django/wsgi app?  You can put
objects into the cache, but they'll timeout.


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



Re: Need to upload outside of MEDIA_ROOT, but I get SuspiciousOperation error

2009-06-23 Thread Nick Day

That worked, 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Internationalization in django and search engine indexing

2009-06-23 Thread Olivier

Thanks yml.
The middleware part interests me a lot but I don't understand how the
code work in your post.
Do you use Django's LocaleMiddleware ? Where do you add the
language_code in the url ?
Finally, does it work with search engine indexing ? Because you still
need to change language with a link, don't you ?

My concern is really practical, I already have a site (http://
www.spiderchallenge.com) that is localized both in english and french
but google has only index the english content.

Thanks again,

Olivier


On 23 juin, 03:39, yml  wrote:
> This is the motivation for me to write this piece of middleware 
> :http://yml-blog.blogspot.com/search/label/Internationalisation
> --yml
>
> On Jun 22, 5:52 pm, Olivier  wrote:
>
>
>
> > Hello everyone,
>
> > I'm currently using django localization on my site to manage both
> > english and french. I'm using template tags blocktrans and block but
> > both the french & english pages have the same url. I'm wondering if
> > the search engines can work with this configuration and index the two
> > versions or should I use different url ?
>
> > I first tried to find if the question was already solved in a
> > different topic but I didn't see it, sorry if I'm wrong.
> >l
> > Thanks in advance,
>
> > Olivier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django 1.0.2 foreign key display puzzle

2009-06-23 Thread adelaide_mike

Hi Kenneth
I agree that on my reading of the literature what you say is right.
Here is my actual line adjusted as you suggest:
form = ListingForm(initial={'date': request.session['date'],
'source_id': '2',})
In this case the date field is correctly populated with the preset
date, the source foreign key widget is not, thus the user has to make
a choice.  I want the choice that I presume to be correct to be
already presented.

Surely this must be possible?  BTW I have tried every variation I can
think of at the end of that line, with quotes, without quotes, and as
a request.session value (that I know is set).

Thanks for your reply.

Mike
On Jun 23, 1:08 pm, Kenneth Gonsalves  wrote:
> On Tuesday 23 June 2009 09:14:01 adelaide_mike wrote:
>
> > form = MyModelForm(initial={'myforeignkeyfieldname': myvalue})
>
> assuming the foreignkey value exists, then you would have to insert it's id
> into the field myforeignkeyfieldname_id.
> --
> regards
> kghttp://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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to use Sum function with expression

2009-06-23 Thread Russell Keith-Magee

On Tue, Jun 23, 2009 at 2:36 AM, pr wrote:
>
> Hi,
>
> I want to get total price (quantity*price) in this example for objest
> list (not one) of A class
>
> class A(models.Model)
>  name = models.CharField(max_length=255)
>
> class B(models.Model)
>  quantity = models.PositiveIntegerField()
>  price = models.DecimalField(max_digits=10, decimal_places=2)
>  a = models.ForeignKey(A)
>
> I try:
> A.objects.all().select_related().annotate(my_sum=Sum
> ('b__price*b__quantity'))
> but it doesn't work...

You can't currently annotate a computed expression onto a model (at
least, not using the annotate() clause). You can only annotate an
aggregate, which must be a Sum/max/min etc of a single field.

For the moment, if you want to do something like this, you will need
to look into using extra(select=...), or using custom SQL.

Annotating computed fields is something that I would like to add in
the future, but probably it probably won't get done until at least
Django v1.2, probably later (unless someone else volunteers to do the
work).

Yours,
Russ Magee %-)

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



using multilingual fields to slugify urls

2009-06-23 Thread Marco Bazzani

ok this is a little bit complex problem (at least for me)

let's supose that I've a model like this one:


class News(models.Model):
name = CharField(max_length=200, unique=True)
body  = TextField()

usually I put a slug field like this one

   slug = CharField(max_length=200, unique=True, blank=True)

and instead of using models.Model as parent class I use this one:

class UniqueSlugFromName(models.Model):
class Meta:
abstract = True
def save(self):
"""Auto-populate an empty slug field from the MyModel name and
if it conflicts with an existing slug then append a number and try
saving again.
name = original
slug = the slug
"""
if not self.slug:
self.slug = slugify(self.name)  # Where self.name is the
field used for 'pre-populate from'

while True:
try:
super(UniqueSlugFromName, self).save()
# Assuming the IntegrityError is due to a slug fight
except IntegrityError:
match_obj = re.match(r'^(.*)-(\d+)$', self.slug)
if match_obj:
next_int = int(match_obj.group(2)) + 1
self.slug = match_obj.group(1) + '-' + str(next_int)
else:
self.slug += '-2'
else:
break

so the Model class is now something like this:

class News(models.Model):
name = CharField(max_length=200, unique=True)
body  = TextField()
slug = CharField(max_length=200, unique=True, blank=True)

in this way every slug field is populated with the slugify version of
the name field.

now I need to translate the 2 fields name and body so instead of the
above class I change this like this one

class News(models.Model):
slug = CharField(max_length=200, unique=True, blank=True)
class Translation(multilingual.Translation):
name = CharField(max_length=200)
body  = TextField()

but now the slug field is populated with the value of "none" I think
because the value of the fields is not yet in the database
moreover I should need translatable slug too so I can request the page
with all its urls for example

/news/hello-I-am-a-news/  -> content in english
/news/sono-una-news/ -> content in italian

is there a way to solve this problem ?
cheers
 Marco

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



Re: Diffents admin sites into the same project

2009-06-23 Thread Russell Keith-Magee

On Tue, Jun 23, 2009 at 5:55 AM, KrcK wrote:
>
> Hi group!
>
> I've a problem with AdminSite. I don't know how can I get 3 admin sites
> differents and if it's posible to do it.

It is certainly possible, and it's documented:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adminsite-objects

You mention that you've read this but you don't understand it - the
docs give a complete worked example for how to hook two admin sites
into your URL patterns - all that is left is to instantiate a new
AdminStite object.

django.contrib.admin.site is just an instance of AdminSite(); you can
create your own instance by calling

myadmin = AdminSite()

Then register you apps with the new site instance:

myadmin.register(MyModel)

and hook myadmin into your urls.py.

If you require any more help than this, you will need to be a little
more specific about what is causing you difficulties - what you have
tried, why you tried it, what happens when you tried, etc. Without
knowing the source of your confusion, it's very hard to provide
assistance.

Yours,
Russ Magee %-)

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



Re: How to load fixtures only once in django unit tests?

2009-06-23 Thread Russell Keith-Magee

On Tue, Jun 23, 2009 at 1:21 PM, Rama Vadakattu wrote:
>
> In unit tests i need to load few fixtures  i have done as below
>
>   class TestQuestionBankViews(TestCase):
>
>        #load this fixtures
>        fixtures = ['qbank',]
>
>        def setUp(self):
>            login = self.client.login
> (email="m...@gmail.com",password="welcome")
>
>
>        def test_starting_an_exam_view(self):
>            candidate = Candidate.objects.get(email="m...@gmail.com")
>            ...etc
>
>
>        def test_review_view(self):
>            self.assertTrue(True)
>            .
>
>       def test_review_view2(self):
>            self.assertTrue(True)
>            
>
> Problem:
>
> These fixtures are loading for every test (i.e) before
> test_review_view, test_review_view2 etc... as django flushes the
> database after every test
>
> How can i prevent that as it is taking lots of time?

> Can't i load in setUp and flush them out while exit but not between
> every test and still inheriting django.test.TestCase ?

No - this isn't a feature that Django has out of the box. Unit tests
need to be able to guarantee the entry state of the database, and the
only way to easily guarantee this is to ensure that the data is
reloaded at the start of each test, which means flushing out old data
before reloading.

"Oh", you say. "But my test doesn't modify data! It would be ok if the
database wasn't flushed!". Sure... for the moment. Then you change
your implementation (on purpose or accidentally), and something
strange starts happening to your tests. Tests pass or fail when they
shouldn't because other tests are modifying the base data. Tests pass
or fail depending on which other tests have been executed, or the
order in which tests are executed.

Django's test suite has repeatedly demonstrated that leaking test
preconditions can be a real headache - Doctests are particularly prone
to exactly this sort of problem. The sort of change you are suggesting
would only serve to introduce these sorts of problems where they don't
exist right now, and to introduce them into the worst possible area of
the code to have surprising and unexpected results.

For the record, I can think of a few ways this could be accomplished
without needing changes to the Django core. However, I'm not going to
document them here (or anywhere else for that matter). Without wanting
to be rude - if you can't work out how to do this, then you probably
shouldn't be doing it.

That said, I am sensitive to the fact that Django's unit tests can
take a long time to run, and that this is mostly due to the database
flush. This is why Django v1.1 has modified TestCase to use
transactions to optimize the test running process. This change has
resulted in significantly faster test execution - in some extreme
cases, up to an order of magnitude faster. If you aren't already using
Django trunk, I strongly encourage you to try it out.

> b.Also there should very good line of separation between
> initialization of object vs initialization before every method
>  at present setUp method trying to do both the things

As I noted earlier, each test case needs to be isolated. Setting up
database data is one of the conditions that needs to be guaranteed.
The distinction you are pointing to only exists in your imagination.
Completely aside from any feature of  Django - there is a very good
reason why setUp and tearDown are run before and after each test, but
there is no equivalent method for the start and end of execution for
an entire TestCase.

Yours,
Russ Magee %-)

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



Re: how to not saving models

2009-06-23 Thread Matías Costa
Monkey patch django.db.model.save
Where? in manage.py?

On Tue, Jun 23, 2009 at 12:56 PM, ReneMarxis  wrote:

>
> what i forgot to say: Of course i don't like to change all models-
> code. Some 'global' solution is what i am looking for.
> >
>

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



Re: how to not saving models

2009-06-23 Thread ReneMarxis

what i forgot to say: Of course i don't like to change all models-
code. Some 'global' solution is what i am looking for.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to not saving models

2009-06-23 Thread ReneMarxis

Hello

i have a question if something is possible to implement :)

i need some demo functionality in my django app and i'd like to
realize it by having some flag in the user's session that defines if
data should be saved at all or not in the whole app (for the session
user).

That way i could just create some data (via fixtures) and define some
demo-user and all functionality would be 'visible', but no data could
be changed/saved.

Could something like this be realized in django? Probably with
signals?

Any hints are very welcome.

_rene


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



problem with mod_wsgi and integrated devserver

2009-06-23 Thread patrickk

we have our dedicated webserver setup with django & mod_wsgi, where
everything works fine.
but: when I start the devserver, the templates and mediafiles are not
there ...

if I start the integrated devserver with:
--adminmedia = /path/to/admin/media/
and if I add:
"/var/www/myserver/django_src/django/contrib/admin/templates/",
to TEMPLATE_DIRS in settings.py
everythings ok.

although this seems to work, I´m a bit uncertain because the templates
and mediafiles for the admin should be found automatically, right?

FYI: without starting the devserver, all admin-templates and
mediafiles are found.

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



Re: Question IMAGE in Django

2009-06-23 Thread Vlad(L)

Guys, can throw off to me to you on an e-mail my project to find an
error - why the map is not output?
I tried to do everything that to me prompted in it topic, but anything
it is impossible to 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Issue on using emailID as the username

2009-06-23 Thread Rama Vadakattu

1. i don't know whether it is expected behavior or not.

But here are some ways to solve the above problem.
---
Why it is not accepting @ character in admin ?

As the username of  UserCreation form  ( from
django.contrib.auth.forms
import UserCreationForm )  form  associated with alphanumeric
regular expression it is not accepting @:

regex=r'^\w+$'  (below you see the code)

How to change the form to accept it?
---
Solution1:
~~~
Please follow the below link
http://stackoverflow.com/questions/471550/customizing-an-admin-form-in-django-while-also-using-autodiscover

1.instead of list_filter change the add_form
2.change UserCreationForm(django.contrib.auth.form...) to accept @
for username
  ( this i hope you can do be creating an instance and changing the
field attributes)
3.associate the changed UserCreationForm to add_form

Then you can able to accept  @. ( i haven;t tested it)

Solution 2:
---
Write a new authentication  backend which authenticates based on email
and password
 more details : http://bit.ly/hekni

Solution 3:
--
1.Give the email address in email field
2.move this email to username once user object is being saved by
catching the postsignal.


On Jun 23, 11:22 am, bvemu  wrote:
> Hi
>
> I was using the email ID as the username as shown below in my view.py
>
> view.py
> --
> def signup(request)
> ..
>       username=emailid ;
>       valid_user = authenticate
> (username=username,password=password  )
> ..
>
> and it works fine for me
>
> Django version being the development version
>
> # django-admin.py --version
> 1.1 beta 1 SVN-10957
>
> 1.) The problem is in the admin interface "@" is not accepted as
> username while I can populate the same from the view.py
> Is this an expected behaviour or should I raise a ticket ( if at all
> it doesnt exists )
>
> 2.) Do we have a configuration file or so where we can define these
> constraints like max_length of user name, accepted character set  in
> the user name and others.
> I can very well change the code in django-trunk of my web server,  but
> I dont want to do that since I want to avoid the overhead of re-doing
> the svn tasks
>
> Thanks
> Subramanyam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Issue on using emailID as the username

2009-06-23 Thread bvemu

Hi

I was using the email ID as the username as shown below in my view.py


view.py
--
def signup(request)
..
  username=emailid ;
  valid_user = authenticate
(username=username,password=password  )
..

and it works fine for me

Django version being the development version

# django-admin.py --version
1.1 beta 1 SVN-10957



1.) The problem is in the admin interface "@" is not accepted as
username while I can populate the same from the view.py
Is this an expected behaviour or should I raise a ticket ( if at all
it doesnt exists )

2.) Do we have a configuration file or so where we can define these
constraints like max_length of user name, accepted character set  in
the user name and others.
I can very well change the code in django-trunk of my web server,  but
I dont want to do that since I want to avoid the overhead of re-doing
the svn tasks

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



Error -- 'str' object has no attribute 'creation_counter'

2009-06-23 Thread Phil

Hi,

I'm getting the error 'str' object has no attribute 'creation_counter'
in Django admin when adding an Inlines option to an admin.ModelAdmin
class... and I don't understand why.

Traceback:
File "C:\python25\lib\site-packages\django\core\handlers\base.py" in
get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\python25\lib\site-packages\django\contrib\admin\sites.py" in
root
  157. return self.model_page(request, *url.split('/',
2))
File "C:\python25\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "C:\python25\lib\site-packages\django\contrib\admin\sites.py" in
model_page
  176. return admin_obj(request, rest_of_url)
File "C:\python25\lib\site-packages\django\contrib\admin\options.py"
in __call__
  199. return self.change_view(request, [unquote(part) for
part in url.split(PRIMARY_KEY_URL_SEPARATOR)])
File "C:\python25\lib\site-packages\django\db\transaction.py" in
_commit_on_success
  238. res = func(*args, **kw)
File "C:\python25\lib\site-packages\django\contrib\admin\options.py"
in change_view
  597. formset = FormSet(instance=obj)
File "C:\python25\lib\site-packages\django\forms\models.py" in
__init__
  468. queryset=qs)
File "C:\python25\lib\site-packages\django\forms\models.py" in
__init__
  352. super(BaseModelFormSet, self).__init__(**defaults)
File "C:\python25\lib\site-packages\django\forms\formsets.py" in
__init__
  67. self._construct_forms()
File "C:\python25\lib\site-packages\django\forms\models.py" in
_construct_forms
  474. super(BaseInlineFormSet, self)._construct_forms()
File "C:\python25\lib\site-packages\django\forms\formsets.py" in
_construct_forms
  76. self.forms.append(self._construct_form(i))
File "C:\python25\lib\site-packages\django\forms\models.py" in
_construct_form
  477. form = super(BaseInlineFormSet, self)._construct_form
(i, **kwargs)
File "C:\python25\lib\site-packages\django\forms\models.py" in
_construct_form
  357. return super(BaseModelFormSet, self)._construct_form(i,
**kwargs)
File "C:\python25\lib\site-packages\django\forms\formsets.py" in
_construct_form
  96. self.add_fields(form, i)
File "C:\python25\lib\site-packages\django\forms\models.py" in
add_fields
  491. if self._pk_field == self.fk:
File "C:\python25\lib\site-packages\django\db\models\options.py" in
__eq__
  28. return field_name in self.names
File "C:\python25\lib\site-packages\django\db\models\fields
\__init__.py" in __cmp__
  102. return cmp(self.creation_counter,
other.creation_counter)

Exception Type: AttributeError at /admin/binatang/plantfamily/1/
Exception Value: 'str' object has no attribute 'creation_counter'

Parent and child models:
class plantFamily(models.Model):
familyID = models.AutoField(primary_key=True)
family = models.CharField(max_length=50,null=True)

class plantGenus(models.Model):
genusID = models.AutoField(primary_key=True)
familyID = models.ForeignKey(plantFamily,
verbose_name='family',null=True,blank=True)
genus = models.CharField(max_length=50,null=True)

...and admin entries:
class plGenIn(admin.TabularInline):
model = plantGenus

class plFamAdmin(admin.ModelAdmin):
inlines = [plGenIn,]

I'm sure I had this working before, but since then I have installed
the composite primary key patch and I notice the 2nd to last traceback
is in class CompositePrimaryKey... Could this be something to do with
it?? All ideas appreciated

Thanks

Phil B

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