Read only fields once created

2006-12-05 Thread Ross Burton

Hi,

Is it possible to have fields in the model that can be set at object
creation, but are immutable after that?  I have an "original estimate"
field that should only be set when creating the object, and never
edited after that.

Thanks,
Ross


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



Programatic defaults

2006-12-05 Thread Ross Burton

Hi,

Is it possible to have programmatic defaults in a model?  If I have a
many to one relationship between A and B, I'd like A.flob to default to
B.flob.  Also A.foo should default to B.foo if it isn't specified.

Would the best way of doing this be in a custom save() method in the
model?

Thanks,
Ross


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



Re: Admin 404s on users

2006-12-05 Thread MerMer

Yes, I broke the model that was being edited  by the USER model.   From
memory mine also validated OK, because the problem lay with some of the
data in the DB - not the actual structure of the model.   That's why I
was able to see a complete USER list and only got the error when I
clicked on the individual record.

Merric


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



Re: using a global login form

2006-12-05 Thread Guillermo Fernandez Castellanos

Hi,

For every page login form, check:
http://brehaut.net/blog/2006/08/21/django-user-logins/

No need to use the login view. Use the authenticate function instead.

Hope it helps,

G

On 12/4/06, Milan Andric <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I'm having the same problem as this thread:
> http://groups-beta.google.com/group/django-users/browse_thread/thread/b711b5c4579535c8/
>
> Where to call set_test_cookie?  Since a POST to authenticate can come
> from any page, I need to call set_test_cookie on any page.  I'm using
> the django.contrib.auth.views.login, a pretty basic login setup.
>
> Where is the appropriate place for this or is there a better way?  I
> figure I could stick it in one of my context processor functions but
> want to avoid the hack if possible.
>
> Thanks for your tips,
>
> --
> Milan
>
>
> >
>

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



SQLAlchemy Progress

2006-12-05 Thread Burhan

Hello:

  Is there any update on the SQLAlchemy integration project? The last
thread is too old for me to reply to.

Regards,
Burhan


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



Admin: recursive edit_inline possible?

2006-12-05 Thread Darin Lee

Hi all,

I have three tables, A,B, abd C which have admin classes.
B has a ForeignKey field to A, and C has a ForeignKey field to B.

I am trying to get an admin form (change/detail) that contains A's,  
B's and C's fields inline when I visit A's change/update pages. In  
short, is it possible to recurse "edit_inline" arguments across three  
tables (where C is indirectly related to A via B)? Or would it be a  
better approach to write custom admin views and templates that do this?

I'm a Django newbie so any advice would be greatly appreciated.

Thanks in advance,
Darin



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



Saving relation information

2006-12-05 Thread [EMAIL PROTECTED]

Hi.
I'm wondering is there any way to determine changes made in relations
for particular object from the model save method?
Let's say that we have a model class with name and some many-to-many
field. Now for example through admin interface we change realtions for
our object. Btw objects history in admin application will not display
notification abut such action :). As far as i know saving relation
information takes place after saving object metadata (by manipulator's
save).
The reason i'm diging in is that i want some logging information about
all changes on my objects. My current idea is to override save for my
objects and introduce some application specific logging api. The
disadvantage of such solution will be lack of informations about
changes on relations from places other than my application (admin site
i.e.)
Does anyone have any ideas?

Kind regards


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



Django and mod_python issues

2006-12-05 Thread Tipan

I've seen various posts with similar problems, but not managed to find
consistent advice on trouble shooting this issue.

I've got an installation of xampp Apache 2.2 and mod_python 3.2.10 and
Python 2.5. Running on Windows 2003 server.

I have mod_python working fine in apache - I can view the contents of a
simple python file (mptest from mod_python testing).

I installed Django -  I did this from the latest files via Subversion,
because the install file on Official version failed several times (the
note said Python 2.5 may cause problems)

I've added details of my project file in a location statement to
httpd.conf.

However, when I open the project in the browser:
http://localhost:/myproject/

I get the following error(s) displayed in the browser:
---
Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "D:\Python25\Lib\site-packages\mod_python\apache.py", line 299,
in HandlerDispatch
result = object(req)

  File
