breadcrumb solution

2009-09-08 Thread Mike Dewhirst

I would like to get breadcrumbs working in a simple way. Could anyone 
please help?

I think I need a singleton with a dict like this ...

bread = singleton()

bread.dct['last_title'] =

Within each view and before doing anything else I want to ...

def someview(request):
title = 'whatever'
crumb = bread.dct['last_title']
bread.dct['last_title'] = title
# put title and crumb into the view context for extraction
# in the template as {{title}} and {{crumb}}


Is there a better way?

Thanks

Mike

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



Re: python manage.py syncdb problem

2009-09-08 Thread Kenneth Gonsalves

On Wednesday 09 Sep 2009 11:07:22 am Zico wrote:
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/man
>agement.py", line 13, in _get_postgis_func
> cursor.execute('SELECT %s()' % func)
> *psycopg2.InternalError: current transaction is aborted, commands ignored
> until end of transaction block*

is postgis installed?
-- 
regards
kg
http://lawgon.livejournal.com

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



How to display and update selected fields from a model

2009-09-08 Thread Jim Myers

I have a database model with many fields, some of which I don't want
displayed in a form and others I don't want to be editable.  Is it
possible to do this with a ModelForm?  Or is it even possible with
regular forms?

Furthermore, I only want the SQL update statement to update ONLY the
fields actually displayed in the form (only the editable ones).  I
know it can do it if I write my own SQL but does Django provide a way?

I've read most of the available docs and a lot of stuff on Google and
still don't see how to do these things.

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



Re: Is it secure "enough" to put login info in the session?

2009-09-08 Thread Craig McClanahan

On Tue, Sep 8, 2009 at 10:20 PM, ristretto.rb wrote:
>
> Hi
>
> I want to have a guest concept.  You get instant access to my app.
> There are limits.  But, you will be allowed to come back multiple
> times before I require you to register.

How do you plan to tell if the guest "came back"?  The only reasonable
mechanism I can think of is to use a session cookie (you can't rely on
things like IP address ... like most folks with a home router, all the
computers in my household will appear to have the same IP address to a
service we contact, and the same would be true for most business
situations).  And even if you rely on a session cookie, your
restrictions are easily bypassed by the user who simply clears their
cookie cache.

Until you can solve this problem reliably (good luck!), the
implementation details are not really worth thinking about.  But
things like using a session cookie are no more or less secure for this
use case than they are for the usual approach to keep a user logged on
to a web app, other than the fact that you'd probably need to keep
your session alive a lot longer.

Craig

PS:  The typical solution I've seen for a "guest" concept is to offer
only a limited subset of the overall functionality to non-registered
users, with lots of teasers about "if you would only bother to
register, you could do FOO and BAR and BAZ!".  Example:  ESPN's web
site has a bunch of "freely available" stories accessible to anonymous
users, but the (presumbably) good stuff requires a login.  Figuring
out the balance point is a challenge -- for me, for example, I'm not a
fantasy football junkie, so the extra subscribers-only analysis
doesn't have enough value for me to bother to register (or pay, as the
case may be).

>
> When a user comes in as a guest, I will create a user with a bogus
> username, password and email, and put  the user_id in the session, so
> that when the user comes back I can read it and restore saved state.
>
> I'm mildly concerned that it's unsafe to put the user_id in the
> session.  I can imagine a hacker faking that somehow, and getting
> access to other guest accounts.  I'm not sure the risk is that big,
> and once users register, the risk goes down.  But, I'm wondering if
> this is at all foolhardy.  Is there a better way to approach this?
>
> Perhaps a hash key or something that isn't sequentially too
> guessable.  Or some encryption.
>
> This guest concept has inherent security issues with shared computers:
> labs, cafes, etc.  The user will made aware of this when logging in as
> Guest.  Also there will be no sensitive or private data in this guest
> account that if seen by another user would make much difference.
>
> Thanks for any insight
> Gene
>
>
> >
>

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



Re: python manage.py syncdb problem

2009-09-08 Thread ankit rai
hello,

this error shows that there is some postgres db connection exception.please
check ur connection or debug ur code.

On Wed, Sep 9, 2009 at 11:07 AM, Zico  wrote:

> Hi, I have been trying to install fixmystreet in one of my Fedora 11
> machine. In one step, i need to enter the command to sync my database.
> Command is: *python manage.py syncdb
>
> *But, here, i get the error:
>
> *psycopg2.InternalError: current transaction is aborted, commands ignored
> until end of transaction block
> *
> Here is the full error:
>
> [r...@fedora fixmystreet]# python manage.py syncdb
> local_settings.py not set; using default settings
> local_settings.py not set; using default settings
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
> execute_manager(settings)
>   File "/usr/lib/python2.6/site- packages/django/core/management/__init__.py",
> line 362, in execute_manager
> utility.execute()
>   File
> "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line
> 303, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.6/site-packages/django/core/management/base.py",
> line 195, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/lib/python2.6/site-packages/django/core/management/base.py",
> line 221, in execute
> self.validate()
>   File "/usr/lib/python2.6/site-packages/django/core/management/base.py",
> line 249, in validate
> num_errors = get_validation_errors(s, app)
>   File
> "/usr/lib/python2.6/site-packages/django/core/management/validation.py",
> line 28, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
>   File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line
> 131, in get_app_errors
> self._populate()
>   File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line
> 58, in _populate
> self.load_app(app_name, True)
>   File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line
> 74, in load_app
> models = import_module('.models', app_name)
>   File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line
> 35, in import_module
> __import__(name)
>   File "/opt/fixmystreet/mainapp/models.py", line 3, in 
> from django.contrib.gis.db import models
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/models/__init__.py",
> line 5, in 
> from django.contrib.gis.db.models.aggregates import *
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/models/aggregates.py",
> line 2, in 
> from django.contrib.gis.db.backend import SpatialBackend
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/__init__.py",
> line 12, in 
> from django.contrib.gis.db.backend.postgis import
> create_test_spatial_db, get_geo_where_clause, SpatialBackend
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/__init__.py",
> line 4, in 
> from django.contrib.gis.db.backend.postgis.adaptor import
> PostGISAdaptor
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/adaptor.py",
> line 5, in 
> from django.contrib.gis.db.backend.postgis.query import GEOM_FROM_WKB
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/query.py",
> line 27, in 
> version_tuple = postgis_version_tuple()
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/management.py",
> line 45, in postgis_version_tuple
> version = postgis_lib_version()
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/management.py",
> line 25, in postgis_lib_version
> return _get_postgis_func('postgis_lib_version')
>   File
> "/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/management.py",
> line 13, in _get_postgis_func
> cursor.execute('SELECT %s()' % func)
> *psycopg2.InternalError: current transaction is aborted, commands ignored
> until end of transaction block*
>
>
>
> --
> Best,
> Zico
>
> >
>

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



python manage.py syncdb problem

2009-09-08 Thread Zico
Hi, I have been trying to install fixmystreet in one of my Fedora 11
machine. In one step, i need to enter the command to sync my database.
Command is: *python manage.py syncdb

*But, here, i get the error:

*psycopg2.InternalError: current transaction is aborted, commands ignored
until end of transaction block
*
Here is the full error:

[r...@fedora fixmystreet]# python manage.py syncdb
local_settings.py not set; using default settings
local_settings.py not set; using default settings
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.6/site- packages/django/core/management/__init__.py",
line 362, in execute_manager
utility.execute()
  File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py",
line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py",
line 221, in execute
self.validate()
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py",
line 249, in validate
num_errors = get_validation_errors(s, app)
  File
"/usr/lib/python2.6/site-packages/django/core/management/validation.py",
line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line
131, in get_app_errors
self._populate()
  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line
58, in _populate
self.load_app(app_name, True)
  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line
74, in load_app
models = import_module('.models', app_name)
  File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line
35, in import_module
__import__(name)
  File "/opt/fixmystreet/mainapp/models.py", line 3, in 
from django.contrib.gis.db import models
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/models/__init__.py",
line 5, in 
from django.contrib.gis.db.models.aggregates import *
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/models/aggregates.py",
line 2, in 
from django.contrib.gis.db.backend import SpatialBackend
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/__init__.py",
line 12, in 
from django.contrib.gis.db.backend.postgis import
create_test_spatial_db, get_geo_where_clause, SpatialBackend
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/__init__.py",
line 4, in 
from django.contrib.gis.db.backend.postgis.adaptor import PostGISAdaptor
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/adaptor.py",
line 5, in 
from django.contrib.gis.db.backend.postgis.query import GEOM_FROM_WKB
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/query.py",
line 27, in 
version_tuple = postgis_version_tuple()
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/management.py",
line 45, in postgis_version_tuple
version = postgis_lib_version()
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/management.py",
line 25, in postgis_lib_version
return _get_postgis_func('postgis_lib_version')
  File
"/usr/lib/python2.6/site-packages/django/contrib/gis/db/backend/postgis/management.py",
line 13, in _get_postgis_func
cursor.execute('SELECT %s()' % func)
*psycopg2.InternalError: current transaction is aborted, commands ignored
until end of transaction block*



-- 
Best,
Zico

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



Re: haml + sass + django

2009-09-08 Thread Emmanuel Surleau

> Hello,
> 
> I just came across haml and sass, but looks like it is built for Ruby on
> Rails.

Actually, they can work standalone too.

> Any implementation that can work on Django?

There's GHRML (http://www.ghrml.org/) for HAML, but I don't think it's 
developed anymore. One issue is that choosing a different template 
language means giving up on django's tag libraries, which might or might 
not be a problem.

> Though I also came across http://bit.ly/3el7iR, by which apache can take
> care of converting haml to html.

Cheers,

Emm

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



Is it secure "enough" to put login info in the session?

2009-09-08 Thread ristretto.rb

Hi

I want to have a guest concept.  You get instant access to my app.
There are limits.  But, you will be allowed to come back multiple
times before I require you to register.

When a user comes in as a guest, I will create a user with a bogus
username, password and email, and put  the user_id in the session, so
that when the user comes back I can read it and restore saved state.

I'm mildly concerned that it's unsafe to put the user_id in the
session.  I can imagine a hacker faking that somehow, and getting
access to other guest accounts.  I'm not sure the risk is that big,
and once users register, the risk goes down.  But, I'm wondering if
this is at all foolhardy.  Is there a better way to approach this?

Perhaps a hash key or something that isn't sequentially too
guessable.  Or some encryption.

This guest concept has inherent security issues with shared computers:
labs, cafes, etc.  The user will made aware of this when logging in as
Guest.  Also there will be no sensitive or private data in this guest
account that if seen by another user would make much difference.

Thanks for any insight
Gene


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



Re: login required

2009-09-08 Thread putih

ok thanks .. i have use this tutorial but i a lot of errors comes in..
mayb need to understand for python code first. btw, thanks again

On Sep 9, 1:08 am, "ristretto.rb"  wrote:
> Have you not had a peek in here yet?
>
> http://docs.djangoproject.com/en/dev/topics/auth/#topics-auth
>
> gene
>
> On Sep 9, 4:30 pm, putih  wrote:
>
> > hii,
>
> > need your help on this matter :-
>
> > 1. how to restrict user for certain page. for example :-
>
> > non-register user have to register first before they can join a
> > survey. after register, they login and redirect to the survey page.
> > (not main page.)
>
> > anyone, please advise me on this problem. seriously i didn't have any
> > ideas on this matter..
>
> > thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MySQL-Python and Snow Leopard

2009-09-08 Thread Brandon Taylor

Hi everyone,

After following the custom build instructions for MySQL from
Hivelogic, http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/
MySQL is running just fine.

However, I can't get MySQL-Python 1.2.3c1 to compile. I have re-
installed Xcode for 10.6, but I get an error trace a mile long, ending
with error: Setup script exited with error: command 'gcc' failed with
exit status 1

Fun times. Has anyone been able to get this running? I'd appreciate
some pointers!

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



Re: login required

2009-09-08 Thread ristretto.rb

Have you not had a peek in here yet?

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

gene


On Sep 9, 4:30 pm, putih  wrote:
> hii,
>
> need your help on this matter :-
>
> 1. how to restrict user for certain page. for example :-
>
> non-register user have to register first before they can join a
> survey. after register, they login and redirect to the survey page.
> (not main page.)
>
> anyone, please advise me on this problem. seriously i didn't have any
> ideas on this matter..
>
> thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Editors of choice

2009-09-08 Thread Emmanuel Surleau

Vim

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



Re: problem in define variables.

2009-09-08 Thread Kenneth Gonsalves

On Wednesday 09 Sep 2009 9:56:24 am putih wrote:
> then how to define the variables..??

here is a simple view which defines and passes some variables to the template:

def downall(request):
""" view for display of downloads
"""
lst = Downloadtype.objects.all()

return render_to_response('web/downall.html',
{'lst':lst,
 'mn':makemenu('Downloads'),
 'rbox':rightbox(),'request':request,
 })
you will notice a dictionary of variables that can be used by the template. 
Here is the template:

{% extends "basefull.html" %}
{% block centercontent %}

Choose download category
{% if lst %}

{% for p in lst %}


{{ p.name }}



{% endfor %}

{% else %}
No download categories posted
{% endif %}

{% endblock %}

I would suggest you learn some python before going further.
-- 
regards
kg
http://lawgon.livejournal.com

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



login required

2009-09-08 Thread putih

hii,

need your help on this matter :-

1. how to restrict user for certain page. for example :-

non-register user have to register first before they can join a
survey. after register, they login and redirect to the survey page.
(not main page.)

