Re: unique=True and IntegrityError

2009-08-31 Thread aa56280

On Aug 31, 9:51 pm, Karen Tracey  wrote:

> However if you use a ModelForm to validate the data prior to attempting to
> save the model you get these problems reported as validation errors:

Karen,

Thanks for the thorough explanation. I really appreciate it. What I
took from it is that if I'm using a ModelForm, Django should return a
validation error for a duplicate value. However, for my scenario, I
*am* using a ModelForm. Here's a snippet:

### Model ###
class School(models.Model):
url = models.SlugField(max_length=50, unique=True)
name = models.CharField(max_length=255)
...


### Form ###
class SchoolForm(ModelForm):

class Meta:
model = School
fields = ('url', 'name')

### View ###
def new_school(request):
if request.method == 'POST':
form = SchoolForm(request.POST)
if form.is_valid():
form.save()

new_school craps out with an IntegrityError exception any time I have
a duplicate value. Any additional thoughts?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: subprocess.Popen in django production - are file descriptors closed?

2009-08-31 Thread aaron smith

it ended up being an incorrect working directory. I had to give the
runfcgi parameter the "workdir" parameter so that it would run from
the right place. arg!. By default if you don't specify workdir it puts
the working dir as "/"

On Mon, Aug 31, 2009 at 7:16 AM, Bill Freeman wrote:
> Are you saying that it works in the development server environment?  If so,
> it could be permission
> issues.  Have the ruby script append a time stamp to a world writable log
> file to confirm that it gets
> run.
>
> Bill
>
> On Fri, Aug 28, 2009 at 9:07 PM, aaron smith
>  wrote:
>>
>> Hey All, quick question.
>>
>> I have a small snippet of code that runs a ruby script, which I read
>> the stdout when it's done. But, I'm not getting the stdout when it's
>> in django production.
>>
>> Here's my python snippet:
>>
>> def generate_license(paymentForm,dsaPrivFile):
>>        name = paymentForm.cleaned_data['firstname'] + " " +
>> paymentForm.cleaned_data['lastname']
>>        product = paymentForm.cleaned_data['product_code']
>>        command = "/usr/bin/ruby licensing/genlicense.rb " + "'" +
>> dsaPrivFile + "'" + " " + product + " '"+name+"'"
>>        process =
>> subprocess.Popen(command,stdout=subprocess.PIPE,shell=True)
>>        stdout_value = process.communicate()[0]
>>        print process.stdout.read()
>>        print stdout_value
>>        return stdout_value
>>
>> I have a couple prints in there just for testing in debug. My question
>> is how to get this to behave normally in django production
>> environment. I've tried a couple different things with opening tmp
>> files and using that for stdout for subprocess. But no luck. Any help
>> is much appreciated.
>>
>> 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: unique=True and IntegrityError

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 6:27 PM, aa56280  wrote:

>
> I can't find an answer to this, so I'm hoping folks here can help: why
> is it that Django catches IntegrityError for a field with unique=True
> in the Admin tool but requires you to catch it yourself in your app?
> That is, why isn't it handled like all other built-in validation
> checks that come bundled with other options like, say, max_length?
>

It is handled like other built-in validation checks.  Within admin both
max_length, unique, etc. are checked/validated through use of a ModelForm
for the model.  If your code uses ModelForms you will get the same
validation checks.  If you don't use forms you won't (as presently there is
no model validation).  Depending on the database you can get an exception
raised as easily for violating max_length as you can for violating
uniqueness.  For example, given this model:

class Foo(models.Model):
name = models.CharField(max_length=2, unique=True)

and using a MySQL db with DEBUG on, attempting to create a model that
violates the max_length constraint will raise an exception:

>>> from ttt.models import Foo
>>> Foo.objects.all()
[]
>>> Foo.objects.create(name='Yeppers')
Traceback (most recent call last):
  File "", line 1, in 
[snip]
  File "/usr/lib/python2.5/warnings.py", line 102, in warn_explicit
raise message
Warning: Data truncated for column 'name' at row 1
>>>


MySQL considers that just a warning (though there may well be a
configuration option to tell it whether to treat this is a warning or error
situation, I haven't checked) so you need to have DEBUG True for that to
raise an exception, and MySQL has saved the model anyway with the truncated
data.  Sqlite won't enforce the max_length check at all, I don't believe.
Not sure off the top of my head how others behave.

If you then try to add another object that violates the unique constraint
again you get an exception if you do it directly by attempting to create the
model:

>>> Foo.objects.create(name='Ye')
Traceback (most recent call last):
  File "", line 1, in 
[snip]
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line 35,
in defaulterrorhandler
raise errorclass, errorvalue
IntegrityError: (1062, "Duplicate entry 'Ye' for key 2")
>>>

However if you use a ModelForm to validate the data prior to attempting to
save the model you get these problems reported as validation errors:

>>> from django import forms
>>> class FooForm(forms.ModelForm):
...  class Meta:
... model = Foo
...
>>> ff = FooForm(data={'name': 'Yeppers'})
>>> ff.is_valid()
False
>>> ff.errors
{'name': [u'Ensure this value has at most 2 characters (it has 7).']}
>>> ff = FooForm(data={'name': 'Ye'})
>>> ff.is_valid()
False
>>> ff.errors
{'name': [u'Foo with this Name already exists.']}
>>>

Since admin uses ModelForms, you see form validation errors when using it
instead of exceptions.

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



Accessing Child Meta Attributes from Abstract Model Class

2009-08-31 Thread Brett Epps

Hi,

I've got an abstract base class like this:

class Base(models.Model):

class Meta:
abstract = True

def save(self, *args, **kwargs):
print dir(self.Meta)
super(Base, self).save(*args, **kwargs)

and a child model class inheriting from it like this:

class Child(Base):

class Meta:
verbose_name_plural = "children"

When save() is called on an instance of Child, Base.save() prints the
attributes of Base.Meta instead of Child.Meta (as I may be wrongly
expecting).  I have tried changing Child.Meta to extend from Base.Meta
with the same result.

So far, the workaround seems to be to use self._meta in Base.save()
instead of self.Meta, which allows me to access the attributes of
Child.Meta.  I've noticed that the django-mptt project (on Google
Code) does this.  Is this the correct way for a base class to access a
child class's Meta attributes?

Brett

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Renaming displayed django application name in admin

2009-08-31 Thread Joshua Partogi
Dear all,
How do we change the displayed application name in django admin? Let's say I
have an application called foo, I wanted it to be displayed as bar instead
of foo in the admin system.

I've searched the document but failed to get the answer for this.

Thank you in advance for your help.

-- 
http://blog.scrum8.com
http://twitter.com/scrum8

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ImportError No module named myapp.views.hometest

2009-08-31 Thread weiwei

forgot to mention i am using django1.1

On Aug 31, 5:35 pm, weiwei  wrote:
> backgroud information:
> server: fedora11
> web server : apache 2.2 + mod_wsgi2.5
>
> my project location
> '/usr/local/django/myproject'
> '/usr/local/django/myproject/myapp'
>
> in the django.wsgi i have
>
> ---
> sys.path.append('/usr/local/django')
> sys.path.append('/usr/local/django/myproject')
> -
>
> In the debug information i already saw python path '[/usr/local/
> django]'
>
> And i have everything under /usr/local/django readable an
> executable .
>
> i still got this error.  Something else i need to check?
>
> Thanks for any 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
-~--~~~~--~~--~--~---



ImportError No module named myapp.views.hometest

2009-08-31 Thread weiwei

backgroud information:
server: fedora11
web server : apache 2.2 + mod_wsgi2.5

my project location
'/usr/local/django/myproject'
'/usr/local/django/myproject/myapp'

in the django.wsgi i have

---
sys.path.append('/usr/local/django')
sys.path.append('/usr/local/django/myproject')
-

In the debug information i already saw python path '[/usr/local/
django]'

And i have everything under /usr/local/django readable an
executable .

i still got this error.  Something else i need to check?


Thanks for any 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
-~--~~~~--~~--~--~---



SQL query with complex WHERE clause

2009-08-31 Thread Gyanit


Hi All,

I don't seem to find good source to help me write a complex where condition
in the django.

The where condition is generic boolean clause built on top of literals. The
literal are just == or != check on a single field.
for example ((field1 == 2 and field2 != 5) or field3 == 6).
another example ((field1 > 1 or field1 < -3) and (field2 != "comment")) or
field3 == "django"

I think it should be writable in the django queryset but I can't seem to
formulate it in generic format.

Any pointers or guidance will be great.

thanks

-- 
View this message in context: 
http://www.nabble.com/SQL-query-with-complex-WHERE-clause-tp25232455p25232455.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: Django and SSL Deployment using mod_wsgi

2009-08-31 Thread Graham Dumpleton



On Sep 1, 3:39 am, Francis  wrote:
> We setup a Nginx proxy in front of Apache/WSGI and got Nginx to handle
> the SSL cert and simply pass on a flag to WSGI if the connection was
> coming through http or https.
>
> Next you'll want a SSL middleware, we 
> use:http://www.djangosnippets.org/snippets/240/
>
> Now its a matter of configuring which views you want SSL (follow
> example in the middleware)

You don't need a SSL middleware. Just add to your Apache
configuration:

  SetEnvIf X-Forwarded-SSL on HTTPS=1

Apache/mod_wsgi will allow overriding of wsgi.url_scheme based on
HTTPS variable. The HTTPS variable can be set to 'On' or '1'. Case
ignored in comparison.

Thus, you can use mod_setenvif to check for header being set and what
value and then set HTTPS.

Graham

> On Aug 28, 11:04 pm, Vitaly Babiy  wrote:
>
>
>
> > Hey guys,
> > What is the best way to deploy an app that uses mod_wsgi that some parts of
> > it need to be behind SSL?
>
> > Thanks,
> > Vitaly Babiy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



hacking django-comments timestamp input - 400 error

2009-08-31 Thread Joseph Brown
Hello,

A user on my site recently complained to me about getting a 405 error after
slavishly writing a 15 minute comment - losing all they had written!  I
looked into the server logs and saw a 400 followed by a 405 error, and I'm
guessing it was the timestamp input:

"The timestamp is used to ensure that "reply attacks" can't continue very
long. Users who wait too long between requesting the form and posting a
comment will have their submissions refused."

http://docs.djangoproject.com/en/dev/ref/contrib/comments/#redirecting-after-the-comment-post

I'll figure a way around this, but if anyone knows a cool way to adjust this
or has any suggestions on how to make the experience better for users,
please reply!  Thanks very much,

Joe

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



unique=True and IntegrityError

2009-08-31 Thread aa56280

