On Tuesday 11 August 2009 09:43:38 am consiglieri wrote:
> Hi
>
> I'm new with django and have made a small test app which works as it
> should with the development server.
>
> However when i try and deploy it with apache and mod_python I cant get
> it to work. I have tested that mod_python works. I can do the
> recommended mod_python test. When i try to run the django app via
> apache it works well as long as the page being displayed does not
> actually try and access the database. In other words if I enter a url
> that just pops up an empty page with no django tags in it the page is
> displayed as it should.
>
> These are my settings.
>
> Apache 2.2.11
> mod_python 3.3.2-dev
> I am on a Mac (Leopard 10.5.8)
> I have the latest stable version of django 1.1
>
> When I start apache the following can be found in the logs
>
> Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7l DAV/2 mod_python/
> 3.3.2-dev-20080819 Python/2.5.1 configured -- resuming normal
> operations
>
> The necessary settings in httpd.conf with regards to django is as
> follows
>
> Alias test.django.com "/Users/someone/djangoproject/appname"
>
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE appname.settings
> PythonDebug On
> PythonPath "['/Users/someone/djangoproject/'] + sys.path"
>
> When i run a url that invokes a function which tries to access the
> database (sqlite3 in this case) i receive the following error
>

You have to make sure the database file is also readable and writeable by the 
user apache is running as.  The leading path should also be readable to the 
apache user.  755 settings on the directories in the tree.  

Some ways of fixing this are making a group; say djangodevs and add both your 
user and the apache user to that group and setting the sqlite file to be 
rwxrwx---.

You could run apache as your user by changing the User/Group setting in your 
httpd.conf/apache2.conf (see sample below) or a variation of this with the 
above suggestion.

# User/Group: The name (or #number) of the user/group to run httpd as.      
#  . On SCO (ODT 3) use "User nouser" and "Group nogroup".                  
#  . On HPUX you may not be able to use shared memory as nobody, and the    
#    suggested workaround is to create a user www and use that user.        
#  NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)        
#  when the value of (unsigned)Group is above 60000;                        
#  don't use Group #-1 on these systems!                                    
#                                                                           
User youruser                                                              
Group youruser

I would personally recommend that you store your project files outside of your 
home directory, I believe/assume /Users/someone/ is your home directory. I 
would use something like /srv/djangoproject and configure the settings so 
both your user and the apache user can read write to the files through the 
group settings.

With a database like mysql/postgres that you connect to over a network you 
wouldn't need to worry about this since they have their own login.  

Mike



> TemplateSyntaxError at /appname/clients/
> Caught an exception while rendering: no such table:
> addressbook_contacts
>
> Original Traceback (most recent call last):
>   File "/Library/Python/2.5/site-packages/django/template/debug.py",
> line 71, in render_node
>     result = node.render(context)
>   File "/Library/Python/2.5/site-packages/django/template/
> defaulttags.py", line 126, in render
>     len_values = len(values)
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 81, in __len__
>     self._result_cache = list(self.iterator())
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 238, in iterator
>     for row in self.query.results_iter():
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 287, in results_iter
>     for rows in self.execute_sql(MULTI):
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 2369, in execute_sql
>     cursor.execute(sql, params)
>   File "/Library/Python/2.5/site-packages/django/db/backends/util.py",
> line 19, in execute
>     return self.cursor.execute(sql, params)
>   File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 193, in execute
>     return Database.Cursor.execute(self, query, params)
> OperationalError: no such table: addressbook_contacts
>
> Now i know for a fact that the database does contain a table called
> contacts. I have no problems whatsoever accessing this using the
> development server.
>
> As far as I can tell django seems unable to access the database when
> going through apache and mod_python.
> I have googled and I have searched to no avail. If anyone can give me
> a helping hand I would appreciate it very much.
>
> Thanks.
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "Django users" group. To post to this group, send email to
> [email protected] 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
> -~----------~----~----~----~------~----~------~--~---



-- 
I hate babies.  They're so human.
                -- H.H. Munro

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

Reply via email to