"D:\Python25\lib\site-packages\django\core\handlers\modpython.py", line
177, in handler
return ModPythonHandler()(req)

  File
"D:\Python25\lib\site-packages\django\core\handlers\modpython.py", line
145, in __call__
self.load_middleware()

  File "D:\Python25\lib\site-packages\django\core\handlers\base.py",
line 22, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "D:\Python25\lib\site-packages\django\conf\__init__.py", line
27, in __getattr__
self._import_settings()

  File "D:\Python25\lib\site-packages\django\conf\__init__.py", line
54, in _import_settings
self._target = Settings(settings_module)

  File "D:\Python25\lib\site-packages\django\conf\__init__.py", line
82, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

EnvironmentError: Could not import settings 'myproject.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
myproject.settings
--
My httpd.conf file has the following settings at the end:
--

  AllowOverride FIleinfo
  AddHandler mod_python .py
  PythonHandler mptest
  PythonDebug On




SetHandler python-program
PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonDebug On

--
I've checked the "import django" from the python command line and there
were no errors, so I believe it's installed and accessible.

I've tried manually adding to sys.path the directories of the django
installation and my project with no effect. I'm wondering whether by
manually installing the django files from subversion I missed some key
settings, but I've not found any notes to allow me to check.

Can anyone give me any pointers for resolving this behaviour?


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



Re: Django and mod_python issues

2006-12-05 Thread Jeremy Dunck

On 12/5/06, Tipan <[EMAIL PROTECTED]> wrote:
...
> EnvironmentError: Could not import settings 'myproject.settings' (Is it
> on sys.path? Does it have syntax errors?): No module named
> myproject.settings
...
> PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"

> Can anyone give me any pointers for resolving this behaviour?
>

I think you want this:

PythonPath "['d:/program files/xampp/htdocs/'] + sys.path"

(I don't think this has anything to do with Py2.5, etc.  It's just
python path issues.  :)

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



Re: Django and mod_python issues

2006-12-05 Thread Nicolas Steinmetz

Tipan a écrit :

> PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"

Try : PythonPath "['d:/program files/xampp/htdocs/'] + sys.path"

Nicolas


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



[importError] No module name py. Newby

2006-12-05 Thread Snirp

Hi there,

I am starting off with django and decided to stick with the "django
book"

The webserver initiates just fine, and i made the first example: return
current time when requested the URL: /now/

It returns the following error when requesting the url:



Traceback (most recent call last):
File "d:\webdev\python\django\core\handlers\base.py" in get_response
  65. callback, callback_args, callback_kwargs = resolver.resolve(path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
  145. for pattern in self.urlconf_module.urlpatterns:
File "d:\webdev\python\django\core\urlresolvers.py" in
_get_urlconf_module
  161. self._urlconf_module = __import__(self.urlconf_name, '', '',
[''])

  ImportError at /now/
  No module named py



The path to d:\webdev\python is just fine and the welcome screen
displays just fine.


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



Re: SQLAlchemy Progress

2006-12-05 Thread Adrian Holovaty

On 12/5/06, Burhan <[EMAIL PROTECTED]> wrote:
>   Is there any update on the SQLAlchemy integration project? The last
> thread is too old for me to reply to.

It looks like no work has been checked in for that branch, aside from
the occasional merges from trunk changes. You can follow the progress
on this page, which lists all of the changes to the branch:

http://code.djangoproject.com/log/django/branches/sqlalchemy

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Admin: recursive edit_inline possible?

2006-12-05 Thread Adrian Holovaty

On 12/5/06, Darin Lee <[EMAIL PROTECTED]> wrote:
> I am trying to get an admin form (change/detail) that contains A's,
> B's and C's fields inline when I visit A's change/update pages. In
> short, is it possible to recurse "edit_inline" arguments across three
> tables (where C is indirectly related to A via B)? Or would it be a
> better approach to write custom admin views and templates that do this?

Recursive or multi-level edit_inline is not supported at this time,
but we've talked about adding that support in the future. Your best
bet at this point is to write custom admin views/templates.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Support Ticket System

2006-12-05 Thread [EMAIL PROTECTED]



On Dec 1, 9:51 pm, "Bret Walker" <[EMAIL PROTECTED]> wrote:
> On 12/1/06, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On 12/1/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > 1.  Mark fields as optional.
> > >  I don't like this because there will be lots of null values
> > > inserted into the database.  I also don't think that this would be
> > > following SQL best practices.
>
> > Well, even in PHP you were going to have null columns. What you really
> > seem to want is a way to say, in SQL,
>
> > create table ticket (
> > user_id integer not null references "end_user" ('id') or references
> > "temp_user" ('id')
> > );
>
> > Except databases don't work that way ;)
>
> > So no matter what, you're going to get optional fields, with some
> > filled in for "real" users and NULL otherwise (and vice-versa).
>
> > Given that, optional fields seem to be the way to go. Use the admin,
> > train your staff on which fields need to be used in which situations,
> > and move on.I may not have been clear in my description of how I see the 
> > database working.
> In the ticket table, there would be a bool dictating whether or not
> the ticket if for end_user or temp_user.  There would also be a field
> for the id of the end or temp user (the user data would be in another
> table).  If foreign keys were required, I guess there could be two
> columns, one for end_user id and one for temp_user id, one of which
> would always be null.  This would at least allow the admin interface
> to display similar data the table view.  This seems like a perfect
> application of model inheritance.  The admin interface could display
> the columns that the parent class has (which means all child classes
> would have them as well).
>
> If I use optional fields, I'm going to end up having disparate columns
> that hold the same type of date (name, email, phone).  This doesn't
> make sense to me.  It also will render the admin interface ineffective
> (since, for example, I won't be able to sort by name because there
> will be two name columns).  This is also impractical because I require
> too much information for the end_user objects.  Trying to collect the
> data for each end user each time a ticket is created will lead to
> inconsistent data and wasted time.
>
> Surely someone has an eloquent solution to this type of problem, which
> I'm sure has come up before.
>
> Thanks for all of the quick responses.
>
> Bret

No answers to my questions?  I'm thinking that my problem may be
related to the SQLAlchemy work that is going on.  Is this the case?

Also, I tried to make my ForeignKey field optional, as suggested, but
Django threw an error saying that it had to have a value.

Bret


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



Re: No module name py. Newby

2006-12-05 Thread Snirp

ok, made a typo, but i am still not out of the woods...

I now have a AttributeError at /now/ error

Exception Value:'function' object has no attribute 'rindex'

Traceback (most recent call last):
File "d:\webdev\python\django\core\handlers\base.py" in get_response
  65. callback, callback_args, callback_kwargs = resolver.resolve(path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
  147. sub_match = pattern.resolve(new_path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
  112. self.func = self.get_callback()
File "d:\webdev\python\django\core\urlresolvers.py" in get_callback
  116. mod_name, func_name = get_mod_func(self.callback)
File "d:\webdev\python\django\core\urlresolvers.py" in get_mod_func
  23. dot = callback.rindex('.')

  AttributeError at /now/
  'function' object has no attribute 'rindex'


The urls.py looks like this:


from django.conf.urls.defaults import *
from mysite.timeview import current_datetime

urlpatterns = patterns('',
(r'^now/$', current_datetime),
)


The current_datetime function is defined in timeview.py in the same
folder


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



Re: Admin 404s on users

2006-12-05 Thread [EMAIL PROTECTED]

Syncdb didn't appear to do anything.

Adrian, I think you're right about ObjectDoesNotExist, and I think
something in my database is off... any Ideas how to track it down?


Adrian Holovaty wrote:
> On 12/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > It doesn't give me anything to go on:
> >
> > Page not found (404)
> > Request Method: GET
> > Request URL:http://gretschpages.com/admin/auth/user/1/
> >
> > You're seeing this error because you have DEBUG = True in your Django
> > settings file. Change that to False, and Django will display a standard
> > 404 page.
>
> Try running "manage.py syncdb" to install any permissions that might
> be missing. I think an ObjectDoesNotExist exception is being raised
> somewhere, causing the 404. I seem to recall having a similar problem
> once, where the PermissionDoesNotExist exception was causing a 404.
>
> Adrian
> 
> -- 
> Adrian Holovaty
> holovaty.com | djangoproject.com


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



Re: [importError] No module name py. Newby

2006-12-05 Thread Waylan Limberg

On 12/5/06, Snirp <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> I am starting off with django and decided to stick with the "django
> book"
>
> The webserver initiates just fine, and i made the first example: return
> current time when requested the URL: /now/
>
> It returns the following error when requesting the url:
>
>
>
> Traceback (most recent call last):
> File "d:\webdev\python\django\core\handlers\base.py" in get_response
>   65. callback, callback_args, callback_kwargs = resolver.resolve(path)
> File "d:\webdev\python\django\core\urlresolvers.py" in resolve
>   145. for pattern in self.urlconf_module.urlpatterns:
> File "d:\webdev\python\django\core\urlresolvers.py" in
> _get_urlconf_module
>   161. self._urlconf_module = __import__(self.urlconf_name, '', '',
> [''])
>
>   ImportError at /now/
>   No module named py
>

I have a sneaking suspicion that you are trying to `import
somefile.py`. When importing in your python code, the `.py` file
extension is assumed, so leave if off: `import somefile`.

If that's not it, post your urls.py file here so we can see what may
be causing the problem.

>
>
> The path to d:\webdev\python is just fine and the welcome screen
> displays just fine.
>
>
> >
>


-- 

Waylan Limberg
[EMAIL PROTECTED]

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



Re: No module name py. Newby

2006-12-05 Thread tonetheman

I think unless you are using the stuff from the bleeding edge the
second object in the tuple should be a string. Check out this doc
(http://www.djangoproject.com/documentation/url_dispatch/) and see how
they did the urls.py and see if that works better.

Something like this...

urlpatterns = patterns('', ('/something or other',
'mysite.timeview.current_datetime'),)

Tone


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



Re: Django and mod_python issues

2006-12-05 Thread Waylan Limberg

On 12/5/06, Nicolas Steinmetz <[EMAIL PROTECTED]> wrote:
>
> Tipan a écrit :
>
> > PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"
>
> Try : PythonPath "['d:/program files/xampp/htdocs/'] + sys.path"

Actually, you may want to include both lines. That way,
`myproject.settings` will still work and you will be able to `import
myapp` instead of `import myproject.myapp` making your apps more
portable across projects.


-- 

Waylan Limberg
[EMAIL PROTECTED]

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



Re: Singleton model instance

2006-12-05 Thread Jeff Forcier

As James and Fredrik have implied, I believe the proper solution here
is to abstract things enough so that you *can* map the concept to a
relational database; in this case, assuming that every 'Page' has an
identifier, a 'Title' and, perhaps, multiple 'Sections' (each with an
identifier and text), you make a Page model with (unique) Name and
Title attributes, and then a Section or PageSection or etc, model, with
Name and Text fields and a ForeignKey to Page.

Then your homepage is a Page whose Name is "homepage" and whose Title
is the page title, then with a few Sections: one named "introduction"
with the intro text, one named "footer" with footer text, etc.

Finally, you'd probably want to make a templatetag that operates on
these models, so you can do something like {% printsection 
 %} where  is the current Page object, and  is the name of the section you wish to print.

So your homepage would looke something like this:



{{ mypage.title }}


{{ mypage.title }}
{% printsection mypage "introduction" %}

stuff goes here

{% printsection mypage "footer" %}



I'm sure you can come up with more specific and/or efficient variants
on this theme, but basically this is going down the road that leads to
content management systems, which have solved this basic problem for
some time now :)

Regards,
Jeff

Phil Powell wrote:
>
> Perhaps I've not explained myself properly.  Here's an example:
>
> I have a "Homepage" which has fields such as "Page Title",
> "Introduction Text", "Footer Text" etc.  I want to be able to edit
> these fields just like I'd edit a standard model instance, but because
> there is only one instance of my "Homepage" I never want more than one
> instance of it to exist.
> 
> -Phil


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



Re: Auto-login with REMOTE_USER

2006-12-05 Thread dchandek

Thanks, Brian and Ivan! The CAS example was helpful in figuring things
out. Turns out the solution was simple, but the Django documentation
was not as much help as I would have liked -- I guess because, again,
the general assumption is that Django is going to handle the
authentication credentials (username and password) via a login form
submitted to Django. In my case, the real authentication is handled in
Apache prior to Django entering the picture (i.e., an Apache module
handles redirecting the client to login form, etc.).

So, the heart of the solution was in the middleware piece:

def process_request(self, request):
# AuthenticationMiddleware is required to create request.user
error = """The Django RemoteUserAuth middleware requires
authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES
setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware' *before* the
RemoteUserMiddleware class."""
assert hasattr(request, 'user'), error
if request.user.is_anonymous():
user = authenticate(username=request.META['REMOTE_USER'])
if user is not None:
request.user = user# set request.user to the 
authenticated user
login(request, user)   # auto-login the user to Django
return None

The authentication backend just gets the user object by username:

def authenticate(self, username, password=None):
"""
Authenticate user - RemoteUserAuth middleware passes REMOTE_USER
as username. password param is not used, just added in case :)
"""
user = None
if username:
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
# Auto-create user
if settings.REMOTE_USER_AUTH_AUTO_CREATE:
# We'll create a password, but it won't be used
password = User.objects.make_random_password()
# TODO: add LDAP lookup here
user = User.objects.create_user(username, '', 
password)
user.is_staff = True
user.save()
return user


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



Re: No module name py. Newby

2006-12-05 Thread Snirp


Great Tone! This works.

Just one thing... you are supposed to show me the general direction,
not to solve my problems with complete code included.

How will i ever learn? ;-)

If you were a pretty girl, i'd kiss you. Come to speak of it, I would
do just that with any pretty girl.

Well you get the general idea, i am greatful.



tonetheman wrote:
> I think unless you are using the stuff from the bleeding edge the
> second object in the tuple should be a string. Check out this doc
> (http://www.djangoproject.com/documentation/url_dispatch/) and see how
> they did the urls.py and see if that works better.
>
> Something like this...
>
> urlpatterns = patterns('', ('/something or other',
> 'mysite.timeview.current_datetime'),)
> 
> Tone


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



Re: No module name py. Newby

2006-12-05 Thread Snirp

I was doing just that in the original post. I fixed that and got the
error in the second post. I am going to give it another try now


Waylan Limberg wrote:
> On 12/5/06, Snirp <[EMAIL PROTECTED]> wrote:
> >
> > Hi there,
> >
> > I am starting off with django and decided to stick with the "django
> > book"
> >
> > The webserver initiates just fine, and i made the first example: return
> > current time when requested the URL: /now/
> >
> > It returns the following error when requesting the url:
> >
> >
> >
> > Traceback (most recent call last):
> > File "d:\webdev\python\django\core\handlers\base.py" in get_response
> >   65. callback, callback_args, callback_kwargs = resolver.resolve(path)
> > File "d:\webdev\python\django\core\urlresolvers.py" in resolve
> >   145. for pattern in self.urlconf_module.urlpatterns:
> > File "d:\webdev\python\django\core\urlresolvers.py" in
> > _get_urlconf_module
> >   161. self._urlconf_module = __import__(self.urlconf_name, '', '',
> > [''])
> >
> >   ImportError at /now/
> >   No module named py
> >
>
> I have a sneaking suspicion that you are trying to `import
> somefile.py`. When importing in your python code, the `.py` file
> extension is assumed, so leave if off: `import somefile`.
>
> If that's not it, post your urls.py file here so we can see what may
> be causing the problem.
>
> >
> >
> > The path to d:\webdev\python is just fine and the welcome screen
> > displays just fine.
> >
> >
> > >
> >
> 
> 
> -- 
> 
> Waylan Limberg
> [EMAIL PROTECTED]


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



Re: Django and mod_python issues

2006-12-05 Thread Tipan

Thanks for the advice. Adding the line:

PythonPath "['d:/program files/xampp/htdocs'] + sys.path"

to my httpd.conf overcame the issue with loading myproject module.
Simple when you know how.

Thanks again, 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Specifying a pub date with syndication

2006-12-05 Thread [EMAIL PROTECTED]

Hey,

Just a quick question - what would I need to add to the following feed
class to get pub dates for each item?

class latest_entries(Feed):
title = "oBeattie - Latest Posts"
link = "/blog/"
description = "Latest posts on oBeattie"

def items(self):
return Post.objects.order_by('-pub_date')[:5]

The pub date is in Post > pub_date

Many Thanks,
O


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



Re: Specifying a pub date with syndication

2006-12-05 Thread Suriya

[EMAIL PROTECTED] wrote:

>   def items(self):
>   return Post.objects.order_by('-pub_date')[:5]
>
> The pub date is in Post > pub_date

def items(self):
  return [ i.pub_date for i in Post.objects.order_by('-pub_date')[: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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Specifying a pub date with syndication

2006-12-05 Thread [EMAIL PROTECTED]

Suriya wrote:
> [EMAIL PROTECTED] wrote:
>
> > def items(self):
> > return Post.objects.order_by('-pub_date')[:5]
> >
> > The pub date is in Post > pub_date
>
> def items(self):
>   return [ i.pub_date for i in Post.objects.order_by('-pub_date')[:5] ]

Thanks for posting this. However, I couldn't get it to work but after a
bit of a play around I got it working with:

def items(self):
return Post.objects.order_by('-pub_date')[:15]

def item_pubdate(self, item):
return item.pub_date

Just in case anyone else ever needs this!

Cheers,
O


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



Editing multiple objects in a single page

2006-12-05 Thread [EMAIL PROTECTED]

Hello everyone,

I have a project for work that I can do in django and I have a little
problem.  Basically, my create and edit forms must edit three different
kind of objects: they both ask information about a company (ForeignKey
to a contact), a contact and a project (ForeignKey to a company.)

My problem is writing a form that can easily validate and save the data
entered.  I'm not sure how to go about it, because some fields in
company and project have the same name (thus, same id when using a
FormWrapper).  Also, the fact that there's a foreign key messes me up,
because if I do the validation for the company, it says that there's no
contact specified..  Has anyone done something similar in the past?

Vincent.


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



Re: graceful shopping cart questions

2006-12-05 Thread Noah

No one?


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



Syndication for objects

2006-12-05 Thread [EMAIL PROTECTED]

Hey Again,

I am using the syndication framework to generate feeds for my site.
With this, I want to have feeds which will list the posts in a
category. To do this, I am currently using the following code:

--- urls ---

feeds = {
'post': latest_entries,
'category': posts_by_category,
}

(r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),

--- views ---

class posts_by_category(Feed):
def get_object(self, bits):
if len(bits) != 1:
raise ObjectDoesNotExist

return Category.objects.get(slug__exact = bits[0])

def title(self, obj):
return obj.get_absolute_url()

def link(self, obj):
return "%s" % (site_url)

def description(self, obj):
return "Posts in the %s on oBeattie" % obj.name

def items(self,obj):
return
Post.objects.filter(category__slug__exact=obj.slug).order_by('-pub_date')[:20]

But this throws an error at me saying "Invalid feed parameters. Slug
'category' is valid, but other parameters, or lack thereof, are not.".
Why does it not accept the slug which I give it?

Many Thanks,
Oliver


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



OpenID

2006-12-05 Thread Caz

Has anyone used OpenID on any of their Django powered websites?

I discovered it just now and it looks to be a really elegant cross
website user authentication solution.

See http://www.lifewiki.net/openid/OpenIDLibraries
It even has python libraries available:
http://www.openidenabled.com/openid/libraries/python/

Mmmm, I just discovered the answer to my own question, but I'm posting
in anycase to raise awareness!

The wiki page is at:
http://code.djangoproject.com/wiki/CookBookShortcutsOpenIDAuthentication


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



Re: Syndication for objects

2006-12-05 Thread [EMAIL PROTECTED]

Sorry about that - just realized that it was a problem with the browser
(Safari), not Django!


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



Re: High Load

2006-12-05 Thread [EMAIL PROTECTED]

We tried Apache and it seemed slower. We're doing probably 1-2 million
uniques today and the sessions are now killing the website :)

This is on like 12 web servers now too.

On Dec 4, 11:42 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > We are running lighttpd with fastcgi in prefork mode. We tried using
> > threaded but django spits out an error about a weakly-referenced
> > object, related to sessions I believe, no longer existing.it's not related 
> > to this, by any chance:
>
> http://wolfram.kriesing.de/blog/index.php/2006/multithreading-with-my...
> 
> 


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



Re: High Load

2006-12-05 Thread [EMAIL PROTECTED]

Let me add, that this could simply be SQL overloaded right now. We had
managed to get all the servers down to 2-4 load, sometimes a little
more. Problem was something related to python creating zombie
processes, and the other guy I worked with managed to find a solution.

We may test postgreSQL to see if this fixes our latest problem, as our
SQL cluster isnt setup yet as the hoster didnt have it ready, and this
is a peak traffic day.

Also that multithreading weakref fix, that may help a lot :) That was
the exact error we were getting when using threaded mode and it was
completely random. I'll implement that and hopefully it will make it so
we can drop prefork.

On Dec 6, 1:40 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> We tried Apache and it seemed slower. We're doing probably 1-2 million
> uniques today and the sessions are now killing the website :)
>
> This is on like 12 web servers now too.
>
> On Dec 4, 11:42 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>
> > [EMAIL PROTECTED] wrote:
> > > We are running lighttpd with fastcgi in prefork mode. We tried using
> > > threaded but django spits out an error about a weakly-referenced
> > > object, related to sessions I believe, no longer existing.it's not 
> > > related to this, by any chance:
>
> >http://wolfram.kriesing.de/blog/index.php/2006/multithreading-with-my...
> 
> > 


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



Re: High Load

2006-12-05 Thread Jeremy Dunck

On 12/5/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> We tried Apache and it seemed slower. We're doing probably 1-2 million
> uniques today and the sessions are now killing the website :)
>
> This is on like 12 web servers now too.

It sounds like you must be I/O bound.  What's your CPU utilization at that load?

Suspecting session traffic to the DB makes sense; any write to the
request.session state bag forces serialization to the DB.  If you're
dirtying session often, that's a lot of traffic to the DB, and all on
one table.   I figure it's a matter of time until someone writes a
non-DB backend for sessions.  ;-)