I can't find an answer to this, so I'm hoping folks here can help: why
is it that Django catches IntegrityError for a field with unique=True
in the Admin tool but requires you to catch it yourself in your app?
That is, why isn't it handled like all other built-in validation
checks that come bundled with other options like, say, max_length?

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



Re: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Zico
On Tue, Sep 1, 2009 at 3:14 AM, Karen Tracey  wrote:

>
> Yes, I see that now right in the subject.  You'll need to upgrade to 1.1 if
> you want to use this fixmystreet package, since it is using support added
> between 1.0 and 1.1.
>
>
Thanks Karen! Thanks a lot! Now it`s working after upgraded my django to
1.2.

-- 
Best,
Zico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Install going well but problem with syncdb

2009-08-31 Thread eka

Check that you have python-sqlite2 installed 
http://oss.itsystementwicklung.de/trac/pysqlite/



On Aug 31, 6:14 pm, Franck Y  wrote:
> Hello
> I had the install going pretty well but when i do
> python manage.py syncdb
>
> i got this error message
>
> python manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
>     execute_manager(settings)
>   File "/usr/lib/python2.4/site-packages/django/core/management/
> __init__.py", line 362, in execute_manager
>     utility.execute()
>   File "/usr/lib/python2.4/site-packages/django/core/management/
> __init__.py", line 303, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.4/site-packages/django/core/management/
> base.py", line 195, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/usr/lib/python2.4/site-packages/django/core/management/
> base.py", line 221, in execute
>     self.validate()
>   File "/usr/lib/python2.4/site-packages/django/core/management/
> base.py", line 249, in validate
>     num_errors = get_validation_errors(s, app)
>   File "/usr/lib/python2.4/site-packages/django/core/management/
> validation.py", line 22, in get_validation_errors
>     from django.db import models, connection
>   File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line
> 41, in ?
>     backend = load_backend(settings.DATABASE_ENGINE)
>   File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line
> 17, in load_backend
>     return import_module('.base', 'django.db.backends.%s' %
> backend_name)
>   File "/usr/lib/python2.4/site-packages/django/utils/importlib.py",
> line 35, in import_module
>     __import__(name)
>   File "/usr/lib/python2.4/site-packages/django/db/backends/sqlite3/
> base.py", line 30, in ?
>     raise ImproperlyConfigured, "Error loading %s: %s" % (module, exc)
> django.core.exceptions.ImproperlyConfigured: Error loading pysqlite2
> module: No module named pysqlite2
>
> Any idea ?
> I am runing Python 2.4.3, i installed django 1.1 under CentOS 5.3
>
> Franck
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 & flex

2009-08-31 Thread Thomas Hill
Yup, I was going to reply with this as well. One draw back to this, however,
is that it makes the app a little bit more complicated to test and debug,
I've found, unless you concoct your own other test cases that import the
pyAmf libs and test separately. Another thing you might want to think about
is future expansion. If you decide to build off of your now AMF exposed API,
how do other technologies interact?
I kind of feel like I made a mistake going down the AMF path - I want to
implement my API in other ways, but I have to rewrite it in JSON or some
other destination agnostic transport protocol.

I guess long story short, stick with JSON, REST, SOAP, etc... it will make
future expansion easier (if you can see it going that route).

-Thomas

On Mon, Aug 31, 2009 at 11:32 AM, Randy Barlow wrote:

>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> solar declared:
> > Is there a 'common' way to build apps with django and a Adobe Flex
> > frontend?
> > I'm about to do just that, and I'm a bit overwhelmed by the number of
> > choices that you get by multiplying
> > communication layers (REST, XML-RPC, SOAP) times data formats (XML,
> > JSON, etc.) times Flex microarchitectures (Cairngorm, RestfulX, etc.).
> > Obviously, not all of the above combine, but nevertheless... some of
> > them are probably dead ends, and I'm wondering what people on the
> > list usually choose for building "rich clients" on a django backend.
>
> My quick reply to you about this is that we're using Flex with Django
> over the AMF protocol.  We're using PyAMF to accomplish the RPC
> protocol, and have implemented various object managers to be used over
> that protocol to set and retrieve data.  The AMF protocol allows the use
> of ordinary Python data types, so no need to worry about XML or JSON -
> just use strings, dicts, and lists as usual!
>
> - --
> Randy Barlow
> Software Developer
> The American Research Institute
> http://americanri.com
> 919.228.4971
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkqcFykACgkQw3vjPfF7QfU05gCgi9iJnXiOIWLxrE51Zjd4zdJ3
> P6oAniM4sPAXmNj0IYDzuwgPX5qt+2u+
> =fGXU
> -END PGP SIGNATURE-
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Install going well but problem with syncdb

2009-08-31 Thread Daniel Roseman

On Aug 31, 10:14 pm, Franck Y  wrote:
> Hello
> I had the install going pretty well but when i do
> python manage.py syncdb
>
> i got this error message
>
> python manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
>     execute_manager(settings)
...
>     raise ImproperlyConfigured, "Error loading %s: %s" % (module, exc)
> django.core.exceptions.ImproperlyConfigured: Error loading pysqlite2
> module: No module named pysqlite2
>
> Any idea ?
> I am runing Python 2.4.3, i installed django 1.1 under CentOS 5.3
>
> Franck

You haven't installed sqlite.
--
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
-~--~~~~--~~--~--~---



Install going well but problem with syncdb

2009-08-31 Thread Franck Y

Hello
I had the install going pretty well but when i do
python manage.py syncdb

i got this error message


python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in ?
execute_manager(settings)
  File "/usr/lib/python2.4/site-packages/django/core/management/
__init__.py", line 362, in execute_manager
utility.execute()
  File "/usr/lib/python2.4/site-packages/django/core/management/
__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.4/site-packages/django/core/management/
base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.4/site-packages/django/core/management/
base.py", line 221, in execute
self.validate()
  File "/usr/lib/python2.4/site-packages/django/core/management/
base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.4/site-packages/django/core/management/
validation.py", line 22, in get_validation_errors
from django.db import models, connection
  File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line
41, in ?
backend = load_backend(settings.DATABASE_ENGINE)
  File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line
17, in load_backend
return import_module('.base', 'django.db.backends.%s' %
backend_name)
  File "/usr/lib/python2.4/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
  File "/usr/lib/python2.4/site-packages/django/db/backends/sqlite3/
base.py", line 30, in ?
raise ImproperlyConfigured, "Error loading %s: %s" % (module, exc)
django.core.exceptions.ImproperlyConfigured: Error loading pysqlite2
module: No module named pysqlite2

Any idea ?
I am runing Python 2.4.3, i installed django 1.1 under CentOS 5.3

Franck


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 4:55 PM, Zico  wrote:

>
>
> On Tue, Sep 1, 2009 at 2:48 AM, Karen Tracey  wrote:
>
>>
>> What version of Django are you using?
>>
>
> 1.0.3
>

Yes, I see that now right in the subject.  You'll need to upgrade to 1.1 if
you want to use this fixmystreet package, since it is using support added
between 1.0 and 1.1.

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: signals (post_save, pre_save) vs save()

2009-08-31 Thread Maksymus007

On Mon, Aug 31, 2009 at 10:49 PM, eka wrote:
>
> Hi all.
>
> I have this question on when one is preffered over another. I mean
> overriding save or using signals like post_save or pre_save.
>
> cheers.
>

The scale. signals are used for every model, save() per one

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems trying to use jinja2

2009-08-31 Thread Jeff

Alright, I found this: http://code.djangoproject.com/ticket/10216
which explains the cryptic error message. The fix is to disable
TEMPLATE_DEBUG.

On Aug 31, 2:44 pm, Jeff  wrote:
> Hi,
>
> I seem to have run into a problem trying to use the jinja2 template
> language. I've tried using Mitsuhiko's snippet (http://bitbucket.org/
> mitsuhiko/jinja2-main/src/c07588cf115f/ext/djangojinja2.py) and this
> other one by Joe Vasquez (http://jobscry.net/downloads/jinja_r2r.txt)
> where I had to comment out lines 60 and 61 to avoid import errors. I
> tried putting one script, then the other in jinja2integration/
> __init__.py and then using:
>
> from oslaurier.jinja2integration import render_to_response
>
> at the top of my view file. When I try to load the page with the
> jinja2 template I get:
> -
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.6/site-packages/django/core/servers/
> basehttp.py", line 279, in run
>     self.result = application(self.environ, self.start_response)
>
>   File "/usr/lib/python2.6/site-packages/django/core/servers/
> basehttp.py", line 651, in __call__
>     return self.application(environ, start_response)
>
>   File "/usr/lib/python2.6/site-packages/django/core/handlers/
> wsgi.py", line 241, in __call__
>     response = self.get_response(request)
>
>   File "/usr/lib/python2.6/site-packages/django/core/handlers/
> base.py", line 134, in get_response
>     return self.handle_uncaught_exception(request, resolver, exc_info)
>
>   File "/usr/lib/python2.6/site-packages/django/core/handlers/
> base.py", line 154, in handle_uncaught_exception
>     return debug.technical_500_response(request, *exc_info)
>
>   File "/usr/lib/python2.6/site-packages/django/views/debug.py", line
> 40, in technical_500_response
>     html = reporter.get_traceback_html()
>
>   File "/usr/lib/python2.6/site-packages/django/views/debug.py", line
> 69, in get_traceback_html
>     for loader in template_source_loaders:
>
> TypeError: 'NoneType' object is not iterable
>
> -
>
> The admin interface is working so the regular Django templates are
> working. Is there a preferred way to use jinja2 with Django 1.1 or can
> you provide any assistance in helping me find what's causing this
> error?
>
> Thank you in advance for any help you can provide.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Custom form validation request or user-based

2009-08-31 Thread Matthias Kestenholz

On Fri, Aug 28, 2009 at 10:34 AM, Enrico
Sartorello wrote:
> Hi,
> i'm developing a Django application where i need to differentiate the
> validation of an admin-site model form between different users: some user
> must respect some particular restrictions (imposed via "clean_*" methods)
> while others should do what they want without them.
>
> The problem arises because during form validation i cannot access any
> request object (so i can't build a permission-based criteria), and checking
> everything in other places (like Model_admin.save_model() method or with
> signals) can't do the job because there i can't raise form's validation
> errors.
>
> I've searched on the net but seems i cannot find any solution for that
> problem.
>
> Any hints?
>

Simple: Pass the current user to the form:

class MyForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.saved_user = kwargs.pop('user')
super(MyForm, self).__init__(*args, **kwargs)

Somewhere else in the code:

form = MyForm(request.POST, user=request.user)

resp.

form = MyForm(user=request.user)



Of course that isn't the only possibility to achieve what you want,
but it's quite straightforward to do it like this.


Matthias


-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Zico
On Tue, Sep 1, 2009 at 2:48 AM, Karen Tracey  wrote:

>
> What version of Django are you using?
>

1.0.3

-- 
Best,
Zico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



signals (post_save, pre_save) vs save()

2009-08-31 Thread eka

Hi all.

I have this question on when one is preffered over another. I mean
overriding save or using signals like post_save or pre_save.

cheers.

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



Re: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 4:29 PM, Zico  wrote:

> Now, the transmeta is gone!! and... new one just appeared!!
>
> ImportError at /
>
> cannot import name GIcon
>
>  Request Method: GET  Request URL: http://localhost:8000/  Exception Type:
> ImportError  Exception Value:
>
> cannot import name GIcon
>
>  Exception Location: /opt/fixmystreet/mainapp/models.py in , line
> 4
> By the way, according to your last email, i have just did the same. Went
> into my /opt/fixmystreet/contrib/ and used the command:
> *
> svn checkout http://django-googleanalytics.googlecode.com/svn/trunk/
>
>
> *And, after that, i ran my database by:*
>
> python manage.py syncdb *
>
> It went well. And after that, run the server! Then the error came
>

What version of Django are you using?  GIcon looks to be new in 1.1, so if
you are running something older that could be the problem.

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: Custom form validation request or user-based

2009-08-31 Thread Enrico Sartorello
Up.

On Fri, Aug 28, 2009 at 10:34 AM, Enrico Sartorello <
enrico.sartore...@gmail.com> wrote:

> Hi,
> i'm developing a Django application where i need to differentiate the
> validation of an admin-site model form between different users: some user
> must respect some particular restrictions (imposed via "clean_*" methods)
> while others should do what they want without them.
>
> The problem arises because during form validation i cannot access any
> request object (so i can't build a permission-based criteria), and checking
> everything in other places (like Model_admin.save_model() method or with
> signals) can't do the job because there i can't raise form's validation
> errors.
>
> I've searched on the net but seems i cannot find any solution for that
> problem.
>
> Any hints?
>
> Thanks for the attention
>
>
> --
> Enrico Sartorello
>



-- 
Enrico Sartorello

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: __getitem__ and lookups in templates

2009-08-31 Thread Fernando Gómez

On Aug 31, 5:16 pm, Karen Tracey  wrote:

> Based on that code, a dictionary lookup that raises TypeError,
> AttributeError, or KeyError will cause the template code to continue with
> trying an attribute lookup, so it is one of those three specifically that
> you will need to raise in the case where you want the dictionary lookup to
> be seen as failing.

Thank you Karen for pointing me to the right part of the code, and for
such a clear explanation.

--
Fernando


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Zico
On Tue, Sep 1, 2009 at 2:03 AM, Karen Tracey  wrote:

> The traceback might help since it would show the import that is triggering
> this.  If it is "from contrib.transmeta import something" then I don't
> understand why you'd still be having problems with the setup you describe
> above.
>
>
:D

Now, the transmeta is gone!! and... new one just appeared!!

ImportError at /

cannot import name GIcon

 Request Method: GET  Request URL: http://localhost:8000/  Exception Type:
ImportError  Exception Value:

cannot import name GIcon

 Exception Location: /opt/fixmystreet/mainapp/models.py in , line 4
By the way, according to your last email, i have just did the same. Went
into my /opt/fixmystreet/contrib/ and used the command:
*
svn checkout http://django-googleanalytics.googlecode.com/svn/trunk/


*And, after that, i ran my database by:*

python manage.py syncdb *

It went well. And after that, run the server! Then the error came

-- 
Best,
Zico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 and ZSI

2009-08-31 Thread Antoni Aloy

2009/8/31 Julián C. Pérez :
>
> Anyone has experience with using web services in Django??
> I mean, not necessarily with ZSI but others methods...
>

Yes, we have many of the working. But this is no a Django issue is
more a Python programming one. You can access to Soap web services
using ZSI, SUDS, Soappy or whatever you like to use.

Isolate the web service client and use the parts you need. We have
worked with ZSI mainly, but actually we're moving to Suds.

To act a a server we prefer to simplify and we're using xml over http
or REST services. Both live perfectly with Django.


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

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



Re: __getitem__ and lookups in templates

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 3:48 PM, efege  wrote:

>
> Hi,
>
> According to the docs,
>
> "... when the template system encounters a dot in a variable name, it
> tries the following lookups, in this order:
>
>* Dictionary lookup. Example: foo["bar"]
>* Attribute lookup. Example: foo.bar
>* Method call. Example: foo.bar()
>* List-index lookup. Example: foo[bar]
>
> The template system uses the first lookup type that works. It's short-
> circuit logic."
>
> I wonder what's the exact meaning of "works" in the last paragraph...
>
> This is my problem: my template's variables are instances of a class
> which has a special method __getitem__ defined. It also has a method
> foo. So, when I want my template to invoke the method foo of that same
> class, I wrote something like
>
>someobject.foo
>
> And guess what... dictionary lookup, i.e. __getitem__('foo'), takes
> precedence, and so the method foo is not invoked!
>
> In my case, __getitem__ only accepts as valid certain specific
> arguments, and 'foo' is not valid, so that __getitem__('foo') might
> raise an exception, or return None. But in any case, the fact is that
> Django *stops* trying the other possible lookups.
>

Your __getitem__ might raise an exception, or return None?  Which does it
do?

Returning None will be seen by the template system as "working", as it is
perfectly valid for None to be a value stored in a dictionary.  You will
need to make this method raise an appropriate exception to make the template
system consider the dictionary lookup to have failed.  Here's where the
template code tries these different lookups in order:

http://code.djangoproject.com/browser/django/tags/releases/1.1/django/template/__init__.py#L712

Based on that code, a dictionary lookup that raises TypeError,
AttributeError, or KeyError will cause the template code to continue with
trying an attribute lookup, so it is one of those three specifically that
you will need to raise in the case where you want the dictionary lookup to
be seen as failing.

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: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 2:40 PM, Zico  wrote:

>
> Yes, I did it. Now my transmeta is in:
>
> /opt/fixmystreet/contrib/transmeta/__init__.py
>
> And, my stdimage is in:
>
> /opt/fixmystreet/contrib/stdimage/__init__.py
>
> But, nothing changed yet!!! Same error is coming:
>
> *No module named transmeta*
>
>
>

The traceback might help since it would show the import that is triggering
this.  If it is "from contrib.transmeta import something" then I don't
understand why you'd still be having problems with the setup you describe
above.

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



__getitem__ and lookups in templates

2009-08-31 Thread efege

Hi,

According to the docs,

"... when the template system encounters a dot in a variable name, it
tries the following lookups, in this order:

* Dictionary lookup. Example: foo["bar"]
* Attribute lookup. Example: foo.bar
* Method call. Example: foo.bar()
* List-index lookup. Example: foo[bar]

The template system uses the first lookup type that works. It's short-
circuit logic."

I wonder what's the exact meaning of "works" in the last paragraph...

This is my problem: my template's variables are instances of a class
which has a special method __getitem__ defined. It also has a method
foo. So, when I want my template to invoke the method foo of that same
class, I wrote something like

someobject.foo

And guess what... dictionary lookup, i.e. __getitem__('foo'), takes
precedence, and so the method foo is not invoked!

In my case, __getitem__ only accepts as valid certain specific
arguments, and 'foo' is not valid, so that __getitem__('foo') might
raise an exception, or return None. But in any case, the fact is that
Django *stops* trying the other possible lookups.

BTW, the data my app uses is not stored in a Django model. Maybe this
is part of the price I must pay for doing unusual things? :-)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Getting all unique values of a field with Django ORM

2009-08-31 Thread stevedegrace

Thanks guys!

On Aug 30, 10:56 pm, Alex Gaynor  wrote:
> On Sun, Aug 30, 2009 at 9:37 PM, stevedegrace wrote:
>
> > Hi guys,
>
> > I'm making a refback type linkback app for my hobby CMS. I want to
> > find all the unique page targets. I am thinking broadly of a couple of
> > ways to do it. One with the ORM sort of line this:
>
> > targets = list(set([linkback.target_url for linkback in
> > LinkBacks.objects.all()]))
>
> > This seems like way too much work being done by the framework and the
> > database for a table which could in theory get very large. The other
> > way I was thinking of doing it was like this:
>
> > from django.db import connection
> > cursor = connection.cursor()
> > cursor.execute("SELECT target_url FROM linkbacks_linkback DISTINCT")
> > targets = [item[0] for item in cursor.fetchall()]
>
> > I'm leaning towards number 2, but I wonder if there is a better way to
> > do this with the Django ORM.
>
> > Thanks for any thoughts on this,
>
> > Stephen
>
> LinkBack.objects.values_list('target_url', flat=True).distinct()
>
> should do what you want.
>
> 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
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Extending the add/change form at the admin

2009-08-31 Thread Hellnar

Hello, I want to extend the admin panel of Django where adding/
changing happens for a specific object, say Foo. I have already done
alot of research and found a part discussing this at the old version
djangobook.

I have made an admin/myapp/foo/change_list.html at my template
directory and did some experient such as adding some html and it works
well.

And this is where problem starts, I need to tweak the view of this
admin display(no overriding the whole thing but just extending it) so
that, with a small GET/POST form at the change_list.html, I want to do
a specific action such as:

Say I have 2 objects Foo and Bar:

class Bar(models.Model):
  bar_text = models.TextField( )


class Foo(models.Model):
  name = models.TextField( )
  my_bar = models.models.ForeignKey( Bar)
The regular admin interface while adding a new Foo, I can pick a
single my_bar foreignKey as it should be, now I want a tickbox at the
end of the page "add to all" which makes the same input(name for my
example) connected for all Bar objects. So after save I will have
several Foo objects which are having same "name" field and each has a
different Bar connection
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Problems trying to use jinja2

2009-08-31 Thread Jeff

Hi,

I seem to have run into a problem trying to use the jinja2 template
language. I've tried using Mitsuhiko's snippet (http://bitbucket.org/
mitsuhiko/jinja2-main/src/c07588cf115f/ext/djangojinja2.py) and this
other one by Joe Vasquez (http://jobscry.net/downloads/jinja_r2r.txt)
where I had to comment out lines 60 and 61 to avoid import errors. I
tried putting one script, then the other in jinja2integration/
__init__.py and then using:

from oslaurier.jinja2integration import render_to_response

at the top of my view file. When I try to load the page with the
jinja2 template I get:
-

Traceback (most recent call last):

  File "/usr/lib/python2.6/site-packages/django/core/servers/
basehttp.py", line 279, in run
self.result = application(self.environ, self.start_response)

  File "/usr/lib/python2.6/site-packages/django/core/servers/
basehttp.py", line 651, in __call__
return self.application(environ, start_response)

  File "/usr/lib/python2.6/site-packages/django/core/handlers/
wsgi.py", line 241, in __call__
response = self.get_response(request)

  File "/usr/lib/python2.6/site-packages/django/core/handlers/
base.py", line 134, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)

  File "/usr/lib/python2.6/site-packages/django/core/handlers/
base.py", line 154, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)

  File "/usr/lib/python2.6/site-packages/django/views/debug.py", line
40, in technical_500_response
html = reporter.get_traceback_html()

  File "/usr/lib/python2.6/site-packages/django/views/debug.py", line
69, in get_traceback_html
for loader in template_source_loaders:

TypeError: 'NoneType' object is not iterable

-

The admin interface is working so the regular Django templates are
working. Is there a preferred way to use jinja2 with Django 1.1 or can
you provide any assistance in helping me find what's causing this
error?

Thank you in advance for any help you can provide.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 and ZSI

2009-08-31 Thread Julián C . Pérez

Anyone has experience with using web services in Django??
I mean, not necessarily with ZSI but others methods...

On Aug 31, 11:56 am, Julián C. Pérez  wrote:
> Hi you all
> I'm trying to serve a simple web service using ZSI
> Anyone how can I configure an app's urls and views files to do this??
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Zico
On Tue, Sep 1, 2009 at 12:15 AM, Karen Tracey  wrote:

> On Mon, Aug 31, 2009 at 1:49 PM, Zico  wrote:
>
>> Hi, may be you have seen my previous email regarding stdimage. The
>> previous error was:
>> *"ImportError: No module named stdimage"
>> *
>> I have solve this problem by this way:
>>
>> 1. I have created a "contrib" directory in my /opt/fixmystreet/
>> 2. Then, i have downloaded the stdimage with *
>> *
>>
>> *svn checkout http:**//django-stdimage.googlecode.com/svn/trunk/ stdimage*
>>
>>
>>
>>
>>
>> Then, this problem went away.
>>
>> Did you also create an empty file __init__.py within
> /opt/fixmystreet/contrib?  If not I'm puzzled how the stdimage problem could
> have gone away.
>

Yes, you are right. I have created another "contrib" in /opt/fixmystreet/

in where, i have "stdimage" folder and also "transmeta" folder! But, yet...
same problem is occuring:

No module named transmeta




>
>>
>> Now, the new error occurs: *ImportError: No module named transmeta
>>
>> *I have also tried to do the same for transmeta, what i did for stdimage.
>>
>> 1. Downloaded the trnsmeta with the command:
>>
>> *
>> **svn checkout http://django-transmeta.googlecode.com/svn/trunk/ transmeta*
>>
>> But, nothing changed!!! What should i do now?
>>
>
> This transmeta project appears to have an extra level of directory under
> trunk.  I'm guessing you now have
> /opt/fixmystreet/contrib/transmeta/transmeta/__init__.py etc., where what
> you want is simply  /opt/fixmystreet/contrib/transmeta/__init__.py.
>


Yes, I did it. Now my transmeta is in:

/opt/fixmystreet/contrib/transmeta/__init__.py

And, my stdimage is in:

/opt/fixmystreet/contrib/stdimage/__init__.py

But, nothing changed yet!!! Same error is coming:

*No module named transmeta*



-- 
Best,
Zico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 & flex

2009-08-31 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

solar declared:
> Is there a 'common' way to build apps with django and a Adobe Flex  
> frontend?
> I'm about to do just that, and I'm a bit overwhelmed by the number of  
> choices that you get by multiplying
> communication layers (REST, XML-RPC, SOAP) times data formats (XML,  
> JSON, etc.) times Flex microarchitectures (Cairngorm, RestfulX, etc.).
> Obviously, not all of the above combine, but nevertheless... some of  
> them are probably dead ends, and I'm wondering what people on the  
> list usually choose for building "rich clients" on a django backend.

My quick reply to you about this is that we're using Flex with Django
over the AMF protocol.  We're using PyAMF to accomplish the RPC
protocol, and have implemented various object managers to be used over
that protocol to set and retrieve data.  The AMF protocol allows the use
of ordinary Python data types, so no need to worry about XML or JSON -
just use strings, dicts, and lists as usual!

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqcFykACgkQw3vjPfF7QfU05gCgi9iJnXiOIWLxrE51Zjd4zdJ3
P6oAniM4sPAXmNj0IYDzuwgPX5qt+2u+
=fGXU
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 1:49 PM, Zico  wrote:

> Hi, may be you have seen my previous email regarding stdimage. The previous
> error was:
> *"ImportError: No module named stdimage"
> *
> I have solve this problem by this way:
>
> 1. I have created a "contrib" directory in my /opt/fixmystreet/
> 2. Then, i have downloaded the stdimage with *
> *
>
> *svn checkout http:**//django-stdimage.googlecode.com/svn/trunk/ stdimage*
>
>
>
> Then, this problem went away.
>
> Did you also create an empty file __init__.py within
/opt/fixmystreet/contrib?  If not I'm puzzled how the stdimage problem could
have gone away.


> Now, the new error occurs: *ImportError: No module named transmeta
>
> *I have also tried to do the same for transmeta, what i did for stdimage.
>
> 1. Downloaded the trnsmeta with the command:
>
> *
> **svn checkout http://django-transmeta.googlecode.com/svn/trunk/ transmeta*
>
> But, nothing changed!!! What should i do now?
>

This transmeta project appears to have an extra level of directory under
trunk.  I'm guessing you now have
/opt/fixmystreet/contrib/transmeta/transmeta/__init__.py etc., where what
you want is simply  /opt/fixmystreet/contrib/transmeta/__init__.py.

You can either manually rename and move things around to fix up what you've
got, or blow away the /opt/fixmystreet/contrib/transmeta tree you have and
instead use this checkout command:

svn checkout http://django-transmeta.googlecode.com/svn/trunk/transmetatransmeta

to avoid the duplicate transmeta directories.

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: Table with search results and returning to previous page.

2009-08-31 Thread Viacheslav Chumushuk

But in this case we lose pretty URLs, and keep your mind that form can be very 
large.

On Sun, Aug 30, 2009 at 11:08:34AM -0500, Frank Wiles  wrote:
> Hi Viacheslav,
> 
> All you need to do is on your edit/view links include the necessary
> extra args to recreate the search they used and then in your actual
> editing views use those values in the redirect upon save or cancel.
> 
> For example, if your links are currently like /model/edit/7 change
> them to be /model/edit/7?search=keyword
> And then use 'search' there, along with whatever other args to your
> search view you need, when redirecting to your search page.
> 
> -- 
> Frank Wiles
> Revolution Systems | http://www.revsys.com/
> fr...@revsys.com   | (800) 647-6298
> 
> 
-- 
Please, use plain text message format contacting me, and
don't use proprietary formats for attachments (such as DOC, XLS)
use PDF, TXT, ODT, HTML instead. 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
-~--~~~~--~~--~--~---



django & flex

2009-08-31 Thread solar

Is there a 'common' way to build apps with django and a Adobe Flex  
frontend?
I'm about to do just that, and I'm a bit overwhelmed by the number of  
choices that you get by multiplying
communication layers (REST, XML-RPC, SOAP) times data formats (XML,  
JSON, etc.) times Flex microarchitectures (Cairngorm, RestfulX, etc.).
Obviously, not all of the above combine, but nevertheless... some of  
them are probably dead ends, and I'm wondering what people on the  
list usually choose for building "rich clients" on a django backend.

TIA,
best regards,
Christoph




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Job - freelance Django developer needed

2009-08-31 Thread replyforall

I'm looking for a Django developer to join us at replyforall.com on a
full-time, or near full-time, contractor basis.

Our current need is more slanted towards a backend web developer/
engineer who ideally is familiar with HTML/CSS and capable of front-
end implementation.  Our site was built on Django so familiarity with,
or interest in, Django would be good.

Location is pretty irrelevant as long as you have decent Internet
access, chat and email. Our team includes people from New York, San
Francisco, Portland and Argentina.

If you're interested please send us your availability and a few words
about your programming background and experience with Django.  We'll
also need samples/URLs of past projects, completed or still pending.

replyforall's an exciting, young product that I'm looking to really
ramp up in the next few mos. with some interesting initiatives.  Let
me know if you want to connect to discuss further.

Thanks,
Enmi

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ImportError: No module named stdimage in Django 1.0.3 under Fedora 11

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 1:15 PM, Zico  wrote:

>
>
> On Mon, Aug 31, 2009 at 7:43 PM, Karen Tracey  wrote:
>
>> You seem to have been following the doc for downloading/installing
>> stdimage, which says to put it somewhere in a directory included in your
>> PYTHONPATH.  By putting it directly in site-packages you can do imports of
>> the form "from stdimage import StdImageField".
>>
>> What does it actually means?  *"The fixmystreet project is configured to
> look for these projects in a contrib directory on your python path."
>
> What does "python path" means actually??*
>

See http://docs.python.org/tutorial/modules.html#the-module-search-path for
the official doc on the module search path.  The "installation-dependent
default path" mentioned there will usually include the site-packages
directory, where you placed stdimage.

The problem is that fixmystreet isn't expecting these things to be directly
accessible on your python path, it's expecting them to be found under a
'contrib' package.  That is, instead of using:

from stdimage import StdImageField

fixmystreet uses:

from contrib.stdimage import StdImageField

So in searching for a match to fixmystreet's way of importing this support,
Python will be looking for a file /site-packages/contrib/stdimage/__init__.py, which won't be found since
you've got it under /site-packages/stdimage/__init__.py.

Where you have placed it is good (I'd guess) for how most code dependent on
this package would use it.  Most packages (that I have run across) that are
dependent on other packages simply expect them to be available directly on
the python path.

The fixmystreet package seems to be the one that is doing things a bit
oddly.  I don't know what their install instructions mean when they say "You
may either change this configuration" -- I haven't dug into it in any detail
to see if there is really a way you can easily tell the package to import
these things directly instead of "from contrib.stdimage", e.g.  If there is
a way (other than going and changing the imports in their code) I'd use it.
If not, you'll need to make these dependencies accessible to fixmystreet
under a contrib directory.  Personally I'd probably put it under
/opt/fixmystreet rather than site-packages, and either link to the version
installed under site-packages or install another copy under
/opt/fixmystreet/contrib.

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 and SSL Deployment using mod_wsgi

2009-08-31 Thread Francis

We setup a Nginx proxy in front of Apache/WSGI and got Nginx to handle
the SSL cert and simply pass on a flag to WSGI if the connection was
coming through http or https.

Next you'll want a SSL middleware, we use: 
http://www.djangosnippets.org/snippets/240/

Now its a matter of configuring which views you want SSL (follow
example in the middleware)

On Aug 28, 11:04 pm, Vitaly Babiy  wrote:
> Hey guys,
> What is the best way to deploy an app that uses mod_wsgi that some parts of
> it need to be behind SSL?
>
> Thanks,
> Vitaly Babiy

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



ImportError: No module named transmeta in Django 1.0.3 under Fedora 11

2009-08-31 Thread Zico
Hi, may be you have seen my previous email regarding stdimage. The previous
error was:
*"ImportError: No module named stdimage"
*
I have solve this problem by this way:

1. I have created a "contrib" directory in my /opt/fixmystreet/
2. Then, i have downloaded the stdimage with *
*

*svn checkout http:**//django-stdimage.googlecode.com/svn/trunk/ stdimage*


Then, this problem went away.


Now, the new error occurs: *ImportError: No module named transmeta

*I have also tried to do the same for transmeta, what i did for stdimage.

1. Downloaded the trnsmeta with the command:
*
**svn checkout http://django-transmeta.googlecode.com/svn/trunk/ transmeta*

But, nothing changed!!! What should i do now?

-- 
Best,
Zico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 question

2009-08-31 Thread Bobby Roberts

On Aug 31, 1:38 pm, Julián C. Pérez  wrote:
> Hi
> I use Django 1.0 and I define a template function like...
> ---
> from django import template
> register = template.Library()
> def doSomething(param1, param2):
>    # Do something like...
>    return str(param1)+''+str(param2)
> register.simple_tag(doSomething)
> ---
> to use that in template system, assuming a and b are in context...
> ---
> {% doSomething a b %}
> 
> ---
> Hope it helps you out
> ;)


yeah just found that after i posted this msg... thanks for your quick
response.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: template tag question

2009-08-31 Thread Julián C . Pérez

Hi
I use Django 1.0 and I define a template function like...
---
from django import template
register = template.Library()
def doSomething(param1, param2):
   # Do something like...
   return str(param1)+''+str(param2)
register.simple_tag(doSomething)
---
to use that in template system, assuming a and b are in context...
---
{% doSomething a b %}

---
Hope it helps you out
;)

On Aug 31, 12:31 pm, Bobby Roberts  wrote:
> hi group.  I"ve got an issue i'm needing help with.  I have two
> variables, a and b in my template and I need to pass those to a single
> template tag so I can process them and return a result to the
> template.  Is there a way to pass more than one variable to a template
> tag... if so, how?
>
> thanks in advance,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



template tag question

2009-08-31 Thread Bobby Roberts

hi group.  I"ve got an issue i'm needing help with.  I have two
variables, a and b in my template and I need to pass those to a single
template tag so I can process them and return a result to the
template.  Is there a way to pass more than one variable to a template
tag... if so, how?


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



Re: ImportError: No module named stdimage in Django 1.0.3 under Fedora 11

2009-08-31 Thread Zico
On Mon, Aug 31, 2009 at 7:43 PM, Karen Tracey  wrote:

> You seem to have been following the doc for downloading/installing
> stdimage, which says to put it somewhere in a directory included in your
> PYTHONPATH.  By putting it directly in site-packages you can do imports of
> the form "from stdimage import StdImageField".
>
> What does it actually means?  *"The fixmystreet project is configured to
look for these projects in a contrib directory on your python path."

What does "python path" means actually??
*

-- 
Best,
Zico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 and ZSI

2009-08-31 Thread Julián C . Pérez

Hi you all
I'm trying to serve a simple web service using ZSI
Anyone how can I configure an app's urls and views files to do this??
Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django lucene

2009-08-31 Thread Puneet

Hi,

Can anyone help with this in django with lucene? Is there anyone able
to use this module sucessfully. I am getting this error when I am
trying to search :

Error : 'Manager' object has no attribute 'objects_search'

Thanks,
Puneet
On Aug 25, 7:55 pm, Puneet  wrote:
> Hi,
>
> Does anyone have tried django-lucenemodule for search ??
>
> I am able to compile theluceneand jcc as  required but the module is
> not working properly as it is expected to work.  As mentioned in the
> docs I have added to fields in my model
>
>    objects = models.Manager()
>    objects_search = Manager() # add search manager
>
> But when I say ModelName.save() its not getting indexed withlucene
> and when I say
>
>  ModelName.objects.objects_search(name_first="Spike")
>
> I am getting error that
>
> AttributeError: 'Manager' object has no attribute 'objects_search'
>
> Can any one help me with this ?? Does anyone have a small working
> example ?
>
> Thanks,
> Puneet
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: create a link from an object - template tag or?

2009-08-31 Thread MIL

Hi Bill

Cool I understand that :D
And youre right, I will need template.Variable() someday soon
Thank you

Michael

On 31 Aug., 16:29, Bill Freeman  wrote:
> WIth your original version here, I'm going to guess that you need to use
> template.Variable()  (or learn a lot about doing what it does).  It is
> mentioned
> on the how to page for template tags.  IIRC, all arguments to a tag are
> strings (after all, you get them with a split operation), so they must be
> looked up.  So, instead of self.object = object in LinkNode, use
> self.object = template.Variable(object)
>
> Not that you need it for this tag, since simple_tag works, but you may want
> to
> write something fancier someday.
>
> Bill
>
> On Fri, Aug 28, 2009 at 10:34 PM, MIL  wrote:
>
> > Hi :o)
>
> > I am attempting to create a simpler way to create my links. and I
> > developed this template tag:
>
> > class LinkNode(Node):
> >        def __init__(self, object):
> >                self.object = object
>
> >        def render(self, context):
> >                model_name = self.object.get_model_name()
> >                linktext = self.object.get_linktext()
> >                url = self.object.get_absolute_url()
> >                if model_name and linktext and url:
> >                        return '%s' % (url,
> > model_name.lower(),
> > linktext)
> >                return ''
>
> > @register.tag
> > def create_a_link(parser, token):
> >        # {% create_a_link to object %}
> >        bits = token.contents.split()
> >        if len(bits) != 3:
> >                raise TemplateSyntaxError, "create_a_link tag takes exactly
> > three
> > arguments"
> >        if bits[1] != 'to':
> >                raise TemplateSyntaxError, "second argument to create_a_link
> > tag
> > must be 'to'"
> >        return LinkNode(bits[2],)
>
> > But I get this error message:
> > TemplateSyntaxError at /
> > Caught an exception while rendering: 'unicode' object has no attribute
> > 'get_model_name'
>
> > What am I doing wrong
>
> > Is there a simpler and better way to do this job?
>
> > I would also like to develop something that can make it simpler to
> > create tables and lists, but that later on.
>
> > Thank you :o)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problem subclassing Widget with value_from_datadict

2009-08-31 Thread Mike Ramirez
On Monday 31 August 2009 08:08:50 am you wrote:
> On Monday 31 August 2009 07:51:52 am you wrote:
> > > Either make sure you always pass in userip when you instantiate the
> > > form, or (preferably) change the __init__ so that userip is in the
> > > kwargs dictionary, and use kwargs.pop('userip') to get its value
> > > before you hand off to super().
> > > --
> > > DR.
> >
> > Ok, changed the __init__ to look like this:
> >
> > class ReCaptchaForm(forms.Form):
> > captcha = forms.CharField(widget=ReCaptchaWidget)
> >
> > def __init__(self,  *args,  **kwargs):
> > super(ReCaptchaForm,  self).__init__(self,  *args,  **kwargs)
> > if kwargs.has_key('userip'):
> > self.userip = kwargs.pop('userip')
> >
> >
> > I still get the same error.
> >
> > Mike
>
Ok, I did change it so kwargs.pop() comes _before_ the super, no change in
the error.

(sorry was 1/2 sleep when I implemented and answered it the first time)


 Mike



-- 
In my end is my beginning.
-- Mary Stuart, Queen of Scots


signature.asc
Description: This is a digitally signed message part.


model validation errors

2009-08-31 Thread alain31

Hello, I wrote a model to manage small TeX fragments:

class LaTeX(models.Model):
latex = models.TextField(help_text="Un extrait de source LaTeX")
macros = models.ForeignKey(Macros)

For now, I override save() to compile the latex string using macros
strings with LaTeX compilator, and produce a
png image that I store with a name made with self.id (so I need to
call super...save() before). But in case of
LaTeX compilation errors, I just raise an exception that will not
appear in production with DEBUG = False.

I'd like to treat  LaTeX compilation errors as standard validation
errors to
appear in error list in forms, admin...

 I don't know how to do this, I looked at
- signals (pre-post save) : what about validation ?
- write a TextField  subclass and override validate to do compilation
here ? But I need to access another field 'macros'  and model.id  ...
- I found http://code.djangoproject.com/ticket/6845 with a patch to do
model validation (1 year ago) that looks
like what I need, but is it stable?

Any hint ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 is a LEFT OUTER JOIN used to select records with a NULL foreign key?

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 10:30 AM, wallenfe  wrote:

>
> I'm trying to understand why a LEFT OUTER JOIN is being used in
> queries that filter on a NULL foreign key.  It seems that the same
> result can be achieved without the LEFT OUTER JOIN.
>
> Here is an example:
> [snip]

Why is the LEFT OUTER JOIN used?  Is there a different way this filter
> should be structured so that the LEFT OUTER JOIN is not used?
>

Looks like:

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

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: Problem subclassing Widget with value_from_datadict

2009-08-31 Thread Mike Ramirez
On Monday 31 August 2009 05:48:18 am Daniel Roseman wrote:
> On Aug 31, 11:58 am, Mike Ramirez  wrote:
> > On Monday 31 August 2009 02:46:27 am Daniel Roseman wrote:
> > > I think you're going to need to post your view code as well. It seems
> > > that the form is passing itself, rather than its data, to the widget,
> > > so I'd guess there's something weird about the way it's being
> > > instantiated.
> > > --
> > > DR.
> >
> > Hereyou go, nothing special.
> >
> > http://dpaste.com/87647/
> >
> > Mike
>
> OK I think the problem is that you've declared the form's __init__ to
> take an extra argument, userip. So after a POST, in line 6, you're
> correctly instantiating your form with the extra arg. However, on a
> GET, in line 26, you don't pass in any arguments at all, so the
> arguments are all shifted leftwards - what should be in data ends up
> in userip, etc.
>
> Either make sure you always pass in userip when you instantiate the
> form, or (preferably) change the __init__ so that userip is in the
> kwargs dictionary, and use kwargs.pop('userip') to get its value
> before you hand off to super().
> --
> DR.

Ok, changed the __init__ to look like this:

class ReCaptchaForm(forms.Form):
captcha = forms.CharField(widget=ReCaptchaWidget)

def __init__(self,  *args,  **kwargs):
super(ReCaptchaForm,  self).__init__(self,  *args,  **kwargs)
if kwargs.has_key('userip'):
self.userip = kwargs.pop('userip')

The view didn't change much except for this:

if request.method == "POST":
userip = request.META['REMOTE_ADDR']
form = ContactForm(request.POST, userip=userip)

I still get the same error.

Mike

-- 
Wanna buy a duck?


signature.asc
Description: This is a digitally signed message part.


ImportError: No module named stdimage in Django 1.0.3 under Fedora 11

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 2:13 AM, Zico  wrote:

>
>
> On Mon, Aug 31, 2009 at 7:04 AM, Karen Tracey  wrote:
>
>> File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py", line 
>> 214, in _resolve_special
>>>
>>>
>>>
>>>
>>>
>>>
>>> callback = getattr(self.urlconf_module, 'handler%s' % view_type)
>>>
>>>   File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py", line 
>>> 205, in _get_urlconf_module
>>> self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/opt/fixmystreet/../fixmystreet/urls.py", line 5, in 
>>> from mainapp.feeds import LatestReports, LatestReportsByCity, 
>>> LatestReportsByWard, LatestUpdatesByReport
>>>
>>>   File "/opt/fixmystreet/../fixmystreet/mainapp/feeds.py", line 4, in 
>>> 
>>>
>>>
>>>
>>>
>>>
>>>
>>> from mainapp.models import Report, ReportUpdate, City, Ward
>>>
>>>   File "/opt/fixmystreet/mainapp/models.py", line 16, in 
>>> from contrib.stdimage import StdImageField*
>>>
>>> ImportError: No module named stdimag*
>>>
>>>
>> You don't appear to have installed the stdimage project in a contrib
>> directory on your python path as described here:
>>
>> http://wiki.github.com/visiblegovernment/django-fixmystreet/installation
>>
>> under "2. Check Out Project Dependencies".
>>
>>
> Thanks Karen for your reply. Actually, i did it. I followed this:
>
> Download using subversion to any directory included in PYTHON_PATH (for
> example /usr/lib/python2.5/site-package)
>
> svn checkout http://django-stdimage.googlecode.com/svn/trunk/ stdimage
>
>
>
> I have downloaded the "stdimage" with this svn in my
> /usr/lib/python2.5/site-package   but, nothing changed I cannot
> understand what is my problem
>
>
You seem to have been following the doc for downloading/installing stdimage,
which says to put it somewhere in a directory included in your PYTHONPATH.
By putting it directly in site-packages you can do imports of the form "from
stdimage import StdImageField".

However, that isn't what fixmystreet does, and that isn't what the doc I
pointed to for installing the fixmystreet dependencies, recommended.   The
fixmystreet package, for some reason, has opted to assume all of its
dependencies are installed in a 'contrib' package found somewhere on your
PYTHONPATH.  I don't know why they've done this (it seems like a bad idea to
me), but their import for stdimage, from the traceback, is: from
contrib.stdimage import StdImageField.  If you've placed stdimage directly
in site-packages this will not work.

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 recursion

2009-08-31 Thread gentlestone

I have solve it!

The point is to use a variable not a constant for recursion's file
name. Why recursion? I've translated my model into rendering context.
And if a field is a relationship with fields, the rendering is the
same.

Here is the template:



{{contextElement.label}}:


{% if contextElement.href %}


{{contextElement.value}}

{% else %}
{{contextElement.value}}
{% endif %}

{% if contextElement.fields %}
{% comment %}
Use contextElement.field.aFieldName for individual field
rendering!
{% endcomment %}
{% if not contextRecursionForbidden %}

{% for field in contextElement.fields %}
{% with field as contextElement %}
{% comment %} Uncomment this line for stop
recursion!
{% with field as contextRecursionForbidden
%}
{% endcomment %}
{% with field.name as
contextPrefix %}
{% with
"context_element_template.html" as context_element_template %}
{% include
context_element_template %}
{% endwith %}
{% endwith %}
{% comment %} Uncomment this line for
stop recursion!
{% endwith %}
{% endcomment %}
{% endwith %}
{% endfor %}

{% endif %}
{% endif %}
{% if contextElement.queryset %}


{% for object in contextElement.queryset %}

{% comment %}
Obviously queried contexts have only value
and url.
Use queriedContext.fields for rendering
object's fields or
queriedContext.field.aFieldName for
rendering object's individual field
{% endcomment %}
{% if object.href %}

{{object.value}}

{% else %}
{{object.value}}
{% endif %}

{% endfor %}


{% endif %}





And here is the rendering code:

class ContextElement:

def __unicode__(self):
try:
return self.value
except AttributeError:
pass
return ""

def __iter__(self):
try:
return self.fields
except AttributeError:
pass
try:
return self.queryset
except AttributeError:
pass
return []

def __init__(self, *args, **kwargs):

args_help = "ContextElement(\n\
[model|(instance [, field_meta])]\n\
[, value = value]\n\
[, label = label]\n\
[, name = name]\n\
[, href = href]\n\
[, fields = fields]\n\
[, queryset = queryset]\n\
)"

for k, v in kwargs.items():
if k in ('value', 'label', 'name', 'href', 'fields',
'queryset'):
setattr(self, k, v)
else:
raise Exception(args_help)

if len(args) == 0:
return

try:
ismodel = issubclass(args[0], models.Model)
except TypeError:
ismodel = False
if ismodel:
if len(args) > 1:
raise Exception(args_help)
model = args[0]
opts = model._meta
name = opts.object_name
label = opts.verbose_name_plural
queryset = model.objects.all()._clone(klass =
ContextQuery)

else:
if not isinstance(args[0], models.Model):
raise Exception(args_help)
instance = args[0]

if len(args) > 1:
if len(args) > 2:
try:
isfield = issubclass(args[0], Field)
except TypeError:
isfield = False
if not isfield:
raise Exception(args_help)
field_meta = args[1]
field_instance = getattr(instance, field_meta.name)
name = field_meta.name
label = field_meta.verbose_name

if field_meta.rel:
value = field_instance

if isinstance(field_meta.rel,
models.ManyToOneRel):
if hasattr(field_instance,
'get_absolute_url'):
href = getattr(field_instance,
'get_absolute_url')
fields = 

Re: Changing the Date Format

2009-08-31 Thread vishak

I'm using it in model.model,DateField() date that forms from this i
need to change.

On Aug 31, 6:56 pm, PANCHICORE  wrote:
> Hi v. I guess you want to give a format in the template, date tag,
> formats a date according to the given format as you can see here
> (http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date).
>
> ex:
>
> {{ date_value|date:"d-M-Y" }}
> return:
>  '31-Aug-2009'.
>
> On Aug 31, 3:45 pm, vishak  wrote:
>
> > Hi All
>
> >    I'm trying to change the default date format of django. The present
> > format is '2009-08-31'. I want to display this format as '31-
> > Aug-2009'.
>
> > I tried putting date_time format in settings.py but no result. Even
> > tried to do with java script but all went in vain. Can the group give
> > me an idea on this. Is it possible in django.
>
> > This link has the information but i don't know how to use 
> > it.http://docs.djangoproject.com/en/dev/ref/settings/#date-format.
>
> > Hoping for Reply
> > Vishak.V
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: DjangoCon '09 Schedule

2009-08-31 Thread adrian


Tickets are now sold out.

I need a ticket.   If anyone would like to sell their ticket please
contact me
at adrian_nye at yahoo.   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
-~--~~~~--~~--~--~---



Why is a LEFT OUTER JOIN used to select records with a NULL foreign key?

2009-08-31 Thread wallenfe

I'm trying to understand why a LEFT OUTER JOIN is being used in
queries that filter on a NULL foreign key.  It seems that the same
result can be achieved without the LEFT OUTER JOIN.

Here is an example:
> cat models.py
from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Widget(models.Model):
  owner = models.ForeignKey(User, null=True, blank=True)


python manage.py shell
>>> from widgets.models import Widget
>>> from django.db import connection
>>> Widget.objects.filter(owner=None)
>>> connection.queries
[{'time': '0.001', 'sql': u'SELECT `widgets_widget`.`id`,
`widgets_widget`.`owner_id` FROM `widgets_widget` LEFT OUTER JOIN
`auth_user` ON (`widgets_widget`.`owner_id` = `auth_user`.`id`) WHERE
`auth_user`.`id` IS NULL LIMIT 21'}]

It seems that this could be accomplished with a simpler query that
does not use a join:
SELECT `widgets_widget`.`id`, `widgets_widget`.`owner_id` FROM
`widgets_widget` WHERE `owner_id` IS NULL LIMIT 21'}

This becomes a bigger issue when the filter is combined with an update
command as the join forces the update to be split into two SQL
commands.  This opens the door to race conditions.
>>> from django.contrib.auth.models import
>>> u = User.objects.get(pk=1)
>>> connection.queries = []
>>> Widget.objects.filter(owner=None).update(owner=u)
1L
>>> connection.queries
[{'time': '0.006', 'sql': u'SELECT U0.`id` FROM `widgets_widget` U0
LEFT OUTER JOIN `auth_user` U1 ON (U0.`owner_id` = U1.`id`) WHERE
U1.`id` IS NULL'}, {'time': '0.002', 'sql': u'UPDATE `widgets_widget`
SET `owner_id` = 1 WHERE `widgets_widget`.`id` IN (1)'}]
>>>

The behavior is the also the same with owner__isnull=True.

Why is the LEFT OUTER JOIN used?  Is there a different way this filter
should be structured so that the LEFT OUTER JOIN is not used?

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: create a link from an object - template tag or?

2009-08-31 Thread Bill Freeman
WIth your original version here, I'm going to guess that you need to use
template.Variable()  (or learn a lot about doing what it does).  It is
mentioned
on the how to page for template tags.  IIRC, all arguments to a tag are
strings (after all, you get them with a split operation), so they must be
looked up.  So, instead of self.object = object in LinkNode, use
self.object = template.Variable(object)

Not that you need it for this tag, since simple_tag works, but you may want
to
write something fancier someday.

Bill

On Fri, Aug 28, 2009 at 10:34 PM, MIL  wrote:

>
> Hi :o)
>
> I am attempting to create a simpler way to create my links. and I
> developed this template tag:
>
>
> class LinkNode(Node):
>def __init__(self, object):
>self.object = object
>
>def render(self, context):
>model_name = self.object.get_model_name()
>linktext = self.object.get_linktext()
>url = self.object.get_absolute_url()
>if model_name and linktext and url:
>return '%s' % (url,
> model_name.lower(),
> linktext)
>return ''
>
> @register.tag
> def create_a_link(parser, token):
># {% create_a_link to object %}
>bits = token.contents.split()
>if len(bits) != 3:
>raise TemplateSyntaxError, "create_a_link tag takes exactly
> three
> arguments"
>if bits[1] != 'to':
>raise TemplateSyntaxError, "second argument to create_a_link
> tag
> must be 'to'"
>return LinkNode(bits[2],)
>
>
> But I get this error message:
> TemplateSyntaxError at /
> Caught an exception while rendering: 'unicode' object has no attribute
> 'get_model_name'
>
> What am I doing wrong
>
> Is there a simpler and better way to do this job?
>
> I would also like to develop something that can make it simpler to
> create tables and lists, but that later on.
>
> Thank you :o)
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: subprocess.Popen in django production - are file descriptors closed?

2009-08-31 Thread Bill Freeman
Are you saying that it works in the development server environment?  If so,
it could be permission
issues.  Have the ruby script append a time stamp to a world writable log
file to confirm that it gets
run.

Bill

On Fri, Aug 28, 2009 at 9:07 PM, aaron smith <
beingthexemplaryli...@gmail.com> wrote:

>
> Hey All, quick question.
>
> I have a small snippet of code that runs a ruby script, which I read
> the stdout when it's done. But, I'm not getting the stdout when it's
> in django production.
>
> Here's my python snippet:
>
> def generate_license(paymentForm,dsaPrivFile):
>name = paymentForm.cleaned_data['firstname'] + " " +
> paymentForm.cleaned_data['lastname']
>product = paymentForm.cleaned_data['product_code']
>command = "/usr/bin/ruby licensing/genlicense.rb " + "'" +
> dsaPrivFile + "'" + " " + product + " '"+name+"'"
>process =
> subprocess.Popen(command,stdout=subprocess.PIPE,shell=True)
>stdout_value = process.communicate()[0]
>print process.stdout.read()
>print stdout_value
>return stdout_value
>
> I have a couple prints in there just for testing in debug. My question
> is how to get this to behave normally in django production
> environment. I've tried a couple different things with opening tmp
> files and using that for stdout for subprocess. But no luck. Any help
> is much appreciated.
>
> 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: Is ‘if element in a List’ possible with in Django templates?

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 9:26 AM, Lokesh  wrote:

>
> Hi,
>
> I am trying to check the check boxes while serve of a page.
>
> I will be passing the elements/indexes of an element(checkbox) as a
> list from FORM.
>
> Here is the sample code that I am trying to implement
>
> sampleForm():
>  check = [1,3,5]
>  hobbies_list = {'1':'Chess', '2':'Cricket', '3':'Tennis',
> '4':'Shuttle', '5':'BasketBall'}
>  return render_to_response(template.html, {'hoby_list': hobbies_list,
> 'check_list':check})
>
> template.html
> {% for hbyId, hbyVal in hoby_list.items %}
>  {% if hbyId in check_list %} ### - Here I would like
> to check the existence of an element


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

requests this.  I believe the latest patch supports the syntax you are
trying to use here.  The ticket is in design decision needed, so it's
unknown whether it will be accepted/implemented It rather moves towards more
programming in templates, which is generally not Django's template
philosophy.

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 recursion

2009-08-31 Thread Karen Tracey
On Mon, Aug 31, 2009 at 9:03 AM, gentlestone  wrote:

>
> is recursion allowed in templates?
>
> for example can the "xy_template.html" file contain {% include
> "xy_template.html" %}?
>

It's "allowed" in the sense that it's not caught as an error.  But it will
lead to infinite recursion...


>
> because I tried but the system crushed:
>

...which is what you are seeing here.  For some reason it often seems that
instead of reporting maximum recursion depth exceeded, Python on Macs crash.

So no, it's not something you actually want to do.  What is the real problem
you are trying to solve by including a template inside itself?

Karen



>
> Process: Python [97385]
> Path:/System/Library/Frameworks/Python.framework/Versions/
> 2.5/Resources/Python.app/Contents/MacOS/Python
> Identifier:  Python
> Version: ??? (???)
> Code Type:   X86 (Native)
> Parent Process:  Python [97384]
>
> Interval Since Last Report:  3912 sec
> Crashes Since Last Report:   12
> Per-App Interval Since Last Report:  0 sec
> Per-App Crashes Since Last Report:   12
>
> Date/Time:   2009-08-31 15:02:00.210 +0200
> OS Version:  Mac OS X 10.5.7 (9J61)
> Report Version:  6
> Anonymous UUID:  BD3D5563-F1EA-4DC8-9293-5BCBADDFA1DE
>
> Exception Type:  EXC_BAD_ACCESS (SIGBUS)
> Exception Codes: KERN_PROTECTION_FAILURE at 0xbfec
> Crashed Thread:  1
>
> >
>

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



Re: Changing the Date Format

2009-08-31 Thread PANCHICORE

Hi v. I guess you want to give a format in the template, date tag,
formats a date according to the given format as you can see here
(http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date).

ex:

{{ date_value|date:"d-M-Y" }}
return:
 '31-Aug-2009'.


On Aug 31, 3:45 pm, vishak  wrote:
> Hi All
>
>    I'm trying to change the default date format of django. The present
> format is '2009-08-31'. I want to display this format as '31-
> Aug-2009'.
>
> I tried putting date_time format in settings.py but no result. Even
> tried to do with java script but all went in vain. Can the group give
> me an idea on this. Is it possible in django.
>
> This link has the information but i don't know how to use 
> it.http://docs.djangoproject.com/en/dev/ref/settings/#date-format.
>
> Hoping for Reply
> Vishak.V
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Changing the Date Format

2009-08-31 Thread vishak

Hi All

   I'm trying to change the default date format of django. The present
format is '2009-08-31'. I want to display this format as '31-
Aug-2009'.

I tried putting date_time format in settings.py but no result. Even
tried to do with java script but all went in vain. Can the group give
me an idea on this. Is it possible in django.

This link has the information but i don't know how to use it.
http://docs.djangoproject.com/en/dev/ref/settings/#date-format.

Hoping for Reply
Vishak.V

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: '%d-%m-%Y' format for DateTimefield in django

2009-08-31 Thread zayatzz

Check out this thread, where Karen Throughly explained date formats
and widgets to me:

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

Alan.

On Aug 28, 4:10 pm, Karen Tracey  wrote:
> On Aug 28, 3:19 am, Jigar  wrote:
>
> > Hi All,
>
> > I am trying to add the '%d-%m-%Y' format in DateTimefield. As django
> > does not support this format so when I add different date formats, it
> > gives "invalid date/time" error in django console.This error occurs
> > because the form is not valid(form.is_valid()) as above mentioned date
> > format is not supported by django.
>
> It is not correct to say that Django does not support that format.
> That format is not one that is accepted by default as an input format
> for the DateTimeField form field.  However, you can easily specify
> your own input_formats and then your form will accept that format:
>
> http://docs.djangoproject.com/en/dev/ref/forms/fields/#datetimefield
>
> > Also, I want to store this date in
> > the mysql database.
>
> It does not make sense to say you want to store that format in MySQL.
> The value stored in MySQL is a DATETIME, independent of any particular
> format.  Since you are using Django you do not need to be concerned
> with what format is used when Django stores the data to MySQL or
> retrieves it from MySQL.  What you need to adjust is the input formats
> your field accepts, and the output format used by your form field's
> widget to display existing data (see the format parameter here, for
> example:http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms)
>
> 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
-~--~~~~--~~--~--~---



Is ‘if element in a List’ possible with in Django templates?

2009-08-31 Thread Lokesh

Hi,

I am trying to check the check boxes while serve of a page.

I will be passing the elements/indexes of an element(checkbox) as a
list from FORM.

Here is the sample code that I am trying to implement

sampleForm():
  check = [1,3,5]
  hobbies_list = {'1':'Chess', '2':'Cricket', '3':'Tennis',
'4':'Shuttle', '5':'BasketBall'}
  return render_to_response(template.html, {'hoby_list': hobbies_list,
'check_list':check})

template.html
{% for hbyId, hbyVal in hoby_list.items %}
  {% if hbyId in check_list %} ### - Here I would like
to check the existence of an element
 {{ hbyVal }}
  {% else %}
 {{ hbyVal }}
  {% endif %}
{% endfor %}

Thanks for your time.

Regards,
Lokesh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Defining subsets of "list" variable at template level

2009-08-31 Thread Alex Robbins

First, if you aren't running into db performance problems, I wouldn't
optimize. Keep everything as simple as possible, then optimize the
parts that actually demonstrate themselves to be a performance issue.

If this really is a performance issue, you could solve it like this:

If you know that you need the whole list why not do this logic in the
view? This should only make one db query.

mylist = list(MyModel.objects.filter(type="A")|MyModel.objects.filter
(type="B"))

mylist_type_a = [ x for x in mylist if x.type == "A" ]
mylist_type_b = [ x for x in mylist if x.type == "B" ]

Then pass both mylist_type_* variables in your context.

On Aug 7, 1:35 am, bweiss  wrote:
> Is there a simple way to do the following that I'm just not seeing, or
> am I looking at trying to write a custom tag?  The functionality I
> need is similar to {% regroup %} but not quite the same...
>
> My app currently has a custom admin view in which I've defined a whole
> bunch of different lists, which are all objects of the same model,
> filtered according to different options of a field called "Type".
> (eg. type_A_list = mymodel.objects.filter(Type="A"); type_B_list =
> mymodel.objects.filter(Type="B"); etc.)
>
> I've realised that the number of database hits this involves is
> inefficient, and it would be cleaner to have a single list of objects
> and try to perform the logic I need at the template level.
>
> What I'd like to be able to do is, for a single variable,
> "object_list", define subsets of this list containing objects that
> meet a certain condition.  So, to filter by the field "Type", I could
> define lists called "type_A_list", "type_B_list", etc, that could be
> iterated through in the same way as the original list.
>
> The reason I need to do this is to be able to use the {% if
> type_A_list %} tag in order to flag when there are NO objects of a
> given type.  This is why (as far as I can see) the {% regroup %} tag
> won't quite work, as it only lists the groups that actually have
> members.
>
> Output would look something like:
>
> Type 1:
> Object 1, Object 5, Object 6
>
> Type 2:
> There are no objects of Type 2
>
> Type 3:
> Object 2, Object 4
>
> Does anyone have any suggestions?
>
> Thanks,
> Bianca
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 recursion

2009-08-31 Thread gentlestone

is recursion allowed in templates?

for example can the "xy_template.html" file contain {% include
"xy_template.html" %}?

because I tried but the system crushed:

Process: Python [97385]
Path:/System/Library/Frameworks/Python.framework/Versions/
2.5/Resources/Python.app/Contents/MacOS/Python
Identifier:  Python
Version: ??? (???)
Code Type:   X86 (Native)
Parent Process:  Python [97384]

Interval Since Last Report:  3912 sec
Crashes Since Last Report:   12
Per-App Interval Since Last Report:  0 sec
Per-App Crashes Since Last Report:   12

Date/Time:   2009-08-31 15:02:00.210 +0200
OS Version:  Mac OS X 10.5.7 (9J61)
Report Version:  6
Anonymous UUID:  BD3D5563-F1EA-4DC8-9293-5BCBADDFA1DE

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0xbfec
Crashed Thread:  1

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



Re: Problem subclassing Widget with value_from_datadict

2009-08-31 Thread Daniel Roseman

On Aug 31, 11:58 am, Mike Ramirez  wrote:
> On Monday 31 August 2009 02:46:27 am Daniel Roseman wrote:
>
> > I think you're going to need to post your view code as well. It seems
> > that the form is passing itself, rather than its data, to the widget,
> > so I'd guess there's something weird about the way it's being
> > instantiated.
> > --
> > DR.
>
> Hereyou go, nothing special.
>
> http://dpaste.com/87647/
>
> Mike

OK I think the problem is that you've declared the form's __init__ to
take an extra argument, userip. So after a POST, in line 6, you're
correctly instantiating your form with the extra arg. However, on a
GET, in line 26, you don't pass in any arguments at all, so the
arguments are all shifted leftwards - what should be in data ends up
in userip, etc.

Either make sure you always pass in userip when you instantiate the
form, or (preferably) change the __init__ so that userip is in the
kwargs dictionary, and use kwargs.pop('userip') to get its value
before you hand off to super().
--
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
-~--~~~~--~~--~--~---



Re: How do you remove fields from a subclassed form?

2009-08-31 Thread Alex Gaynor

On Mon, Aug 31, 2009 at 12:13 AM, buttman wrote:
>
> class MyForm(ModelForm):
>    field1 = CustomField(custom_option="sdsdsd")
>    field2 = CustomField(custom_option="sdsdsd")
>    field3 = CustomField(custom_option="sdsdsd")
>    # 
>
>    class Meta:
>        model = MyModel
>        exclude = ('some_field')
>
> class AnotherForm(MyForm):
>    field1 = CustomFIeld(custom_option="different")
>
>    class Meta:
>        model = MyModel
>        exclude = ('some_field', 'field2')
>
> For some reason, I can't get field2 removed from the subclassed form.
> If I subclass AnotherForm from ModelForm, field2 will be removed, but
> then I lose all my customizations from MyForm...
> >
>

The answer is you don't.  You change the inheritance scheme.  A
fundamental idea of inheritance is that you do not remove
functionality in subclasses.

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
"Code can always be simpler than you think, but never as simple as you
want" -- 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: Database connection closed after each request?

2009-08-31 Thread Graham Dumpleton



On Aug 31, 8:47 pm, Mike  wrote:
> Hi,
>
> I also would like to note that this code is not threadsafe - you can't
> use it with python threads because of unexpectable results, in case of
> mod_wsgi please use prefork daemon mode with threads=1

Provided you set WSGIApplicationGroup to %{GLOBAL} in mod_wsgi 2.X, or
instead use newer mod_wsgi 3.0, you could always use thread locals.
That way each thread would have its own connection.

You need to ensure main interpreter is used in mod_wsgi 2.X, as thread
locals weren't preserved beyond lifetime of request in sub
interpreters. This issue has been addressed in mod_wsgi 3.0.

Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Localized timesince template tag?

2009-08-31 Thread LaundroMat

I seem to remember being able to have template tags and filters
localized in Django, but I can't find any information on this back.
Did I misremember, or have my search skill deteriorated?

I'm particularly looking for a Dutch localization of the timesince
template tag..

Many thanks in advance,

Mathieu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problem subclassing Widget with value_from_datadict

2009-08-31 Thread Mike Ramirez
On Monday 31 August 2009 02:46:27 am Daniel Roseman wrote:

> I think you're going to need to post your view code as well. It seems
> that the form is passing itself, rather than its data, to the widget,
> so I'd guess there's something weird about the way it's being
> instantiated.
> --
> DR.

Hereyou go, nothing special. 

http://dpaste.com/87647/

Mike

-- 
I see the eigenvalue in thine eye,
I hear the tender tensor in thy sigh.
Bernoulli would have been content to die
Had he but known such _a-squared cos 2(phi)!
-- Stanislaw Lem, "Cyberiad"


signature.asc
Description: This is a digitally signed message part.


Re: Database connection closed after each request?

2009-08-31 Thread Mike

Hi,

I also would like to note that this code is not threadsafe - you can't
use it with python threads because of unexpectable results, in case of
mod_wsgi please use prefork daemon mode with threads=1


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



Re: Blocks tags inside inclusion template tags are ignored

2009-08-31 Thread Daniel Roseman

On Aug 31, 4:56 am, ips006  wrote:
> Is it possible to have block tags inside inclusion template tags
> overwrite the block tags in parent templates?
>
> I have a chunk of html generated by an inclusion tag, and I would like
> to assign a CSS file with it. I would like to be able to append to an
> extracss block in base.html (which has links to all css files).
> Currently I cannot do this inside inclusion tags as the {% block %}
> tags are simply ignored.

Well, no, you can't do that. An inclusion tag just renders a template
and includes it, it's not part of the inheritance chain (how could
that work if you had multiple tags?)

You might be able to do something by writing a custom tag that sets
variables in the context, as described in the documentation, rather
than using the inclusion_tag shortcut.
--
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
-~--~~~~--~~--~--~---



Re: Problem subclassing Widget with value_from_datadict

2009-08-31 Thread Daniel Roseman

On Aug 30, 8:59 pm, Mike Ramirez  wrote:
> hey,
>   I'm trying to write a recaptcha widget using the recaptcha client, the
> problem I'm having is that redefining value_from_datadict I get this
> error: 'ContactForm' object has no attribute named 'get'.  This happens on
> the initial loading of the from.
>
> here is the traceback:
>
> http://dpaste.com/87440/
>
> I'm not sure what I'm doing wrong here is the relevant code:
>
> http://dpaste.com/87441/
>
> Mike

I think you're going to need to post your view code as well. It seems
that the form is passing itself, rather than its data, to the widget,
so I'd guess there's something weird about the way it's being
instantiated.
--
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
-~--~~~~--~~--~--~---



FormWizard: how to pass in extra keyword arguments into a form's __init__?

2009-08-31 Thread Berco Beute

One of the forms I'm using in a FormWizard takes an aditional keyword
argument in its __init__, e.g.:

=
def __init__(self, arg1=None, *args, **kwargs):
pass
=

I'm at a loss how to make FormWizard construct my form while passing
in the extra keyword argument (arg1). Any ideas?

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



Re: Django POST data errors

2009-08-31 Thread Matthias Kestenholz

On Mon, Aug 31, 2009 at 3:12 AM, Greg wrote:
>
> Hi all,
>
> I have a large-ish form (40-odd fields) on a pretty busy site, and I'm
> constantly getting "ManagementForm data is missing or has been
> tampered with" or "IOError: request data read error" errors. I can't
> reproduce it, and it always seems to be IE users (sigh)
>
> Does anyone have any ideas on what might be causing this? The form has
> one image upload field, otherwise it's just select boxes and text
> inputs.
>
> Thanks in advance,
>

I'm seeing this too, in a satchmo store administration interface. I've
no idea what causes this either except that it seems related to
Internet Explorer in some way (as you noticed too).

I'd be interested in a way to debug this too, or gather hopefully
helpful information about what's causing this.


Matthias



-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-many column admin interface

2009-08-31 Thread Thomas Guettler

Thank you for this link. Looks good

Sven Richter schrieb:
> Ah, and google does help or at least django_snippets.
> I found the solution here:
> http://www.djangosnippets.org/snippets/1295
> 
> The trick is to create a column in both models and in one with the option to
> not syncdb.
> Its really simple, just 6 lines at all.


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



Re: need help: unique_together in both directions

2009-08-31 Thread ckar...@googlemail.com

Thank you, I have "solved" this with a custom Form method, that's not
very clean, but I works so far.

Chris

On 29 Aug., 20:23, Matthias Kestenholz 
wrote:
> On Sat, Aug 29, 2009 at 7:51 PM,
>
> ckar...@googlemail.com wrote:
>
> > Really no ideas?
>
> > Chris
>
> Is there any way you could define a stable ordering for the
> SinglePoint model? You could ensure that the "smaller" SinglePoint
> gets stored in p1 and the "bigger" SinglePoint in p2 in a custom save
> method.
>
> If that isn't an option, you might want to implement a check in your
> save method. I don't know how you could implement a database UNIQUE
> index which would reject reversed relationships.
>
> Matthias
>
> --
> FeinCMS Django CMS building toolkit:http://spinlock.ch/pub/feincms/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ImportError: No module named stdimage in Django 1.0.3 under Fedora 11

2009-08-31 Thread Zico
On Mon, Aug 31, 2009 at 7:04 AM, Karen Tracey  wrote:

> File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py", line 
> 214, in _resolve_special
>>
>>
>>
>>
>> callback = getattr(self.urlconf_module, 'handler%s' % view_type)
>>
>>   File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py", line 
>> 205, in _get_urlconf_module
>> self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])
>>
>>
>>
>>
>>   File "/opt/fixmystreet/../fixmystreet/urls.py", line 5, in 
>> from mainapp.feeds import LatestReports, LatestReportsByCity, 
>> LatestReportsByWard, LatestUpdatesByReport
>>
>>   File "/opt/fixmystreet/../fixmystreet/mainapp/feeds.py", line 4, in 
>> 
>>
>>
>>
>>
>> from mainapp.models import Report, ReportUpdate, City, Ward
>>
>>   File "/opt/fixmystreet/mainapp/models.py", line 16, in 
>> from contrib.stdimage import StdImageField*
>>
>> ImportError: No module named stdimag*
>>
>>
> You don't appear to have installed the stdimage project in a contrib
> directory on your python path as described here:
>
> http://wiki.github.com/visiblegovernment/django-fixmystreet/installation
>
> under "2. Check Out Project Dependencies".
>
>
Thanks Karen for your reply. Actually, i did it. I followed this:

Download using subversion to any directory included in PYTHON_PATH (for
example /usr/lib/python2.5/site-package)

svn checkout http://django-stdimage.googlecode.com/svn/trunk/ stdimage



I have downloaded the "stdimage" with this svn in my
/usr/lib/python2.5/site-package   but, nothing changed I cannot
understand what is my problem



-- 
Best,
Zico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---