AttributeError at /admin/ when logging into the default Admin site.

2010-09-02 Thread daniel.osterme...@gmail.com
Hi,
Ive been running into a problem lately (not sure when it started)
where I receive an AttributeError when logging into the admin site.
The circumstances seem to be that I start the application, go to the
admin site (and log in successfully), navigate around the rest of the
application (which does not require authentication).  Then at some
point the session or authentication times out and I get the
AttributeError whenever I try to go back to the admin site.
Ive tried googling with out success.  Any help would be appreciated.
Specific details are below:
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.2.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'optiver.public',
 'optiver.xmlrpc']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in wrapper
  207. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/
decorators.py" in _wrapped_view
  76. response = view_func(request, *args,
**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in inner
  188. if not self.has_permission(request):
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in has_permission
  141. return request.user.is_active and
request.user.is_staff
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
middleware.py" in __get__
  9. request._cached_user = get_user(request)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
__init__.py" in get_user
  99. backend = load_backend(backend_path)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
__init__.py" in load_backend
  11. i = path.rfind('.')
Exception Type: AttributeError at /admin/
Exception Value: 'bool' object has no attribute 'rfind'
The value of path at the end is the boolean True
Cheers,
-Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-02 Thread Mike Dewhirst

On 3/09/2010 2:16pm, Jesse wrote:

I have django and postgres working on the local django server.  I had
to install psycopg2-2.2.2.win32-py2.7 in order for that to work.  I
don't believe I have access to an earlier version of psycopg.  Are you
using postgres?


Yes but a different stack - python 2.6, the same revision of postgresl 
and psycopg2. I run the django development server on Win XP and Apache 
2.2 on linux. I leave postgresql running on the XP machine and point the 
linux setup at it across the LAN so I can use development machine data 
for the time being. Works well.


I haven't been following this thread closely but I do remember some time 
ago getting the same error because I had forgotten to install psycopg2 
when deploying to the linux machine.


Your error actually says django either can't find the backend you have 
specified in your settings.py or it can find it but it isn't available 
for some reason.


I would be investigating the database side of things. Without googling I 
would know whether there might be any subtle psycopg2 version problems 
but I'd eliminate everything else as a possibility first.


Mike


Jesse

On Sep 2, 5:41 pm, Mike Dewhirst  wrote:

On 3/09/2010 7:46am, Jesse wrote:


Hello Graham,



I have the c:/public/apache/apache_django_wsgi.conf working now, at
least apache restarts.  Do you know if mod_wsgi has a problem with
these versions:
python 2.7 and apache 2.2, and postgres 8.4, psycopg 2.2.2



My server error is:



TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
'django.db.backends.postgresql_psycopg2' isn't an available database
backend.


I don't think it is a wsgi problem. This looks like you may not have
installed psycopg2 on your server.





--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-02 Thread Jesse
I have django and postgres working on the local django server.  I had
to install psycopg2-2.2.2.win32-py2.7 in order for that to work.  I
don't believe I have access to an earlier version of psycopg.  Are you
using postgres?
Jesse

On Sep 2, 5:41 pm, Mike Dewhirst  wrote:
> On 3/09/2010 7:46am, Jesse wrote:
>
> > Hello Graham,
>
> > I have the c:/public/apache/apache_django_wsgi.conf working now, at
> > least apache restarts.  Do you know if mod_wsgi has a problem with
> > these versions:
> > python 2.7 and apache 2.2, and postgres 8.4, psycopg 2.2.2
>
> > My server error is:
>
> > TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
> > 'django.db.backends.postgresql_psycopg2' isn't an available database
> > backend.
>
> I don't think it is a wsgi problem. This looks like you may not have
> installed psycopg2 on your server.
>
>
>
> > [Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using
> > django.db.backends.XXX, where XXX is one of:
> > [Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1]     'dummy',
> > 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
> > [Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was:
> > cannot import name utils
>
> > Thank you!
>
> > On Sep 2, 9:10 am, Jesse  wrote:
> >> Thanks!  I did see the hello using the corrected localhost/myapp, so I
> >> at least know that I have the right version of mod_wsgi.  Now I'm back
> >> to my original problem.  The apache server will not restart when I add
> >> the following line to the http.conf file:
>
> >> Include "c:/public/apache/apache_django_wsgi.conf"
>
> >> which I place before the here:
> >> Include "c:/public/apache/apache_django_wsgi.conf"
> >> #WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"
>
> >> 
> >> Order allow,deny
> >> Allow from all
> >> 
>
> >> The apache_django_wsgi.conf file has the following:
> >> //start code
> >> Alias /media/ "c:/public/media/"
>
> >> 
> >> Order allow, deny
> >> Option Indexes
> >> Allow from all
> >> IndexOptions FancyIndexing
> >> 
>
> >> WSGIScriptAlias / "c:/public/apache/django.wsgi"
>
> >>  >> Order deny,allow
> >> Allow from all
> >> 
>
> >> //end code
>
> >> The error is Request operation failed.
>
> >> Thx for your help!!
>
> >> Jesse
> >> On Sep 1, 8:53 pm, Graham Dumpleton
> >> wrote:
>
> >>> On Sep 2, 1:13 pm, Jesse  wrote:
>
>  I'm using Python 2.7, Apache 2.2 and grabbed the mod_wsgi that
>  supposedly works.  I changed the name of the file to mod_wsgi and
>  placed into Apache modules library.  I changed the folders, so the
>  apache folder by itself and created the following in the apache
>  http.conf file:
>  WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"
>
>  
>  Order allow,deny
>  Allow from all
>  
>
>  The myapp.wsgi is:
>  def application(environ, start_response):
>       status = '200 OK'
>       output = 'Hello World!'
>
>       response_headers = [('Content-type', 'text/plain'),
>                           ('Content-Length', str(len(output)))]
>       start_response(status, response_headers)
>
>       return [output]
>
>  Apache starts fine, no errors, but the localhost is still the original
>  apache page and not hello world.
>
> >>> What URL are you using? Sounds like you are using:
>
> >>>  http://localhost
>
> >>> and not:
>
> >>>  http://localhost/myapp
>
> >>> Your WSGIScriptAlias has it mounted at sub URL not root of site which
> >>> is where standard Apache 'It Works' page would be found.
>
> >>> Graham
>
>  On Sep 1, 4:25 pm, Graham Dumpleton
>  wrote:
>
> > On Sep 2, 4:46 am, Jesse  wrote:
>
> >> created project using startproject testproject
>
> >> Problems with apache_django_wsgi.conf
> >> 1.  Added following line toApache:
> >> LoadModule wsgi_module modules/mod_wsgi.so
>
> >> 2. Created folder c:/django/testproject/apache
>
> >> 3.  Created file c:/django/testproject/apache/django.wsgi
> >> // code starts
> >> import os, sys
> >> sys.path.append("/c:/django")
>
> > All your paths where you have '/c:' instead of just 'c:' are wrong to
> > start with.
>
> >> os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> >> import django.core.handlers.wsgi
>
> >> application = django.core.handlers.wsgi.WSGIHandler()
> >> // code ends
>
> >> 4.  Apachestarts and restarts. local host is originalapache"It
> >> works"
>
> >> 5.  Created file c:/django/testproject/apache_django_wsgi.conf
> >> //code starts
> >> Alias /media/ /c:/django/testproject/media/
>
> >> 
> >> Order deny,allow
> >> Allow from all
> >> 
>
> >> WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi
>
> >> 
> >> Order deny,allow
> >> Allow from all
> >> 
> >> //code ends
>
> 

Re: fetching values from model

2010-09-02 Thread Pradnya
ok Thanks. How about using Register tags. It's in
Django.template.Library.
Is it a good practice to use simple_tag? I want to know the plus
points and drawbacks of simple_tag.

On Sep 2, 8:52 pm, Justin Myers  wrote:
> In theory, if the view passed that function to the template (or if it
> were available as a method on something else that was passed to the
> template), I suppose you could. That said, you wouldn't be able to
> pass it any arguments.
>
> Once again, the template is _not_ designed for programming logic. It's
> _only_ designed for presentation. For the most part, if you want to
> call a function, call it in the view.
> -Justin
>
> On Sep 1, 11:02 pm, Pradnya  wrote:
>
> > Hey thanks,
> > Is there anyway I can call a function in HTML template?
>
> > On Sep 1, 6:23 pm, Steve Holden  wrote:
>
> > > On 9/1/2010 9:13 AM, Pradnya wrote:>> ok. Is there any way I can load the 
> > > model inside HTML template?
> > > >> What is {% load  %} tag all about?
>
> > > The {% load %} tag is for loading custom tags. Nothing to do with
> > > accessing the database.
>
> > > Why do you find it desirable to load records in the template?  What's
> > > wrong with doing it in the view, which is what everyone else does and
> > > how Django is intended to be used? See Jonas' remarks below.
>
> > > regards
> > >  Steve
>
> > > >> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
> > >  You don't write Python code inside your template file. That's
> > >  one of the basic django template rules. You can pass values
> > >  from your views to your template and show them there. Or
> > >  generate the HTML in your view and show it from there, which
> > >  isn't something I could advise if you're creating a larger
> > >  application.
>
> > >  Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
> > > >> Hello,
>
> > > >> Is it possible to fetch a particular record from model
> > > >> using school.object.get(id = 1) inside html template.
>
> > > >> Please suggest.
>
> > > >> Thanks Pradnya
>
> > > >> -- You received this message because you are subscribed to
> > > >> the Google Groups "Django users" group. To post to this
> > > >> group, send email to django-us...@googlegroups.com. To
> > > >> unsubscribe from this group, send email to
> > > >> django-users+unsubscr...@googlegroups.com. For more
> > > >> options, visit this group
> > > >> athttp://groups.google.com/group/django-users?hl=en.
>
> > >  Met vriendelijke groeten,
>
> > >  Jonas Geiregat jo...@geiregat.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Multiple authentication sources to one database

2010-09-02 Thread Jeff Bell
Auth backends fail down the list of middleware.  So I'm thinking something
like this.

Maybe, the users that you authenticate using LDAP or AD, append something to
their username, like _xyzuser.

johndoe has LDAP/AD password and logs in.
AD_AUTH_Middleware succeeds with original username and passwd,
Adds pre-determined suffix to username and queries local users for that new
username.
Object does not exist but since he validated against other service you
create a username with suffix and password of your choice.

johndoe has LDAP/AD password and logs in.
AD_AUTH_Middleware succeeds,
Adds pre-determined suffix to username and queries users for that username.
User object is returned.

johndoe (a different one) logs in with a contrib auth password from your
django database.
AD_AUTH_Middleware fails and fails over to contrib_auth.
Django Auth Middleware queries local users and returns User object.

Only chink in the armor would be if they both had the same passwords.  I'm
sure you could add some other criteria to your LDAP auth backend to help
with that though by adding a field to a user profile.

I'm no expert.  I just want to start giving back to the Django community so
this is my best shot.

Jeff





On Thu, Sep 2, 2010 at 4:28 PM, Shawn Milochik  wrote:

> You can use multiple authentication backends in the same Django
> project. All you have to do is write/install a backend that supports
> your alternative method, and add it to AUTHENTICATION_BACKENDS in your
> settings file.
>
> The info here should help a lot:
>
> http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend
>
> For users who authenticate against the alternative source, just create
> a new User instance on-the-fly when they first successfully log in.
> This will allow the rest of your app and pluggable apps to "just work"
> if they rely on contrib.auth.
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

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

2010-09-02 Thread spearsear
Account.objects.filter(balance__lt=20) selects accounts with balance
less than $20

Account.objects.filter(balance__lt=jeff.balance) selects accounts with
balance less than the balance of jeff's account

Now, How do I do this?

accounts with balance whose absolute value is greater than the
absolute value of jeff's account balance?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-02 Thread Mike Dewhirst

On 3/09/2010 7:46am, Jesse wrote:

Hello Graham,

I have the c:/public/apache/apache_django_wsgi.conf working now, at
least apache restarts.  Do you know if mod_wsgi has a problem with
these versions:
python 2.7 and apache 2.2, and postgres 8.4, psycopg 2.2.2

My server error is:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
'django.db.backends.postgresql_psycopg2' isn't an available database
backend.


I don't think it is a wsgi problem. This looks like you may not have 
installed psycopg2 on your server.




[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using
django.db.backends.XXX, where XXX is one of:
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] 'dummy',
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was:
cannot import name utils

Thank you!

On Sep 2, 9:10 am, Jesse  wrote:

Thanks!  I did see the hello using the corrected localhost/myapp, so I
at least know that I have the right version of mod_wsgi.  Now I'm back
to my original problem.  The apache server will not restart when I add
the following line to the http.conf file:

Include "c:/public/apache/apache_django_wsgi.conf"

which I place before the here:
Include "c:/public/apache/apache_django_wsgi.conf"
#WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"


Order allow,deny
Allow from all


The apache_django_wsgi.conf file has the following:
//start code
Alias /media/ "c:/public/media/"


Order allow, deny
Option Indexes
Allow from all
IndexOptions FancyIndexing


WSGIScriptAlias / "c:/public/apache/django.wsgi"



//end code

The error is Request operation failed.

Thx for your help!!

Jesse
On Sep 1, 8:53 pm, Graham Dumpleton
wrote:




On Sep 2, 1:13 pm, Jesse  wrote:



I'm using Python 2.7, Apache 2.2 and grabbed the mod_wsgi that
supposedly works.  I changed the name of the file to mod_wsgi and
placed into Apache modules library.  I changed the folders, so the
apache folder by itself and created the following in the apache
http.conf file:
WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"




Order allow,deny
Allow from all




The myapp.wsgi is:
def application(environ, start_response):
 status = '200 OK'
 output = 'Hello World!'



 response_headers = [('Content-type', 'text/plain'),
 ('Content-Length', str(len(output)))]
 start_response(status, response_headers)



 return [output]



Apache starts fine, no errors, but the localhost is still the original
apache page and not hello world.



What URL are you using? Sounds like you are using:



  http://localhost



and not:



  http://localhost/myapp



Your WSGIScriptAlias has it mounted at sub URL not root of site which
is where standard Apache 'It Works' page would be found.



Graham



On Sep 1, 4:25 pm, Graham Dumpleton
wrote:



On Sep 2, 4:46 am, Jesse  wrote:



created project using startproject testproject



Problems with apache_django_wsgi.conf
1.  Added following line toApache:
LoadModule wsgi_module modules/mod_wsgi.so



2. Created folder c:/django/testproject/apache



3.  Created file c:/django/testproject/apache/django.wsgi
// code starts
import os, sys
sys.path.append("/c:/django")



All your paths where you have '/c:' instead of just 'c:' are wrong to
start with.



os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'



import django.core.handlers.wsgi



application = django.core.handlers.wsgi.WSGIHandler()
// code ends



4.  Apachestarts and restarts. local host is originalapache"It
works"



5.  Created file c:/django/testproject/apache_django_wsgi.conf
//code starts
Alias /media/ /c:/django/testproject/media/




Order deny,allow
Allow from all




WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi




Order deny,allow
Allow from all

//code ends



6.  Added following line toApachehttp.conf
Include "c:/django/testproject/apache/apache_django_wsgi.conf"



7.  Apacheerror, cannot restart.



Any help is much appreciated.



Does theApacheerror log have anything in it?



WhichApacheversion? Which Python version? Which mod_wsgi object did
you grab, or did you compile from source code?



Are you trying to run 64bitWindows?



BTW, recommended to test first with a WSGI hello world program and not
Django.



See hello world example in:



  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide



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-us...@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: ForeignKey, Index conflict going from 1.0 to 1.2

2010-09-02 Thread HiTekElvis
That's a huge help in understanding the underlying concepts.  Thank
you very much.  While attempting to answer my question, you actually
led me to the answer myself.

I was trying to generate an index with South and that was raising the
error.  Essentially, I was trying to apply an index to a foreign key
field, without knowing that ForeignKey fields are indexed by default,
even in 1.0.  I was creating an index on a field that was already
indexed and thought I had a naming conflict.

Sorry for wasting your time.  I'm a little new to Django, having spent
a lot of years with SQLAlchemy, and now, coming into a large,
existing, Django project.  So, I'm still learning the intricacies.

Thanks so much for taking the time to respond.  You're a rock star.

-Josh

On Sep 2, 4:54 pm, Russell Keith-Magee 
wrote:
> On Fri, Sep 3, 2010 at 6:03 AM, HiTekElvis  wrote:
> > Have a db that was generated under 1.0.  Hence, foreign keys in MySQL
> > have been named [tablename]_[fieldname]_id.
>
> A slight correction - foreign key *indexes* will be named like that;
> the fields themselves don't include the table name.
>
> > However, when upgrading to 1.2, I tried to create an index on that
> > field and got an error, because 1.2 names its foreign keys
> > [tablename]_[hash] and its index keys [tablename]_[fieldname]_id.
>
> > Is there a solution for this?  A script that renames the foreignkeys
> > to follow the 1.2 format, or a way to alternatively name the index
> > key?
>
> > Apologize if this is already documented somewhere.  I looked all over
> > and didn't find anything.
>
> There isn't a simple script, because what you're describing
> *shouldn't* be posing a problem.
>
> Django doesn't touch tables once they're originally created.
> Therefore, once a table has been created, there's no way to get Django
> to create a new index (or make any other table modification for that
> matter).
>
> You *could* use sqlall or sqlindexes commands et al to work out the
> likely syntax for any new table modifications; however, if you're
> taking snippets of those commands and running them manually over your
> database (e.g., in your case, taking some index creation commands)
> then you'll need to audit them to make sure they are appropriate to
> your existing database. There's a reason Django provides sqlindexes,
> but doesn't provide a way to apply that SQL directly to your database
> -- we want to make sure that you audit any SQL that we generate but
> don't provide a way to automatically apply.
>
> The change you're referring to was introduced to avoid warnings and
> errors that you must be either seeing or suppressing. It relates to
> the use of column names that exceed system limits -- on MySQL, that's
> 64 characters. If a column name, table name or index name exceeds this
> limit, MySQL ignores the 65+ characters, potentially introducing an
> ambiguity in queries. To compensate, all indexes are named using the
> scheme table_name_HASH, with the hash constructed from a digest of the
> fields involved.
>
> However, the *name* of the index doesn't actually matter. If you
> didn't have an index in an older version of some code, and now you do,
> it doesn't matter what you call the new index -- the name is just an
> identifier. Once it's created, Django doesn't have anything to do with
> it; it exists, and MySQL handles all the interaction with the index.
>
> So -- I'm a little confused as to the errors you are seeing. Can you 
> elaborate?
>
> Yours,
> Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: what to do instead of adding to Query.extra_where ?

2010-09-02 Thread Steve Holden
On 9/2/2010 1:44 AM, Paul Winkler wrote:
> Hah. That was a pretty long message relative to how quickly I found
> the answer myself :-p
> Sorry for the noise.
> 
> For posterity, extra(where=...) is indeed the solution. I overlooked
> the obvious:
> the class I was trying to fix is itself a subclass of QuerySet.  So
> given this line:
> 
> clone.query.extra_where += ('db_newsitem.id =
> db_attribute.news_item_id',)
> 
> the replacement is now:
> 
> clone = clone.extra(where=('db_newsitem.id =
> db_attribute.news_item_id',))
> 
> Seems to work fine.
> 
[...]

Once again this group proves itself at least as valuable as a stuffed
bear ;-)

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ForeignKey, Index conflict going from 1.0 to 1.2

2010-09-02 Thread Russell Keith-Magee
On Fri, Sep 3, 2010 at 6:03 AM, HiTekElvis  wrote:
> Have a db that was generated under 1.0.  Hence, foreign keys in MySQL
> have been named [tablename]_[fieldname]_id.

A slight correction - foreign key *indexes* will be named like that;
the fields themselves don't include the table name.

> However, when upgrading to 1.2, I tried to create an index on that
> field and got an error, because 1.2 names its foreign keys
> [tablename]_[hash] and its index keys [tablename]_[fieldname]_id.
>
> Is there a solution for this?  A script that renames the foreignkeys
> to follow the 1.2 format, or a way to alternatively name the index
> key?
>
> Apologize if this is already documented somewhere.  I looked all over
> and didn't find anything.

There isn't a simple script, because what you're describing
*shouldn't* be posing a problem.

Django doesn't touch tables once they're originally created.
Therefore, once a table has been created, there's no way to get Django
to create a new index (or make any other table modification for that
matter).

You *could* use sqlall or sqlindexes commands et al to work out the
likely syntax for any new table modifications; however, if you're
taking snippets of those commands and running them manually over your
database (e.g., in your case, taking some index creation commands)
then you'll need to audit them to make sure they are appropriate to
your existing database. There's a reason Django provides sqlindexes,
but doesn't provide a way to apply that SQL directly to your database
-- we want to make sure that you audit any SQL that we generate but
don't provide a way to automatically apply.

The change you're referring to was introduced to avoid warnings and
errors that you must be either seeing or suppressing. It relates to
the use of column names that exceed system limits -- on MySQL, that's
64 characters. If a column name, table name or index name exceeds this
limit, MySQL ignores the 65+ characters, potentially introducing an
ambiguity in queries. To compensate, all indexes are named using the
scheme table_name_HASH, with the hash constructed from a digest of the
fields involved.

However, the *name* of the index doesn't actually matter. If you
didn't have an index in an older version of some code, and now you do,
it doesn't matter what you call the new index -- the name is just an
identifier. Once it's created, Django doesn't have anything to do with
it; it exists, and MySQL handles all the interaction with the index.

So -- I'm a little confused as to the errors you are seeing. Can you elaborate?

Yours,
Russ Magee %-)

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



ForeignKey, Index conflict going from 1.0 to 1.2

2010-09-02 Thread HiTekElvis
Have a db that was generated under 1.0.  Hence, foreign keys in MySQL
have been named [tablename]_[fieldname]_id.

However, when upgrading to 1.2, I tried to create an index on that
field and got an error, because 1.2 names its foreign keys
[tablename]_[hash] and its index keys [tablename]_[fieldname]_id.

Is there a solution for this?  A script that renames the foreignkeys
to follow the 1.2 format, or a way to alternatively name the index
key?

Apologize if this is already documented somewhere.  I looked all over
and didn't find anything.

Thanks,

Josh

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



Customizing the login generic view with a custom backend

2010-09-02 Thread Steven L Smith
I've written a custom backend for Django auth to hook into our Active
Directory. It works great, but some users can't seem to figure out
that "username" does not equal "email address". Since our AD is kind
of borked, multiple users *might* have the same email addresses, so
simply changing it to also allow auth based on email won't work.

We had the idea that, if we checked for the presence of an "@" sign in
the code, we could raise a validation error in our backend, and it
would be a nice "user education" opportunity.


Inside my authenticate() method, I have:
if "@" in username:
 raise ValidationError("Hey idiot")

In the template, when I access {{ form.errors }} it shows up, but it
is wrapped very strangely. Likewise when I try to loop through it.

How can I get *just* the text of the error? I tried looping over
form.errors.itervalues, but that still returns html.

I could *settle* for the extra html, but we're using the same backend
for the admin, and my ValidationError is not trapped by its login
view, so I end up with a 500.

Thanks!


AD Backend:
http://dpaste.com/237935/

Template Examples:
http://dpaste.com/237938/


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

2010-09-02 Thread Bill Freeman
Don't use [] subscripting, use dot.  The template engine tries using
the thing after the dot in various ways, including as a dictionary key
and as a list index.  So, for example:

  {% ifequal param1_trunc.i "-" %}

On Thu, Sep 2, 2010 at 5:11 PM, Bradley Hintze
 wrote:
> Hi,
>
> Django says that this is a TemplateSyntaxError.
>
> if param1_trunc[i][1]
>
> The i refers to an index of a for loop as shown:
>
> {% for i in pdb1_nums_len_dev6 %}
>        
>          {% ifequal param1_trunc[i] '-' %}
>          {% else %}
>            {% if param1_trunc[i][1] %}
>            {% else %}
>            
>            {% endifequal %}
>          {% endifequal %}
>        {% endfor %}
>
> param1_trunc is a list of lists. Can I not access a object within an
> internal list in a template llke regular python (see below)?
>
>>>p =[[1,2,3],[3,4,5]]
>>>print p[0][1]
> 2
>
>
>
>
> --
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

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



Re: how to add a non-field text property to forms in a formset

2010-09-02 Thread bobhaugen
I am so dense sometimes...

I had forgotten that initial data in a formset is a *list* of
dictionaries.

So I set up the initial data in a loop over the available products,
and created a parallel list of product_descriptions in the same loop.

Then set up the formset, and looped over formset.forms adding the
parallel form.product_description to each.

Don't know why I didn't think of that at before I got stumped.  But
thanks again for leading me through the possibilities.

Might still be an simpler way to do it, but that way was simple enough.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-02 Thread Jesse
Hello Graham,

I have the c:/public/apache/apache_django_wsgi.conf working now, at
least apache restarts.  Do you know if mod_wsgi has a problem with
these versions:
python 2.7 and apache 2.2, and postgres 8.4, psycopg 2.2.2

My server error is:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
'django.db.backends.postgresql_psycopg2' isn't an available database
backend.
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using
django.db.backends.XXX, where XXX is one of:
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] 'dummy',
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was:
cannot import name utils

Thank you!

On Sep 2, 9:10 am, Jesse  wrote:
> Thanks!  I did see the hello using the corrected localhost/myapp, so I
> at least know that I have the right version of mod_wsgi.  Now I'm back
> to my original problem.  The apache server will not restart when I add
> the following line to the http.conf file:
>
> Include "c:/public/apache/apache_django_wsgi.conf"
>
> which I place before the here:
> Include "c:/public/apache/apache_django_wsgi.conf"
> #WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"
>
> 
> Order allow,deny
> Allow from all
> 
>
> The apache_django_wsgi.conf file has the following:
> //start code
> Alias /media/ "c:/public/media/"
>
> 
> Order allow, deny
> Option Indexes
> Allow from all
> IndexOptions FancyIndexing
> 
>
> WSGIScriptAlias / "c:/public/apache/django.wsgi"
>
>  Order deny,allow
> Allow from all
> 
>
> //end code
>
> The error is Request operation failed.
>
> Thx for your help!!
>
> Jesse
> On Sep 1, 8:53 pm, Graham Dumpleton 
> wrote:
>
>
>
> > On Sep 2, 1:13 pm, Jesse  wrote:
>
> > > I'm using Python 2.7, Apache 2.2 and grabbed the mod_wsgi that
> > > supposedly works.  I changed the name of the file to mod_wsgi and
> > > placed into Apache modules library.  I changed the folders, so the
> > > apache folder by itself and created the following in the apache
> > > http.conf file:
> > > WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"
>
> > > 
> > > Order allow,deny
> > > Allow from all
> > > 
>
> > > The myapp.wsgi is:
> > > def application(environ, start_response):
> > >     status = '200 OK'
> > >     output = 'Hello World!'
>
> > >     response_headers = [('Content-type', 'text/plain'),
> > >                         ('Content-Length', str(len(output)))]
> > >     start_response(status, response_headers)
>
> > >     return [output]
>
> > > Apache starts fine, no errors, but the localhost is still the original
> > > apache page and not hello world.
>
> > What URL are you using? Sounds like you are using:
>
> >  http://localhost
>
> > and not:
>
> >  http://localhost/myapp
>
> > Your WSGIScriptAlias has it mounted at sub URL not root of site which
> > is where standard Apache 'It Works' page would be found.
>
> > Graham
>
> > > On Sep 1, 4:25 pm, Graham Dumpleton 
> > > wrote:
>
> > > > On Sep 2, 4:46 am, Jesse  wrote:
>
> > > > > created project using startproject testproject
>
> > > > > Problems with apache_django_wsgi.conf
> > > > > 1.  Added following line toApache:
> > > > > LoadModule wsgi_module modules/mod_wsgi.so
>
> > > > > 2. Created folder c:/django/testproject/apache
>
> > > > > 3.  Created file c:/django/testproject/apache/django.wsgi
> > > > > // code starts
> > > > > import os, sys
> > > > > sys.path.append("/c:/django")
>
> > > > All your paths where you have '/c:' instead of just 'c:' are wrong to
> > > > start with.
>
> > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> > > > > import django.core.handlers.wsgi
>
> > > > > application = django.core.handlers.wsgi.WSGIHandler()
> > > > > // code ends
>
> > > > > 4.  Apachestarts and restarts. local host is originalapache"It
> > > > > works"
>
> > > > > 5.  Created file c:/django/testproject/apache_django_wsgi.conf
> > > > > //code starts
> > > > > Alias /media/ /c:/django/testproject/media/
>
> > > > > 
> > > > > Order deny,allow
> > > > > Allow from all
> > > > > 
>
> > > > > WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi
>
> > > > > 
> > > > > Order deny,allow
> > > > > Allow from all
> > > > > 
> > > > > //code ends
>
> > > > > 6.  Added following line toApachehttp.conf
> > > > > Include "c:/django/testproject/apache/apache_django_wsgi.conf"
>
> > > > > 7.  Apacheerror, cannot restart.
>
> > > > > Any help is much appreciated.
>
> > > > Does theApacheerror log have anything in it?
>
> > > > WhichApacheversion? Which Python version? Which mod_wsgi object did
> > > > you grab, or did you compile from source code?
>
> > > > Are you trying to run 64bitWindows?
>
> > > > BTW, recommended to test first with a WSGI hello world program and not
> > > > Django.
>
> > > > See hello world example in:
>
> > > >  

Re: How is this feature called?

2010-09-02 Thread John M
So the example you gave of "other peoples" looks like they have a
related table for "Service Checks" and that table has two fields, one
for check and the other for options, from what I can tell.

HTH

J

On Sep 1, 7:03 am, norus  wrote:
> Hi all,
>
> I've decided to start learning Django and Python at the same time. The
> project I'm working on will help configure Nagios directly from the
> Django administation page. Here's a sample screenshot of what I've
> done so far:http://valiyev.net/tmp/progress.png
>
> Now my question is as follows, under "Check options", how do I add an
> additional CharField where I would be able to submit arguments to the
> command in "Service Checks"? Here's how other people did it (all I
> could find was this 
> screenshot:http://www.linuxaddicted.de/blog/wp-content/uploads/2009/03/picture-6...).
>
> Thanks in advance.
>
> norus

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



Re: How to display many-to-many field as a list of text input fields?

2010-09-02 Thread Steve Holden
On 9/2/2010 4:27 PM, adelein wrote:
> When I display the ToolBoxEditForm it uses a multiple select field.
> But what I want is a form that lets the user edit each tool he has in
> the toolbox as a text field. I cant figure out how to do this with the
> many-to-many field.
> 
A many-to-many relationship represents a constraint on the database,
which is therefore reflected by Django as a constraint in the user input.

What would you expect Django to do if the user enters the name of a
tool in your form that doesn't exist?

regards
 Steve

> class Tool(models.Model):
> tool_name = models.CharField(unique=True, max_length=200)
> ..
> 
> class ToolBox(models.Model):
> tools = models.ManyToManyField(Tool,max_length=300)
> 
> class ToolBoxEditForm (ModelForm):
> tools = ???
> class Meta:
>   model = ToolBox
>   exclude  = ('user', 'popularity',)
> 
> I would appreciate any pointers!
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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

2010-09-02 Thread Bradley Hintze
Hi,

Django says that this is a TemplateSyntaxError.

if param1_trunc[i][1]

The i refers to an index of a for loop as shown:

{% for i in pdb1_nums_len_dev6 %}

  {% ifequal param1_trunc[i] '-' %}
  {% else %}
{% if param1_trunc[i][1] %}
{% else %}

{% endifequal %}
  {% endifequal %}
{% endfor %}

param1_trunc is a list of lists. Can I not access a object within an
internal list in a template llke regular python (see below)?

>>p =[[1,2,3],[3,4,5]]
>>print p[0][1]
2




-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

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



Re: how to add a non-field text property to forms in a formset

2010-09-02 Thread bobhaugen
Bill,

thanks a ton for the conversation.

I will try some variations of that set of ideas over the weekend and
report back here with what works.

And you are correct, I am not now creating the formset forms in a
loop, but might try that as one variation.

-Bob

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



Re: how to add a non-field text property to forms in a formset

2010-09-02 Thread Bill Freeman
Well, if you can iterate the forms of a formset in the template, you can
do it in python.  I guess the trick is whether there is a public interface
for accessing the model instance of the current form during such an
iteration,  (I'm assuming here that the fields you do want to use a fields
comes from instances of a model, and that the text you want to play
with does too.)  You could iterate (in python) over a zip() of the forms
of the formset and a same order list of the model instance (or something
else that gives you access to the strings (such as a list of the strings).

Of course, if you're creating the formset in a loop already, you could
maybe do it at that time.  I'd guess, however, that you're doing it
with a queryset that's not actually getting iterated until the template
iterates it.  Assuming that these are instances of the same form, you
could override the Form class's __init__ method, which, for model
forms, has access to the instance, could extract the description, and
stick it on an instance of "self", after calling the super class __init__
method.  (Remember to pass instance on to the super clas __init__ if
you capture it with a named argument rather than extracting ti from
kwargs.)  Does that fit?

Bill

On Thu, Sep 2, 2010 at 4:08 PM, bobhaugen  wrote:
> On Sep 2, 2:54 pm, Bill Freeman  wrote:
>> Let's start by agreeing on common terminology.  "property" has
>>  a meaning in Python slightly different than its usage in some
>> other languages, and I don't think that's what you mean.
>>
>> I'm thinking that what you mean by "property" on the form is what
>> Python calls an attribute of the instance of the form class.
>
> Yeah, sorry about the term. Attribute is what I mean.
>
> [some paragraphs elided for now...]
>
>> And you want to include, somewhere between the statements above:
>>
>>    form.product_description = u'Some string involving "hanging weight"'
>>
>> Am I tracking so far?
>
> Yeah, except I can do that easily for a normal form.  Am trying to
> figure out how to do it for forms in a formset.  I can add the same
> attribute with the same value to all forms in a formset by doing
> something like:
>
> for form in formset.forms:
>    form.project_description = "Beef etc."
>
> But of course each product has a different description.
>
>> If so, in your template, you should, at the appropriate point, be able to
>> say:
>>
>>   {{ beef_form.product_description }}
>>
>> That should do what you would think.  The product_description attribute is
>> not used automatically by anything, but is available for the variable 
>> reference
>> in the template.
>>
>> So, is this what you want, and if so have you tried it, and if so what don't
>> you like about the result?
>
> Works great and is less filling for regular forms, and I do it all the
> time.  Including in my set-of-forms which is not a formset, which is
> how I did it before formsets were invented.  I want to do the same
> thing for forms in a formset.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Multiple authentication sources to one database

2010-09-02 Thread Shawn Milochik
You can use multiple authentication backends in the same Django
project. All you have to do is write/install a backend that supports
your alternative method, and add it to AUTHENTICATION_BACKENDS in your
settings file.

The info here should help a lot:
http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend

For users who authenticate against the alternative source, just create
a new User instance on-the-fly when they first successfully log in.
This will allow the rest of your app and pluggable apps to "just work"
if they rely on contrib.auth.

Shawn

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



How to display many-to-many field as a list of text input fields?

2010-09-02 Thread adelein
When I display the ToolBoxEditForm it uses a multiple select field.
But what I want is a form that lets the user edit each tool he has in
the toolbox as a text field. I cant figure out how to do this with the
many-to-many field.

class Tool(models.Model):
tool_name = models.CharField(unique=True, max_length=200)
..

class ToolBox(models.Model):
tools = models.ManyToManyField(Tool,max_length=300)

class ToolBoxEditForm (ModelForm):
tools = ???
class Meta:
  model = ToolBox
  exclude  = ('user', 'popularity',)

I would appreciate any pointers!

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



Re: how to add a non-field text property to forms in a formset

2010-09-02 Thread bobhaugen
On Sep 2, 2:54 pm, Bill Freeman  wrote:
> Let's start by agreeing on common terminology.  "property" has
>  a meaning in Python slightly different than its usage in some
> other languages, and I don't think that's what you mean.
>
> I'm thinking that what you mean by "property" on the form is what
> Python calls an attribute of the instance of the form class.  

Yeah, sorry about the term. Attribute is what I mean.

[some paragraphs elided for now...]

> And you want to include, somewhere between the statements above:
>
>    form.product_description = u'Some string involving "hanging weight"'
>
> Am I tracking so far?

Yeah, except I can do that easily for a normal form.  Am trying to
figure out how to do it for forms in a formset.  I can add the same
attribute with the same value to all forms in a formset by doing
something like:

for form in formset.forms:
form.project_description = "Beef etc."

But of course each product has a different description.

> If so, in your template, you should, at the appropriate point, be able to
> say:
>
>   {{ beef_form.product_description }}
>
> That should do what you would think.  The product_description attribute is
> not used automatically by anything, but is available for the variable 
> reference
> in the template.
>
> So, is this what you want, and if so have you tried it, and if so what don't
> you like about the result?

Works great and is less filling for regular forms, and I do it all the
time.  Including in my set-of-forms which is not a formset, which is
how I did it before formsets were invented.  I want to do the same
thing for forms in a formset.

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



Re: how to add a non-field text property to forms in a formset

2010-09-02 Thread Bill Freeman
Let's start by agreeing on common terminology.  "property" has
 a meaning in Python slightly different than its usage in some
other languages, and I don't think that's what you mean.

I'm thinking that what you mean by "property" on the form is what
Python calls an attribute of the instance of the form class.  So, below,
you got the item "form" by doings something like

  form = MyModelFormClass(instance=some_model_instance, ...)

and that you are passing it as part of the context (possibly indirectly, but
we can worry about details later) in a template rendering operation, someting
like:

  return render_to_response("some/template.html", {'beef_form': form, ...})

And you want to include, somewhere between the statements above:

   form.product_description = u'Some string involving "hanging weight"'


Am I tracking so far?

If so, in your template, you should, at the appropriate point, be able to
say:

  {{ beef_form.product_description }}

That should do what you would think.  The product_description attribute is
not used automatically by anything, but is available for the variable reference
in the template.

So, is this what you want, and if so have you tried it, and if so what don't
you like about the result?

Bill

On Thu, Sep 2, 2010 at 3:06 PM, bobhaugen  wrote:
> Bill,
>
> Thanks a lot for sticking with this question.
>
> On Sep 2, 1:44 pm, Bill Freeman  wrote:
>> I guess that what I'm saying is that when you get fussy about rendering, you
>> need to write the html/css yourself.  Because you say you want read only for
>> these fields, don't use the form field's rendering at all (or use a
>> hidden field).
>
> I don't want a field, I want an additional property on each form in
> the formset, that I can set differently for each form.  I can do this
> easily if I roll my own set-of-forms (not a formset) where I add to
> each form something like form.product_description = "Beef, Whole,
> choice or better, per pound hot hanging weight".
>
> I swear, that is an actual product description. But so is
> "Strawberries, pint".  So if I use a product_description field, and
> put it in a table cell, I need to size the field to handle the Beef,
> Whole etc.  and the table gets too wide for  the window. If I use a
> non-field property, HTML wraps the cell nicely as needed.
>
>> Or I may be totally misunderstanding the original problem.
>
> I don't know, probably I am not communicating well, or maybe I am
> missing something in your suggestions.  I did read through all of the
> Django documentation on forms, formsets, form api, fields, etc., and
> did not find anything that I could see helping.
>
> And this forum thread appears to say that I cannot display the value
> of the field in a template:
> http://groups.google.com/group/django-users/browse_thread/thread/cb62abb7eeab54c4/
>
> Thus the simplest thing I can think of is to add a non-field property
> to each form, but I don't know how to do that with forms in a formset.
>
> I suppose I could use a hidden field and extract and present the value
> using javascript.
>
> Or maybe I could create a custom widget that rendered its value as a
> string, not an HTML input.
>
> And if I can't find a way to add a simple non-field property to forms
> in a formset, I will probably try the custom widget next.
>
> Anyway, I do appreciate your followup reply.
>
> -Bob
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

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

2010-09-02 Thread Kev
Patricia wrote:

>
>
> Hi all!
>
> I have a page with some years. I want to click over the year, for
> instance 2000, to see all the information.
> I've build some permalinks in other pages to built the URL, now I
> wanted to do the same thing, but the field I wanted to connect is not
> the year, is the date.
>
> @permalink
> def get_absolute_url(self):
> return('year', [str(self.date.year)])
>
> But this give me a error, I suppose I can't make a query inside
> permalink.
> Anyone has any idea how to solve this?
> Thanks :)
>

Hello Patricia,

You need to provide the stacktrace of the error that you are getting.

Kev

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



Re: how to add a non-field text property to forms in a formset

2010-09-02 Thread bobhaugen
Bill,

Thanks a lot for sticking with this question.

On Sep 2, 1:44 pm, Bill Freeman  wrote:
> I guess that what I'm saying is that when you get fussy about rendering, you
> need to write the html/css yourself.  Because you say you want read only for
> these fields, don't use the form field's rendering at all (or use a
> hidden field).

I don't want a field, I want an additional property on each form in
the formset, that I can set differently for each form.  I can do this
easily if I roll my own set-of-forms (not a formset) where I add to
each form something like form.product_description = "Beef, Whole,
choice or better, per pound hot hanging weight".

I swear, that is an actual product description. But so is
"Strawberries, pint".  So if I use a product_description field, and
put it in a table cell, I need to size the field to handle the Beef,
Whole etc.  and the table gets too wide for  the window. If I use a
non-field property, HTML wraps the cell nicely as needed.

> Or I may be totally misunderstanding the original problem.

I don't know, probably I am not communicating well, or maybe I am
missing something in your suggestions.  I did read through all of the
Django documentation on forms, formsets, form api, fields, etc., and
did not find anything that I could see helping.

And this forum thread appears to say that I cannot display the value
of the field in a template:
http://groups.google.com/group/django-users/browse_thread/thread/cb62abb7eeab54c4/

Thus the simplest thing I can think of is to add a non-field property
to each form, but I don't know how to do that with forms in a formset.

I suppose I could use a hidden field and extract and present the value
using javascript.

Or maybe I could create a custom widget that rendered its value as a
string, not an HTML input.

And if I can't find a way to add a simple non-field property to forms
in a formset, I will probably try the custom widget next.

Anyway, I do appreciate your followup reply.

-Bob

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

2010-09-02 Thread Piotr Zalewa
 On 09/02/10 17:12, commonzenpython wrote:
> hey, guys
> is it possible to have multiple django projects in one server ?
>
You can also make them using different django versions
check django + virtualenv  on google

zalun

-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



Re: how to add a non-field text property to forms in a formset

2010-09-02 Thread Bill Freeman
I guess that what I'm saying is that when you get fussy about rendering, you
need to write the html/css yourself.  Because you say you want read only for
these fields, don't use the form field's rendering at all (or use a
hidden field).
Compose a div or span or whatever suits your fancy, and pass what you want
for content as a context variable (or possibly extract it from the
hidden field's
bound field object, I'd have to go look at the docs and maybe code).  If you
want to choose between two constructs based on a complex evaluation of
the content, do it in python, in the view and pass it as a boolean in another
context variable to use in an if tag (or calculate in a model or form method
that is easy to call from the template code).

Or I may be totally misunderstanding the original problem.

Bill

On Wed, Sep 1, 2010 at 9:48 PM, bobhaugen  wrote:
> On Sep 1, 12:17 pm, Bill Freeman  wrote:
>> This seems to me to be a job for the template.  The forms documentation has
>> a section on custom rendering which shows you how to iterate through the
>> fields, or access them by name.  You would insert whatever HTML construct
>> was appropriate for your text, providing a context variable giving its 
>> contents,
>> if necessary.
>
> I guess I do not understand your reply.
>
> I'm already iterating through the fields in the template, accessing
> them by name.  Actually, many forms' worth of fields, in a many-rowed
> table.  How would I display the product description for each row as
> flexibly-wrapped text, rather than as a field widget?  That is what I
> am trying to do.
>
> Sorry if I am missing something that should have been obvious to me
> from "whatever HTML construct".  Could you provide an example (or even
> another hint), that works with a formset?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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-dbindexer for advanced queries with NoSQL

2010-09-02 Thread Waldemar Kornewald
Hi,
we've started a new open-source project which extends Django's
querying capabilities on NoSQL databases (App Engine, MongoDB, etc.),
so you can use filters like "__month" or "__iexact" even if they're
not natively supported by the database. The advantage is that you
don't need to deal with writing ugly workarounds for unsupported
filters. The indexer automates this work for you. In the future we
even want to support efficient JOINs by automating denormalization on
non-relational DBs and we also want to support aggregates and other
advanced features. Read more about it here:
http://www.allbuttonspressed.com/blog/django/2010/09/Get-SQL-features-on-NoSQL-with-django-dbindexer

Basically, instead of accepting "NoSQL == no features" we've chosen a
more pragmatic approach: This is a middle path which combines the
scalability of NoSQL with the simplicity of SQL where possible. It
does for you what you would do by hand, anyway.

If you want to help with improving the indexer please join the
Django-nonrel discussion group:
http://groups.google.com/group/django-non-relational

Note: Ideally these indexing capabilities would be part of the DB, but
the NoSQL DBs don't seem to go in that direction (yet?), so we've
decided to build something that solves our problems independently of
the DB today instead of in a few years (or never).

Bye,
Waldemar Kornewald

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



Passing view extra info from urls.py

2010-09-02 Thread r_f_d
I have looked at the django documentation and searched the group
archive for my answer, and believe I know how this is supposed to
work, I just cannot figure out why it is not working for me.  I want
to pass an extra keyword parameter to my view that contains a filter
value, but it is not getting passed.  Here is the urls.py entry:

(r'requirementlibrary/(?P\d+)/requirements/$', 'requirements',
{'filter_param':'library'}),

and the view:
def requirements(request, id=None, filter_param=None):
print filter_param

the filter_param is always "None"

Here is the example from the django docs:

(r'^blog/(?P\d{4})/$', 'year_archive', {'foo': 'bar'}),

In this example, for a request to /blog/2005/, Django will call the
blog.views.year_archive() view, passing it these keyword arguments:
year='2005', foo='bar'

Anyone know what I a missing?

-richard

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

2010-09-02 Thread creecode
Hello,

Yes you can have many Django projects installed on one server.

On Sep 2, 9:12 am, commonzenpython  wrote:

> hey, guys
> is it possible to have multiple django projects in one server ?

Toodle-lo..
creecode

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

2010-09-02 Thread Max Countryman

Absolutely! :)

On Sep 2, 2010, at 12:12 PM, commonzenpython wrote:


hey, guys
is it possible to have multiple django projects in one server ?

--  
You received this message because you are subscribed to the Google  
Groups "Django users" group.

To post to this group, send email to django-us...@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 
.




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Alternative to passing request object to every object/function?

2010-09-02 Thread Scott Gould
Have a read through this article, Dan:

http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/

On Sep 2, 11:19 am, Dan Klaffenbach 
wrote:
> On 2 Sep., 16:48, Daniel Roseman  wrote:> It's not 
> clear exactly what you want. Using RequestContext and the
> > request context processor will ensure that the request is present in
> > all your templates. Is that enough?
>
> No. I'll give an example:
>
> I use a custom Acl class for checking the user's permissions (main
> idea: RBAC-like, with role and permission inheritance). Let's say I
> have a form model:
>
> I need the request.user e.g in my application's form models, because I
> need to create an Acl instance in the model in order to check if the
> user can edit fields or not. There are three cases:
> * user can edit form field
> * user can view value (form widget attribute = readonly)
> * user is not allowed to view field at all (do not add element to the
> form at all)
>
> Isn't there any other way to get at least the currently logged in user
> ('REMOTE_USER') in models? Passing the request parameter to models
> doesn't seem like good style to me, it bloats the code and makes it
> harder to read. I do not need the request object in my templates (I
> know this is possible), just in e.g. form models.
>
> Regards,
> Dan

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



Multiple django projects

2010-09-02 Thread commonzenpython
hey, guys
is it possible to have multiple django projects in one server ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-02 Thread Jesse
Thanks!  I did see the hello using the corrected localhost/myapp, so I
at least know that I have the right version of mod_wsgi.  Now I'm back
to my original problem.  The apache server will not restart when I add
the following line to the http.conf file:

Include "c:/public/apache/apache_django_wsgi.conf"

which I place before the here:
Include "c:/public/apache/apache_django_wsgi.conf"
#WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"


Order allow,deny
Allow from all


The apache_django_wsgi.conf file has the following:
//start code
Alias /media/ "c:/public/media/"


Order allow, deny
Option Indexes
Allow from all
IndexOptions FancyIndexing


WSGIScriptAlias / "c:/public/apache/django.wsgi"



//end code

The error is Request operation failed.

Thx for your help!!

Jesse
On Sep 1, 8:53 pm, Graham Dumpleton 
wrote:
> On Sep 2, 1:13 pm, Jesse  wrote:
>
>
>
>
>
> > I'm using Python 2.7, Apache 2.2 and grabbed the mod_wsgi that
> > supposedly works.  I changed the name of the file to mod_wsgi and
> > placed into Apache modules library.  I changed the folders, so the
> > apache folder by itself and created the following in the apache
> > http.conf file:
> > WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"
>
> > 
> > Order allow,deny
> > Allow from all
> > 
>
> > The myapp.wsgi is:
> > def application(environ, start_response):
> >     status = '200 OK'
> >     output = 'Hello World!'
>
> >     response_headers = [('Content-type', 'text/plain'),
> >                         ('Content-Length', str(len(output)))]
> >     start_response(status, response_headers)
>
> >     return [output]
>
> > Apache starts fine, no errors, but the localhost is still the original
> > apache page and not hello world.
>
> What URL are you using? Sounds like you are using:
>
>  http://localhost
>
> and not:
>
>  http://localhost/myapp
>
> Your WSGIScriptAlias has it mounted at sub URL not root of site which
> is where standard Apache 'It Works' page would be found.
>
> Graham
>
>
>
>
>
> > On Sep 1, 4:25 pm, Graham Dumpleton 
> > wrote:
>
> > > On Sep 2, 4:46 am, Jesse  wrote:
>
> > > > created project using startproject testproject
>
> > > > Problems with apache_django_wsgi.conf
> > > > 1.  Added following line toApache:
> > > > LoadModule wsgi_module modules/mod_wsgi.so
>
> > > > 2. Created folder c:/django/testproject/apache
>
> > > > 3.  Created file c:/django/testproject/apache/django.wsgi
> > > > // code starts
> > > > import os, sys
> > > > sys.path.append("/c:/django")
>
> > > All your paths where you have '/c:' instead of just 'c:' are wrong to
> > > start with.
>
> > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> > > > import django.core.handlers.wsgi
>
> > > > application = django.core.handlers.wsgi.WSGIHandler()
> > > > // code ends
>
> > > > 4.  Apachestarts and restarts. local host is originalapache"It
> > > > works"
>
> > > > 5.  Created file c:/django/testproject/apache_django_wsgi.conf
> > > > //code starts
> > > > Alias /media/ /c:/django/testproject/media/
>
> > > > 
> > > > Order deny,allow
> > > > Allow from all
> > > > 
>
> > > > WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi
>
> > > > 
> > > > Order deny,allow
> > > > Allow from all
> > > > 
> > > > //code ends
>
> > > > 6.  Added following line toApachehttp.conf
> > > > Include "c:/django/testproject/apache/apache_django_wsgi.conf"
>
> > > > 7.  Apacheerror, cannot restart.
>
> > > > Any help is much appreciated.
>
> > > Does theApacheerror log have anything in it?
>
> > > WhichApacheversion? Which Python version? Which mod_wsgi object did
> > > you grab, or did you compile from source code?
>
> > > Are you trying to run 64bitWindows?
>
> > > BTW, recommended to test first with a WSGI hello world program and not
> > > Django.
>
> > > See hello world example in:
>
> > >  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
>
> > > 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-us...@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: fetching values from model

2010-09-02 Thread Justin Myers
In theory, if the view passed that function to the template (or if it
were available as a method on something else that was passed to the
template), I suppose you could. That said, you wouldn't be able to
pass it any arguments.

Once again, the template is _not_ designed for programming logic. It's
_only_ designed for presentation. For the most part, if you want to
call a function, call it in the view.
-Justin

On Sep 1, 11:02 pm, Pradnya  wrote:
> Hey thanks,
> Is there anyway I can call a function in HTML template?
>
> On Sep 1, 6:23 pm, Steve Holden  wrote:
>
> > On 9/1/2010 9:13 AM, Pradnya wrote:>> ok. Is there any way I can load the 
> > model inside HTML template?
> > >> What is {% load  %} tag all about?
>
> > The {% load %} tag is for loading custom tags. Nothing to do with
> > accessing the database.
>
> > Why do you find it desirable to load records in the template?  What's
> > wrong with doing it in the view, which is what everyone else does and
> > how Django is intended to be used? See Jonas' remarks below.
>
> > regards
> >  Steve
>
> > >> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
> >  You don't write Python code inside your template file. That's
> >  one of the basic django template rules. You can pass values
> >  from your views to your template and show them there. Or
> >  generate the HTML in your view and show it from there, which
> >  isn't something I could advise if you're creating a larger
> >  application.
>
> >  Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
> > >> Hello,
>
> > >> Is it possible to fetch a particular record from model
> > >> using school.object.get(id = 1) inside html template.
>
> > >> Please suggest.
>
> > >> Thanks Pradnya
>
> > >> -- You received this message because you are subscribed to
> > >> the Google Groups "Django users" group. To post to this
> > >> group, send email to django-us...@googlegroups.com. To
> > >> unsubscribe from this group, send email to
> > >> django-users+unsubscr...@googlegroups.com. For more
> > >> options, visit this group
> > >> athttp://groups.google.com/group/django-users?hl=en.
>
> >  Met vriendelijke groeten,
>
> >  Jonas Geiregat jo...@geiregat.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: I don't understand the difference between these two views

2010-09-02 Thread Karim Gorjux
On Thu, Sep 2, 2010 at 17:46, Daniel Roseman  wrote:
> See here for an explanation:
> http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext
> especially the "Note" box a screen or so down.

Thanks! Now everything is clear

-- 
Karim Gojux
www.karimblog.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-us...@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: Alternative to passing request object to every object/function?

2010-09-02 Thread Dan Klaffenbach


On 2 Sep., 16:48, Daniel Roseman  wrote:
> It's not clear exactly what you want. Using RequestContext and the
> request context processor will ensure that the request is present in
> all your templates. Is that enough?
No. I'll give an example:

I use a custom Acl class for checking the user's permissions (main
idea: RBAC-like, with role and permission inheritance). Let's say I
have a form model:

I need the request.user e.g in my application's form models, because I
need to create an Acl instance in the model in order to check if the
user can edit fields or not. There are three cases:
* user can edit form field
* user can view value (form widget attribute = readonly)
* user is not allowed to view field at all (do not add element to the
form at all)


Isn't there any other way to get at least the currently logged in user
('REMOTE_USER') in models? Passing the request parameter to models
doesn't seem like good style to me, it bloats the code and makes it
harder to read. I do not need the request object in my templates (I
know this is possible), just in e.g. form models.


Regards,
Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Where and how should I write translations

2010-09-02 Thread Tom Evans
On Thu, Sep 2, 2010 at 2:15 PM, Martin Tiršel  wrote:
> I tried to create second .po file with manual translations, but had no luck
> either :( `compilemessages` creates the second .mo file, but doesn't use it
> in the app. Only django.mo is used, but all my translations in django.po
> file are commented out after I run `makemessages`.
>
> In the documentation:
>
> "(The caveat with using variables or computed values, as in the previous two
> examples, is that Django's translation-string-detecting utility,
> django-admin.py makemessages, won't be able to find these strings. More on
> makemessages later.)"
>
> But there is no "later" :(
>
> Thanks,
> Martin
>

I had to do some clever things to import languages names from the
CLDR. I ended up writing a small management command (sorry, can't
share the entire thing) which first of all runs makemessages for each
language. This generates/updates the django.po files for each
language.

I then step through each of the languages, load the CLDR xml file, and
manually update the generated po file, inserting/updating entries as
necessary. Having added all the extra translations, I then run
compilemessages, so they are always available.

To update the po file, I use polib - which you can get standalone, but
is also a part of the amazing django-rosetta.

The code to add/update entries using polib is pretty straightforward.
First load the po file, look for your key, if it isn't there add it.
In code:

for (lang, name) in settings.LANGUAGES:
  lang_po_path = os.path.join(settings.PROJECT_ROOT, '',
'locale', lang, 'LC_MESSAGES', 'django.po')
  po = polib.pofile(lang_po_path)
  cldr = self.load_cldr_data(lang, ccodes)
  for code in ccodes:
idx = u'Country code %s' % code
try:
  trans = cldr[code]
except KeyError:
  self.debug("No translation for country code %s" % code)
  continue
entry = po.find(idx)
if entry:
  entry.msgstr = trans
  entry.obsolete = 0
else:
  entry = polib.POEntry(msgid=idx, msgstr=trans)
  entry.occurrences = [ ('Common Locale Data Repository', 1), ]
  entry.comment = 'Country name, imported from CLDR (Do not
manually translate, translation is automatically updated!)'
  entry.tcomment = entry.comment
  entry.obsolete = 0
  po.append(entry)
  po.save()


Obviously, with your problem, you aren't adding the actual
translations, just the msg id, so don't set msgstr. In this example,
I'm adding translations for 'Country code AD' -> 'Country code ZW'
(which will now translate into 'Andorra' -> 'Zimbabwe' :)

Cheers

Tom

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



Setting a default value for a select widget in a modelformset

2010-09-02 Thread Steve McConville
We have a modelformset created like this:

DocumentFormSet = modelformset_factory(Document, extra=0,
fields=('name', 'category')

with a models.py like this:

class Category(models.Model):
name = CharField(max_length=100)
# other stuff

class Document(models.Model):
name = CharField(max_length=100)
category = ForeignKey(Category)
# other stuff

When the DocumentFormSet renders, category appears as a select widget.

I have a variable in my request session that I would like to use to
set the initial value of the category widget.

What would be the best way to go about this? Is it necessary to create
a custom widget to achieve this?

-- 
steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Alternative to passing request object to every object/function?

2010-09-02 Thread Daniel Roseman
On Sep 2, 3:30 pm, Daniel Klaffenbach 
wrote:
> Hi,
>
> I am developing a Django app which relies on information from the
> request object a lot, especially request.user. I need this object (or
> let's say at least 'REMOTE_USER') in many models and I was wondering
> if there is another way to get the request object?
>
> In PHP there is something like $_SERVER which is a global variable
> containing for example the REMOTE_USER. I'm afraid I haven't found the
> Python/Django equivalent yet, but since it is a bit stupid to always
> pass the request object as a parameter to objects and functions I am
> sure there is another (better) approach.
>
> Could someone point out what I should do in this case?
>
> Regards,
> Dan Klaffenbach

It's not clear exactly what you want. Using RequestContext and the
request context processor will ensure that the request is present in
all your templates. Is that enough?

You say though that you need it 'in many models' - do you mean model
methods? Can you give an example, perhaps there is a better way of
achieving what you want to do.
--
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-us...@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: I don't understand the difference between these two views

2010-09-02 Thread Daniel Roseman
On Sep 2, 2:45 pm, Karim Gorjux  wrote:
> Working on the Coltrane's Book :-) ...
>
> I create two views that do the same thing but the first one use the
> generic view and the second a render to response.
> I don't understand why because both works but the second besides don't
> passe the category object, don't load the
> django.core.context_processors.media I set in settings.py.
> So if I use the second view, the media I use with MEDIA_URL are not
> loaded. Why happening this?
>
> [...] href="{{ MEDIA_URL }}/style.css" [...]
>
> from django.shortcuts import get_object_or_404, render_to_response
> from coltrane.models import Entry, Category
> from django.views.generic.list_detail import object_list
>
> # this works and load everything
>
> def category_detail(request, slug):
>    category = get_object_or_404(Category, slug=slug)
>    return object_list(request,
>                        queryset=category.live_entry_set(),
>                        template_name='coltrane/category_detail.html',
>                        extra_context={ 'category': category })
>
> # this doesn't load the django.core.context_processors.media
>
> def category_detail(request, slug):
>    category = get_object_or_404(Category, slug=slug)
>    return render_to_response(
>                        'coltrane/category_detail.html',
>                        { 'object_list': category.live_entry_set()}
>                        )
>
> --
> Karim Gojuxwww.karimblog.net

See here for an explanation:
http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext
especially the "Note" box a screen or so down.
--
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-us...@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: Alternative to passing request object to every object/function?

2010-09-02 Thread Tom Evans
On Thu, Sep 2, 2010 at 3:30 PM, Daniel Klaffenbach
 wrote:
> Hi,
>
> I am developing a Django app which relies on information from the
> request object a lot, especially request.user. I need this object (or
> let's say at least 'REMOTE_USER') in many models and I was wondering
> if there is another way to get the request object?
>
> In PHP there is something like $_SERVER which is a global variable
> containing for example the REMOTE_USER. I'm afraid I haven't found the
> Python/Django equivalent yet, but since it is a bit stupid to always
> pass the request object as a parameter to objects and functions I am
> sure there is another (better) approach.
>
> Could someone point out what I should do in this case?
>
>
> Regards,
> Dan Klaffenbach
>

Take the pain - part of django's design is that it isn't PHP, and
globals aren't exactly a good programming paradigm.

I would either pass the request object, or (better) actually pass the
objects/data that the function actually needs - eg request.user,
request.POST. This will be more verbose, but you (and future people
reading the code) will have a clearer understanding of what inputs the
function takes, and the function is not so readily tied to a
request/response cycle and so can be used outside of that context as
well.

Personally, I try to avoid passing the request to any function that is
not a view/middleware/etc, as it makes it harder to use that function
without a request.

Cheers

Tom

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



Alternative to passing request object to every object/function?

2010-09-02 Thread Daniel Klaffenbach
Hi,

I am developing a Django app which relies on information from the
request object a lot, especially request.user. I need this object (or
let's say at least 'REMOTE_USER') in many models and I was wondering
if there is another way to get the request object?

In PHP there is something like $_SERVER which is a global variable
containing for example the REMOTE_USER. I'm afraid I haven't found the
Python/Django equivalent yet, but since it is a bit stupid to always
pass the request object as a parameter to objects and functions I am
sure there is another (better) approach.

Could someone point out what I should do in this case?


Regards,
Dan Klaffenbach

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



I don't understand the difference between these two views

2010-09-02 Thread Karim Gorjux
Working on the Coltrane's Book :-) ...

I create two views that do the same thing but the first one use the
generic view and the second a render to response.
I don't understand why because both works but the second besides don't
passe the category object, don't load the
django.core.context_processors.media I set in settings.py.
So if I use the second view, the media I use with MEDIA_URL are not
loaded. Why happening this?

[...] href="{{ MEDIA_URL }}/style.css" [...]


from django.shortcuts import get_object_or_404, render_to_response
from coltrane.models import Entry, Category
from django.views.generic.list_detail import object_list


# this works and load everything

def category_detail(request, slug):
   category = get_object_or_404(Category, slug=slug)
   return object_list(request,
   queryset=category.live_entry_set(),
   template_name='coltrane/category_detail.html',
   extra_context={ 'category': category })

# this doesn't load the django.core.context_processors.media

def category_detail(request, slug):
   category = get_object_or_404(Category, slug=slug)
   return render_to_response(
   'coltrane/category_detail.html',
   { 'object_list': category.live_entry_set()}
   )


-- 
Karim Gojux
www.karimblog.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-us...@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.



Models, nulls and default values confusion

2010-09-02 Thread Sells, Fred
I've got several tables like the one below, where I initialize it with
"template" values that I copy when I create a new record.
INSERT INTO A VALUES
(19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ., 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '&', '&'),
(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0. 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '&', '&'),
(21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0., 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '&', '&'),
(22, 0, 0, 0, 0, 0, 0., '&', '&', 0, 0, 0, 0, 0, '&',
'&', '&', '&', '&', '&', '&', 0, 0, 0, 0, 0, '&', 0, 0, 0, 0, '&', '&'),
(23, 0, 0, 0, 0, 0..0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, '&', 0, 0, 0, 0, '&', '&'),

I would like to replace some of those "0"'s with a different value, but
it's pretty hard to count over to the right field on the larger tables.

I thought it would be better to replace all the 0's with NULL and let
the default value in the django model put in the correct value, but
either that's not how Django works or I don't know how to do it.

Can anyone point me to the right docs or better yet, provide a snippet?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Where and how should I write translations

2010-09-02 Thread Martin Tiršel
I tried to create second .po file with manual translations, but had no  
luck either :( `compilemessages` creates the second .mo file, but doesn't  
use it in the app. Only django.mo is used, but all my translations in  
django.po file are commented out after I run `makemessages`.


In the documentation:

"(The caveat with using variables or computed values, as in the previous  
two examples, is that Django's translation-string-detecting utility,  
django-admin.py makemessages, won't be able to find these strings. More on  
makemessages later.)"


But there is no "later" :(

Thanks,
Martin

On Thu, 02 Sep 2010 13:33:36 +0200, Martin Tiršel   
wrote:



Hello,

I can not find in Django documentation a word about translating  
variables or strings with variables. I have:


...
{% trans question_category %}
...

django-admin.py makemessages creates .po but without a mention about  
this template line ({% trans "some text" %} is ok). It is clear, that I  
have somehow to specify translation strings in .po file, but when I do  
it manually, next django-admin.py makemessages overwrite the .po file.


So, my question is, where and how should I write translation for strings  
in variables (or variable in a string)?



Next, I have some strings in initial_data.json fixture, is there a way  
how to automatically extract it into .po file while running  
django-admin.py makemessages? Or it could extract it from database, it  
doesn't matter. Yes, I know, that I should change DB structure and not  
translate strings  from DB this way, but I have my reasons why I am  
doing it so.


Thanks,
Martin


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: PIL on 10.6 = PAIN

2010-09-02 Thread lukaszb
Hi,
I'd strongly advise to try homebrew instead of macports. You can find
it here: http://github.com/mxcl/homebrew .
After installation do: brew up && brew install jpeg and install PIL as
usual.
Since I needed freetype support I had to update PIL's setup.py
FEETYPE_ROOT: FREETYPE_ROOT = libinclude('/usr/X11')
[line 40 at PIL 1.1.7].

Currently I have no problem with PIL installation for every virtualenv
needing one.

Hope that helps if you can't stand ports etc anymore (I couldn't and
homebrew was quite a relief).

On Sep 1, 9:42 pm, keynesiandreamer  wrote:
> Well last night I started working on removing all traces of PIL and
> libjpeg as well as the install instructions from Andrews link (Thansk
> Andrew!)
>
> If there was a problem to encounter I seemed to hit it... :-(
>
> It all started when Git would not unzip, I finally got that with the
> xjvf flag I believe, and then now I get an error due to a dylib not
> being linked to x86_64 architecture. JESUS!
>
> I spent time trying to research that without much luck :(
>
> I upgraded the default mac installation python to python 2.6.6 and
> also am using virtualenv for my django envs and am having issues
> installing virtualenvwrapper, yet another install problem... Looks
> like something with the the source file and the virtualenv_bashrc
> file.
>
> Atleast in the morning my patience is a bit better... I will try
> hammering away at it again tomororw. I think I need a day off from it.
>
> Thanks everybody for all their insight and advice, it is very much
> appreciated. If you are anywhere near SF, there is beer on me for it.
>
> -Ben
>
> On Sep 1, 4:09 am, Mathieu Leduc-Hamel  wrote:
>
>
>
> > This is because you should not use the Python interpreter from you're
> > Mac installation. Are you using buildout ? VirtualEnv? or nothing ?
>
> > Buildout:
>
> > /opt/local/bin/python2.6 bootstrap.py
>
> > Virtualenv:
>
> > virtualenv -p /opt/local/bin/python2.6 
>
> > Nothing:
>
> > /opt/local/bin/python2.6 manage.py runserver
>
> > On Tue, Aug 31, 2010 at 9:40 PM, keynesiandreamer
>
> >  wrote:
> > > So I tried the Macports option and it started to look good, but then I
> > > got:
>
> > > --->  Installing py26-pil @1.1.7_1
> > > --->  Activating py26-pil @1.1.7_1
> > > Error: Target org.macports.activate returned: Image error: /opt/local/
> > > Library/Frameworks/Python.framework/Versions/2.6/bin/pilconvert.py
> > > already exists and does not belong to a registered port.  Unable to
> > > activate port py26-pil. Use 'port -f activate py26-pil' to force the
> > > activation.
> > > Log for py26-pil is at: /opt/local/var/macports/logs/
> > > _opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py2
> > >  6-
> > > pil/main.log
> > > Error: Status 1 encountered during processing.
> > > To report a bug, see 
> > > Ben-Jammin-MacBook:~ martinek$ port -f activate py26-pil
> > > Warning: Failed to open Portfile from registry for py26-pil @1.1.7_1
> > > --->  Activating py26-pil
> > > Error: port activate failed: sqlite error: attempt to write a readonly
> > > database (8)
> > > Ben-Jammin-MacBook:~ martinek$ sudo port install py26-pil
>
> > > Sudo didn't work either
> > > :-(
>
> > > I am not even sure what DB is being discussed there...
>
> > > I also tried reinstalling PIL after the failure of MacPorts and
> > > something might have worked here. I don't get the same problem at the
> > > python prompt trying import _imaging
>
> > > Unfortunately Django/Pinax doesn't seem to see this after reactivating
> > > the ENV and restarting the server:
>
> > > BLurghh!!!
>
> > > Is it worth trying to remake the virtualenv I am working with? Would
> > > that help or is the problem still up the stream?
>
> > > -Ben
>
> > > On Aug 31, 11:49 am, keynesiandreamer 
> > > wrote:
> > >> Thanks Bill and Mathieu!
>
> > >> I will try the Mac port option first, in fact I did look at it last
> > >> night probably around 1am or so...
>
> > >> I treied rebuilding the virtual env I was using as well just to
> > >> verify, but the problem seem higher up the stream and Bill indicated.
> > >> I will take a look for the ld.conf equiv in OSX at lunch today.
>
> > >> Thanks!
> > >> Ben
>
> > >> On Aug 31, 10:20 am, Mathieu Leduc-Hamel  wrote:
>
> > >> > To work with PIL and other librairies a little bit weird and difficult
> > >> > to install the best way is to install Macport and after that:
>
> > >> > port install py26-pil
>
> > >> > and you'll need to use the python of the macport installation:
>
> > >> > $ /opt/local/bin/python2.6
>
> > >> > It's the samething on linux, i'm alway using the PIL package from my 
> > >> > distro...
>
> > >> > On Tue, Aug 31, 2010 at 7:10 PM, Bill Freeman  
> > >> > wrote:
> > >> > > This sounds more like libjpeg isn't on the library load path, a
> > >> > > system, rather 

Re: django-registration + e-mail confirmation

2010-09-02 Thread tom84
Thank You very much.
Tomek

On 2 Wrz, 14:45, Federico Maggi  wrote:
>  wrote:
> > How to open port 25 in ubuntu?
>
>     If you google for "mail ubuntu" or "smtp ubuntu" there is a nice 
> community doc/wiki explaining you all the steps for setting up an SMTP server 
> on Ububtu.
>
> Otherwise, for testing purposes, you could use the debug mail backend in 
> Django that writes e-mails on txt files.
>
> -- Fede

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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-registration + e-mail confirmation

2010-09-02 Thread Federico Maggi
 wrote:

> How to open port 25 in ubuntu?

If you google for "mail ubuntu" or "smtp ubuntu" there is a nice community 
doc/wiki explaining you all the steps for setting up an SMTP server on Ububtu.

Otherwise, for testing purposes, you could use the debug mail backend in Django 
that writes e-mails on txt files.

-- Fede

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: multiple oracle database queries in one request problem

2010-09-02 Thread Reinout van Rees

On 09/01/2010 11:54 PM, Reinout van Rees wrote:

On 09/01/2010 02:00 PM, Reinout van Rees wrote:

Hi,

I'm deploying a site on windows with oracle (and I don't know either of
them well). Simple apache+wsgi setup for now.


I'll have to test it out tomorrow when I'm near the windows machine
again, but I might have found the solution in an existing bug report:
http://code.djangoproject.com/ticket/13351

In a threaded situation (which you always have with mod_wsgi on
windows), you apparently need to pass the cx_oracle database driver a
threaded=True option (which is off by default).

So I added the following to my database config and I'm hoping I'll be
happy tomorrow morning...

'OPTIONS': {'threaded': True}


That did not help... If anything, it crashes earlier.

Some things I know for (reasonably) sure:

- It occurs when running with threads: mod_wsgi on windows.

- It occurs when talking to the oracle database.

- It occurs when I talk to two databases on the same oracle server 
(well, that's database in django speak, oracle calls it a schema: it is 
in the same physical oracle-speak database).




So I'm desperately trying to figure out how to tell mod_wsgi to run in 
single threaded mode for the time being.  The problem is that only 
WSGIDaemonProcess has the required "threads=1" option and exactly that 
WSGIDaemonProcess isn't available on windows!  Catch 22.




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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-registration + e-mail confirmation

2010-09-02 Thread tom84
I scanned ports of my IP using network tools and seems that only 45784
and 47344 are open. How to open port 25 in ubuntu?
thanks
Tomek

On 2 Wrz, 14:28, Federico Maggi  wrote:
> On 02/set/2010, at 14:10, tom84  wrote:
>
> > Unfortunately after sending filled registration form I received 111
> > error- connection refused.
>
>     Looks lice you're trying to connect to a closed/filtered port (25). Have 
> you tested the SMTP outside Django (e.g., using telnet localhost 25)?
>
> -- Fede

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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-registration + e-mail confirmation

2010-09-02 Thread Federico Maggi
On 02/set/2010, at 14:10, tom84  wrote:

> Unfortunately after sending filled registration form I received 111
> error- connection refused.

Looks lice you're trying to connect to a closed/filtered port (25). Have 
you tested the SMTP outside Django (e.g., using telnet localhost 25)?

-- Fede

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



Re: django,how to read data from database when db has large volume of data

2010-09-02 Thread girish shabadimath
oh,,,thanks a lot for d reply,,,

On Thu, Sep 2, 2010 at 4:33 PM, Daniel Roseman wrote:

> On Sep 2, 9:49 am, girish shabadimath 
> wrote:
> > actually i wanted to access values from database and use those values in
> url
> > unittesting,,,
> >
> > like:
> > response = self.client.get('def/defect/', {'*ID*':*id*})
> > self.failUnlessEqual(response.status_code, 200)
> >
> > how to get id from database..?,,,and also i want this test to be done for
> > each id in database,,hw to proceed..?
> >
> > ,,,this may sound silly but plz help..
>
> Have you read the extensive documentation on how to make a query
> against the database?
> http://docs.djangoproject.com/en/1.2/topics/db/queries/
>
> However, I must say that it seems very odd to want to test requesting
> a URL against every ID in the database. That's not how unit testing
> works. Test with a representative sample of data, that's what fixtures
> are for.
> --
> 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-us...@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.
>
>


-- 
Girish M S

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



django-registration + e-mail confirmation

2010-09-02 Thread tom84
Hello.
I installed django-registration from 
http://bitbucket.org/ubernostrum/django-registration/downloads.
Unfortunately after sending filled registration form I received 111
error- connection refused. I found somewhere that it may be because of
the wrong server configuration, so I set some values in the
settings.py file:

EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
EMAIL_FILE_PATH = os.path.join(os.path.dirname(__file__),
'emaildata')
EMAIL_HOST='localhost'
EMAIL_HOST_PASSWORD=''
EMAIL_HOST_USER=''
EMAIL_PORT=25
DEFAULT_FROM_EMAIL = "anyem...@anydomain.com"
SERVER_EMAIL = "anyem...@anydomain.com"
EMAIL_SUBJECT_PREFIX='[Django] '
EMAIL_USE_TLS=False
SEND_BROKEN_LINK_EMAILS=True

Unfortunately it doesn't help. What should I change?

Thanks in advance
Tomek


More error info:
error at /accounts/register/

[Errno 111] Connection refused

Request Method: POST
Request URL:http://127.0.0.1:8000/accounts/register/
Django Version: 1.2.1
Exception Type: error
Exception Value:

[Errno 111] Connection refused

Exception Location: /usr/lib/python2.6/socket.py in
create_connection, line 514
Python Executable:  /usr/bin/python
Python Version: 2.6.5
Python Path:['/home/tomek/Pulpit/djangoPage/mysite', '/usr/lib/
python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-
tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/
usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/
PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/
python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/
pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-
packages']
Server time:Thu, 2 Sep 2010 13:28:25 +0200

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



AttributeError at /admin/ logging into the default Admin site.

2010-09-02 Thread daniel.osterme...@gmail.com
Hi,

Ive been running into a problem lately (not sure when it started)
where I receive an AttributeError when logging into the admin site.
The circumstances seem to be that I start the application, go to the
admin site (and log in successfully), navigate around the rest of the
application (which does not require authentication).  Then at some
point the session or authentication times out and I get the
AttributeError whenever I try to go back to the admin site.

Ive tried googling with out success.  Any help would be appreciated.

Specific details are below:


Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.2.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'optiver.public',
 'optiver.xmlrpc']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in wrapper
  207. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/
decorators.py" in _wrapped_view
  76. response = view_func(request, *args,
**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in inner
  188. if not self.has_permission(request):
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in has_permission
  141. return request.user.is_active and request.user.is_staff
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
middleware.py" in __get__
  9. request._cached_user = get_user(request)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
__init__.py" in get_user
  99. backend = load_backend(backend_path)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
__init__.py" in load_backend
  11. i = path.rfind('.')

Exception Type: AttributeError at /admin/
Exception Value: 'bool' object has no attribute 'rfind'

The value of path at the end is the boolean True

Cheers,
-Daniel

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



Where and how should I write translations

2010-09-02 Thread Martin Tiršel

Hello,

I can not find in Django documentation a word about translating variables  
or strings with variables. I have:


...
{% trans question_category %}
...

django-admin.py makemessages creates .po but without a mention about this  
template line ({% trans "some text" %} is ok). It is clear, that I have  
somehow to specify translation strings in .po file, but when I do it  
manually, next django-admin.py makemessages overwrite the .po file.


So, my question is, where and how should I write translation for strings  
in variables (or variable in a string)?



Next, I have some strings in initial_data.json fixture, is there a way how  
to automatically extract it into .po file while running django-admin.py  
makemessages? Or it could extract it from database, it doesn't matter.  
Yes, I know, that I should change DB structure and not translate strings  
from DB this way, but I have my reasons why I am doing it so.


Thanks,
Martin

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Extracting json data for parsing from HTTP GET

2010-09-02 Thread irum
Thank you so much, it worked:)...Now I just have to play with parsing
json that I think I can manage.

Thanks again:)

Irum

On Sep 2, 1:11 pm, Daniel Roseman  wrote:
> On Sep 2, 10:37 am, irum  wrote:
>
>
>
> > Hi,
> > Thanks for your prompt reply.
> > I have tried both the things but I get the same error.
> > With,
> > x = json.loads(p.read())
> >            print x
>
> > I get following error:  'HttpResponse' object has no attribute
> > 'read'
> > Also I get same error with, json.dumps(p.read()), and same when I use
> > loads and dumps as load and dump without s.
>
> > Then, I tried the other option,
>
> > x = json.dump(p)
> >         print x
>
> > I get the following error: dump() takes at least 2 arguments (1 given)
> > What would be the second argument, I googled on this but find no
> > helpful tips as everything written is too complicated.
>
> > And with:
> >            x = json.load(p)
> >            print x
>
> > 'HttpResponse' object has no attribute 'read'
>
> > In all the examples, p is the HttpResponse object I get.
>
> > Looking forward,
> > Irum
>
> Apologies for steering you wrong - that'll teach me to post without
> checking.
>
> You're right that HttpResponse doesn't have a read() method, contrary
> to what I thought. So neither of those methods will work. Instead, get
> the content of the response and call loads() on that:
>
>     json.loads(p.content)
>
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django,how to read data from database when db has large volume of data

2010-09-02 Thread Daniel Roseman
On Sep 2, 9:49 am, girish shabadimath 
wrote:
> actually i wanted to access values from database and use those values in url
> unittesting,,,
>
> like:
> response = self.client.get('def/defect/', {'*ID*':*id*})
> self.failUnlessEqual(response.status_code, 200)
>
> how to get id from database..?,,,and also i want this test to be done for
> each id in database,,hw to proceed..?
>
> ,,,this may sound silly but plz help..

Have you read the extensive documentation on how to make a query
against the database?
http://docs.djangoproject.com/en/1.2/topics/db/queries/

However, I must say that it seems very odd to want to test requesting
a URL against every ID in the database. That's not how unit testing
works. Test with a representative sample of data, that's what fixtures
are for.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django,how to read data from database when db has large volume of data

2010-09-02 Thread girish shabadimath
buddy did i convince u..?,,,reply soon...solution to my problem,,

On Thu, Sep 2, 2010 at 2:19 PM, girish shabadimath  wrote:

> actually i wanted to access values from database and use those values in
> url unittesting,,,
>
> like:
> response = self.client.get('def/defect/', {'*ID*':*id*})
> self.failUnlessEqual(response.status_code, 200)
>
> how to get id from database..?,,,and also i want this test to be done for
> each id in database,,hw to proceed..?
>
>
> ,,,this may sound silly but plz help..
>
>
>
>
>
> On Thu, Sep 2, 2010 at 1:39 PM, Daniel Roseman wrote:
>
>> On Sep 2, 8:17 am, girishmss  wrote:
>> >  Hi folks,im working on django project,,is there a way to access
>> db
>> > without using fixtures,, as fixtures is not working in my project,,i
>> > want to test urls of type:
>> >
>> >/abc/xyz/123 where '123' comes from database.,
>> >
>> > and that database contains lots of ids( ex:123 ) i
>> > dont want to loop through each ids and want to get dis unittest
>> > working..
>> >
>> > any help or related links is appreciated
>>
>> Sorry, this message makes no sense at all. What do fixtures have to do
>> with reading from the database? Why can't you do a normal ORM call?
>> --
>> 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-us...@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.
>>
>>
>
>
> --
> Girish M S
>



-- 
Girish M S

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



Re: django,how to read data from database when db has large volume of data

2010-09-02 Thread girish shabadimath
actually i wanted to access values from database and use those values in url
unittesting,,,

like:
response = self.client.get('def/defect/', {'*ID*':*id*})
self.failUnlessEqual(response.status_code, 200)

how to get id from database..?,,,and also i want this test to be done for
each id in database,,hw to proceed..?


,,,this may sound silly but plz help..




On Thu, Sep 2, 2010 at 1:39 PM, Daniel Roseman wrote:

> On Sep 2, 8:17 am, girishmss  wrote:
> >  Hi folks,im working on django project,,is there a way to access
> db
> > without using fixtures,, as fixtures is not working in my project,,i
> > want to test urls of type:
> >
> >/abc/xyz/123 where '123' comes from database.,
> >
> > and that database contains lots of ids( ex:123 ) i
> > dont want to loop through each ids and want to get dis unittest
> > working..
> >
> > any help or related links is appreciated
>
> Sorry, this message makes no sense at all. What do fixtures have to do
> with reading from the database? Why can't you do a normal ORM call?
> --
> 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-us...@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.
>
>


-- 
Girish M S

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Extracting json data for parsing from HTTP GET

2010-09-02 Thread Daniel Roseman
On Sep 2, 10:37 am, irum  wrote:
> Hi,
> Thanks for your prompt reply.
> I have tried both the things but I get the same error.
> With,
> x = json.loads(p.read())
>            print x
>
> I get following error:  'HttpResponse' object has no attribute
> 'read'
> Also I get same error with, json.dumps(p.read()), and same when I use
> loads and dumps as load and dump without s.
>
> Then, I tried the other option,
>
> x = json.dump(p)
>         print x
>
> I get the following error: dump() takes at least 2 arguments (1 given)
> What would be the second argument, I googled on this but find no
> helpful tips as everything written is too complicated.
>
> And with:
>            x = json.load(p)
>            print x
>
> 'HttpResponse' object has no attribute 'read'
>
> In all the examples, p is the HttpResponse object I get.
>
> Looking forward,
> Irum

Apologies for steering you wrong - that'll teach me to post without
checking.

You're right that HttpResponse doesn't have a read() method, contrary
to what I thought. So neither of those methods will work. Instead, get
the content of the response and call loads() on that:

json.loads(p.content)

--
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-us...@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: Extracting json data for parsing from HTTP GET

2010-09-02 Thread irum
Hi,
Thanks for your prompt reply.
I have tried both the things but I get the same error.
With,
x = json.loads(p.read())
   print x

I get following error:  'HttpResponse' object has no attribute
'read'
Also I get same error with, json.dumps(p.read()), and same when I use
loads and dumps as load and dump without s.

Then, I tried the other option,

x = json.dump(p)
print x

I get the following error: dump() takes at least 2 arguments (1 given)
What would be the second argument, I googled on this but find no
helpful tips as everything written is too complicated.

And with:
   x = json.load(p)
   print x

'HttpResponse' object has no attribute 'read'

In all the examples, p is the HttpResponse object I get.

Looking forward,
Irum




On Sep 2, 12:09 pm, Daniel Roseman  wrote:
> On Sep 2, 9:57 am, irum  wrote:
>
>
>
> > Hi,
> > I am having problems with extracting json data  for parsing from HTTP
> > GET request.
>
> > What I am doing is that I am receiving json data over HTTP via GET.
> > After debugging much, I have realized that the data also has HTTP
> > headers and other information that serializer is not able to
> > deserialize. How can I extract json data from the complete data
> > (including HTTP information)?
>
> > This is the data I receive, i.e. p, and I want to extract json from it
> > and deserialize it for parsing.
>
> > HTTP/1.0 200 OK Date: Thu, 02 Sep 2010 08:37:39 GMT Server: WSGIServer/
> > 0.1 Python/2.6.4 Content-Type: application/json [{"pk": 33, "model":
> > "hbexample.payment", "fields": {"confirm": true, "pDate": "2010-08-31
> > 10:42:19", "waiting": false, "amount": 33.0, "p_try": 0, "booking":
> > 34}}]
>
> > I have tried json.loads and json.dumps on this data.
>
> > With json.loads(p), I get the following error: expected string or
> > buffer
>
> > With json.dumps(p), I get the following error:
> >  is not JSON
> > serializable
>
> > How do I address this problem? Any help regarding this would be
> > helpful.
>
> > Thanks and Looking forward,
> > Irum
>
> json.loads() and dujmps() work on a string or string-like object.
> HttpResponse is a file-like object, not a string, so you could either
> do loads(p.read()), or - much better - use the load() and dump()
> methods, without the s, directly on the HttpResponse.
> --
> 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-us...@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: Extracting json data for parsing from HTTP GET

2010-09-02 Thread Daniel Roseman
On Sep 2, 9:57 am, irum  wrote:
> Hi,
> I am having problems with extracting json data  for parsing from HTTP
> GET request.
>
> What I am doing is that I am receiving json data over HTTP via GET.
> After debugging much, I have realized that the data also has HTTP
> headers and other information that serializer is not able to
> deserialize. How can I extract json data from the complete data
> (including HTTP information)?
>
> This is the data I receive, i.e. p, and I want to extract json from it
> and deserialize it for parsing.
>
> HTTP/1.0 200 OK Date: Thu, 02 Sep 2010 08:37:39 GMT Server: WSGIServer/
> 0.1 Python/2.6.4 Content-Type: application/json [{"pk": 33, "model":
> "hbexample.payment", "fields": {"confirm": true, "pDate": "2010-08-31
> 10:42:19", "waiting": false, "amount": 33.0, "p_try": 0, "booking":
> 34}}]
>
> I have tried json.loads and json.dumps on this data.
>
> With json.loads(p), I get the following error: expected string or
> buffer
>
> With json.dumps(p), I get the following error:
>  is not JSON
> serializable
>
> How do I address this problem? Any help regarding this would be
> helpful.
>
> Thanks and Looking forward,
> Irum

json.loads() and dujmps() work on a string or string-like object.
HttpResponse is a file-like object, not a string, so you could either
do loads(p.read()), or - much better - use the load() and dump()
methods, without the s, directly on the HttpResponse.
--
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-us...@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.



Extracting json data for parsing from HTTP GET

2010-09-02 Thread irum
Hi,
I am having problems with extracting json data  for parsing from HTTP
GET request.

What I am doing is that I am receiving json data over HTTP via GET.
After debugging much, I have realized that the data also has HTTP
headers and other information that serializer is not able to
deserialize. How can I extract json data from the complete data
(including HTTP information)?

This is the data I receive, i.e. p, and I want to extract json from it
and deserialize it for parsing.

HTTP/1.0 200 OK Date: Thu, 02 Sep 2010 08:37:39 GMT Server: WSGIServer/
0.1 Python/2.6.4 Content-Type: application/json [{"pk": 33, "model":
"hbexample.payment", "fields": {"confirm": true, "pDate": "2010-08-31
10:42:19", "waiting": false, "amount": 33.0, "p_try": 0, "booking":
34}}]


I have tried json.loads and json.dumps on this data.

With json.loads(p), I get the following error: expected string or
buffer

With json.dumps(p), I get the following error:
 is not JSON
serializable

How do I address this problem? Any help regarding this would be
helpful.


Thanks and Looking forward,
Irum

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

2010-09-02 Thread irum
Hi,
Sorry for late reply. I had to switch to another project so this work
got delayed.

Actually, what I am doing is that I am receiving json data over HTTP
via GET. After debugging much, I have realized that the data also has
HTTP headers and other information that serializer is not able to
serialize. How can I extract json data from the complete data
(including HTTP information)?

This is the data I receive, i.e. p, and I want to extract json from it
and deserialize it for parsing.

HTTP/1.0 200 OK Date: Thu, 02 Sep 2010 08:37:39 GMT Server: WSGIServer/
0.1 Python/2.6.4 Content-Type: application/json [{"pk": 33, "model":
"hbexample.payment", "fields": {"confirm": true, "pDate": "2010-08-31
10:42:19", "waiting": false, "amount": 33.0, "p_try": 0, "booking":
34}}]



I have tried json.loads and json.dumps on this data.

With json.loads(p), I get the following error: expected string or
buffer

With json.dumps(p), I get the following error:
 is not JSON
serializable

How do I address this problem? Any help regarding this would be
helpful.


Thanks and Looking forward,
Irum



On Aug 20, 9:33 pm, Reinout van Rees  wrote:
> On 08/20/2010 02:16 PM,irumwrote:
>
> > Hi,
> > I am trying to parse json, loop through it and access its data.
> > At first I tried this:
>
> >                 for obj in serializers.deserialize("json", p):
> >                          a=2
> >                  response = HttpResponse()
> >                  response.status_code = 200
> >                  return response
>
> One small thing to try:
> response = HttpResponse('')
> instead of:
> response = HttpResponse()
>
> So: feed it an empty string.
>
> As it complains about being unreadable, perhaps you should stuff
> something into it.  Just a pretty wild guess...
>
> Reinout
>
> --
> Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org
> Programmer athttp://www.nelen-schuurmans.nl
> "Military engineers build missiles. Civil engineers build targets"

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

2010-09-02 Thread onorua
Hello, I'm creating the system, which will rely on plugins.
For instance, I have main application with model:
 class User(models.Model):
ContractNum = models.PositiveIntegerField(unique=True, blank=True,
null=True )
LastName = models.CharField(max_length=50)
FirstName = models.CharField(max_length=50,)

in application billing

I want to create plugin, in case it's installed (let say in
settings.py), it adds new attributes of User class and User model
virtually become:
 class User(models.Model):
ContractNum = models.PositiveIntegerField(unique=True, blank=True,
null=True )
LastName = models.CharField(max_length=50)
FirstName = models.CharField(max_length=50,)
Balance = models.IntegerField(),

etc
and in Admin interface it's become like I've created User model as in
second case.

Could you please let me know how to acheave it?
Thank you.

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



Re: django,how to read data from database when db has large volume of data

2010-09-02 Thread Daniel Roseman
On Sep 2, 8:17 am, girishmss  wrote:
>          Hi folks,im working on django project,,is there a way to access db
> without using fixtures,, as fixtures is not working in my project,,i
> want to test urls of type:
>
>                    /abc/xyz/123 where '123' comes from database.,
>
>                 and that database contains lots of ids( ex:123 ) i
> dont want to loop through each ids and want to get dis unittest
> working..
>
> any help or related links is appreciated

Sorry, this message makes no sense at all. What do fixtures have to do
with reading from the database? Why can't you do a normal ORM call?
--
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-us...@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: Can't login to admin site

2010-09-02 Thread vgarvardt
On Sep 2, 6:58 am, Karen Tracey  wrote:
> On Wed, Sep 1, 2010 at 1:23 PM, vgarvardt  wrote:
> > Django 1.2.1
>
> > Created new project, set DB settings (postgresql_psycopg2),
> > MEDIA_ROOT, MEDIA_URL, TEMPLATE_DIRS, added django.contrib.admin to
> > INSTALLED_APPS.
>
> > In urls.py uncommented:
> > from django.contrib import admin
> > admin.autodiscover()
>
> > and
>
> > (r'^admin/', include(admin.site.urls)),
>
> > Run manage.py syncdb - tables and superuser were successfully created.
> > Run manage.py runserver, openedhttp://127.0.0.1:8000/admin/in
> > browser - got admin site login page, entered superuser login/pwd,
> > pressed Login button and got django debug error page:
>
> > TypeError at /admin/
>
> > add() takes at most 6 arguments (7 given)
>
> > Request Method:         POST
> > Request URL:    http://127.0.0.1:8000/admin/
> > Exception Type:         TypeError
> > Exception Value:
>
> > add() takes at most 6 arguments (7 given)
>
> > Exception Location:     /usr/local/lib/python2.6/dist-packages/django/db/
> > models/base.py in _collect_sub_objects, line 558
> > Python Executable:      /usr/bin/python
> > Python Version:         2.6.5
> > etc.
>
> > What am I doing wrong?
>
> The full traceback would help diagnose. Is there any possibility your
> installation of Django is corrupt -- like from a partially-applied install
> of 1.2.1 over 1.1? That's rather what it looks like.
>
> Karen
> --http://tracey.org/kmt/

Completely uninstalling Django and installing 1.2.1 helped.
Thank you for 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-us...@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: Can't login to admin site

2010-09-02 Thread vgarvardt


On Sep 2, 6:58 am, Karen Tracey  wrote:
> On Wed, Sep 1, 2010 at 1:23 PM, vgarvardt  wrote:
> > Django 1.2.1
>
> > Created new project, set DB settings (postgresql_psycopg2),
> > MEDIA_ROOT, MEDIA_URL, TEMPLATE_DIRS, added django.contrib.admin to
> > INSTALLED_APPS.
>
> > In urls.py uncommented:
> > from django.contrib import admin
> > admin.autodiscover()
>
> > and
>
> > (r'^admin/', include(admin.site.urls)),
>
> > Run manage.py syncdb - tables and superuser were successfully created.
> > Run manage.py runserver, openedhttp://127.0.0.1:8000/admin/in
> > browser - got admin site login page, entered superuser login/pwd,
> > pressed Login button and got django debug error page:
>
> > TypeError at /admin/
>
> > add() takes at most 6 arguments (7 given)
>
> > Request Method:         POST
> > Request URL:    http://127.0.0.1:8000/admin/
> > Exception Type:         TypeError
> > Exception Value:
>
> > add() takes at most 6 arguments (7 given)
>
> > Exception Location:     /usr/local/lib/python2.6/dist-packages/django/db/
> > models/base.py in _collect_sub_objects, line 558
> > Python Executable:      /usr/bin/python
> > Python Version:         2.6.5
> > etc.
>
> > What am I doing wrong?
>
> The full traceback would help diagnose. Is there any possibility your
> installation of Django is corrupt -- like from a partially-applied install
> of 1.2.1 over 1.1? That's rather what it looks like.
>
> Karen
> --http://tracey.org/kmt/

Yes, I installed 1.2.1 over 1.1, but I did not get any error message
on installation. Will try to reinstall.

Here is backtrace:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.2.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  101. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in wrapper
  207. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/
decorators.py" in _wrapped_view
  76. response = view_func(request, *args,
**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in inner
  189. return self.login(request)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/
sites.py" in login
  342. login(request, user)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
__init__.py" in login
  78. request.session.cycle_key()
File "/usr/local/lib/python2.6/dist-packages/django/contrib/sessions/
backends/base.py" in cycle_key
  250. self.delete(key)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/sessions/
backends/db.py" in delete
  76.
Session.objects.get(session_key=session_key).delete()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py"
in delete
  636. self._collect_sub_objects(seen_objs)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py"
in _collect_sub_objects
  558.  type(parent), parent, nullable):

Exception Type: TypeError at /admin/
Exception Value: add() takes at most 6 arguments (7 given)

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



django,how to read data from database when db has large volume of data

2010-09-02 Thread girishmss
 Hi folks,im working on django project,,is there a way to access db
without using fixtures,, as fixtures is not working in my project,,i
want to test urls of type:

   /abc/xyz/123 where '123' comes from database.,

and that database contains lots of ids( ex:123 ) i
dont want to loop through each ids and want to get dis unittest
working..

any help or related links is appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: _unicode_ method not working?

2010-09-02 Thread Kevan Stannard
Thanks Yangmin

I did notice that changes are picked up automatically, but this
particular case the change did not show up automatically. It is my
first time writing a django app to perhaps I did something wrong.
Thanks for the feedback though.



On Sep 2, 5:04 pm, Yangmin Li  wrote:
> if you are django's built-in  development server, it will reload the changes
> after you've saved the changes.
>
> On Thu, Sep 2, 2010 at 12:42 PM, Kevan Stannard 
> wrote:
>
>
>
> > I had the same problem going through the tutorial just now. I quit the
> > interpreter and restarted it and it seemed to pick up the changes.
>
> > Anyone know a better way to reload changes?
>
> > Thanks
>
> > On Sep 2, 4:28 am, Erskine  wrote:
> > > Hi,
>
> > > I've just started using Django and have been following the 'Writing
> > > your first Django App' tutorial. So far so good, but I've run into a
> > > little irritation - the use of the _unicode_ method doesn't work for
> > > me. I'm using Django 1.2.1. I'm pretty sure I've got the indenting
> > > right, but when I run the Python shell the only response I get for
> > > Poll.objects.all() is Polls: poll objects and not the objects
> > > themselves. This is my code as I've been following along on Page 1 of
> > > the tutorial.
>
> > > Thanks
>
> > > from django.db import models
> > > import datetime
>
> > > class Poll(models.Model):
> > >     question = models.CharField(max_length=200)
> > >     pub_date = models.DateTimeField('date published')
> > >     def _unicode_(self):
> > >         return self.question
> > >     def was_published_today(self):
> > >         return self.pub_date.date() == datetime.date.today()
>
> > > class Choice(models.Model):
> > >     poll = models.ForeignKey(Poll)
> > >     choice = models.CharField(max_length=200)
> > >     votes = models.IntegerField()
> > >     def _unicode_(self):
> > >         return self.choice
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: _unicode_ method not working?

2010-09-02 Thread Yangmin Li
if you are django's built-in  development server, it will reload the changes
after you've saved the changes.



On Thu, Sep 2, 2010 at 12:42 PM, Kevan Stannard wrote:

> I had the same problem going through the tutorial just now. I quit the
> interpreter and restarted it and it seemed to pick up the changes.
>
> Anyone know a better way to reload changes?
>
> Thanks
>
>
> On Sep 2, 4:28 am, Erskine  wrote:
> > Hi,
> >
> > I've just started using Django and have been following the 'Writing
> > your first Django App' tutorial. So far so good, but I've run into a
> > little irritation - the use of the _unicode_ method doesn't work for
> > me. I'm using Django 1.2.1. I'm pretty sure I've got the indenting
> > right, but when I run the Python shell the only response I get for
> > Poll.objects.all() is Polls: poll objects and not the objects
> > themselves. This is my code as I've been following along on Page 1 of
> > the tutorial.
> >
> > Thanks
> >
> > from django.db import models
> > import datetime
> >
> > class Poll(models.Model):
> > question = models.CharField(max_length=200)
> > pub_date = models.DateTimeField('date published')
> > def _unicode_(self):
> > return self.question
> > def was_published_today(self):
> > return self.pub_date.date() == datetime.date.today()
> >
> > class Choice(models.Model):
> > poll = models.ForeignKey(Poll)
> > choice = models.CharField(max_length=200)
> > votes = models.IntegerField()
> > def _unicode_(self):
> > return self.choice
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

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

2010-09-02 Thread Ivan Uemlianin
Dear Shamail

As well as the resources already mentioned, I mention a few on this
comment on a similar thread in May:


http://groups.google.com/group/django-users/browse_thread/thread/6032003efcf2c2df/0575d5b54ecd5254#0575d5b54ecd5254

Hotdot (django, orbited and twisted) is good for realtime chat, and
easy to set up.  Whether Twisted is a pro or a com I leave up to you.

Speeqe is a hybrid system with django collaborating with an ejabberd
server for the realtime content.  In the long run this is probably
more robust (however, I'm afraid I haven't got round to testing it
myself).

Do let us know how you got on.

Best wishes

Ivan

On Sep 1, 3:05 pm, yves_s  wrote:
> I also looking for realtime messaging for django and found this two
> links.
>
> http://www.clemesha.org/blog/realtime-web-apps-python-django-orbited-...
>
> http://bitshaq.com/2010/07/30/a-simple-experiment-with-hookbox/
>
> yves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: _unicode_ method not working?

2010-09-02 Thread Kevan Stannard
I had the same problem going through the tutorial just now. I quit the
interpreter and restarted it and it seemed to pick up the changes.

Anyone know a better way to reload changes?

Thanks


On Sep 2, 4:28 am, Erskine  wrote:
> Hi,
>
> I've just started using Django and have been following the 'Writing
> your first Django App' tutorial. So far so good, but I've run into a
> little irritation - the use of the _unicode_ method doesn't work for
> me. I'm using Django 1.2.1. I'm pretty sure I've got the indenting
> right, but when I run the Python shell the only response I get for
> Poll.objects.all() is Polls: poll objects and not the objects
> themselves. This is my code as I've been following along on Page 1 of
> the tutorial.
>
> Thanks
>
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
>     def _unicode_(self):
>         return self.question
>     def was_published_today(self):
>         return self.pub_date.date() == datetime.date.today()
>
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(max_length=200)
>     votes = models.IntegerField()
>     def _unicode_(self):
>         return self.choice

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