anyone, please advise me on this problem. seriously i didn't have any
ideas on this matter..

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



Re: problem in define variables.

2009-09-08 Thread putih

then how to define the variables..??

On Sep 8, 11:35 pm, Kenneth Gonsalves  wrote:
> On Wednesday 09 Sep 2009 7:50:36 am putih wrote:
>
> > here is my code :-
> > @login_required
> > def survey(request):
> >   return render_to_response('survey.html', variables)
>
> > please help me because this is my first time using django..
> > really need your help guys..
>
> you have not defined your variables.
> --
> regards
> kghttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem in define variables.

2009-09-08 Thread Kenneth Gonsalves

On Wednesday 09 Sep 2009 7:50:36 am putih wrote:
> here is my code :-
> @login_required
> def survey(request):
>   return render_to_response('survey.html', variables)
>
> please help me because this is my first time using django..
> really need your help guys..

you have not defined your variables.
-- 
regards
kg
http://lawgon.livejournal.com

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



File Storage Suggestions

2009-09-08 Thread brad

I currently have a django site running on a single machine (web server
+ database + file storage).  This site contains many multimedia files
(audio, video, documents) that are uploaded and retrieved by end-
users.

We've reached the point where we need to push the multimedia storage
off of this server, and I'm looking for suggestions on ways to do
this.  We're considering purchasing another machine or pushing our
files out to something like S3.

I've also run across django-storages, so I'm intrigued by the
solutions that it supports as well.

I'd just like to get feedback on what other people are doing before
jumping in too deep.

Thanks!




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



problem in define variables.

2009-09-08 Thread putih

hii,

i'm newbie in django. i'm facing some problem where the error is like
below :-

NameError at /survey/

global name 'variables' is not defined

Environment:

Request Method: GET
Request URL: http://localhost:8000/survey/
Django Version: 1.0.2 final
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'aper.apps']
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
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
decorators.py" in __call__
  67. return self.view_func(request, *args, **kwargs)
File "/home/www/django/aper/../aper/apps/views.py" in survey
  107.   return render_to_response('survey.html', variables)

Exception Type: NameError at /survey/
Exception Value: global name 'variables' is not defined

here is my code :-
@login_required
def survey(request):
  return render_to_response('survey.html', variables)

please help me because this is my first time using django..
really need your help guys..

thanks

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



Re: Authenticate against FDS

2009-09-08 Thread Tim Chase

> How to autenticate against Fedora Directory Server?

I believe FDS is simply Red Hat's LDAP server.  If you google 
"django ldap" there are a number of good resources on using LDAP 
for Django authentication.

-tim




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



Re: Trying to get tinyMCE working on an admin page

2009-09-08 Thread Kenneth Gonsalves

On Wednesday 09 Sep 2009 1:44:53 am DrKen wrote:
> Hi, new to Django and tinyMCE. I'm trying to get the tinyMCE HTML
> editor working on the admin page, so started out by doing the Django
> tutorial, then attempting to modify. I've got the admin page working
> with text fields instead of character fields, but don't see any change
> whatsoever when I convert the fields to HTMLField() - my html content
> appears as straight text, no syntax highlighting etc. I've googled all
> over for suggestions and tried several dozen, but something is still
> not happening. According to what I've been reading, this should bring
> up an HTML editor on all of the (one) text fields. Suggestions
> appreciated.

here is a snippet of my admin.py:

from southzone.web.models import *
from django.contrib import admin

class StaticpageAdmin(admin.ModelAdmin):
list_display = ['page',]
class Media:
js = ('/sitemedia/js/tiny_mce/jscripts/tiny_mce/tiny_mce.js',
  '/sitemedia/js/tiny_mce/jscripts/tiny_mce/textareas.js',)
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: apache2+mod_wsgi: 403 Forbidden

2009-09-08 Thread Graham Dumpleton



On Sep 9, 12:28 am, Matias  wrote:
> sorry, I messed up!
>
> I'm not sure now, i couldn't test it, but maybe you should set the Directory
> directive in the specific path where wsgi files are
>
> 
>        Order Allow,Deny
>        Deny from all
> 
> 

Don't use wildcards, ie., '*', like that, it is unnecessary in this
sort of situation and technically will match other directories you may
not have intended to expose, if they so happened to exist.

Graham

>        Order Allow,Deny
>        Allow from all
> 
>
> Regards,
> Matias.
>
>
>
>
>
> On Tue, Sep 8, 2009 at 11:04 AM, Matias  wrote:
> > You should use Directory with the real path, not the alias
>
> > 
> >        Order Allow,Deny
> >        Deny from all
> > 
> > 
> >        Order Allow,Deny
> >        Allow from all
> > 
>
> > like in the example :)
>
> > Regards,
> > Matias.
>
> > On Mon, Sep 7, 2009 at 5:56 PM, Léon Dignòn  wrote:
>
> >> No, I have it here, but forgot to post it:
>
> >> 
> >>        Order Allow,Deny
> >>        Deny from all
> >> 
> >> 
> >>        Order Allow,Deny
> >>        Allow from all
> >> 
>
> >> On Sep 7, 10:11 pm, Matias  wrote:
> >> > I think you missed the allow directive in your apache conf.
>
> >> > Example from [1]
>
> >> > Alias /media/ /usr/local/django/mysite/media/
>
> >> > 
> >> > Order deny,allow
> >> > Allow from all
> >> > 
>
> >> > WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
>
> >> > 
> >> > Order deny,allow
> >> > Allow from all
> >> > 
>
> >> > [1]http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
> >> > HTH,
> >> > Matias.
>
> >> > On Mon, Sep 7, 2009 at 2:55 PM, Léon Dignòn 
> >> wrote:
>
> >> > > I get a 403 forbidden.
>
> >> > > I serve Django with apache2+mod_wsgi. I disabled some plugins I think
> >> > > I don't need. Set the listen port to 8000 on localhost only. Later I
> >> > > will serve django through reverse proxy on cherokee webserver. But for
> >> > > now, localhost:8000 is returning a 403 forbidden error.
>
> >> > > Any ideas?
>
> >> > > # error.log
> >> > >    [Mon Sep 07 17:14:59 2009] [error] [client 127.0.0.1] client
> >> > > denied by server configuration: /htdocs
>
> >> > > lwp-request -m GET -Sedhttp://127.0.0.1:8000/
> >> > > lwp-request  -m GET -Sed
> >> > >http://beispiel.de:8000/
> >> > >    GEThttp://127.0.0.1:8000/--> 403 Forbidden
> >> > >    Connection: close
> >> > >    Date: Mon, 07 Sep 2009 14:56:32 GMT
> >> > >    Server: Apache
> >> > >    Content-Length: 202
> >> > >    Content-Type: text/html; charset=iso-8859-1
> >> > >    Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
> >> > >    Client-Peer: 127.0.0.1:8000
> >> > >    Client-Response-Num: 1
> >> > >    Title: 403 Forbidden
>
> >> > > # /etc/apache2/ports.conf
> >> > >    NameVirtualHost 127.0.0.1:8000
> >> > >    Listen 127.0.0.1:8000
>
> >> > > # /etc/apache2/sites-enabled/000-default
> >> > >    
> >> > >            ServerName localhost
> >> > >            ServerAdmin webmas...@localhost
> >> > >    
>
> >> > > # /etc/apache2/sites-enabled/beispiel.de
> >> > >    
> >> > >            ServerNamewww.beispiel.de
> >> > >            ServerAlias beispiel.de
> >> > >            ServerAdmin daniel.nicc...@gmail.com
>
> >> > >            DocumentRoot /var/www/django/beispiel
>
> >> > >            Alias /robots.txt  /var/www/django/beispiel/media/
> >> > > robots.txt
> >> > >            Alias /favicon.ico /var/www/django/beispiel/media/
> >> > > favicon.ico
> >> > >            Alias /media/      /var/www/django/beispiel/media/
>
> >> > >            ErrorLog  "|/usr/sbin/rotatelogs /var/log/apache2/
> >> > > beispiel.de/error_log.%Y-%m-%d 86400"
> >> > >            CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/
> >> > > beispiel.de/access_log.%Y-%m-%d 86400" common
>
> >> > >            WSGIScriptAlias / /var/www/django/wsgi-scripts/
> >> > > beispiel.wsgi
> >> > >    
>
> >> > > # mods-enabled
> >> > >    alias.conf
> >> > >    alias.load
> >> > >    auth_digest.load
> >> > >    authn_file.load
> >> > >    authz_default.load
> >> > >    authz_groupfile.load
> >> > >    authz_host.load
> >> > >    authz_user.load
> >> > >    status.conf
> >> > >    status.load
> >> > >    wsgi.conf
> >> > >    wsgi.load
>
> >> > --
> >> > :wq- Hide quoted text -
>
> >> > - Show quoted text -
>
> > --
> > :wq
>
> --
> :wq
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Authenticate against FDS

2009-09-08 Thread opp

How to autenticate against Fedora Directory Server?
Thanks

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



Re: Editors of choice

2009-09-08 Thread Mike Dewhirst

Dj Gilcrease wrote:
> On Mon, Sep 7, 2009 at 9:55 AM, Samuel Hopkins  
> wrote:
>> Hello Django peeps,
>>
>> I am a Django newbee. I have had my eye on Djanjo for a year or so now but
>> held off because I had limited python experience. However, after a summer of
>> python and watching Django's popularity snowball, I think I am ready to go
>> :)
>>
>> Anyhow, the purpose of this email was just to ask the community what
>> editor(s) they preferred to use with Django.
> 
> 
> I used TextPad for years, with no syntax highlighting. I now use
> Wingware, and since I work primarily on OpenSource Projects the Pro
> version is free.

I use TextPad with Python highlighting. It suits me because I'm used to 
it. I use the 'Run' option to launch Python with my unit tests or 
anything else for a quick syntax check. The results come back nicely.

Speaking of results I also like TextPad's search results (with or 
without re) and grep-like 'Find in files' which is very fast and lets 
you double-click a found line to open the file at that point.

I tried PyDev and like that too but found Eclipse too heavy when 
associated with SVN. I know there is SVN integration but I couldn't get 
it going smoothly enough so I gave up and happily went back to TextPad.

I'm definitely going to try Joshua's suggestion of pdb.

Thanks

Mike


> 
> > 
> 
> 


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



Re: Abstract Base Classes

2009-09-08 Thread Bill Freeman

Actually, maybe it is working.  I should have been looking for _meta
rather than _meta_ .

But does anyone have an opinion about subclassing models.Model.__metaclass__ ?

Bill

On Tue, Sep 8, 2009 at 4:35 PM, Bill Freeman wrote:
> I'm trying to use an Abstract Base Class as described at:
>
> http://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes
>
> (Django 1.1, Python 2.6.2)
>
> Things may be complicated by my desire to use a mixin:
>
> class Mixin(object):
>    """I will actually be creating some of these that aren't model instances"""
>    def _setFoo(self, v):
>        self._inner_foo = ...
>
>    def _getFoo(self):
>        ...
>
>    foo = property(_getFoo, _setFoo)
>
>    # and other methods that process self that has _inner_foo
>
> class AbsModel(models.Model, Mixin):
>    _inner_foo = models.FloatFiedl(...)
>
>    class Meta:
>        abstract = True
>
> class Thing(AbsModel):
>    """I want to use the property and methods from Mixin on these instances
>    and on instances of other subclasses of AbsModel without having to
>    define _inner_foo as a field in each lexical class definition (there are
>    actually a number of fields)."""
>    # Other fields
>    # Other methods
>
> x = Thing()
>
> So far, so good.  But, while x is an instance of models.Model, it is
> not an instance of Mixin (according to isinstance, and also according
> to the lack of a foo property).
>
> I can make it seem to work by changing the Meta class declaration to:
>
>    class Meta(models.Model.__metaclass__):
>
> The property is there, and isinstance reports that x is an instance of
> both, but now Thing doesn't have a _meta_ attribute (so it doesn't
> have fields).
>
> Is this a bug in the Abstract Base Class mechanism, my efforts, or both?
>
> Bill
>

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



Re: Open Position: Software/System Engineer....Django...

2009-09-08 Thread Jim McGaw

There is a site for posting Django jobs:

http://djangogigs.com/

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



Re: Having Trouble with Reverse method

2009-09-08 Thread Peter Coles

What you provided looks correct -- which means that something else is
probably broken...

Some things to investigate:

1. If you manually go that url: http:/in_development/
does anything get served?
2. Is your ROOT_URLCONF setup to properly point to this file in your
settings file?
3. Is this another url file than the one defined in your ROOT_URLCONF?
If so are you properly "including" this one from your root urls.py?
Details on include here: 
http://docs.djangoproject.com/en/dev/topics/http/urls/#including-other-urlconfs

You'll find a wealth of information about urls in django here:
http://docs.djangoproject.com/en/dev/topics/http/urls/

Once you get it working, you may find it more convenient to use named
url patterns: 
http://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns


On Sep 8, 1:49 pm, Streamweaver  wrote:
> I'm having trouble understanding the output of the reverse method.
>
> I have the following URL pattern:
>
> urlpatterns = patterns('dwrangler.project.views',
>     (r'^in_development/$', 'summary_in_development'),
> )
>
> from the documentation I would think I can get the URL by using
>
> reverse('dwrangler.project.views.summary_in_development')
>
> But I keep getting a NoReverseMatch error.  I have tried several
> different formats but keep getting similar errors.
>
> I must be missing something obvious and would be thankful if something
> could point me in the right direction.
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Managers in admin

2009-09-08 Thread Alasdair