Anyway, you could use tethereal to see what your web/db traffic looks
like, and similar tools (sorry, none at hand) to see if your pipe is
full or if your db is disk bound.

I dunno much about MySQL tuning, sorry.

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



Re: OpenID

2006-12-05 Thread Sandro

Ian Holsman deserves to be noted.
http://feh.holsman.net/articles/2006/07/14/zyons-openid-what-a-match


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



Anonymous Sessions

2006-12-05 Thread [EMAIL PROTECTED]

I'd like a simple option to disable this, any plans to implement
something of the sorts?

The problem is our servers are dieing around 1mil sessions due to every
single unique getting a session.. this becomes a seroius problem when
those 1 mil sessions happen in less than a day.


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



creating alerts

2006-12-05 Thread [EMAIL PROTECTED]

i am trying to build an alert system where i want to send out e-mail
alerts periodically (every 5 mins, 15 mins etc..)  until a specified
time.
this alert has to be created dynamically and i dont know this at the
beginning of launching the python program.
the alerts created is stored in a postgres database.

what is the best way to do this?
thanks
mark


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



Re: Re: Django + FastCGI Problems

2006-12-05 Thread Uros Trebec
I am sorry to report that this method does NOT work on my
machine/account. I've tried different users (on the same machine) and
it does not work. Symptoms are the same.

