Re: How to use form fields
Limodou, Thanks a lot.That is what I need. Regards, L. --~--~-~--~~~---~--~~ 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: apache threading - 'QueryDict' object has no attribute '_mutable'
The patch is in the Trac: http://code.djangoproject.com/ticket/1539. I've submitted both versions for the Django trunk and the magic-removal branch. Big thanks to Alex Brown for finding the bug and testing the fix. Thanks, Eugene Alex Brown wrote: > Ivan Sagalaev wrote: >> I think so too... I was investigating Alex's report and it looks like >> somewhere onr thread is creating a QueryDict and another tries to access >> it while it's being created. It's the only place where it doesn't >> contain self._mutable. >> >> This may mean that mod_python somehow supplies shared request object >> which it shouldn't. On a mod-python list I saw a suggestion >> (http://www.modpython.org/pipermail/mod_python/2003-October/014398.html): >> >>> It means your Python that mod_python was built against doesn't support >>> threads. You might have a thread.py module under your python libs dir >>> but that doesn't mean your python supports threads. >>> >>> Go the the mod_python page, get the appropriate version per your apache >>> version, and then get EXACTLY the version of Python recommended. Build >>> this python in your source tree (with threads!) and mod_python against >>> this. Everything will work fine. >>> >> But I didn't put it here since it's to unfounded :-). Alex, could you >> check these versioning issues anyway? > > Ivan, > > My python and mod_python were both compiled with threading. Whilst > investigating these issues I did find mention in a few posts that > mod_python 3.1.4 and earlier having some thread related bugs. I was > running 3.1.3 and when I upgraded to 3.2.5b at least one of my apache > crashing issues seemed to disappeared. > > Eugene's patch did also seem to resolve the QueryDict issue I reported. > > Thanks > > Alex > > > > --~--~-~--~~~---~--~~ 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: Advice on developing with django for a team of 10+
tonemcd wrote: > Oooh, now that's neat. My own tinkering with svn to ignore .pyc files > hasn't worked out so well... > > % svn proplist > Properties on '.': > svn:ignore "svn proplist -v" prints the property value as well. > % svn st > M magic/site1/modeltest/models.pyc > > hmmm... unless you removed some whitespace from that output, the fact that the "M" appears in the first column means that the file is already checked into subversion. svn:ignore doesn't affect stuff that you've already checked in. to get rid of the PYC files, you have to use "svn delete". --~--~-~--~~~---~--~~ 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: Extreme file uploading
arthur debert wrote: >Regarding memory usage on the server, AFAIK this is something related >to cgi.FieldStorage. more about this here: >http://groups.google.com/group/django-developers/browse_frm/thread/2c379ec0fa30804a/# > >It would be great to have a streaming option, but aparentely this is >trickier than it seems. > Why that? The patch is there and is working (I'm using it in my current project). The only problem (that doesn't happen with real files though) is that the file still can be uploaded entirely in memory as Django does currently anyway. But nothing disasterous :-) --~--~-~--~~~---~--~~ 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: Preformatted text in templates
On 3/25/06, Hari <[EMAIL PROTECTED]> wrote: > > Hi, > > I am quite new to Django; been working on an app using Django for 3-4 > days. > > I have a need to show large piece of text as is. I had issues with > linebreaks, which I solved using > {{ text|linebreaks }} > > Now, the problem is with whitespaces. I have to display them as is. > > One of the solutions is to surround {{text}} with tag. > Is there any other way (a filter or something) that can achieve the > same? > > Thanks > -Hari > I'v write something to do this thing, you can change it to a custom filter: import re import cgi re_string = re.compile(r'(?P[<&>])|(?P^[ \t]+)|(?P\r\n|\r|\n)|(?P\b((http|ftp)://.*?))(\s|$)', re.S|re.M|re.I) def plaintext2html(text, tabstop=4): def do_sub(m): c = m.groupdict() if c['htmlchars']: return cgi.escape(c['htmlchars']) if c['lineend']: return '' elif c['space']: t = m.group().replace('\t', ''*tabstop) t = t.replace(' ', '') return t elif c['space'] == '\t': return ' '*tabstop; else: last = m.groups()[-1] if last in ['\n', '\r', '\r\n']: last = '' return '%s%s' % (c['protocal'], c['protocal'], last) return re.sub(re_string, do_sub, text) -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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: apache threading - 'QueryDict' object has no attribute '_mutable'
Ivan Sagalaev wrote: > I think so too... I was investigating Alex's report and it looks like > somewhere onr thread is creating a QueryDict and another tries to access > it while it's being created. It's the only place where it doesn't > contain self._mutable. > > This may mean that mod_python somehow supplies shared request object > which it shouldn't. On a mod-python list I saw a suggestion > (http://www.modpython.org/pipermail/mod_python/2003-October/014398.html): > > >It means your Python that mod_python was built against doesn't support > >threads. You might have a thread.py module under your python libs dir > >but that doesn't mean your python supports threads. > > > >Go the the mod_python page, get the appropriate version per your apache > >version, and then get EXACTLY the version of Python recommended. Build > >this python in your source tree (with threads!) and mod_python against > >this. Everything will work fine. > > > But I didn't put it here since it's to unfounded :-). Alex, could you > check these versioning issues anyway? Ivan, My python and mod_python were both compiled with threading. Whilst investigating these issues I did find mention in a few posts that mod_python 3.1.4 and earlier having some thread related bugs. I was running 3.1.3 and when I upgraded to 3.2.5b at least one of my apache crashing issues seemed to disappeared. Eugene's patch did also seem to resolve the QueryDict issue I reported. Thanks Alex --~--~-~--~~~---~--~~ 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: Need help for query, how could i do this with django ? or a raw SQL.
On 3/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > coulix wrote: > > Hello, > > I was trying to play with custom query but i didnt manage to get it > > working, > > I too could not get the custom query from the API reference working: > > polls.get_list( > select={ > 'choice_count': 'SELECT COUNT(*) FROM choices WHERE poll_id = > polls.id' > } > ) > > Trying the query in a 0.91/MySQL installation on both Mac OS X and an > NT box generated the same error. (Since there's a single quote, a > backtick and a double quote in the error message, it seems something is > wonky in the behind-the-scenes query quoting.) There's a closing parenthesis as well (after polls.id): > ProgrammingError: (1064, "You have an error in your SQL syntax. Check > the manual that corresponds to your MySQL server version for the right > syntax to use near 'SELECT COUNT(*) FROM choices WHERE poll_id = > polls.id) AS `choi") But then, you are putting polls.id in your query, and you are not selecting from a polls table, so something is not right there. Maybe you need a JOIN, or is polls.id supposed to be a Python attribute reference? If so, it can't go directly in SQL. -- The Pythonic Principle: Python works the way it does because if it didn't, it wouldn't be Python. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Preformatted text in templates
Hi, I am quite new to Django; been working on an app using Django for 3-4 days. I have a need to show large piece of text as is. I had issues with linebreaks, which I solved using {{ text|linebreaks }} Now, the problem is with whitespaces. I have to display them as is. One of the solutions is to surround {{text}} with tag. Is there any other way (a filter or something) that can achieve the same? Thanks -Hari --~--~-~--~~~---~--~~ 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: Advice on developing with django for a team of 10+
On Thu, Mar 23, 2006 at 09:23:30AM -0800, tonemcd wrote: > Oooh, now that's neat. My own tinkering with svn to ignore .pyc files > hasn't worked out so well... The way I did it was to edit my ~/.subversion/config file. There is a section, "[miscellany]" that includes a "global-ignores" option. Just add "*.pyc" to this space separated list. Unfortunately this is a per-user solution, but you could add this to the user skeleton or just tell everyone to adjust this setting. Nate --~--~-~--~~~---~--~~ 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: RSS Feeds - what am I doing wrong?
I'm looking but I don't see anything you are doing wrong. It's been a while since I implemented my feeds and I vaguely remember maybe getting an error like that at one point. What you have looks a lot like what I have that works though. Sorry, I'm not helping much here, but I guess I didn't want you to think you're being ignored. Bryan On 3/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi. > > I'm trying to put together a feed for a specific blog in my system. > I've been following the example at > http://www.djangoproject.com/documentation/syndication/#a-complex-example > > Unfortunately, when I access the feed, I get: > > - - - - - - - - - - - - - - - - - - - - - - - - > TypeError at /rss/blog/1/ > items() takes exactly 2 arguments (1 given) > Request Method: > GET > Request URL: > http://localhost:8000/rss/blog/1/ > Exception Type: > TypeError > Exception Value: > items() takes exactly 2 arguments (1 given) > Exception Location: > /usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/contrib/syndication/feeds.py > in __get_dynamic_attr, line 38 > - - - - - - - - - - - - - - - - - - - - - - - - > > Here's the feed implementation: > > - - - - - - - - - - - - - - - - - - - - - - - - > # Die neuesten Einträge in einem bestimmten Blog > class BlogFeed(Feed): > > def get_object(self, bits): > if len(bits) != 1: > raise ObjectDoesNotExist > return blogs.get_object(id__exact=bits[0]) > > def title(self, obj): > return "www.trogger.de - Neue Beiträge in %s" % obj.title > > def link(self, obj): > return "/world/blog/%s" % obj.id > > def description(self, obj): > return "Neue Einträge in %s -- Blog von %s" % ( obj.title, > obj.get_author().get_full_name) > > def items(self, obj): > return submissions.get_list(blog__id__exact = obj.id, > order_by=('-date_submitted',), limit=5) > - - - - - - - - - - - - - - - - - - - - - - - - > > According to the docs, the RSS framework should be calling my > "items(self, obj):" method. Unfortunately, it seems to be only looking > for "items(self)", which isn't there. > > My feeds definition is: > feeds = { > 'travelreports': LatestTravelReports, > 'newblogs': NewBlogs, > 'blog': BlogFeed, > 'blogentries': LatestBlogEntries, > } > > so for /rss/blog/1/ it should be calling my BlogFeed implementation. > > The "simple" feeds (with no parameters) work fine, by the way. > > Django release is "Django-0.91-py2.4.egg" > > Can someone please point out my mistake? I'm sure it's a case of not > seeing the forest for the trees. > > Thanks, > > Daniel > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: trying to get my first app up.
On Friday 24 March 2006 16:49, sergio_101 wrote: > but no matter what happens, i get this: > > ViewDoesNotExist at /opps/ > Could not import learningOpps.opps.views. Error was: cannot import > name opps > > can someone tell me what i am doing wrong? Have you created __init__.py files in the relevant directories? Luke -- A dyslexic agnostic doesn't believe in Dog Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ASCII or PDF version of docs?
Is there an ASCII or PDF version of the documentation? Specially installation, tutorial and overview. Tried to print them, but any line that is long, gets cutoff when printing from my FreeBSD desktop at work.. Will try a windows machine at home.. but it would be nice if the documentation was available in other formats. Worst case will try an HTML -> ASCII tool and then format. If there isn't PDF available yet, would it be helpfull if I made PDFs for overview, installation and tutorial? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
syntax error with tutorial1 in "python manage.py sql polls" step
Hi, at the ''python manage.py sql polls'' step of the [http://www.djangoproject.com/documentation/tutorial1/ poll tutorial] I get a syntax error: {{{ [EMAIL PROTECTED]:~/code/djtutor$ python manage.py sql polls Traceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1051, in execute_manager execute_from_command_line(action_mapping) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1017, in execute_from_command_line mod_list = [meta.get_app(app_label) for app_label in args[1:]] File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py", line 76, in get_app return __import__('%s.%s' % (MODEL_PREFIX, app_label), '', '', ['']) File "/usr/lib/python2.4/site-packages/django/models/__init__.py", line 13, in ? modules = meta.get_installed_model_modules(__all__) File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py", line 111, in get_installed_model_modules mod = __import__('django.models.%s' % submodule, '', '', ['']) File "/home/matt/code/djtutor/../djtutor/polls/models/polls.py", line 12 ^ SyntaxError: invalid syntax }}} if I remove the poll addition to the INSTALLED_APPS section of settings.py, it works again: Works: {{{ INSTALLED_APPS = ( ) }}} Doesn't: {{{ INSTALLED_APPS = ( 'djtutor.polls', ) }}} any idea what I've done wrong? --~--~-~--~~~---~--~~ 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: Assigning default value for field in admin
If I read you right: http://www.djangoproject.com/documentation/faq/#how-do-i-automatically-set-a-field-s-value-to-the-user-who-last-edited-the-object-in-the-admin I've solved almost this problem in an app, but that's because I would get the user from the session cookie and put it on the request for the form to be "auto-filled". It seems there's no out of the box way to achieve this. -arthur --~--~-~--~~~---~--~~ 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: Need help for query, how could i do this with django ? or a raw SQL.
coulix wrote: > Hello, > I was trying to play with custom query but i didnt manage to get it > working, I too could not get the custom query from the API reference working: polls.get_list( select={ 'choice_count': 'SELECT COUNT(*) FROM choices WHERE poll_id = polls.id' } ) Trying the query in a 0.91/MySQL installation on both Mac OS X and an NT box generated the same error. (Since there's a single quote, a backtick and a double quote in the error message, it seems something is wonky in the behind-the-scenes query quoting.) ProgrammingError: (1064, "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT COUNT(*) FROM choices WHERE poll_id = polls.id) AS `choi") John --~--~-~--~~~---~--~~ 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: Extreme file uploading
Hi Andy. Regarding memory usage on the server, AFAIK this is something related to cgi.FieldStorage. more about this here: http://groups.google.com/group/django-developers/browse_frm/thread/2c379ec0fa30804a/# It would be great to have a streaming option, but aparentely this is trickier than it seems. I guess there's quite a few people with this kind on need hanging around this list... so maybe a solution can be implemented. I am not uploading anything near 200MB, but 8 MB with no progress feeback and no resume is pretty scary for me. Maybe at 200 MB you should try ftping it? Off topic, has anyone seen dropsend (http://dropsend.com/)? they've managed to get a reliable progress bar... cheers, arthur --~--~-~--~~~---~--~~ 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: admin apache
On 3/24/06, abe <[EMAIL PROTECTED]> wrote: > I get a blank screen (in the browser) and the > httpd error logs say : > > [Fri Mar 24 18:36:09 2006] [notice] mod_python: (Re)importing module > 'django.core.handlers.modpython' > [Fri Mar 24 18:36:17 2006] [notice] child pid 13817 exit signal > Segmentation fault (11) > > does anybody have an idea what goes wrong? Hey there, Check out the Django/mod_python docs for some possible explanations/solutions. http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault 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 -~--~~~~--~~--~--~---
Extreme file uploading
I'm working on a little app to manage a podcast RSS feed (believe it or not, someboody actually edits it by hand now). So my first thought was to use the FileField for uploading the enclosure. This worked fine except for one issue: The podcast in question is for video, and the files are typically 200 MB. I watched top while uploading one of these and the mini-dev server went up to 1.5 GB resident (good thing I had 2 GB of RAM), but obviously this presents a problem. I don't know if apache/mod_python would work any better or not. I'm guessing the django server simply reads the entire request into memory and then parses, while apache may start writing to a temp file somewhere. Anyway. To work around this particular problem I changed it to a FilePathField and stipulated that the files (which were already on the server) would be uploaded by some other means. There are a couple problems with this: 1) You lose all the nice get_*_url(), get_*_size() and friends that FileField gives you. 2) To use an existing directory structure, I had to use the recursive option, but it seems that the value that is stored loses any subdirectory name between the path and the actual file. I filed a bug with a patch for this (magic-removal): http://code.djangoproject.com/ticket/1536 3) It stores the complete path in the database, and there's no obvious way to trim the path down so you can paste the subdirectory/filename onto the end of a URL short of repeating yourself and manually clipping off the initial path, and there's no way I can see to get that value out of the model. i.e. If I am using: enclosure = models.FilePathField(path="/var/media/podcasts", recursive=True, match="\.mp4$") and I select the file /var/media/podcasts/banking/commercial.mp4, there's not a way I can get it to just chop off the original path. I suppose I could do this: PODCAST_PATH = '/var/media/podcasts' ... enclosure = models.FilePathField(path=PODCAST_PATH, recursive=True, match="\.mp4$") def get_enclosure_uri(self): return enclosure[len(PODCAST_PATH):] and then use {{ MEDIA_URL }}/{{ object.get_enclosure_uri }} in the template. (or something like that) Any other suggestions? Maybe a variant of FileField or an additional option that disables upload in the admin interface but let's you pick matching files out of MEDIA_ROOT? -- The Pythonic Principle: Python works the way it does because if it didn't, it wouldn't be Python. --~--~-~--~~~---~--~~ 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
On Friday 24 March 2006 12:23, Jacob Kaplan-Moss wrote: > > I don't think that python built-in formatting can do this. (Am I > > wrong?) > > Actually, locale.format will do it for you, IIRC. >>> import locale >>> locale.setlocale(locale.LC_ALL, '') 'en_US.UTF-8' >>> locale.format("%d", 1234567, True) '1,234,567' --~--~-~--~~~---~--~~ 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
On Mar 24, 2006, at 1:48 PM, Rock wrote: > Is there a template filter for turning a large integer into a human > readable number? > > 1234567 --> 1,234,567 > 12345 --> 12,345 > > I don't think that python built-in formatting can do this. (Am I > wrong?) Actually, locale.format will do it for you, IIRC. But there's not a Django filter for it (probably should be, though...) > Assuming there isn't already a simple filter that will do this, > what do > I need to learn about in order to create my own filter? You want the template language for Python programmers doc, and specificaly the part about writing filters: http:// www.djangoproject.com/documentation/templates_python/#writing-custom- template-filters Jacob --~--~-~--~~~---~--~~ 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: How to change naming convention when creating models?
On Mar 24, 2006, at 1:33 PM, sam wrote: > Waht about the table names? I'd like to remove the 's' at the end of > each name. You want to "db_table" option; this is documented in the Model API doc at http://www.djangoproject.com/documentation/model_api/#meta- options Jacob --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
numeric formatting
Is there a template filter for turning a large integer into a human readable number? 1234567 --> 1,234,567 12345 --> 12,345 I don't think that python built-in formatting can do this. (Am I wrong?) Assuming there isn't already a simple filter that will do this, what do I need to learn about in order to create my own filter? Rock --~--~-~--~~~---~--~~ 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: How to change naming convention when creating models?
Adrian, Thanks for your reply. Waht about the table names? I'd like to remove the 's' at the end of each name. Regards, Sam --~--~-~--~~~---~--~~ 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: How to change naming convention when creating models?
On 3/24/06, sam <[EMAIL PROTECTED]> wrote: > I'd like to change the naming convention when creation Django models. > For instance I don't want to append "_id" to the foreign key field > name. It is apparently possible to change this behavior. Hi Sam, You can't change the naming convention on a global level, but you can manually override the name of the database column by specifying "db_column" in the field parameters. For example: foo = meta.ForeignKey(Foo, db_column='foo') The docs are here: http://www.djangoproject.com/documentation/model_api/#general-field-options 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 -~--~~~~--~~--~--~---
Assigning default value for field in admin
Hi there, i'm currently writing my first Django application. I must say that Django is really what i've been searchin for for years. Right now I have a problem concerning the usage of the admin interface. I have a model like this: from django.core import meta from django.models.auth import users class Series(meta.Model): name = meta.CharField(maxlength=255, primary_key=True) contributor = meta.ForeignKey(users.User) #... When editing or creating a new object of class Series i would like Django to automatically insert the current logged in user as the "contributor". I dont see any way to do this inside the class definition. Hope you guys can help me here. Thanks a lot in advance, Daniel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
admin apache
hi, trying to use the admin site vi apache/mod_python/mysql I get a blank screen (in the browser) and the httpd error logs say : [Fri Mar 24 18:36:09 2006] [notice] mod_python: (Re)importing module 'django.core.handlers.modpython' [Fri Mar 24 18:36:17 2006] [notice] child pid 13817 exit signal Segmentation fault (11) does anybody have an idea what goes wrong? -E --~--~-~--~~~---~--~~ 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: apache threading - 'QueryDict' object has no attribute '_mutable'
Ivan Sagalaev wrote: >> > I think so too... I was investigating Alex's report and it looks like > somewhere onr thread is creating a QueryDict and another tries to access > it while it's being created. It's the only place where it doesn't > contain self._mutable. > > This may mean that mod_python somehow supplies shared request object > which it shouldn't. On a mod-python list I saw a suggestion I reproduced it in python interpreter. I don't think it is mod_python-related problem. There are two problems as far as I can tell: 1) QueryDict uses the hacks with class-level variables, which are reassigned temporarily during copy(). Its base class (MultiValueDict) does the same. It's a no-no for multithreaded programming. The same goes for module-level variables. In short: all changes to common variables should be analyzed and synchronized, or avoided. The latter is the best approach. 2) copy.deepcopy() doesn't like to be fooled with dynamic class modifications, e.g. with replacing __setitem__. Example: = class Ex(dict): def __init__(self, mutable=True): dict.__init__(self) self._mutable = mutable def _setitem_if_mutable(self, key, value): print 'Setting', key, 'to', value self._assert_mutable() dict.__setitem__(self, key, value) __setitem__ = _setitem_if_mutable def _assert_mutable(self): if not self._mutable: raise AttributeError, "This Ex instance is immutable" def copy(self): "Returns a mutable copy of this object." import copy # Our custom __setitem__ must be disabled for copying machinery. old_mutable = self._mutable self._mutable = True cp = copy.deepcopy(self) self._mutable = old_mutable return cp a = Ex() # it works fine # a is fully functional b = a.copy() # it works fine # b is fully functional c = b.copy() # it blows: AttributeError: 'Ex' object has no attribute '_mutable' c = a.copy() # it works fine = Try to play with it. The right way to handle copy/deepcopy is to define proper ___copy__/__deepcopy__ methods, or to define custom pickling helpers. Incidentally it was a point of the hacks in #1. I implemented a patch for #1 and #2, and sent it to Alex. If he confirms it, I'll create a ticket. Otherwise I'll dig more. I am afraid we'll find more places with class-level (like this) or module-level (like in uncommitted #1442 patch) variables. Thanks, Eugene --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to change naming convention when creating models?
Hi All, I'd like to change the naming convention when creation Django models. For instance I don't want to append "_id" to the foreign key field name. It is apparently possible to change this behavior. Thanks in advance. Regards, Sam --~--~-~--~~~---~--~~ 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: OneToOneField
OK, you do, not the original poster. Anyway, I've heard that subclassing has been improved in MR. Why don't you use that instead ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
trying to get my first app up.
i am having a rough time getting my first app running.. i made a new project called "learningOpps" the admin works fine.. i set up a new application called "opps".. everything seems to have built just fine.. the problem is.. now, i added this to my urls: (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': '/path/to/LearningOppsDjango/learningOpps/media'}), so i can serve the images on my development server.. (r'^opps/$','learningOpps.opps.views.index') to handle http://127.0.0.1:8080/opps i added this to my views in opps(opps/views): from django.models.opps import opps from django.utils.httpwrappers import HttpResponse from django.core.template import Context, loader from django.core.extensions import render_to_response def index(request): return render_to_response() but no matter what happens, i get this: ViewDoesNotExist at /opps/ Could not import learningOpps.opps.views. Error was: cannot import name opps can someone tell me what i am doing wrong? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Need help for query, how could i do this with django ? or a raw SQL.
Dropping down to the raw SQL level is easy... Assuming my_sql_command is a string with your select statement... from django.core.db import db cursor = db.cursor() cursor.execute( my_sql_command ) row = cursor.fetchone() result = row[0] You might prefer fetchall(), but I leave the data gathering details to you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
How to use form fields
I use a custom manipulator that creates field_names.These filed names can be a different. To create fields I use formfields.IntegerField(field_name="Pieces_"+`v`, maxlength=4) where Dynamic_value changes. Normaly, for static field, I can use in a form {{form.FieldName}}. If fileds are generated in a dynamic way, how can I use it in a form? For example my custom manipulator can create {{form.ID_1}} only but also {{form.ID_2}},{{form.ID_3}} ... etc. So, is there a list where all fields are? Thanks. L. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RSS Feeds - what am I doing wrong?
Hi. I'm trying to put together a feed for a specific blog in my system. I've been following the example at http://www.djangoproject.com/documentation/syndication/#a-complex-example Unfortunately, when I access the feed, I get: - - - - - - - - - - - - - - - - - - - - - - - - TypeError at /rss/blog/1/ items() takes exactly 2 arguments (1 given) Request Method: GET Request URL: http://localhost:8000/rss/blog/1/ Exception Type: TypeError Exception Value: items() takes exactly 2 arguments (1 given) Exception Location: /usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/contrib/syndication/feeds.py in __get_dynamic_attr, line 38 - - - - - - - - - - - - - - - - - - - - - - - - Here's the feed implementation: - - - - - - - - - - - - - - - - - - - - - - - - # Die neuesten Einträge in einem bestimmten Blog class BlogFeed(Feed): def get_object(self, bits): if len(bits) != 1: raise ObjectDoesNotExist return blogs.get_object(id__exact=bits[0]) def title(self, obj): return "www.trogger.de - Neue Beiträge in %s" % obj.title def link(self, obj): return "/world/blog/%s" % obj.id def description(self, obj): return "Neue Einträge in %s -- Blog von %s" % ( obj.title, obj.get_author().get_full_name) def items(self, obj): return submissions.get_list(blog__id__exact = obj.id, order_by=('-date_submitted',), limit=5) - - - - - - - - - - - - - - - - - - - - - - - - According to the docs, the RSS framework should be calling my "items(self, obj):" method. Unfortunately, it seems to be only looking for "items(self)", which isn't there. My feeds definition is: feeds = { 'travelreports': LatestTravelReports, 'newblogs': NewBlogs, 'blog': BlogFeed, 'blogentries': LatestBlogEntries, } so for /rss/blog/1/ it should be calling my BlogFeed implementation. The "simple" feeds (with no parameters) work fine, by the way. Django release is "Django-0.91-py2.4.egg" Can someone please point out my mistake? I'm sure it's a case of not seeing the forest for the trees. Thanks, Daniel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: OneToOneField
That would be why yours works, this is specific to MR as stated above. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Need help for query, how could i do this with django ? or a raw SQL.
Hello, I was trying to play with custom query but i didnt manage to get it working, for example this one whcih i found on the mail list : Polls.get_list( select={ 'choice_count': { db_table='choices', db_columns=['COUNT(*)'] kwargs={ where=['poll_id=polls.id'] } } } ) the 'choice_count' its like a select stuff AS choice_count ? what is it used for. Then related to my model : i want the name of the top 5 users who wrote the most recipes. Here is my model RECIPE - name - stuf ect [...] - owner USER FK USER (from django) - name in sql i would do SELECT auth_users.username, COUNT(*) AS count FROM auth_users, recettes_recipes WHERE auth_users.id=recettes_recipes.owner_id GROUP BY username ORDER BY count DESC; My eternal respect to the solver. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Need help for query, how could i do this with django ? or a raw SQL.
Hello, I was trying to play with custom query but i didnt manage to get it working, for example this one whcih i found on the mail list : Polls.get_list( select={ 'choice_count': { db_table='choices', db_columns=['COUNT(*)'] kwargs={ where=['poll_id=polls.id'] } } } ) the 'choice_count' its like a select stuff AS choice_count ? what is it used for. Then related to my model : i want the name of the top 5 users who wrote the most recipes. Here is my model RECIPE - name - stuf ect [...] - owner USER FK USER (from django) - name in sql i would do SELECT auth_users.username, COUNT(*) AS count FROM auth_users, recettes_recipes WHERE auth_users.id=recettes_recipes.owner_id GROUP BY username ORDER BY count DESC; My eternal respect to the solver. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
MR Branch - list_filter with ForeignKey -- Help
Hi I am trying to get the list_filter to work with a ForeignKey field in the admin site. It works fine with with a standard charfield with choices, but when I move those values out into a seperate model and add the filter fields in to the list I dont get filters on the right hand side. I searched the forum, and cant see anything relevant. I also looked at the code and it should work in thoery. Any ideas ? My model looks like this: class Site(models.Model): name = models.CharField(maxlength=50) description = models.TextField(maxlength=200) class Admin: list_display = ('name', 'description') search_fields = ['name', 'description'] def __repr__(self): return "%s - %s" % (self.name, self.description) class Department(models.Model): name = models.CharField(maxlength=50) description = models.TextField(maxlength=200) class Admin: list_display = ('name', 'description') search_fields = ['name', 'description'] def __repr__(self): return "%s - %s" % (self.name, self.description) class TelDirEntry(models.Model): first_names = models.CharField(maxlength=150) last_name = models.CharField(maxlength=50) site = models.ForeignKey(Site, verbose_name='Office Location') department = models.ForeignKey(Department, verbose_name='Department') office_tel = models.CharField(maxlength=50) mobile_tel = models.CharField(maxlength=50, blank=True) home_tel = models.CharField(maxlength=50, blank=True) class Admin: list_display = ('first_names', 'last_name', 'site', 'department', 'office_tel') list_filter = ['last_name', 'department', 'site'] #search_fields = ['first_names', 'last_name', 'site', 'department', 'office_tel'] class Meta: verbose_name = 'Telephone Directory' verbose_name_plural = 'Telephone Directory Entries' def __repr__(self): return "%s %s" % (self.first_names, self.last_name) --~--~-~--~~~---~--~~ 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: OneToOneField
No, an up to date svn trunk. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
A newbie question about log files
Hi I am hosting my Django webapp on DreamHost. No real problems so far. And let me just say: I really like the work you've done with Django. Simple and cohesive. Anyway, back to my problem. As I said, everything works fine, but I am chasing this bug I only seem to have when I deploy. I do an AJAX call, and in some cases, I get back an HTTP 500. Ok, fine, Iithought, let me have a look at log files and see what the exact problem was... oops, but I can not find the log files. Been poking around for a while without success, so I was wondering if you could give me a helping hand. Apache error logs show nothing, and I was hoping to see at least as much output as generated by the test server (manage.py runserver). I'll appreciate you help. Thanks, Vladimir --~--~-~--~~~---~--~~ 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: OneToOneField
Hi Are you using the MR Branch for the OneToOne on User ? Thx, S --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: SQL Debugging and limit_choices_to in MR Branch
Glad you solved it, PS the patch wasnt done by me BTW. Kudos to Luke. --~--~-~--~~~---~--~~ 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: OneToOneField
Strange, OneToOne works pretty well for me to extend User model (I would prefer to subclass but without having new database tables). On the contrary, I had many problem with OneToOne to extend my own model(s), I use ForeignKey with intermediary model and Inline Edit instead. hth --~--~-~--~~~---~--~~ 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: apache threading - 'QueryDict' object has no attribute '_mutable'
Eugene Lazutkin wrote: >Alex: I'll look into this problem. Most probably there is a racing >condition in multithreaded Django. It doesn't look like it is related to >database backends. > I think so too... I was investigating Alex's report and it looks like somewhere onr thread is creating a QueryDict and another tries to access it while it's being created. It's the only place where it doesn't contain self._mutable. This may mean that mod_python somehow supplies shared request object which it shouldn't. On a mod-python list I saw a suggestion (http://www.modpython.org/pipermail/mod_python/2003-October/014398.html): >It means your Python that mod_python was built against doesn't support >threads. You might have a thread.py module under your python libs dir >but that doesn't mean your python supports threads. > >Go the the mod_python page, get the appropriate version per your apache >version, and then get EXACTLY the version of Python recommended. Build >this python in your source tree (with threads!) and mod_python against >this. Everything will work fine. > But I didn't put it here since it's to unfounded :-). Alex, could you check these versioning issues anyway? --~--~-~--~~~---~--~~ 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: Strings and % sign fails - Help Please
I see. Thanks, Sia --~--~-~--~~~---~--~~ 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: ManyToManyField corrupts headers
On 3/24/06, John Szakmeister <[EMAIL PROTECTED]> wrote: > This output occures before any legal HTTP header - so we get "Internal> Server Error"> May be it's just forgotten debug code?Caveat: I'm not a Django developer. I think you're right though, it's probably a bug, and it still exists on trunk/. I'd raise this on thedjango-dev@ list if you don't get any other replies.Sorry - I've been meaning to respond to this. It certainly looks like a bug to me. For the record, it has been fixed in the magic-removal stream. I would suggest logging this as a bug at code.djangoproject.com/newticket. Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: ManyToManyField corrupts headers
On Monday 20 March 2006 07:46, burivuh wrote: > Situation: > Django 0.91, common CGI through WSGI, many-to-many fields with only one > available choice > (for example, use flatpages and try to add new flat page - you'll see > error) > > Look at the line after #question target > > fields.py: > ManyToManyField: > def flatten_data(self, follow, obj = None): > new_data = {} [snip] >if len(choices_list) == 1: >#question target >print self.name, choices_list[0][0] >#end question target >new_data[self.name] = [choices_list[0][0]] > return new_data > > > This output occures before any legal HTTP header - so we get "Internal > Server Error" > May be it's just forgotten debug code? Caveat: I'm not a Django developer. I think you're right though, it's probably a bug, and it still exists on trunk/. I'd raise this on the django-dev@ list if you don't get any other replies. -John --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---