Thanks for your reply, Peter. When I set live = BadManager(), it
properly returns posts, so maybe the issue is with my
LiveEntryManager:

class LiveEntryManager(models.Manager):
def get_query_set(self):
return super(LiveEntryManager,self).get_query_set().filter
(status=self.model.LIVE_STATUS)

As for your other suggestions:
1. I haven't set list_display or list_filter for this model.
2. I don't seem to have imported another "models"

Live is my default manager because it filters down to published posts.
I like your method of adding a "published" method, thus keeping
objects intact. However, I was following a tutorial for writing custom
templatetags to fetch objects for any installed model:

http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/

For the templatetag to filter down to published Entries, I need to
have 'live' as the default manager.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Link for new page

2009-09-08 Thread Peter Coles

Make yourself familiar with the django documention page—if you know
where to look for stuff there, you'll find it to be a very handy
resource. http://docs.djangoproject.com/en/dev/

> 1: How can I go to next page when i submit the data in index page(log
> in page)

http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponseRedirect

> 2: How can I link a page with a text. so that when I click on the text
> It will so the page I want.

This sounds like you're trying to just put a link on a page? of the
format Click this link? The following will
show you the best way to generate the url for the "_url_here_" part:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
You should really give this a read too, naming url patterns can be
very convenient: 
http://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns

Finally, you should really read the content provided under "First
Steps" on the doc page: http://docs.djangoproject.com/en/dev/#first-steps
Especially the intro overview 
http://docs.djangoproject.com/en/dev/intro/overview/#intro-overview
and then the tutorials

>
> Can any one give some tips (which may face silly issues while create
> simple web application)
>
> Please help me to for gaining knowledge about django framework.
>
> many many thanks in advance 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Abstract Base Classes

2009-09-08 Thread Bill Freeman

I'm trying to use an Abstract Base Class as described at:

http://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes

(Django 1.1, Python 2.6.2)

Things may be complicated by my desire to use a mixin:

class Mixin(object):
"""I will actually be creating some of these that aren't model instances"""
def _setFoo(self, v):
self._inner_foo = ...

def _getFoo(self):
...

foo = property(_getFoo, _setFoo)

# and other methods that process self that has _inner_foo

class AbsModel(models.Model, Mixin):
_inner_foo = models.FloatFiedl(...)

class Meta:
abstract = True

class Thing(AbsModel):
"""I want to use the property and methods from Mixin on these instances
and on instances of other subclasses of AbsModel without having to
define _inner_foo as a field in each lexical class definition (there are
actually a number of fields)."""
# Other fields
# Other methods

x = Thing()

So far, so good.  But, while x is an instance of models.Model, it is
not an instance of Mixin (according to isinstance, and also according
to the lack of a foo property).

I can make it seem to work by changing the Meta class declaration to:

class Meta(models.Model.__metaclass__):

The property is there, and isinstance reports that x is an instance of
both, but now Thing doesn't have a _meta_ attribute (so it doesn't
have fields).

Is this a bug in the Abstract Base Class mechanism, my efforts, or both?

Bill

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



Re: Managers in admin

2009-09-08 Thread Peter Coles

Are you certain that the django admin interface is actually using
LiveEntryManager?  I just tested this out (using trunk):

class BadManager(models.Manager):
def all(self): return self.get_query_set().filter(slug='')
def filter(self, *args, **kwargs): return super(BadManager,
self).filter(slug='')

and inside my model I have:

class Post(models.Model):
... (column declarations here) ...
live = BadManager()
objects = models.Manager()

When I try out my admin interface, it's properly returning Posts.
When I call Post._default_manager from a shell it returns an instance
of "BadManager"

If you're still seeing this problem with your code, maybe check for:

1. Are your "class Admin" values setup properly for this object?
list_display? list_filter?
2. Have you imported something called "models" into your models file
that isn't django.db.models, which is hijacking your "models.Manager"
declaration?

Some additional things to consider:
Any reason for having "live" as your default manager? Switching the
order of "live" and "objects" will make "objects" the default_manager.
Also, in practice I'll usually make a manager that adds some
additional features to the models.Manager and just use this manager as
my only manager. For example if I have Posts, where I tend to only
retrieve published ones, I might add a function called "published"
that filters down to published posts, which lets me do this:
"Post.objects.published()".  This way all the standard functions of
Post.objects are kept intact, but I have some additional features
available.

