runfcgi - complete lack of joy.
Hi all, django 6525, Apache 1.3, Mac OS X Server 10.4.7, python 2.5.1 (darwin ports) Following: http://code.djangoproject.com/wiki/OsxFcgi , except I've added another folder into the nest: /Library/WebServer/Documents/django Added these lines to my httpd.conf (which, besides turning on php, are the only changes I've made to the default httpd.conf): FastCGIExternalServer /Library/WebServer/Documents/django/django.fcgi - host 127.0.0.1:3033 Servername django.local ErrorLog /var/log/httpd/django-error.log CustomLog /var/log/httpd/django-access.log combined DocumentRoot /Library/WebServer/Documents/django RewriteEngine On RewriteRule ^(/django/m/.*)$ $1 [L] # for custom media RewriteRule ^(/django/media.*)$ $1 [L] # for admin media RewriteRule ^(/django/.*\.)(jpg|gif|png|ico)$ $1$2 [L] # some other media (mostly "accidentaly" in the root) RewriteRule ^(/django/admin.*)$ /django.fcgi$1 [L] # admin application RewriteRule ^(/django/myapp.*)$ /django.fcgi$1 [L] # your own application RewriteRule ^(/django/.*)$ /django.fcgi$1 [L] # the rest of django (only if needed from the web root) Command line I'm launching inside /Library/WebServer/Documents/django/ myapp is: ./manage.py runfcgi settings=settings.py host=127.0.0.1 port=3033 pidfile=/var/run/django.pid I have also tried using the complete path to the settings.py. The server lives at http://192.168.1.10/. There are other php things being served out of their own subdirectories in /Library/WebServer/ Documents which are working just fine. http://192.168.1.10/django/ gives a 403 http://192.168.1.10/django/admin/ gives a 404 http://192.168.1.10/django/myapp/ gives a 403 myapp - there are no applications there yet. I was hoping that the admin site (which I can access when I run the development server), or that nice first error page from Tutorial 1, might be accessible. If I change the VirtualHost line to another port, such as 8247, I get "unable to connect" errors instead of the 404s and 403s. I've also tried not using VirtualHost as detailed in: http://groups.google.com/group/django-users/browse_thread/thread/dc5a1f8e9b413e9b/b592d8f091fad898?lnk=gst&q=runfcgi#b592d8f091fad898 Nothing is throwing off any interesting errors or logs that I can find. I would welcome any suggestions that would get things running in the form of: http://192.168.1.10/django/admin/ or http://192.168.1.10:8080/admin/ or http://192.168.1.10:8080/django/admin/ Thanks for your help, jtm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Multi-tiered edit-inline or multi-page admin screens?
Hi, I can't seem to get edit-inline to work deeper than one level. Simplified example: class A(meta.Model): fields = ( meta.CharField('a_value'), ) admin = meta.Admin() class B(meta.Model): fields = ( meta.ForeignKey(A, edit_inline=True), meta.CharField('b_value'), ) class C(meta.Model): fields = ( meta.ForeignKey(B, edit_inline=True) meta.CharField('c_value'), ) B will show up under A, but C won't be included within B. I'm attempting to get all the data entry on one page. Is this possible? If it requires some hacking, what would be easier - multi- level inline editing, or a multi-page admin section? Any hints and starters/pointers greatly appreciated. jimmy
Re: Multi-tiered edit-inline or multi-page admin screens?
Adrian, Are there any hooks that would make it possible to do recursive edit_inlines from within the application, or would it have to be set up in the Django code? Is there anything like a "render, validate, update_me, insert_me, delete_me" base class that my models I can inherit from to do such things? Otherwise, any pointers into the Django code base and headspace would be handy. Thanks for your reply, jimmy
Re: Adding Record Problem
If I understand things correctly, Django creates an 'id' field for each model automatically, I assume set to unique and to auto-increment, thus avoiding the problem you are seeing. The easiest thing to do is not to create your own 'id' field and use the one Django puts in place for you. jtm
Questions about Django model exceptions and request data
Hiya. Do exceptions like "PollDoesNotExist" get generated in a similar manner that the lookups do? I find that when processing a request, Django is throwing me exceptions like "RespondentDoesNotExist", but if I try and catch that exception, rather than using a bare "except:" statement, I get this: NameError: global name 'RespondentDoesNotExist' is not defined Should I just be using ObjectDoesNotExist, or is there a way of getting the more accurately named exceptions? While I have you, how do you get the data from a form out of a manipulator after this step: manipulator.do_html2python(new_data) or don't you, and I should stick to re-using the POST data like so: login_name__exact=request.POST['login'] And a final question, is there a better way to get HTTP header info out of a request than this (which I haven't yet check to see if it even works): last_ip_address=request.META.get('REMOTE_ADDR') Thanks for your help. I've got a dozen Django and Python related tabs open in Firefox and I can't locate the answer in any of them. :) jtm
DateTimeField TypeError: replace() takes no keyword arguments?
This one has me stumped. I have a mySession class with three DateTimeFields along these lines: meta.DateTimeField('session_start', 'Session Start Time', auto_now_add=True) when I create a new mySession instance and try to .save() it, I get the following Traceback: Traceback (most recent call last): File "D:\python24\lib\site-packages\django\core\handlers\base.py", line 64, in get_response response = callback(request, **param_dict) File "D:\python24\lib\site-packages\dcm\apps\survey\views\survey.py", line 110, in checkLogin sess.save() File "D:\python24\lib\site-packages\django\utils\functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "D:\python24\lib\site-packages\django\core\meta\__init__.py", line 739, in method_save db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.name), False)) for f in non_pks] File "D:\python24\lib\site-packages\django\core\meta\fields.py", line 308, in get_db_prep_save value = value.replace(microsecond=0) TypeError: replace() takes no keyword arguments Anyone have any hints about this? I fiddled a little, like putting an "if not isinstance(value, datetime.datetime): raise TypeError" kind of thing above line 308, and it was throwing the exception, but I have no idea how to progress things from there. Any tips on the best ways to get debugging output from django when you're in the browser would be warmly received. Thanks again, jtm
Re: DateTimeField TypeError: replace() takes no keyword arguments?
It's not Django, it's me. Between the caffeine and lack of sleep and looming deadline, skimming the Django documentation led me to believe that you attach foreign keys like so: a = aClass() b = add_aClass(a) where is I should have been saying: a = aClass(b_id=b.id) Unless there is another way to add foreign keys? Thanks, jtm
Table not found error when ordering by foreign key
Here is a simplified version of what I am trying to do: App X: class A: shortname = meta.CharField(maxlength=6) App Y: class B: the_A = meta.ForeignKey(A) Y.views: blist = bs.get_list(order_by=['as.shortname']) But Django is telling me that there is no table named 'as'. Everything seems to be importing fine. Does anyone have any hints? thanks, jtm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Table not found error when ordering by foreign key
Hi Adrian, Thanks for the reply. I did try using the full table names without success. This is the error and traceback (with real class names): OperationalError at /debtors/current/ (1109, "Unknown table 'matterlist_matters' in order clause") Traceback (most recent call last): File "/opt/local/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/Users/jimmy/simpsons/debtors/views.py" in debtorlist 29. dbtrs = debtreports.get_list(order_by=ordering) File "/opt/local/lib/python2.4/site-packages/django/utils/functional.py" in _curried 3. return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/opt/local/lib/python2.4/site-packages/django/core/meta/__init__.py" in function_get_list 1396. return list(function_get_iterator(opts, klass, **kwargs)) File "/opt/local/lib/python2.4/site-packages/django/core/meta/__init__.py" in function_get_iterator 1379. cursor.execute("SELECT " + (kwargs.get('distinct') and "DISTINCT " or "") + ",".join(select) + sql, params) File "/opt/local/lib/python2.4/site-packages/django/core/db/base.py" in execute 10. result = self.cursor.execute(sql, params) File "/opt/local/lib/python2.4/site-packages/django/core/db/backends/mysql.py" in execute 32. return self.cursor.execute(sql, params) File "/opt/local/lib/python2.4/site-packages/MySQLdb/cursors.py" in execute 137. self.errorhandler(self, exc, value) File "/opt/local/lib/python2.4/site-packages/MySQLdb/connections.py" in defaulterrorhandler 33. raise errorclass, errorvalue the local vars for my view show: ordering('matterlist_matters.code',) I'm running revision 2524. Everything else is working fine (ordering by fields in the class in the app, ordering using a full table name - debtors_debtreports.fees_to_date - for a class in the app, and tracing relationships in the template - debtor.get_matter.get_client.name), it's just when I am ordering by a field in a ForeignKey, or a field in the ForeignKey of a ForeignKey. Am I expecting too much magic and should I be doing some SQL and/or python myself to handle this kind of ordering (not to mention the grouping which I haven't got to yet, and aggregates). thanks again, jimmy --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Solved: Table not found error when ordering by foreign key
My original question (http://groups.google.com/group/django-users/browse_frm/thread/1581881fb9c1ddc1/#): Here is a simplified version of what I am trying to do: App X: class A: shortname = meta.CharField(maxlength=6) App Y: class B: the_A = meta.ForeignKey(A) Y.views: blist = bs.get_list(order_by=['as.shortname']) But Django is telling me that there is no table named 'as'. Everything seems to be importing fine. Does anyone have any hints? I even used fully qualified table names (eg bs.get_list(order_by=['x_as.shortname']) ). The answer was: blist = bs.get_list(order_by=['as.shortname'], select_related=True) Looking at the generated SQL in db.queries, adding select_related makes Django bring in every field in every related table, thereby making any field you wish available for use by the ORDER BY clause. Not the most efficient query for my purposes, but it will do for now. jtm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: numeric formatting
Quick and nasty: from django.core import template register = template.Library() @register.filter(name='commas') def commas(value): return "".join(commafy(value)) def commafy(s): pieces = s.split(".") l = len(pieces[0]) for i in range(0,l): if (l - i) % 3 or not i: yield pieces[0][i] else: yield "," yield pieces[0][i] if len(pieces) > 1: yield "." + pieces[1] value should be a string (eg your preformatted number). obviously does not care about your locale. jtm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Improving performance of lighttpd, flup and django-fcgi.py combo
Hi, I've just got lighttpd running under Mac OS X 10.3.9 and I am using Georg Bauer's django-fcgi.py as the dispatcher. django is .91. The machine I am running it on is, admittedly, pretty lightweight (G4 400 MHz, 832MB), but I have not seen much improvement over the development server. The pages are obviously being streamed faster once they are ready, but there is a noticeable delay at the beginning of the request. Does this combination of software mean that for every request django is starting from scratch and having to re-import everything? If yes, is there any way around this? If no, are there any hints I need that I am not going to find in the docs? regards, jtm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Improving performance of lighttpd, flup and django-fcgi.py combo
James Bennett wrote: > On 4/6/06, jtm <[EMAIL PROTECTED]> wrote: > > Does this combination of software mean that for every request > > django is starting from scratch and having to re-import everything? > > No, pretty much the whole point of FastCGI is that you have a > long-running process which handles lots of requests, rather than > starting up and shutting down on every request. I haven't noticed any > particular speed problems with running Georg's script, but I've also > been running it on a shared hosting account that has a pretty beefy > server. That's what I figured, but the big delay at the request has me stumped. Does anybody have any hints on how I should go about finding the bottleneck? jtm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---