I guess it's just my machine the one that is F00! And they refuse to
move my account to another one. :(

Anyone knows about any concrete alternative hosting that is production
stable for Django and offers reasonable prices (sub $10/month), disk
space (5-10GB) and bandwidth (250GB+) with multiple domain/site
hosting?
(I tried site5.com, but they would not accept my Visa Electron or
PayPal payment :( )

Best regards,
Uros


On 12/1/06, Maciej Bliziński <[EMAIL PROTECTED]> wrote:
>
> Mike,
>
> I was experiencing the same problems: incomplete headers and timeouts.
> I did a simple trick that made my Django application run smoothly.
> Perhaps you can try the same thing (it requires simple changes). I
> described it on my blog:
>
> http://automatthias.wordpress.com/2006/12/01/django-on-dreamhost-incomplete-headers/
>
> I haven't thoroughly verified it, it's an ongoing investigation. Maybe
> you could try the same thing. I'd like to know if it works for other
> people as well.
>
> Cheers,
> Maciej
>
>
> >
>

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



Re: Converting a Django site to flat HTML

2006-12-05 Thread goon

Hi James,

I was pondering the same thing just the other day - trying to get flat
pages from django site. Now at first I thought using *wget* would
suffice, but I also needed to do other things with the files
(archiving, uploading to ftp). So I needed some way of interacting with
the static pages after download.

The obvious thing might have been to find a python wget module. No such
luck. Also further checking wget
(http://en.wikipedia.org/wiki/Wget#Criticisms_of_Wget) I found numerous
things that may get in the way of extracting complete pages. For
example HTTP 1.0 only support, hence js, css referenced data might not
be extracted.

So I looked for an alternative. cURL comes to mind
(http://en.wikipedia.org/wiki/CURL), And becuase the libCurl is exposed
a python interface to cURL, http://pycurl.sourceforge.net/.  Using this
approach I can not only download pages with greater flexability but
also script the downloads in python instead of relying on a shell
command call to wget.


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



Re: Admin 404s on users

2006-12-05 Thread [EMAIL PROTECTED]

Grasping at straws here, but I've been running lots of comparison sql
statements looking for any disparities or oddities, things like:
Select user_id from auth_user_groups where user_id not in (select id
from auth_user)
and I notice that user 1 (admin, superuser, me) isn't in
auth_user_groups. That's normal, right?

This is just killing me... I can't figure out why the admin is flaking
on auth. I've noticed it freaks out on auth_users and auth_user_groups,
but nothing else, not even gp_users, which extends auth_users.


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



problems turning debug off

2006-12-05 Thread luxagraf

I'm trying to launch a site and every time I turn off django's
debugging or python debugging I start getting 500 error pages, but
when the debugging is on none of those pages throw any errors?

Anyone seen this before?

Am I missing something.

sng


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



Re: problems turning debug off

2006-12-05 Thread Adrian Holovaty

On 12/6/06, luxagraf <[EMAIL PROTECTED]> wrote:
> I'm trying to launch a site and every time I turn off django's
> debugging or python debugging I start getting 500 error pages, but
> when the debugging is on none of those pages throw any errors?
>
> Anyone seen this before?
>
> Am I missing something.

Hi luxagraf,

I assume you're using mod_python and you're getting the standard
Apache "500 Server Error" pages, in which case you should check your
Apache error log. If your error page is being served by Django, make
sure your ADMINS and EMAIL_HOST settings are correct -- then, Django
will e-mail you the tracebacks for any error.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Re: problems turning debug off

2006-12-05 Thread luxagraf

Adrian

Thanks for your help. I check the logs and the error generated was
"TemplateNotFound" for 404.html. So I created a 404 template and now
it works fine (even though the page doesn't generate a 404 error),

Curiously it only did that on pages that are served by the flatpages
app, must be something in  django.flatpages that needs a 404 template
I guess.

And yes I am running django through mod_python

Anyway it works now. Thanks again.

cheers
sng


On 12/5/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 12/6/06, luxagraf <[EMAIL PROTECTED]> wrote:
> > I'm trying to launch a site and every time I turn off django's
> > debugging or python debugging I start getting 500 error pages, but
> > when the debugging is on none of those pages throw any errors?
> >
> > Anyone seen this before?
> >
> > Am I missing something.
>
> Hi luxagraf,
>
> I assume you're using mod_python and you're getting the standard
> Apache "500 Server Error" pages, in which case you should check your
> Apache error log. If your error page is being served by Django, make
> sure your ADMINS and EMAIL_HOST settings are correct -- then, Django
> will e-mail you the tracebacks for any error.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com
>
> >
>

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