On Sep 8, 1:20 pm, Alasdair  wrote:
> I've defined a custom manager
>
> class Entry(models.Model):
>     [...]
>     live = LiveEntryManager()
>     objects = models.Manager()
>
> so that when I use _default_manager.all() it uses the LiveEntryManager
> ().
>
> However, the django admin is now also using LiveEntryManager. How can
> I get the admin to use models.Manager, while keeping LiveEntryManager
> as the default for everything else?
>
> (I'm using django 1.1)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: total newb question with custom save()

2009-09-08 Thread Matt

Thank you. That worked perfectly.


On Sep 8, 1:39 pm, Daniel Roseman  wrote:
> On Sep 8, 7:56 pm, Matt  wrote:
>
>
>
> > hey folks,
>
> > I have two models:
> > ___
> > class contentcreator(models.Model):
> >     name = models.CharField(max_length=50)
> >     phone = models.CharField(max_length=60, blank=True)
> >     supervisor = models.CharField(max_length=60)
> >     department = models.CharField(max_length=60, blank=True)
> >     def __unicode__(self):
> >         return self.name
>
> >     class Meta:
> >         verbose_name = u'Content Creator'
> >         verbose_name_plural = u'Content Creators'
>
> > class accuracyreport(models.Model):
> >     byline = models.ForeignKey(contentcreator, related_name="byline")
> >     date = models.DateField()
> >     resolved = models.BooleanField("Resolved?", help_text="Has the
> > issue been resolved?", null=True)
> >     responsible = models.ForeignKey(contentcreator,
> > related_name="ultimately_responsible", blank=True, null=True)
> >     supervisor = models.CharField(max_length=60, editable=False)
>
> >     def save(self):
> >         if not self.responsible:
> >             self.supervisor = contentcreator.objects.get
> > (name__exact=self.byline).supervisor
> >         else:
> >             self.supervisor = contentcreator.objects.get
> > (name__exact=self.responsible).supervisor
> >         super(accuracyreport, self).save()
> > ___
>
> > The custom save(), as you can probably tell, is where I'm having
> > trouble.
>
> > I'd like to set things so that when the "responsible" field is blank,
> > the supervisor of the byline gets saved in the accuracyreport model.
> > If it's filled in, then the supervisor of "responsible" gets filled
> > in.
>
> > I'm aware of the denormalization issues, but I think it's the best way
> > to handle this particular problem.
>
> > Help?
>
> You don't actually say what the problem is. What happens when you save
> an object using the code above?
>
> The main problem that i can see with your code is not with save()
> particularly, but with the way you're accessing the related values.
> 'self.responsible' is a ForeignKey, so using it as the lookup value
> compared to a 'name' field is not likely to work.
>
> The much easier and more obvious way is to do this:
>
>         if not self.responsible:
>             self.supervisor = self.byline.supervisor
>         else:
>             self.supervisor = self.responsible.supervisor
>
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django unicode user name

2009-09-08 Thread Léon Dignòn

It's easier than that, since the username field is a CharField!

Add these lines to your admin.py:
--
from django.contrib.auth.forms import UserCreationForm,
UserChangeForm


# Overrides django.contrib.auth.forms.UserCreationForm and changes
# username to accept a wider range of character in the username.
class UserCreationForm(UserCreationForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
help_text = _("Required. 30 characters or fewer. Alphanumeric
characters only (letters, digits and underscores)."),
error_message = _("This value must contain only letters,
numbers and underscores."))


# Overrides django.contrib.auth.forms.UserChangeForm and changes
# username to accept a wider range of character in the username.
class UserChangeForm(UserChangeForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
help_text = _("Required. 30 characters or fewer. Alphanumeric
characters only (letters, digits and underscores)."),
error_message = _("This value must contain only letters,
numbers and underscores."))


class UserProfileAdmin(UserAdmin):
form = UserChangeForm
add_form = UserCreationForm


admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
--


-ld



On Sep 5, 1:29 pm, joymax  wrote:
> You have to create custom authentication backend (more about it 
> herehttp://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authenti...).
>
> On Sep 5, 12:42 pm, Казбек  wrote:
>
>
>
> > Good day. How can i make django to register and use unicode usernames?
> > When i try to register one (russian symbols username) i get an error
> > says that the username must not contain such symbols. I try to
> > register username in admin panel. Thanks.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django unicode user name

2009-09-08 Thread Léon Dignòn

It's easier than that, since the username field is a CharField!

Add these lines to your admin.py:
--
from django.contrib.auth.forms import UserCreationForm, UserChangeForm

# Overrides django.contrib.auth.forms.UserCreationForm and changes
# username to accept a wider range of character in the username.
class UserCreationForm(UserCreationForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
help_text = _("Required. 30 characters or fewer. Alphanumeric
characters only (letters, digits and underscores)."),
error_message = _("This value must contain only letters,
numbers and underscores."))

# Overrides django.contrib.auth.forms.UserChangeForm and changes
# username to accept a wider range of character in the username.
class UserChangeForm(UserChangeForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
help_text = _("Required. 30 characters or fewer. Alphanumeric
characters only (letters, digits and underscores)."),
error_message = _("This value must contain only letters,
numbers and underscores."))

class UserProfileAdmin(UserAdmin):
inlines = [UserProfileInline]
form = UserChangeForm
add_form = UserCreationForm

admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
--

On Sep 5, 1:29 pm, joymax  wrote:
> You have to create custom authentication backend (more about it 
> herehttp://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authenti...).
>
> On Sep 5, 12:42 pm, Казбек  wrote:
>
>
>
> > Good day. How can i make django to register and use unicode usernames?
> > When i try to register one (russian symbols username) i get an error
> > says that the username must not contain such symbols. I try to
> > register username in admin panel. Thanks.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: total newb question with custom save()

2009-09-08 Thread Daniel Roseman

On Sep 8, 7:56 pm, Matt  wrote:
> hey folks,
>
> I have two models:
> ___
> class contentcreator(models.Model):
>     name = models.CharField(max_length=50)
>     phone = models.CharField(max_length=60, blank=True)
>     supervisor = models.CharField(max_length=60)
>     department = models.CharField(max_length=60, blank=True)
>     def __unicode__(self):
>         return self.name
>
>     class Meta:
>         verbose_name = u'Content Creator'
>         verbose_name_plural = u'Content Creators'
>
> class accuracyreport(models.Model):
>     byline = models.ForeignKey(contentcreator, related_name="byline")
>     date = models.DateField()
>     resolved = models.BooleanField("Resolved?", help_text="Has the
> issue been resolved?", null=True)
>     responsible = models.ForeignKey(contentcreator,
> related_name="ultimately_responsible", blank=True, null=True)
>     supervisor = models.CharField(max_length=60, editable=False)
>
>     def save(self):
>         if not self.responsible:
>             self.supervisor = contentcreator.objects.get
> (name__exact=self.byline).supervisor
>         else:
>             self.supervisor = contentcreator.objects.get
> (name__exact=self.responsible).supervisor
>         super(accuracyreport, self).save()
> ___
>
> The custom save(), as you can probably tell, is where I'm having
> trouble.
>
> I'd like to set things so that when the "responsible" field is blank,
> the supervisor of the byline gets saved in the accuracyreport model.
> If it's filled in, then the supervisor of "responsible" gets filled
> in.
>
> I'm aware of the denormalization issues, but I think it's the best way
> to handle this particular problem.
>
> Help?

You don't actually say what the problem is. What happens when you save
an object using the code above?

The main problem that i can see with your code is not with save()
particularly, but with the way you're accessing the related values.
'self.responsible' is a ForeignKey, so using it as the lookup value
compared to a 'name' field is not likely to work.

The much easier and more obvious way is to do this:

if not self.responsible:
self.supervisor = self.byline.supervisor
else:
self.supervisor = self.responsible.supervisor

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



Re: Trying to get tinyMCE working on an admin page

2009-09-08 Thread Daniel Roseman

On Sep 8, 9:14 pm, DrKen  wrote:
> Hi, new to Django and tinyMCE. I'm trying to get the tinyMCE HTML
> editor working on the admin page, so started out by doing the Django
> tutorial, then attempting to modify. I've got the admin page working
> with text fields instead of character fields, but don't see any change
> whatsoever when I convert the fields to HTMLField() - my html content
> appears as straight text, no syntax highlighting etc. I've googled all
> over for suggestions and tried several dozen, but something is still
> not happening. According to what I've been reading, this should bring
> up an HTML editor on all of the (one) text fields. Suggestions
> appreciated.

You seem to have tried a random selection of things from different
blog posts, many of which reference old versions of Django. So for
example the 'class Admin' lines in your models is for a pre-1.0
version and no longer does anything. Similarly, if you're using the
HTMLField code from django-tinymce, you shouldn't need to reference
the javascript files directly in your admin classes - this is only
relevant if you're manually applying tinyMCE to your fields.

I suspect there are two problems: firstly, the value of TINYMCE_JS_URL
doesn't look much like a URL, it looks like a filesystem path. This
needs to be an actual URL which serves the Javascript.

Which brings me to the second problem: do you actually have anything
that serves static files such as Javascript? Remember, Django won't do
this for you, unless you ask it to and you're running on the
development server. Is something actually serving files from /media/?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom methods

2009-09-08 Thread Daniel Roseman

On Sep 8, 7:29 pm, Slammer  wrote:
> FYI, I'm a beginner,  I'm having trouble with custom methods,  I'm
> using an existing database which is used for a fantasy football
> site,   the primary data return is a list of players for a particular
> team, I've done that fine, but the score for those players is in a
> different table,  So to return the list of players with their current
> scores I tried to create a custom method as such in my models.py
>
> class Player(models.Model):
>     p_keyid = models.IntegerField(primary_key=True)
>     p_lname = models.CharField(max_length=135)
>     #bla bla bla more fieldnames
>     ...
>
>     def ptot(self):
>         from django.db import connection
>         cursor = connection.cursor()
>         cursor.execute("""
>                 SELECT sum(s_total) s_total from score where s_pno =
> %s""", [self.p_keyid])
>         #return [row[0] for row in cursor.fetchone()]
>         #return [self.__class__(*row) for row in cursor.fetchone()]
>         return u'S=%s' % (self.__class(*row).s_total)
>
> As you can see I've tried a bunch of ways to return the related score
> total, none have worked.
>
> in my views.py I have
> def search_roster(request):
>         if 'q' in request.GET and request.GET['q']:
>                 q = request.GET['q']
>                 player = Player.objects.filter(p_uffl__icontains=q)
>                 return render_to_response('search_results.html',
>                         {'player': player, 'query':q})
>         else:
>                 return render_to_response('search_form.html',
> {'error': True})
>
> in my search_results.html I have
> Team Listing for: {{ query }}
> {% if player %}
>     Found {{ player|length }} player{{ player|pluralize }}.
>     
>          
>          PosName
>          NFLValue
>          Score
>          {% for player in player %}
>          {{ player.p_pos }}{{ player.p_lname }}
>          {{ player.p_nfl }}{{ player.p_val }}
> {{ player.ptot }}
>          {% endfor %}
>          
>     
> {% else %}
>     No players matched your search criteria.
> {% endif %}
>
> My questions are this,  when I just want a single field return for a
> custom method how do you form the return statement,  in my case I'm
> wanting what ever I alias the sum of s_total.   After which how does
> that value get successfully called from the html template.  All of it
> works but I never get a return value
>
> or is there an easier way to do this?  thanks in advance

Why do you need to turn it into a field at all? Why not just

return cursor.fetchone()[0]

which will return the first (only) field in the returned data, which
can be used directly in your template.

Also note that you can probably avoid all this by using version 1.1's
new aggregation features, since all you want is the total of
score.s_total for a relevant Player. As long as you have a ForeignKey
from the Score model to Player, you could just do this in your view:

from django.db.models import Sum
players = Player.objects.filter(p_uffl__icontains=q).annotate
(ptot=Sum('score__stotal'))

This generates the ptot values for every player in one go, which is
much more efficient as well as neater.

(And please, consider using better field names - unless this is a
legacy database, there's no reason to prefix them with the table
initial, and no reason not to give them properly descriptive names.)
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Trying to get tinyMCE working on an admin page

2009-09-08 Thread DrKen

Hi, new to Django and tinyMCE. I'm trying to get the tinyMCE HTML
editor working on the admin page, so started out by doing the Django
tutorial, then attempting to modify. I've got the admin page working
with text fields instead of character fields, but don't see any change
whatsoever when I convert the fields to HTMLField() - my html content
appears as straight text, no syntax highlighting etc. I've googled all
over for suggestions and tried several dozen, but something is still
not happening. According to what I've been reading, this should bring
up an HTML editor on all of the (one) text fields. Suggestions
appreciated.

my models.py:
===
from django.db import models
from tinymce import models as tinymce_models

# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __unicode__(self):
return u'poll: ' + self.question

class Meta:
pass
class Admin:
js = ['tiny_mce/tiny_mce.js', 'tiny_mce/textareas.js']

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = tinymce_models.HTMLField()
#choice = models.TextField()
votes = models.IntegerField()
def __unicode__(self):
return u'choice ' + self.choice

class Meta:
pass
class Admin:
js = ['tiny_mce/tiny_mce.js', 'tiny_mce/textareas.js']

my admin,py
==
from tinymce_test.mice.models import Poll
from tinymce_test.mice.models import Choice
from django.contrib import admin

class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3
class Media:
js = ('/media/admin/tiny_mce/tiny_mce.js', '/media/admin/tiny_mce/
textareas.js')

class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None,   {'fields': ['question']}),
('Date information', {'fields': ['pub_date'], 'classes':
['collapse']}),
]
inlines = [ChoiceInline]
class Media:
js = ('/media/admin/tiny_mce/tiny_mce.js', '/media/admin/tiny_mce/
textareas.js')

admin.site.register(Poll, PollAdmin)


settings.py

# Django settings for tinymce_test project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2'   #
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'tinymce' # Or path to database file if
using sqlite3.
DATABASE_USER = 'postgres' # Not used with sqlite3.
DATABASE_PASSWORD = 'postgres' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
#TIME_ZONE = 'America/Chicago'
TIME_ZONE = 'America/New_York'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = 'c:/a4m/django/tinymice_test/media'

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/admin/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'y8z32erg0clu*9goo=m-_kn3+l_ec+0r-97_kh+=0(w5dzzv+('

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'tinymce_test.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# D

Re: custom methods

2009-09-08 Thread Angel Cruz
I think it is just my vision problems, but I can't find where you are
calling the method 'ptot' in your view.

to debug, I would add this in my view (after instantiating with your line:
player = Player.objects.filter(p_uffl__icontains=q):
.
my_total=player.ptot # -- if I was debugging in an IDE, I would put a
breakpoint here and step over and then check the value ##
.
.
return render_to_response('search_results.html',
   {'player': player, 'query':q, 'my_total':my_total})

and in your template, just for debug add:
 Here is my total: {{my_total}}


On Tue, Sep 8, 2009 at 11:29 AM, Slammer  wrote:

>
> FYI, I'm a beginner,  I'm having trouble with custom methods,  I'm
> using an existing database which is used for a fantasy football
> site,   the primary data return is a list of players for a particular
> team, I've done that fine, but the score for those players is in a
> different table,  So to return the list of players with their current
> scores I tried to create a custom method as such in my models.py
>
> class Player(models.Model):
>p_keyid = models.IntegerField(primary_key=True)
>p_lname = models.CharField(max_length=135)
>#bla bla bla more fieldnames
>...
>
>
>def ptot(self):
>from django.db import connection
>cursor = connection.cursor()
>cursor.execute("""
>SELECT sum(s_total) s_total from score where s_pno =
> %s""", [self.p_keyid])
>#return [row[0] for row in cursor.fetchone()]
>#return [self.__class__(*row) for row in cursor.fetchone()]
>return u'S=%s' % (self.__class(*row).s_total)
>
> As you can see I've tried a bunch of ways to return the related score
> total, none have worked.
>
> in my views.py I have
> def search_roster(request):
>if 'q' in request.GET and request.GET['q']:
>q = request.GET['q']
>player = Player.objects.filter(p_uffl__icontains=q)
>return render_to_response('search_results.html',
>{'player': player, 'query':q})
>else:
>return render_to_response('search_form.html',
> {'error': True})
>
> in my search_results.html I have
> Team Listing for: {{ query }}
> {% if player %}
>Found {{ player|length }} player{{ player|pluralize }}.
>
> 
> PosName
> NFLValue
> Score
> {% for player in player %}
> {{ player.p_pos }}{{ player.p_lname }}
> {{ player.p_nfl }}{{ player.p_val }}
> {{ player.ptot }}
> {% endfor %}
> 
>
> {% else %}
>No players matched your search criteria.
> {% endif %}
>
> My questions are this,  when I just want a single field return for a
> custom method how do you form the return statement,  in my case I'm
> wanting what ever I alias the sum of s_total.   After which how does
> that value get successfully called from the html template.  All of it
> works but I never get a return value
>
> or is there an easier way to do this?  thanks in advance
>
>
> >
>

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



Open Position: Software/System Engineer....Django...

2009-09-08 Thread James

Hello All
I do not know if this is the correct forum.  I am looking for a
Software/System Engineer with Django experience in the Cleveland, OH
area.  The skill set looks like this:
•   Expertise in M/S Windows, Red Hat Linux Operating Systems, MySQL
database development and Apache server setup.
•   Expertise in Languages:  Python
•   Knowledge of the Django framework and working in a web development
environment.

Interested individuals can submit resumes to employm...@globalww.com.

If this is not the place for this type of posting, if someone could
suggest an area, I would appreciate the guidance.
Thanks
James

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



Re: Having Trouble with Reverse method

2009-09-08 Thread Ulysses Almeida

Hi there,

On Tue, 8 Sep 2009 10:49:30 -0700 (PDT), Streamweaver
 wrote:
> 
> I'm having trouble understanding the output of the reverse method.
> 
> I have the following URL pattern:
> 
> urlpatterns = patterns('dwrangler.project.views',
> (r'^in_development/$', 'summary_in_development'),
> )
> 
[cut]

 I may be wrong, but I think you need to use 'url' method on urlpatterns
declaration:
 urlpatterns = patterns('dwrangler.project.views',
 url(r'^in_development/$', 'summary_in_development'),
 )


-- 
Ulysses Almeida
Analista Judiciário - Análise de Sistemas
Secretaria de Tecnologia da Informação - COINF - TRE-MS
ulysses.alme...@tre-ms.gov.br


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



Re: Sourcing java script file inside django

2009-09-08 Thread Ulysses Almeida

Hi,
On Tue, 8 Sep 2009 10:59:11 -0700 (PDT), Hrishikesh Dhayagude
 wrote:
> 
> Hi,
[cut]
> If i want to source abc.js then
>  
[cut]
> So do i need to include any action to be performed on that particular
> url in url.py??
  Yes, this abc.js is a static file. You should setup your django do serve
static files. 
  Read http://docs.djangoproject.com/en/dev/howto/static-files/ for a full
explanation. If stay in doubts after reading, let us know.

[cut]
 
  Best regards.

-- 
Ulysses Almeida
Analista Judiciário - Análise de Sistemas
Secretaria de Tecnologia da Informação - COINF - TRE-MS
ulysses.alme...@tre-ms.gov.br


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



custom methods

2009-09-08 Thread Slammer

FYI, I'm a beginner,  I'm having trouble with custom methods,  I'm
using an existing database which is used for a fantasy football
site,   the primary data return is a list of players for a particular
team, I've done that fine, but the score for those players is in a
different table,  So to return the list of players with their current
scores I tried to create a custom method as such in my models.py

class Player(models.Model):
p_keyid = models.IntegerField(primary_key=True)
p_lname = models.CharField(max_length=135)
#bla bla bla more fieldnames
...


def ptot(self):
from django.db import connection
cursor = connection.cursor()
cursor.execute("""
SELECT sum(s_total) s_total from score where s_pno =
%s""", [self.p_keyid])
#return [row[0] for row in cursor.fetchone()]
#return [self.__class__(*row) for row in cursor.fetchone()]
return u'S=%s' % (self.__class(*row).s_total)

As you can see I've tried a bunch of ways to return the related score
total, none have worked.

in my views.py I have
def search_roster(request):
if 'q' in request.GET and request.GET['q']:
q = request.GET['q']
player = Player.objects.filter(p_uffl__icontains=q)
return render_to_response('search_results.html',
{'player': player, 'query':q})
else:
return render_to_response('search_form.html',
{'error': True})

in my search_results.html I have
Team Listing for: {{ query }}
{% if player %}
Found {{ player|length }} player{{ player|pluralize }}.

 
 PosName
 NFLValue
 Score
 {% for player in player %}
 {{ player.p_pos }}{{ player.p_lname }}
 {{ player.p_nfl }}{{ player.p_val }}
{{ player.ptot }}
 {% endfor %}
 

{% else %}
No players matched your search criteria.
{% endif %}

My questions are this,  when I just want a single field return for a
custom method how do you form the return statement,  in my case I'm
wanting what ever I alias the sum of s_total.   After which how does
that value get successfully called from the html template.  All of it
works but I never get a return value

or is there an easier way to do this?  thanks in advance


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



Re: Sourcing java script file inside django

2009-09-08 Thread cootetom

Hi, django doesn't deal with static files. Your web server must serve
static files. You can read about how to use static files whilst in
development in the documentation 
http://docs.djangoproject.com/en/dev/howto/static-files/




On Sep 8, 6:59 pm, Hrishikesh Dhayagude
 wrote:
> Hi,
> I've recently started using django. I want to source a java script
> file inside django. For that, only specifying it in script tag is
> sufficient or do we need to write anything more.
> If i want to source abc.js then
>  
> I tried doing that but was unsuccessful
> When i click view page source info after right clicking..  this abc.js
> is seen as a link
> When i click on it then its source code should be seen but what i get
> is an error saying the url doesn't match any of those in urls.py.
> So do i need to include any action to be performed on that particular
> url in url.py??
> Thank you in advance..
>
> Regards,
> Hrishikesh Dhayagude
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



total newb question with custom save()

2009-09-08 Thread Matt

hey folks,

I have two models:
___
class contentcreator(models.Model):
name = models.CharField(max_length=50)
phone = models.CharField(max_length=60, blank=True)
supervisor = models.CharField(max_length=60)
department = models.CharField(max_length=60, blank=True)
def __unicode__(self):
return self.name

class Meta:
verbose_name = u'Content Creator'
verbose_name_plural = u'Content Creators'

class accuracyreport(models.Model):
byline = models.ForeignKey(contentcreator, related_name="byline")
date = models.DateField()
resolved = models.BooleanField("Resolved?", help_text="Has the
issue been resolved?", null=True)
responsible = models.ForeignKey(contentcreator,
related_name="ultimately_responsible", blank=True, null=True)
supervisor = models.CharField(max_length=60, editable=False)

def save(self):
if not self.responsible:
self.supervisor = contentcreator.objects.get
(name__exact=self.byline).supervisor
else:
self.supervisor = contentcreator.objects.get
(name__exact=self.responsible).supervisor
super(accuracyreport, self).save()
___

The custom save(), as you can probably tell, is where I'm having
trouble.

I'd like to set things so that when the "responsible" field is blank,
the supervisor of the byline gets saved in the accuracyreport model.
If it's filled in, then the supervisor of "responsible" gets filled
in.

I'm aware of the denormalization issues, but I think it's the best way
to handle this particular problem.

Help?


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



Re: Having Trouble with Reverse method

2009-09-08 Thread Joshua Russo
On Tue, Sep 8, 2009 at 4:49 PM, Streamweaver  wrote:

>
> I'm having trouble understanding the output of the reverse method.
>
> I have the following URL pattern:
>
> urlpatterns = patterns('dwrangler.project.views',
>(r'^in_development/$', 'summary_in_development'),
> )
>
> from the documentation I would think I can get the URL by using
>
> reverse('dwrangler.project.views.summary_in_development')
>
> But I keep getting a NoReverseMatch error.  I have tried several
> different formats but keep getting similar errors.
>
> I must be missing something obvious and would be thankful if something
> could point me in the right direction.


All you need is:
reverse('summary_in_development')

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



Re: formatting dates for DateTimeField()

2009-09-08 Thread BJ Swope

On Tue, Sep 8, 2009 at 10:49 AM, Gonzalo wrote:
>
> Hi Daniel, thanks for your reply apologies for the muddled question.
>
> What I need to do is the following:
>
> I receive a piece of data from the serial port, determine node and
> timestamp it.
> then when I receive the next piece of date form the same node I
> timestamp it and determine the time difference form the previous
> reading.
>
> Before using Django I was timestamping data with:
>
> time_start = time.strftime( '%Y-%m-%d %H:%M:%S' )
>
> and computing time difference with:
>
> time_difference = int( time.mktime( time_end ) - time.mktime
> ( time_start ) )
>
> that didn't work with django because of the format required by
> DateTimeField()
>
> now I'm doing:
>
 time_start = datetime.datetime.now()
 time_start
> datetime.datetime(2009, 9, 8, 15, 46, 9, 544688)
 time_end = datetime.datetime.now()
 time_end
> datetime.datetime(2009, 9, 8, 15, 46, 32, 353081)
 time_diff = time_start - time_end
 time_diff
> datetime.timedelta(-1, 86377, 191607)
 print int(time_diff)
> Traceback (most recent call last):
>  File "", line 1, in 
> TypeError: int() argument must be a string or a number, not
> 'datetime.timedelta'
>
> how would you compute the time_diff between the two  datetime.datetime
> objects?
>
> Thank you,
>
> On Sep 8, 11:18 am, Daniel Roseman  wrote:
>> On Sep 8, 10:26 am, Gonzillaaa  wrote:
>>
>> > Hello I'm importing data into django and using its admin interface to
>> > browse and search for data.
>>
>> > Each piece of data is timestamped by me at log time. The docs say data
>> > on a DateTimeField() should be a valid datetime.datetime object but I
>> > am unclear of format (tuple, string etc..)
>>
>> Your question doesn't make sense. As you say, the docs say it should
>> be a datetime.datetime object. What does format have to do with it?
>>
>> >        data = InfrarredTimes( loc_id = loc, node_id = node_id, pin_id
>> > = pin_id, \
>> >                                time_start = time.strftime( '%Y-%m-%d
>> > %H:%M:%S', time_start ), \
>> >                                time_end = time.strftime( '%Y-%m-%d %H:
>> > %M:%S', time_end ), \
>> >                                time_difference = time_difference )
>> >        data.save()
>> >        return True
>>
>> > this is not working at the moment. any pointers much appreciated.
>>
>> But you've ignored the bit that you quoted above! Why are you using
>> time instead of datetime? Why are you converting the time into a
>> string instead of a datetime object?
>>
>> time_start = datetime.datetime(2009, 9, 8, 11, 15)
>> --
>> DR.

Stop calling int on the return value


>>> import datetime
>>> time_start = datetime.datetime.now()
>>> time_end = datetime.datetime.now()
>>> time_diff = time_end - time_start
>>> time_diff
datetime.timedelta(0, 9, 126708)
>>> print time_diff
0:00:09.126708


-- 
We are all slave to our own paradigm. -- Joshua Williams

If the letters PhD appear after a person's name, that person will
remain outdoors even after it's started raining. -- Jeff Kay

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



Unicode [i]regex + sqlite3

2009-09-08 Thread matevzb

I've run into a strange problem using Django's [i]regex search with
non-ascii characters.
I'm using the [i]regex in the following manner:
 begin code 
class Tag(models.Model):
  def __unicode__(self):
return self.keyword
  keyword = models.CharField(max_length=64)

kwlist = [some list of keywords]
tag_query = Q()
for k in kwlist:
  rx = r'\b' + k + r'\b'
  tag_query = tag_query | Q(keyword__iregex=rx)  # or keyword__regex,
neither works

for t in Tag.objects.filter(tag_query):
  print t
 end code 

When a Tag's keyword *begins* with a non-ascii character (e.g. in my
case \u010d, which
is "latin small letter c with caron"), the [i]regex lookup fails for
some reason.
The strange thing is that there seem to be no problems with words
containing such characters
elsewhere, i.e. not at the beginning of a string. I've also tried the
following:
- Q(keyword__iexact), works OK
- modified regex: r'\b.*' + k[1:] + r'\b' works OK, but obviously may
return many false positives
- modified regex: r'\b.' + k[1:] + r'\b' doesn't work(?)
- python's re.search() works OK on such strings

Is this a known issue with Django + sqlite3 combination? I've seen the
docs mention that
iexact might be problematic, but that one actually works fine.

I'm using Django 1.0.2 with sqlite3 3.4.0 and python 2.5.1 (Mac OS X
10.5).

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



Re: Editors of choice

2009-09-08 Thread Dj Gilcrease

On Mon, Sep 7, 2009 at 9:55 AM, Samuel Hopkins  wrote:
> Hello Django peeps,
>
> I am a Django newbee. I have had my eye on Djanjo for a year or so now but
> held off because I had limited python experience. However, after a summer of
> python and watching Django's popularity snowball, I think I am ready to go
> :)
>
> Anyhow, the purpose of this email was just to ask the community what
> editor(s) they preferred to use with Django.


I used TextPad for years, with no syntax highlighting. I now use
Wingware, and since I work primarily on OpenSource Projects the Pro
version is free.

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



Sourcing java script file inside django

2009-09-08 Thread Hrishikesh Dhayagude

Hi,
I've recently started using django. I want to source a java script
file inside django. For that, only specifying it in script tag is
sufficient or do we need to write anything more.
If i want to source abc.js then
 
I tried doing that but was unsuccessful
When i click view page source info after right clicking..  this abc.js
is seen as a link
When i click on it then its source code should be seen but what i get
is an error saying the url doesn't match any of those in urls.py.
So do i need to include any action to be performed on that particular
url in url.py??
Thank you in advance..

Regards,
Hrishikesh Dhayagude


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



Re: Editors of choice

2009-09-08 Thread Brian Jones
I use Komodo Edit (free), and am thinking of perhaps getting Komodo IDE
($$$). I kinda wish Wingware ($$$) would make their IDE work on OS X without
an X server :-/

When I'm not using Komodo, I use Vim, and Komodo has Vi key bindings for
most basic operations. I'd try emacs, but Vi found me first, and I can only
store so many arbitrary, inane keystroke shortcuts in my brain ;-P

brian

On Tue, Sep 8, 2009 at 1:10 PM, Jeff Gentry wrote:

>
> On Mon, Sep 7, 2009 at 2:55 PM, Samuel Hopkins  >wrote:
> > Anyhow, the purpose of this email was just to ask the community what
> > editor(s) they preferred to use with Django.
>
> Emacs
>
>
> >
>


-- 
Brian K. Jones
Python Magazine  http://www.pythonmagazine.com
My Blog  http://www.protocolostomy.com

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



Having Trouble with Reverse method

2009-09-08 Thread Streamweaver

I'm having trouble understanding the output of the reverse method.

I have the following URL pattern:

urlpatterns = patterns('dwrangler.project.views',
(r'^in_development/$', 'summary_in_development'),
)

from the documentation I would think I can get the URL by using

reverse('dwrangler.project.views.summary_in_development')

But I keep getting a NoReverseMatch error.  I have tried several
different formats but keep getting similar errors.

I must be missing something obvious and would be thankful if something
could point me in the right direction.

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



Managers in admin

2009-09-08 Thread Alasdair

I've defined a custom manager

class Entry(models.Model):
[...]
live = LiveEntryManager()
objects = models.Manager()

so that when I use _default_manager.all() it uses the LiveEntryManager
().

However, the django admin is now also using LiveEntryManager. How can
I get the admin to use models.Manager, while keeping LiveEntryManager
as the default for everything else?

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



Re: Editors of choice

2009-09-08 Thread Jeff Gentry

On Mon, Sep 7, 2009 at 2:55 PM, Samuel Hopkins wrote:
> Anyhow, the purpose of this email was just to ask the community what
> editor(s) they preferred to use with Django.

Emacs


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



Re: Django settings function object?

2009-09-08 Thread Maksymus007

On Tue, Sep 8, 2009 at 5:55 PM, Masklinn wrote:
>
> On 8 Sep 2009, at 14:00 , Maksymus007 wrote:
> I tried following code
>>
>> from django.conf import settings
>>
>> ...
>>
>>
>> a = setting.MY_OWN_VARIABLE=2
> You probably shouldn't set settings variables at runtime. And by
> "probably" I mean "really". Use getattr instead if you need "default
> value in case the setting isn't defined".
>

heh, that was just a copypasta from source.
Real problem was simple - i had a view named settings(request) which
made a collision.

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



Re: Django settings function object?

2009-09-08 Thread Masklinn

On 8 Sep 2009, at 14:00 , Maksymus007 wrote:
I tried following code
>
> from django.conf import settings
>
> ...
>
>
> a = setting.MY_OWN_VARIABLE=2
You probably shouldn't set settings variables at runtime. And by  
"probably" I mean "really". Use getattr instead if you need "default  
value in case the setting isn't defined".

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



Re: Django settings function object?

2009-09-08 Thread Bill Freeman
On Tue, Sep 8, 2009 at 8:00 AM, Maksymus007  wrote:

>
> I tried following code
>
> from django.conf import settings
>
> ...
>
>
> a = setting.MY_OWN_VARIABLE=2
>

If that's really what you have, try, instead:

a = settings.My_OWN_VARIABLE=2

(note the "s" on the end of "settings".)

Bill

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



Re: Deployment on same server: Conflict staging/production

2009-09-08 Thread Benjamin Buch


Hi Mike,

that actually helped!

Putting the staging project folder in a folder of its own
and changing server relevant settings did the trick.

-benjamin

Am 08.09.2009 um 15:29 schrieb Mike Ramirez:

> I do something similar one site, but both have parent directory that  
> holds
> misc data and the project dir, example:
>
> staging/
>   apache/
>   apache scripts and custom conf files specific to this deployment
>   myproject/
>   ...
>   misc_stuff/
>   scripts specific to this deployment
> live/
>   apache/
>   scripts and custom conf files specific to this deployment
>   myproject/
>   ...
>   misc_stuff/
>   scripts specific to this deployment
>
> Both are checked out from the same svn (instead of git) repo.   
> Staging of
> course is where I edit and make changes to the code for live and  
> commits are
> from stage. While live is a read only checkout.
>

> Hope this helps,
>
> Mike


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



♀♂@@@@@Nike dunk high shoes wholesale\retail

2009-09-08 Thread 13 3

♀♂@Nike dunk high shoes wholesale\retail

Our company mainly deal with the import and export of the brand sports
shoes, clothes, jewelry, bags , glasses, etc . Products such as Nike
Jordan sell well in America , Canada , as well as Europe and other
countries. Our objective is to supply products of first-class quality
and advanced technology. Customers satisfaction is our greatest
pursuit. We thank you for your attention and wish having a long time
business relationship with all buyers from all over the .
world
we take PAYPAL as the method of payment!
please kindly visite our website: http://www.ccshoe.com
msn: ccshoe2...@hotmail.com
email: wcl020...@gmail.com

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



Re: multi-table inheritance - how to access child object methods/attributes

2009-09-08 Thread Manfre

This digs through _meta to figure any related fields and tries each
until one works.

class Document(models.Model):
...

def __unicode__(self):
name_map = self._meta._name_map

subs = [x for x in name_map if isinstance(name_map[x][0],
RelatedObject)]

for field in subs:
try:
sub = getattr(self, field, None)
return sub.__unicode__()
except ObjectDoesNotExist:
pass

return u'Document {0}'.format(self.id)

On Sep 8, 9:01 am, Jan Ostrochovsky 
wrote:
> Ugly workaround:
>
> class Document(models.Model):
>         pass
>         def __unicode__(self):
>                 if self.accountingdocument:
>                         return self.accountingdocument.__unicode__()
>                 else:
>                         return self.__class__.__name_ + ' ' + self.id_
>
> But I'd prefer solution, where Document class does not know about its
> child classes (AccountingDocument, etc.). Any idea?
>
> On Sep 8, 8:31 am, Jan Ostrochovsky 
> wrote:
>
> > Hello,
>
> > class Document(models.Model):
> >   ...
>
> > class AccountingDocument(Document):
> >   ...
>
> > How am I able to access methods an attributes of some
> > AccountingDocument instance (e.g. its __unicode__()) from Document
> > instance? How am I able to retrieve child object from its parent?
>
> > I tried to search on the web, but I am not a lot wiser after that...
>
> > Thanks in advance.
>
> > Jano

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



Re: formatting dates for DateTimeField()

2009-09-08 Thread Gonzalo

Hi Daniel, thanks for your reply apologies for the muddled question.

What I need to do is the following:

I receive a piece of data from the serial port, determine node and
timestamp it.
then when I receive the next piece of date form the same node I
timestamp it and determine the time difference form the previous
reading.

Before using Django I was timestamping data with:

time_start = time.strftime( '%Y-%m-%d %H:%M:%S' )

and computing time difference with:

time_difference = int( time.mktime( time_end ) - time.mktime
( time_start ) )

that didn't work with django because of the format required by
DateTimeField()

now I'm doing:

>>> time_start = datetime.datetime.now()
>>> time_start
datetime.datetime(2009, 9, 8, 15, 46, 9, 544688)
>>> time_end = datetime.datetime.now()
>>> time_end
datetime.datetime(2009, 9, 8, 15, 46, 32, 353081)
>>> time_diff = time_start - time_end
>>> time_diff
datetime.timedelta(-1, 86377, 191607)
>>> print int(time_diff)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: int() argument must be a string or a number, not
'datetime.timedelta'

how would you compute the time_diff between the two  datetime.datetime
objects?

Thank you,

On Sep 8, 11:18 am, Daniel Roseman  wrote:
> On Sep 8, 10:26 am, Gonzillaaa  wrote:
>
> > Hello I'm importing data into django and using its admin interface to
> > browse and search for data.
>
> > Each piece of data is timestamped by me at log time. The docs say data
> > on a DateTimeField() should be a valid datetime.datetime object but I
> > am unclear of format (tuple, string etc..)
>
> Your question doesn't make sense. As you say, the docs say it should
> be a datetime.datetime object. What does format have to do with it?
>
> >        data = InfrarredTimes( loc_id = loc, node_id = node_id, pin_id
> > = pin_id, \
> >                                time_start = time.strftime( '%Y-%m-%d
> > %H:%M:%S', time_start ), \
> >                                time_end = time.strftime( '%Y-%m-%d %H:
> > %M:%S', time_end ), \
> >                                time_difference = time_difference )
> >        data.save()
> >        return True
>
> > this is not working at the moment. any pointers much appreciated.
>
> But you've ignored the bit that you quoted above! Why are you using
> time instead of datetime? Why are you converting the time into a
> string instead of a datetime object?
>
> time_start = datetime.datetime(2009, 9, 8, 11, 15)
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: automatic initialization of sample data

2009-09-08 Thread Bill Freeman
Jan,

Well, do you want this to happen every time that the module is imported?  Or
spend time
each server start determining that these items are already in the data base
and skipping
the initialization?  If not, then you're stuck telling the system when to do
this anyway (perhaps
a syncdb extension that does them if it has to create the database?).

You do realize that having initializers as default arguments, that they
consume virtual memory
forever, whether the database is already loaded or not.  That isn't
significant for loading 3 rows,
as in your example, but I presume that you're actually loading a much larger
set.

I typically have a CSV file, or a pickle of a list of dictionaries, and use
csv.DictReader or cpickle.load
in a loop that creates a model instance, populates such fields as have keys
in the source, and saves
the instance.  I think that it's less work than figuring out how to
configure some extension, and if you
let it be driven by the keys present, the code is pretty generic (at least
for the pickle; with the CSB
you typically want to convert some strings to ints, floats, and bools.  You
can also use XML, but I find
it more complicated, though attributes could control conversions.)

I've taken to putting that code in a separate load.py file, so that even the
code isn't loaded in the
server.  You could also just hand code a list of dictionaries in such a
file.  I still wind up running the
code from the manage shell, though you could certainly create, for example,
a view that imports the
load.py only if the view is referenced (by someone with enough privelege),
and runs the code.  Or
you could figure out how to attach it to syncdb.

But you should probably look at fixtures.  I haven't, as yet, but should.
They seem to be a supported
means of initializing a database.

Bill

On Mon, Sep 7, 2009 at 4:43 AM, Jan Ostrochovsky  wrote:

>
> Thanks Bill, yes, that is one possible solution, when implementing
> such feature from the scratch.
>
> I am only asking, if there is some existing framework for such need,
> which I see as common.
>
> For example some add-on to Django, which will do this for me. Let's
> imagine additional option for any field of Django model, e.g.:
>
> class Person(models.Model):
>  firstname = models.CharField(max_length=30, initial_values="John,
> Bill, Peter")
>  lastname = models.CharField(max_length=70, initial_values="Smith,
> Clinton, Parker")
>  ...
>
> Django with such add-on could be able to build initial database from
> these values, for example when running syncdb or other way.
>
> Am I more readable now?
>
> Jano
>
> On Aug 20, 10:09 pm, Bill Freeman  wrote:
> > Perhaps I'm not understanding correctly, but how about, assuming you have
> a
> > function
> > run_data_inits() that calls your chain of init_sample_data() functions:
> >
> > $ python manage.py shell
> >
> > >>> import myproject.myapp.models as m
> > >>> m.run_data_inits()
> > >>> ^D
> >
> > Bill
> >
> > On Thu, Aug 20, 2009 at 9:25 AM, Jan Ostrochovsky <
> >
> > jan.ostrochov...@gmail.com> wrote:
> >
> > > Hello,
> >
> > > we are in the initial phase of software project, and data model and
> > > names of attributes are changing very often, and very often we need to
> > > create new database and fill it with the same sample data for testing.
> > > We want to automate this creation of sample data.
> >
> > > Our idea: add into each models.py method e.g. init_sample_data() to
> > > each model class, and put sample data there (with well handled
> > > dependencies - ForeignKey, etc.) and each time we change model, we
> > > will aslo change concerned init_samle_data(). We will run these
> > > chained init_sample_data() for each class in the script.
> >
> > > The question is: is there some existing solution for this (in Django
> > > or its extensions), which we can use, and not reinvent it, or not? Any
> > > idea?
> >
> > > (We are using Django Evolution, which is good help, but only when
> > > changes are not too dramatic.)
> >
> > > Thanks in advance.
> >
> > > Jan Ostrochovsky
> >
>

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



Re: apache2+mod_wsgi: 403 Forbidden

2009-09-08 Thread Matias
sorry, I messed up!

I'm not sure now, i couldn't test it, but maybe you should set the Directory
directive in the specific path where wsgi files are


   Order Allow,Deny
   Deny from all


   Order Allow,Deny
   Allow from all


Regards,
Matias.

On Tue, Sep 8, 2009 at 11:04 AM, Matias  wrote:

> You should use Directory with the real path, not the alias
>
> 
>Order Allow,Deny
>Deny from all
> 
> 
>Order Allow,Deny
>Allow from all
> 
>
> like in the example :)
>
> Regards,
> Matias.
>
> On Mon, Sep 7, 2009 at 5:56 PM, Léon Dignòn  wrote:
>
>>
>> No, I have it here, but forgot to post it:
>>
>> 
>>Order Allow,Deny
>>Deny from all
>> 
>> 
>>Order Allow,Deny
>>Allow from all
>> 
>>
>> On Sep 7, 10:11 pm, Matias  wrote:
>> > I think you missed the allow directive in your apache conf.
>> >
>> > Example from [1]
>> >
>> > Alias /media/ /usr/local/django/mysite/media/
>> >
>> > 
>> > Order deny,allow
>> > Allow from all
>> > 
>> >
>> > WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
>> >
>> > 
>> > Order deny,allow
>> > Allow from all
>> > 
>> >
>> > [1]http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>> >
>> > HTH,
>> > Matias.
>> >
>> >
>> >
>> >
>> >
>> > On Mon, Sep 7, 2009 at 2:55 PM, Léon Dignòn 
>> wrote:
>> >
>> > > I get a 403 forbidden.
>> >
>> > > I serve Django with apache2+mod_wsgi. I disabled some plugins I think
>> > > I don't need. Set the listen port to 8000 on localhost only. Later I
>> > > will serve django through reverse proxy on cherokee webserver. But for
>> > > now, localhost:8000 is returning a 403 forbidden error.
>> >
>> > > Any ideas?
>> >
>> > > # error.log
>> > >[Mon Sep 07 17:14:59 2009] [error] [client 127.0.0.1] client
>> > > denied by server configuration: /htdocs
>> >
>> > > lwp-request -m GET -Sedhttp://127.0.0.1:8000/
>> > > lwp-request  -m GET -Sed
>> > >http://beispiel.de:8000/
>> > >GEThttp://127.0.0.1:8000/--> 403 Forbidden
>> > >Connection: close
>> > >Date: Mon, 07 Sep 2009 14:56:32 GMT
>> > >Server: Apache
>> > >Content-Length: 202
>> > >Content-Type: text/html; charset=iso-8859-1
>> > >Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
>> > >Client-Peer: 127.0.0.1:8000
>> > >Client-Response-Num: 1
>> > >Title: 403 Forbidden
>> >
>> > > # /etc/apache2/ports.conf
>> > >NameVirtualHost 127.0.0.1:8000
>> > >Listen 127.0.0.1:8000
>> >
>> > > # /etc/apache2/sites-enabled/000-default
>> > >
>> > >ServerName localhost
>> > >ServerAdmin webmas...@localhost
>> > >
>> >
>> > > # /etc/apache2/sites-enabled/beispiel.de
>> > >
>> > >ServerNamewww.beispiel.de
>> > >ServerAlias beispiel.de
>> > >ServerAdmin daniel.nicc...@gmail.com
>> >
>> > >DocumentRoot /var/www/django/beispiel
>> >
>> > >Alias /robots.txt  /var/www/django/beispiel/media/
>> > > robots.txt
>> > >Alias /favicon.ico /var/www/django/beispiel/media/
>> > > favicon.ico
>> > >Alias /media/  /var/www/django/beispiel/media/
>> >
>> > >ErrorLog  "|/usr/sbin/rotatelogs /var/log/apache2/
>> > > beispiel.de/error_log.%Y-%m-%d 86400"
>> > >CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/
>> > > beispiel.de/access_log.%Y-%m-%d 86400" common
>> >
>> > >WSGIScriptAlias / /var/www/django/wsgi-scripts/
>> > > beispiel.wsgi
>> > >
>> >
>> > > # mods-enabled
>> > >alias.conf
>> > >alias.load
>> > >auth_digest.load
>> > >authn_file.load
>> > >authz_default.load
>> > >authz_groupfile.load
>> > >authz_host.load
>> > >authz_user.load
>> > >status.conf
>> > >status.load
>> > >wsgi.conf
>> > >wsgi.load
>> >
>> > --
>> > :wq- Hide quoted text -
>> >
>> > - Show quoted text -
>> >>
>>
>
>
> --
> :wq
>



-- 
:wq

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



haml + sass + django

2009-09-08 Thread ThinRhino

Hello,

I just came across haml and sass, but looks like it is built for Ruby on 
Rails.

Any implementation that can work on Django?

Though I also came across http://bit.ly/3el7iR, by which apache can take 
care of converting haml to html.

Was looking for something where django can take care of the nitty-gritties

Cheers
ThinRhino

-- 
Ships are safe in the harbour
But that is not what ships are built for


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



Re: psycopg2.OperationalError: FATAL: role "root" does not exist

2009-09-08 Thread Angel Cruz
That is another forum and postgresql question, and they provide fantastic
documentation:
http://www.postgresql.org/docs/8.1/static/sql-createrole.html

I use pd-Admin tool myself to totally control the database.
I would suggest think you make sure you are able to play around with the
database first creating tables, assigning values, etc.  (via psql or
pg-Admin) with the user you have created before dealing with django.
On Tue, Sep 8, 2009 at 12:03 AM, Jan Ostrochovsky <
jan.ostrochov...@gmail.com> wrote:

>
> How exactly did you put your database user? What is content of your
> pg_hba.conf?
> Maybe some parts of this could be helpful:
>
> http://sharpe-s-postgres.blogspot.com/2009/09/how-to-install-and-configure-postgresql.html/
>
> On Sep 7, 11:15 pm, Zico  wrote:
> > On Tue, Sep 8, 2009 at 3:06 AM, Angel Cruz 
> wrote:
> >
> > > You don't have a user account named 'root' in your database.  You
> should
> > > probably use another user besides root.  Change your settings.py file
> to
> > > the
> > > correct database user?
> >
> > Ok, if i put my database user "fixmystreet" .. which is the exact user..
> > then this error comes:
> >
> > *psycopg2.InternalError: current transaction is aborted, commands ignored
> > until end of transaction block*
> >
> > --
> > Best,
> > Zico
>  >
>

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



Link for new page

2009-09-08 Thread Ajits

Hi,
I am new in Django framework. I am trying to create a web application.
My questions are:

1: How can I go to next page when i submit the data in index page(log
in page)
2: How can I link a page with a text. so that when I click on the text
It will so the page I want.

Can any one give some tips (which may face silly issues while create
simple web application)

Please help me to for gaining knowledge about django framework.

many many thanks in advance 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: apache2+mod_wsgi: 403 Forbidden

2009-09-08 Thread Matias
You should use Directory with the real path, not the alias


   Order Allow,Deny
   Deny from all


   Order Allow,Deny
   Allow from all


like in the example :)

Regards,
Matias.
On Mon, Sep 7, 2009 at 5:56 PM, Léon Dignòn  wrote:

>
> No, I have it here, but forgot to post it:
>
> 
>Order Allow,Deny
>Deny from all
> 
> 
>Order Allow,Deny
>Allow from all
> 
>
> On Sep 7, 10:11 pm, Matias  wrote:
> > I think you missed the allow directive in your apache conf.
> >
> > Example from [1]
> >
> > Alias /media/ /usr/local/django/mysite/media/
> >
> > 
> > Order deny,allow
> > Allow from all
> > 
> >
> > WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
> >
> > 
> > Order deny,allow
> > Allow from all
> > 
> >
> > [1]http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
> >
> > HTH,
> > Matias.
> >
> >
> >
> >
> >
> > On Mon, Sep 7, 2009 at 2:55 PM, Léon Dignòn 
> wrote:
> >
> > > I get a 403 forbidden.
> >
> > > I serve Django with apache2+mod_wsgi. I disabled some plugins I think
> > > I don't need. Set the listen port to 8000 on localhost only. Later I
> > > will serve django through reverse proxy on cherokee webserver. But for
> > > now, localhost:8000 is returning a 403 forbidden error.
> >
> > > Any ideas?
> >
> > > # error.log
> > >[Mon Sep 07 17:14:59 2009] [error] [client 127.0.0.1] client
> > > denied by server configuration: /htdocs
> >
> > > lwp-request -m GET -Sedhttp://127.0.0.1:8000/
> > > lwp-request  -m GET -Sed
> > >http://beispiel.de:8000/
> > >GEThttp://127.0.0.1:8000/--> 403 Forbidden
> > >Connection: close
> > >Date: Mon, 07 Sep 2009 14:56:32 GMT
> > >Server: Apache
> > >Content-Length: 202
> > >Content-Type: text/html; charset=iso-8859-1
> > >Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
> > >Client-Peer: 127.0.0.1:8000
> > >Client-Response-Num: 1
> > >Title: 403 Forbidden
> >
> > > # /etc/apache2/ports.conf
> > >NameVirtualHost 127.0.0.1:8000
> > >Listen 127.0.0.1:8000
> >
> > > # /etc/apache2/sites-enabled/000-default
> > >
> > >ServerName localhost
> > >ServerAdmin webmas...@localhost
> > >
> >
> > > # /etc/apache2/sites-enabled/beispiel.de
> > >
> > >ServerNamewww.beispiel.de
> > >ServerAlias beispiel.de
> > >ServerAdmin daniel.nicc...@gmail.com
> >
> > >DocumentRoot /var/www/django/beispiel
> >
> > >Alias /robots.txt  /var/www/django/beispiel/media/
> > > robots.txt
> > >Alias /favicon.ico /var/www/django/beispiel/media/
> > > favicon.ico
> > >Alias /media/  /var/www/django/beispiel/media/
> >
> > >ErrorLog  "|/usr/sbin/rotatelogs /var/log/apache2/
> > > beispiel.de/error_log.%Y-%m-%d 86400"
> > >CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/
> > > beispiel.de/access_log.%Y-%m-%d 86400" common
> >
> > >WSGIScriptAlias / /var/www/django/wsgi-scripts/
> > > beispiel.wsgi
> > >
> >
> > > # mods-enabled
> > >alias.conf
> > >alias.load
> > >auth_digest.load
> > >authn_file.load
> > >authz_default.load
> > >authz_groupfile.load
> > >authz_host.load
> > >authz_user.load
> > >status.conf
> > >status.load
> > >wsgi.conf
> > >wsgi.load
> >
> > --
> > :wq- Hide quoted text -
> >
> > - Show quoted text -
> >
>


-- 
:wq

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



Re: Deployment on same server: Conflict staging/production

2009-09-08 Thread Mike Ramirez
On Tuesday 08 September 2009 05:47:32 Benjamin Buch wrote:
> Hi,
>
> I'm working on a small project
> trying to get used to the development/staging/production setup.
>
> I develop on my local machine,
> push to a git repo
> and pull from there to staging and then finally to production.
>
> My problem here is that the staging and the production projects are
> deployed on the same server.
> Thus, the project folders can't have the same names -
> the production folder is called say 'myproject', so the staging folder
> has to be called different, say 'myproject_staging'.
>
> Of course I run into conflicts here -
> many imports in my code plus settings.py (INSTALLED_APPS, ROOT_URLCONF)
> refer to 'myproject' - and not to 'myproject_staging'.
>
> How can I work around this?
> Is it time for me to have a look at virualenv?
>
> -benjamin
>
>


I do something similar one site, but both have parent directory that holds 
misc data and the project dir, example:

staging/
   apache/
apache scripts and custom conf files specific to this deployment
   myproject/
...
misc_stuff/
scripts specific to this deployment
live/
apache/
scripts and custom conf files specific to this deployment
myproject/
...
misc_stuff/
scripts specific to this deployment

Both are checked out from the same svn (instead of git) repo.  Staging of 
course is where I edit and make changes to the code for live and commits are 
from stage. While live is a read only checkout. 

For project settings, I use a settings.py and a local_settings.py file,  
local_settings.py is not in revision, as where settings.py is, and lives in my 
project directories. It holds deployment specific paths, required variables 
and info. settings.py holds info and variables that are constant across 
deployments (dev, qc/staging, live).

I've written up this the other day for a friend to learn to use 
local_setttings.py file with settings.py.  I apologize for spelling/grammar 
errors and lack of styling on the pre tags (where the code is), this is a 
problem in the middle of being fixed, rewriting this site from the ground up.  
My personal site does suffer for a lack of attention to it for a couple years.

http://gufymike.com/archives/detail/18/1/


With this setup I don't need to worry about much in terms of conflicted module 
names in the project, you just set the correct paths in your scripts that set 
the sys.path, media directories and so on.

Hope this helps,

Mike

-- 
Nothing in life is to be feared.  It is only to be understood.


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


Re: Editors of choice

2009-09-08 Thread Joshua Russo
On Mon, Sep 7, 2009 at 11:48 PM, Jim  wrote:

>
> On Sep 7, 7:30 pm, Joshua Russo  wrote:
>  > I then switched to just using Textpad with Python highlighting and
> pdb, (http://docs.python.org/library/pdb.html) for debugging. Once you
> get the
> > hang of pdb it's extremely powerful. It basically drops you right into
> the
> > code with a Python command line. If you don't yet have experience with
> the
> > Python command line I would highly recommend getting a feel for it.
>
> I must be doing something wrong.  I have never been able to get a
> sensible output from pdb.  Is there a web page with an illustration of
> using it with Django that you could recommend?


I had a little difficulty with the Python docs on this one too. As it turns
out it's really simple. Put the following line where ever you want a break
point.

import pdb; pdb.set_trace()

The Django dev server window will stop with a Python command line prompt
right there and you have access to all of the context the current code in
the application has. It's extremely handy for testing different variations
of a given line and that the context is what you expect.

Another function I use all the time at the Python command line is dir().
Pass any object or property into it and it will list the available
properties and methods. This in combination with pprint() that formats list
output in a tree view style. I usually import pprint like so from the
command line: from pprint import pprint as pp. Then you can do:
pp(dir(object)) or pp(dir(obect.property))

I hope this helps.

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



Re: multi-table inheritance - how to access child object methods/attributes

2009-09-08 Thread Jan Ostrochovsky

Ugly workaround:

class Document(models.Model):
pass
def __unicode__(self):
if self.accountingdocument:
return self.accountingdocument.__unicode__()
else:
return self.__class__.__name_ + ' ' + self.id_

But I'd prefer solution, where Document class does not know about its
child classes (AccountingDocument, etc.). Any idea?

On Sep 8, 8:31 am, Jan Ostrochovsky 
wrote:
> Hello,
>
> class Document(models.Model):
>   ...
>
> class AccountingDocument(Document):
>   ...
>
> How am I able to access methods an attributes of some
> AccountingDocument instance (e.g. its __unicode__()) from Document
> instance? How am I able to retrieve child object from its parent?
>
> I tried to search on the web, but I am not a lot wiser after that...
>
> Thanks in advance.
>
> Jano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Deployment on same server: Conflict staging/production

2009-09-08 Thread Benjamin Buch

Hi,

I'm working on a small project
trying to get used to the development/staging/production setup.

I develop on my local machine,
push to a git repo
and pull from there to staging and then finally to production.

My problem here is that the staging and the production projects are  
deployed on the same server.
Thus, the project folders can't have the same names -
the production folder is called say 'myproject', so the staging folder  
has to be called different, say 'myproject_staging'.

Of course I run into conflicts here -
many imports in my code plus settings.py (INSTALLED_APPS, ROOT_URLCONF)
refer to 'myproject' - and not to 'myproject_staging'.

How can I work around this?
Is it time for me to have a look at virualenv?

-benjamin


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



Using the login page AND RemoteUserMiddleware depending on user?

2009-09-08 Thread Adam Stein

Couldn't find anything regarding this.  All authentication schemes seem
to assume you are only doing it one way.

Using Django v1.1.  I need the Django admin to come thru the login page
as normal.  However, every other account is authenticated by an external
authentication source.

I can use RemoteUserMiddleware for the external authentication, but then
I can't log in as the Django admin (since RemoteUserMiddleware ALWAYS
gets the user name from REMOTE_USER).  Anybody deal with this before?
It's easy enough to subclass RemoteUserMiddleware, but how do I tell
when to use REMOTE_USER and when to use what user is already set to?

-- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


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



Re: Editors of choice

2009-09-08 Thread Brian McKeever

I recently learned vim, and I'm a ginormous fan of it for editing.
Although, I use pydev for difficult debugging.



On Sep 8, 5:37 am, Mike Ramirez  wrote:
> On Tuesday 08 September 2009 04:11:38 ThinRhino wrote:
>
> > Mike,
>
> > Does Eric4 support mercurial? I tried google, but did not find an answer.
>
> > ThinRhino
>
> ThinRhino,
>
> Unfortunately, no. Only SVN (with subversion and/or pysvn) and CVS.  The good
> news is that these utilize Eric4s VCS api and mercurial support can be added
> as a plugin, CVS support is through a plugin.
>
> Quick look through the docs pointed me to this file:
>
> http://die-
> offenbachs.homelinux.org/svn/eric4repository/eric4/trunk/VCS/VersionControl.py
>
> Which provides an ABC that you can subclass, check out thie CVS plugin for an
> overview.
>
> http://die-
> offenbachs.homelinux.org/svn/eric4pluginrepository/Vcs_CVS/trunk/PluginVcsCVS.py
>
> The actual docs in Eric4 are here, they are actually pydoc style html files.
>
> http://die-
> offenbachs.homelinux.org/svn/eric4repository/eric4/trunk/Documentation/Source/
>
> A quick search showed me this is the best and fastest way to learn how to add
> VCS plugin support for other systems.
>
> Hope this helps,
>
> Mike
>
> --
> Fortune: You will be attacked next Wednesday at 3:15 p.m. by six samurai
> sword wielding purple fish glued to Harley-Davidson motorcycles.
>
> Oh, and have a nice day!
>                 -- Bryce Nesbitt '84
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django settings function object?

2009-09-08 Thread Maksymus007

I tried following code

from django.conf import settings

...


a = setting.MY_OWN_VARIABLE=2

I get error

'function' object has no attribute 'MY_OWN_VARIABLE'

when I

print settings

it says its function object - instead of LazySettings object. I tried even

from django.conf import settings as something_that_cannot_make_collision

but result is the same.

Any idea why and how to fix?

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



Re: Editors of choice

2009-09-08 Thread Mike Ramirez
On Tuesday 08 September 2009 04:11:38 ThinRhino wrote:
> Mike,
>
> Does Eric4 support mercurial? I tried google, but did not find an answer.
>
> ThinRhino

ThinRhino,

Unfortunately, no. Only SVN (with subversion and/or pysvn) and CVS.  The good 
news is that these utilize Eric4s VCS api and mercurial support can be added 
as a plugin, CVS support is through a plugin.

Quick look through the docs pointed me to this file:

http://die-
offenbachs.homelinux.org/svn/eric4repository/eric4/trunk/VCS/VersionControl.py

Which provides an ABC that you can subclass, check out thie CVS plugin for an 
overview.

http://die-
offenbachs.homelinux.org/svn/eric4pluginrepository/Vcs_CVS/trunk/PluginVcsCVS.py

The actual docs in Eric4 are here, they are actually pydoc style html files. 

http://die-
offenbachs.homelinux.org/svn/eric4repository/eric4/trunk/Documentation/Source/


A quick search showed me this is the best and fastest way to learn how to add 
VCS plugin support for other systems.


Hope this helps,

Mike

-- 
Fortune: You will be attacked next Wednesday at 3:15 p.m. by six samurai
sword wielding purple fish glued to Harley-Davidson motorcycles.

Oh, and have a nice day!
-- Bryce Nesbitt '84


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


Re: Django, MySQL, unicode

2009-09-08 Thread Karen Tracey
On Mon, Sep 7, 2009 at 5:03 AM, Tracy Reed  wrote:

> I have a Django app which processes emails. It is often handed emails
> with unicode characters in them. My understanding is that Python and
> Django handle unicode just fine and somewhat transparently. I was,
> however, told that I need to set my database tables to UTF-8
> encoding. I have done this. Yet I still frequently get errors such as
> this when my app encounters unicode:
>
>
In some places here you are using the term 'unicode' where non-ASCII would
be more correct.  The emails your code is handed, for example, contain
non-ASCII characters.  These emails are not packaged as Python unicode
strings (they cannot be, if they are coming from outside Python), they are
bytestrings.  In order to successfully turn them into unicode objects the
correct encoding of the email bytestring must be known.  The exception you
include below shows Django attempting to convert an email bytestring into a
unicode object, assuming the bytestring is utf-8 encoded.  This is failing,
so apparently the email bytestring is using some other encoding.

Python/Django handling unicode "transparently" is a bit of an optimistic
hope.  Python has unicode support, and what Django attempts to do is take
bytestrings at boundary points and convert to and from unicode objects so
that your application code never has to deal with bytestrings but rather
always has unicode strings.  So Django will convert bytestrings from the
database and bytestrings from web clients and convert them to unicode before
handing them to your application code.  Similarly it will accept unicode
from your application and convert to bytestrings for sending outside the
boundary (back to the DB or out as a client response).

Django does not require, however, that your application only use unicode
strings -- you are free to hand Django functions bytestrings.  When given a
bytestring, though, Django has to make some assumption about what encoding
the bytestring is using.  The problem with bytestrings is that they do not
carry around with them any encoding information.  What Django does when
handed a bytestring is assume it utf-8 encoded.  If your application hands
Django a bytestring that is not utf-8 encoded, you'll get errors like the
one you include below.

Someone else responding on this thread mentioned BeautifulSoup fixing
problems like this.  My understanding (I don't have time to verify at the
moment) is BeautifulSoup either detects encoding by examining the bytes and
guessing what the proper encoding may be, or trying different encoding until
one works.  Django does not do this -- it simply assumes if your code hands
in a bytestring that it is utf-8 encoded.  Thus if you have non-utf8 encoded
bytestrings you are dealing with (as you apparently do) you will need to
convert them to unicode before handing them to Django.

That, of course, just pushes the problem back onto you, and you will have to
now figure out what encoding these things are using.  Perhaps someone on
this list can help with that, but you haven't provided enough information to
really help here.  All you have said is that your app is "handed emails".
All I can tell you about those emails, based on the traceback below, is that
they are bytestrings and they are not utf-8 encoded.  If you show some of
your code that is receiving the emails perhaps someone can provide more
guidance on how to transform the email bytestrings into unicode.



>  Traceback (most recent call last):
>
>   File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
> line 92, in get_response
> response = callback(request, *callback_args, **callback_kwargs)
>
>   File "/var/spool/filter/email_archive/store_emails/views.py", line 84, in
> mail_detail
> return render_to_response('mail_detail.html', {'mail': ourmail,
>


  File "/usr/lib/python2.4/site-packages/django/shortcuts/__init__.py", line
> 20, in render_to_response
> return HttpResponse(loader.render_to_string(*args, **kwargs),
> **httpresponse_kwargs)
>
>   [snip bunches of template context traceback]
>   File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line
> 831, in render
> return _render_value_in_context(output, context)
>
>   File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line
> 811, in _render_value_in_context
> value = force_unicode(value)
>
>   File "/usr/lib/python2.4/site-packages/django/utils/encoding.py", line
> 92, in force_unicode
> raise DjangoUnicodeDecodeError(s, *e.args)
>
>  DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in
>  position 1468: unexpected code byte. You passed in "\nGood
>  Day,\n\n\n\nWe offer a part time job on your computer.
>
> 
>
> There is a 0x92 in position 1468 just as the error says.
>
> Do I need to be doing a .encode('utf-8') before putting anything into
> the db? I cannot seem to get a clear answer on this. Some say no, some
> say yes. Do I need to do any decoding or anything on da

Re: Editors of choice

2009-09-08 Thread ThinRhino

On Monday 07 September 2009 10:42 PM, Mike Ramirez wrote:
>
> Depends on the mood and situation, I normally use kate or vi/vim for most
> programming tasks, but I've been delving into PyQt a lot lately and started
> using Eric4 and found Eric4 has a django plugin that is helpful and makes it a
> nice ide for both django and pyqt and sort of has become my editor of choice
> for programming with both libraries.
>
> Mike
>


Mike,

Does Eric4 support mercurial? I tried google, but did not find an answer.

ThinRhino

-- 
Ships are safe in the harbour
But that is not what ships are built for


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



Re: formatting dates for DateTimeField()

2009-09-08 Thread Daniel Roseman

On Sep 8, 10:26 am, Gonzillaaa  wrote:
> Hello I'm importing data into django and using its admin interface to
> browse and search for data.
>
> Each piece of data is timestamped by me at log time. The docs say data
> on a DateTimeField() should be a valid datetime.datetime object but I
> am unclear of format (tuple, string etc..)

Your question doesn't make sense. As you say, the docs say it should
be a datetime.datetime object. What does format have to do with it?

>        data = InfrarredTimes( loc_id = loc, node_id = node_id, pin_id
> = pin_id, \
>                                time_start = time.strftime( '%Y-%m-%d
> %H:%M:%S', time_start ), \
>                                time_end = time.strftime( '%Y-%m-%d %H:
> %M:%S', time_end ), \
>                                time_difference = time_difference )
>        data.save()
>        return True
>
> this is not working at the moment. any pointers much appreciated.


But you've ignored the bit that you quoted above! Why are you using
time instead of datetime? Why are you converting the time into a
string instead of a datetime object?

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



Internationalization Error OSx

2009-09-08 Thread arbi

Hi there,

I got this error while doing makemessages :

$ django-admin.py makemessages -a
processing language fr
Error: errors happened while running msguniq
/bin/sh: msguniq: command not found

I am under OSx, anyone know the pb ?
Thx a lot

Arbi

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



Re: Editors of choice

2009-09-08 Thread David De La Harpe Golden

gnu emacs with ropemacs and nxhtml (has django template mode)
packages.





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



Re: PostgreSQL or MySQL, What are the +'s and -'s?

2009-09-08 Thread Joshua Russo
On Tue, Sep 8, 2009 at 5:53 AM, Jan Ostrochovsky  wrote:
>
> I won't compare PostgreSQL and MySQL as whole, because:
> - I do not know MySQL so well, as PostgreSQL
> - another flamewar could arise ;)
>
> I am only saying: my experience with Django+PostgreSQL is far better,
> than Django+MySQL, see
>
> http://groups.google.com/group/django-users/browse_thread/thread/3abfd993c3c976f9/2e410d567d4ba2db#2e410d567d4ba2db
> .
> If you will need some help with PostgreSQL, do not hesitate to contact
> me directly.
>
> Jano
>
> On Sep 8, 2:58 am, Jason Beaudoin  wrote:
> > While I don't have a whole lot of experience with either, the main issue
> I
> > have against MySQL is it's adherence (lack, that is) to the SQL standard.
> > Moving a MySQL dB--> postgreSQL needn't be so messy.
> >
> > I'm also a bit weary of MySQL having been bought up.
> >
> > Cheers,
> >
> > ~Jason
>

 @Jason - I think that's the number one reason I'm going to PostgreSQL. I
don't use everything all the time but I really like to have the widest array
of query syntax options. MySQL is just too limiting, especially when
PostgreSQL is available.

@Jano - Interesting post that you linked to. I've not see the same problems,
though I'm not dealing with external data. I'm currently working on an
internal app that will be used in Portuguese, thus dealing with UTF-8
everywhere and MySQL seems to be consuming it fine. Tho it can get a little
tricky in Python code when it comes unicode characters.

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



formatting dates for DateTimeField()

2009-09-08 Thread Gonzillaaa

Hello I'm importing data into django and using its admin interface to
browse and search for data.

Each piece of data is timestamped by me at log time. The docs say data
on a DateTimeField() should be a valid datetime.datetime object but I
am unclear of format (tuple, string etc..)

My model looks like this:

class InfrarredTimes(models.Model):
loc_id = models.ForeignKey(Location)
node_id = models.IntegerField(db_index=True)
pin_id = models.IntegerField(db_index=True)
time_start = models.DateTimeField()
time_end = models.DateTimeField()
time_difference = models.IntegerField(db_index=True)


so to log into that I'm doing this:


def log_status_change( self, node_id, pin_id, status ):
   '''logs a change of status for a given node into the
database'''
   if __debug__: print "Loggin status change node_id %s, pin_id
%s, status %s" % ( node_id, pin_id, status )
   loc = self.get_node_location( node_id )
   time_start = self.nodes[node_id]['reading_time_start'][pin_id]
   time_end = time.localtime()
   #time difference expressed in seconds
   time_difference = int( time.mktime( time_end ) - time.mktime
( time_start ) )

   print " loc_id %s, node_id %s, pin_id %s, time_start %s,
time_end %s time_difference %s " % ( loc, node_id, pin_id,
time.strftime( '%Y-%m-%d %H:%M:%S', time_start ), time.strftime( '%Y-
%m-%d %H:%M:%S', time_end ), time_difference )

   data = InfrarredTimes( loc_id = loc, node_id = node_id, pin_id
= pin_id, \
   time_start = time.strftime( '%Y-%m-%d
%H:%M:%S', time_start ), \
   time_end = time.strftime( '%Y-%m-%d %H:
%M:%S', time_end ), \
   time_difference = time_difference )
   data.save()
   return True

this is not working at the moment. any pointers much appreciated.



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



Question on multi-table inheritance docs

2009-09-08 Thread Egon Esser

Hi!

Please consider
http://docs.djangoproject.com/en/dev/topics/db/models/#inheritance-and-reverse-relations

I'm a total failure at understanding this part:
"you must specify the related_name attribute on each such field"

In a Restaurant instance, wouldn't you access the Supplier instances
(that are M2M'd from the Supplier model) via supplier_set?
I.e., as explained here:
http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships

At which point does that clash with the inheritance stuff?

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



Re: Error in setting up psycopg2

2009-09-08 Thread Jan Ostrochovsky

Hi Simon,

I had also problems with psycopg2 on Mac OS X. First with development
server (python manage.py runserver), and when solved, later also with
Apache.

Finally I decided for Linux on production server (with Apache), and
let Mac OS X on development workstations (with runserver).

If such setup is suitable also for you, maybe these howtos will be
also useful:
http://sharpe-s-postgres.blogspot.com/2009/09/how-to-install-postgresql-module-for.html
http://sharpe-s-django.blogspot.com/2009/09/deployment-of-django-project-using.html

If you will need some support with Linux or PostgreSQL, do not
hesitate to contact me directly.

Jano

On Aug 25, 1:19 pm, Simon Lee  wrote:
> Hi Thomas,
>
> I did a Google search and did as one suggestion:
> $ export PYTHONPATH=$HOME/:$PYTHONPATH
> $ export DJANGO_SETTINGS_MODULE=mysite3.settings
> $ python
>
> >>> from django.contrib.sessions.backends import db
>
> It works with no error. The same thing works if I do "python manage.py
> shell" without the export.
>
> That does not solve my problem though. I changed myapp.wsgi to the
> following:
>
> --
>
> import os, sys
> sys.path.append('/Users/simonlee')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> --
>
> It shows the following error in my log:
>
> [Tue Aug 25 19:12:24 2009] [info] [client 127.0.0.1] mod_wsgi
> (pid=170, process='', application='www.test-hago-group.com|'): Loading
> WSGI script '/Users/simonlee/mysite3/apache/myapp.wsgi'.
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] mod_wsgi
> (pid=170): Exception occurred processing WSGI script '/Users/simonlee/
> mysite3/apache/myapp.wsgi'.
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] Traceback (most
> recent call last):
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/core/handlers/wsgi.py", line 241, in __call__
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     response =
> self.get_response(request)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/core/handlers/base.py", line 73, in get_response
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     response =
> middleware_method(request)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/contrib/sessions/middleware.py", line 10, in process_request
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     engine =
> import_module(settings.SESSION_ENGINE)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/utils/importlib.py", line 35, in import_module
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     __import__
> (name)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/contrib/sessions/backends/db.py", line 2, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     from
> django.contrib.sessions.models import Session
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/contrib/sessions/models.py", line 4, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     from
> django.db import models
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/db/__init__.py", line 41, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     backend =
> load_backend(settings.DATABASE_ENGINE)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/db/__init__.py", line 17, in load_backend
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     return
> import_module('.base', 'django.db.backends.%s' % backend_name)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/utils/importlib.py", line 35, in import_module
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     __import__
> (name)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/db/backends/postgresql_psycopg2/base.py", line 22, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     raise
> ImproperlyConfigured("Error loadingpsycopg2module: %s" % e)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]
> ImproperlyConfigured: Error loadingpsycopg2mod

Re: psycopg2.OperationalError: FATAL: role "root" does not exist

2009-09-08 Thread Jan Ostrochovsky

How exactly did you put your database user? What is content of your
pg_hba.conf?
Maybe some parts of this could be helpful:
http://sharpe-s-postgres.blogspot.com/2009/09/how-to-install-and-configure-postgresql.html/

On Sep 7, 11:15 pm, Zico  wrote:
> On Tue, Sep 8, 2009 at 3:06 AM, Angel Cruz  wrote:
>
> > You don't have a user account named 'root' in your database.  You should
> > probably use another user besides root.  Change your settings.py file to
> > the
> > correct database user?
>
> Ok, if i put my database user "fixmystreet" .. which is the exact user..
> then this error comes:
>
> *psycopg2.InternalError: current transaction is aborted, commands ignored
> until end of transaction block*
>
> --
> Best,
> Zico
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---