Re: apache prefork or worker? other settings
Aljosa, The docs are really good. ( http://www.djangoproject.com/documentation/modpython/ ) I can attest that you should definitely use prefork instead of worker. I was getting random crashes on our server until I realized that one of my admins installed worker. Switching to prefork fixed everything. Corey On Feb 28, 2008, at 5:04 AM, Aljosa Mohorovic wrote: > > i'm interested in apache/mod_python/memcached settings for django > site. > > do you use apache prefork or worker? what configuration options work > best for you? > > please share your settings and anything useful for production system. > > Aljosa > > --~--~-~--~~~---~--~~ 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: Deploying django framework with site
Tim, The django module just needs to be on the python path, which you can set in the mod_python configuration. So you could do something like: /My Site /myproject /site-packages /django Shouldn't be to difficult as long as you put both /My Site/myproject and /site-packages on the python path. Corey On Feb 8, 2008, at 7:43 AM, Tim Sawyer wrote: > > Folks, > > Has anyone got any documentation on deploying the django framework > as part of > the site? I'm considering using django for an app at work (on > Oracle - so > need SVN version?) and our release team will want a self contained > site to > deploy. They're used to WAR files and like them. It'll be a > struggle to get > them to install mod_python never mind getting a framework out of SVN! > > Ta, > > 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 -~--~~~~--~~--~--~---
Re: Unicode error
Kristian, I had a similar problem when I needed to send some ASCII emails. I have a snippet at does a translation of unicode characters to close ASCII approximations if it is helpful: http://www.djangosnippets.org/snippets/588/ Corey On Feb 5, 2008, at 3:48 PM, Kristian Øllegaard wrote: > Hi again > > Ok - my bad. > > Thanks a lot > > Regards > Kristian > > On Feb 5, 2008 9:29 PM, Jacob Kaplan-Moss > <[EMAIL PROTECTED]> wrote: > > On 2/5/08, Kristian Øllegaard <[EMAIL PROTECTED]> wrote: > > Is there an obvious thing i did wrong? Have you heard about this > error > > before? > > This is because of the changes in Unicode handling after 0.96; read > more here: > http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist > > In general, if you've upgraded from 0.96 you *need* to read the > backwards-incompatible changes list: > http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges. When > we release new versions, that list becomes the release notes, but if > you're running off a trunk checkout you need to be aware of the > changes. > > 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?hl=en -~--~~~~--~~--~--~---
Re: how to handle django static files(css js etc) properly.the views.static.serve or apache's SetHandler None just too eerie
I recommend this approach because it works seamlessly when transferring between production and development: 1. Put your static files in the repository (assuming you are using one) 2. On the production server, add these lines to the site config so this doesn't get used except on development boxes: Alias /static "/home/myproject/static" SetHandler None 3. At the end of your primary urls.py put: ( r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT} ), 4. In your settings file add: import os SETTINGS_FILE_FOLDER = os.path.dirname(__file__) MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'static') 5. I use it on all my projects so I can see the static files and modify them locally, but it seamlessly lets Apache serve them on the production server Corey On Jan 23, 2008, at 2:28 AM, mxl wrote: > > I recently deployed my dear Django on winows + apache +mod_python.. > following DjangoBook step by step everything is fine but one thing > the static file(css particularly) . > I need press F5 constantly to refresh my no-bug page to get the css > file down to show that page properly. > I tried views.static.serve failed. > tried separate a virual-host to serve the static file sololy failed > and completely out of any clue. > I'm a new comer to django hope you offer some help > ^_^ > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: CSS & Media files
mOne, I use a system that uses the main urls.py and a change on the apache site config. This allows me to have all the files in one repository and see it when I'm using the development server, but use apache to deliver the files when on the production server. in urls.py you put in: ( r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT} ), Then in the apache site config you put: Alias /static "/home/myproject/static" SetHandler None I hope that helps, corey On Jan 15, 2008, at 10:31 AM, mOne wrote: > > Hi, > > How do I "tell" Django to look in the mysite/admin directory for all > the css associated with my project and app. Using the default that is > in the site-packages directory would change the look to all projects > and apps I set up? > > mOne > > --~--~-~--~~~---~--~~ 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: Street address normalisation
I ported part of the Geo Street Address from the perl module: address_regex.py from geocode.address_dicts import * STREET_TYPE_REGEX = "|".join(STREET_TYPES.keys()) + "|" + "|".join(STREET_TYPES.values()) STATE_REGEX = "|".join(STATE_CODES.values()) DIRECTIONS_REGEX = "|".join(DIRECTIONS.keys()) + "|" + "|".join(DIRECTIONS.values()) ZIP_REGEX = "\\d{5}(?:-*\\d{4})?" ZIP_LOOSE_REGEX = "[\\d-]+" #To catch malformed zipcodes CORNER_REGEX = "(?:\\bAND\\b|\\bAT\\b|&|\\@)" UNIT_REGEX = "(?:(?:su?i?te|p\\W*[om]\\W*b(?:ox)?|dept|apt|ro*m|fl|apt| unit|box)\\W+|\#\\W*)[\\w-]+" NUMBER_REGEX = "\\d+-?\\d*" FRACTION_REGEX = "\\d+\/\\d+" # Possible street combinations: STREET_REGEX = """ (?: # special cases like 100 South Street (?: (?P""" + DIRECTIONS_REGEX + """)\\W+ (?P""" + STREET_TYPE_REGEX + """)\\b ) | (?:(?P""" + DIRECTIONS_REGEX + """)\\W+)? (?: (?P[^,]+) (?:[^\\w,]+(?P""" + STREET_TYPE_REGEX + """)\\b) (?:[^\\w,]+(?P""" + DIRECTIONS_REGEX + """)\\b)? | (?P[^,]*\\d) (?P""" + DIRECTIONS_REGEX + """) | (?P[^,]+?) (?:[^\\w,]+(?P""" + STREET_TYPE_REGEX + """)\\b)? (?:[^\\w,]+(?P""" + DIRECTIONS_REGEX + """)\\b)? ) )""" CITYSTATE_REGEX = """ (?: (?P[^,]+?),\\W+ (?P""" + STATE_REGEX +""")\\W* )?""" PLACE_REGEX = CITYSTATE_REGEX + """(?:(?P""" + ZIP_REGEX +"""))?""" ADDRESS_REGEX = """^\\W* (?P""" + NUMBER_REGEX + """)?\\W* (?:""" + FRACTION_REGEX + """\\W*)? # We don't need to keep the fractional part """ + STREET_REGEX + """\\W+ (?:""" + UNIT_REGEX + """\\W+)? # We don't need to keep a unit part """# + PLACE_REGEX + """\\W*$""" INTERSECTION_REGEX = "\\W*" + STREET_REGEX + \ "\\W*?\\s+" + CORNER_REGEX + "\\s+" \ + STREET_REGEX + "\\W+" \ + PLACE_REGEX <<< address_dicts.py DIRECTIONS = { "NORTH": "N", "NORTHEAST": "NE", "EAST": "E", "SOUTHEAST": "SE", "SOUTH": "S", "SOUTHWEST": "SW", "WEST": "W", "NORTHWEST": "NW", } STATE_CODES = { "ALABAMA": "AL", "ALASKA": "AK", "AMERICAN SAMOA": "AS", "ARIZONA": "AZ", "ARKANSAS": "AR", "CALIFORNIA": "CA", "COLORADO": "CO", "CONNECTICUT": "CT", "DELAWARE": "DE", "DISTRICT OF COLUMBIA": "DC", "FEDERATED STATES OF MICRONESIA": "FM", "FLORIDA": "FL", "GEORGIA": "GA", "GUAM": "GU", "HAWAII": "HI", "IDAHO": "ID", "ILLINOIS": "IL", "INDIANA": "IN", "IOWA": "IA", "KANSAS": "KS", "KENTUCKY": "KY", "LOUISIANA": "LA", "MAINE": "ME", "MARSHALL ISLANDS": "MH", "MARYLAND": "MD", "MASSACHUSETTS": "MA", "MICHIGAN": "MI", "MINNESOTA": "MN", "MISSISSIPPI": "MS", "MISSOURI": "MO", "MONTANA": "MT", "NEBRASKA": "NE", "NEVADA": "NV", "NEW HAMPSHIRE": "NH", "NEW JERSEY": "NJ", "NEW MEXICO": "NM", "NEW YORK": "NY", "NORTH CAROLINA": "NC", "NORTH DAKOTA": "ND", "NORTHERN MARIANA ISLANDS": "MP", "OHIO": "OH", "OKLAHOMA": "OK", "OREGON": "OR", "PALAU": "PW", "PENNSYLVANIA": "PA", "PUERTO RICO": "PR", "RHODE ISLAND": "RI", "SOUTH CAROLINA": "SC", "SOUTH DAKOTA": "SD", "TENNESSEE": "TN", "TEXAS": "TX", "UTAH": "UT", "VERMONT": "VT", "VIRGIN ISLANDS": "VI", "VIRGINIA": "VA", "WASHINGTON": "WA", "WEST VIRGINIA": "WV", "WISCONSIN": "WI", "WYOMING": "WY", } STREET_TYPES = { "ALLEE": "ALY", "ALLEY": "ALY", "ALLY": "ALY", "ANEX": "ANX", "ANNEX": "ANX", "ANNX": "ANX", "ARCADE": "ARC", "AV": "AVE", "AVEN": "AVE", "AVENU": "AVE", "AVENUE": "AVE", "AVN": "AVE", "AVNUE": "AVE", "BAYOO": "BYU", "BAYOU": "BYU", "BEACH": "BCH", "BEND": "BND", "BLUF": "BLF", "BLUFF": "BLF", "BLUFFS": "BLFS", "BOT": "BTM", "BOTTM": "BTM", "BOTTOM": "BTM", "BOUL": "BLVD", "BOULEVARD": "BLVD", "BOULV": "BLVD", "BRANCH": "BR", "BRDGE": "BRG", "BRIDGE": "BRG", "BRNCH": "BR", "BROOK": "BRK", "BROOKS": "BRKS", "BURG": "BG", "BURGS": "BGS", "BYPA": "BYP", "BYPAS": "BYP", "BYPASS": "BYP", "BYPS": "BYP", "CAMP": "CP", "CANYN": "CYN", "CANYON": "CYN", "CAPE": "CPE", "CAUSEWAY": "CSWY", "CAUSWAY": "CSWY", "CEN": "CTR", "CENT": "CTR", "CENTER": "CTR", "CENTERS": "CTRS", "CENTR": "CTR", "CENTRE": "CTR", "CIRC": "CIR", "CIRCL": "CIR", "CIRCLE": "CIR", "CIRCLES": "CIRS", "CK": "CRK", "CLIFF": "CLF", "CLIFFS": "CLFS", "CLUB": "CLB", "CMP": "CP", "CNTER": "CTR", "CNTR": "CTR", "CNYN": "CYN", "COMMON": "CMN", "CORNER": "COR", "CORNERS": "CORS", "COURSE": "CRSE", "COURT": "CT", "CO
Anyone attending the Web 2.0 Conference?
I see that Adrian is going to be at Web 2.0 next week. Anyone else going to be in town for a Birds of a Feather? Thanks, Corey --~--~-~--~~~---~--~~ 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: Left Joins / Inheritance / Plugins ...whatever...
Mike, What comes to mind is an intermediary table, a Many-to_many table. Design 1: This design depends on a separate Model that lists the available plugins, but would require a manual join of the plugin_table_id to the appropriate model/table. The plugin model tells you which type of link you are doing. PatronPluginLink patron = ForeignKey(Patron) plugin = ForeginKey(Plugins) plugin_table_id = IntegerField() Design 2: This is easier to model, but more restrictive. The downside is you have to add fields to this table when you add plugins. PatronActivities patron = ForeignKey(Patron) auditioner = ForeignKey(Auditioner) ticketpurchase = ForeignKey(TicketPurchse) ... But these are just off the top of my head. Hope they could help. Corey On Mar 29, 2007, at Thu Mar 29, 8:35 PM, Michael Cuddy wrote: > > > Hard to come up with an appropriate subject for this question.. > > Here's the issue: > > (The site is a small-theater company management app) > I have a model 'Patrons' which encapsulates all of the people that > I want > to track in my site. A Patron is anyone who's done anything with- > or-for > the theater company. In order that I don't have to keep track of > all kinds of information for all kinds of Patrons, I want to have > 'plugins' which 'attach' to the Patron record. For example, when > someone > signs up to audition for a show, they get an "Auditioner" object > attached to their Patron object. The "Auditioner" object encapsulates > information that the director of the show will need (when, voice type, > age, height, etc.) things that we normally don't care about for most > patrons. Most patrons will going to shows, so they will have > "TicketPurchase" > objects attached to their Patron object, keeping track of all of the > ticket purchases that person has made. > > My initial thought is something like this: > > class Patron(models.Model): > last_name = models.CharField( ... ) > first_name = models.CharField( ... ) > addr = models.CharField( ... ) > .. etc .. > > > class Auditioner(models.Model): > patron = models.ForeignKey(Patron) > > audition_date = models.DateTimeField( ... ) > .. etc .. > > > class TicketPurchase(models.Model): > patron = models.ForiegnKey(Patron) > > num = models.IntegerField(...) > show = models.ForeignKey(shows.Show) > .. etc .. > > > Now what I want to display in a list view of patrons is: > > Last, First ... Audition? TicketPurchase? > Cuddy, Michael YY > Smith, John NY > ... > > Where the 'Y' (or 'N') indicates whether or not the Patron has that > particular kind of data attached to their Patron object (and in a > real site > would be links to go look at / modify that data). Not all patrons > will have all plugins associated (Also, ideally, the view for patrons > would not know 'ahead of time' what all of the plugins were -- new > ones should > be able to be added at a later date and not disrupt the existing data. > > The number of patrons will run into the thousands. The number of > 'plugins' > is initially planned to be around 10-15. > > My zero'th thought was some kind of object inheritance, but django > doesn't support that, and it's messy, and, and, and ... so I didn't > really > think about that too much :-) > > My first thought was LEFT JOIN'ing the tables, but that has a > number of > issues: first, it drops to raw SQL and kind of violates the django- > ness (!?) > of the site. Second, LEFT JOINs with more than a couple of tables > starts to be a real performance bottleneck. > > My next thought was that since the primary access for lists of > people will be through the patron model (frankly, most of the queries > will be alphabetical or searching for a specific patron by name), > so when generating a view of patrons, it's probably not that bad > to just do the individual queries for each record displayed on a > particular page hit. I could probably come up with a > 'patron_id__in = [..]' > type query and run that across the plugins which would allow me to > do one > query per plugin once the set of Patrons to show on a particular > page has > been determined; and that's not too bad. > > However, I'm interested in any ideas anyone else might have for this. > > One more (maybe) cog in the works: some plugins (like the > aforementioned > "Auditioner" and "TicketPurchase" will have many entries per Patron. > Some plugins, like "Staff", the one which holds login auth information > will be one-entry per Patron. > > -- > Mike Cuddy ([EMAIL PROTECTED]), Programmer, Baritone, Daddy, Human. > Fen's Ende Software, Redwood City, CA, USA, Earth, Sol System, > Milky Way. > > "The problem with defending the purity of the English language is > that English is about as pure as a cribhouse whore.
Re: Is this bug in Django
What exact command did you type? On Jan 22, 2007, at 5:44 AM, [EMAIL PROTECTED] wrote: > > Traceback (most recent call last): > File "manage.py", line 11, in ? > execute_manager(settings) > File > "/usr/local/lib/python2.4/site-packages/django/core/management.py", > line 1447, in execute_manager > execute_from_command_line(action_mapping, argv) > File > "/usr/local/lib/python2.4/site-packages/django/core/management.py", > line 1348, in execute_from_command_line > translation.activate('en-us') > File > "/usr/local/lib/python2.4/site-packages/django/utils/translation/ > trans_real.py", > line 195, in activate > _active[currentThread()] = translation(language) > File > "/usr/local/lib/python2.4/site-packages/django/utils/translation/ > trans_real.py", > line 184, in translation > default_translation = _fetch(settings.LANGUAGE_CODE) > File > "/usr/local/lib/python2.4/site-packages/django/utils/translation/ > trans_real.py", > line 167, in _fetch > app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), > appname[p+1:]) > AttributeError: 'module' object has no attribute 'blog' > > > I have never seen anything like this while programming in django. > > I have a project named alexsite and app named blog > > Too find if this is blog do I need to give someone more > information. I > tried to load a webpage and thta didnt work so I tried to load a > shell > and the above is what I got. > > > > --~--~-~--~~~---~--~~ 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: Ho do your Django applications fit in your projects?
Hello, I've found that each application should be specific in its functionality. How you organize it really depends on the type of project. A simple blog might only be one application. Our intranet site has 7, including a settings.py file, if necessary. I think how coupled or decoupled you can make applications depends on the project. For example I have several applications that do very specific functionality, but all of them rely on a shared set of tables that I've grouped into a "Core" application. In the same project I have apps that are completely independent. If you post more description of your project, I'd be happy to give you some suggestions. Corey On Jan 16, 2007, at 4:56 AM, [EMAIL PROTECTED] wrote: Hi community, Been playing with Django for a while now, but I am still confused about the separation of applications within a project. So far, I end up either implementing all my features within one Django app, or having too many direct connections between my apps, making each of them unexportable for reuse in another project. I wanted to share my concern, in order to get valuable feedback on effective independency of Django applications. Does everyone manage to get loosely coupled applications in their projects? Any tips to share? Is my twisted mind unrecoverable? Thanks in advance. > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: DB caching - how does Django handle external changes to the DB
Stefan, In my apps I do TONS of offline processing, but an able to have users tweak things using the Admin interface. I haven't had any issues with caching or outdated data. Good luck! Corey Oordt On Oct 16, 2006, at 11:19 AM, Stefán Freyr Stefánsson wrote: > Hello. > > I have a deadline on a project coming up so I'm hoping that you > will forgive me for posting a question that I could technically > experiment with myself but because of the deadline I would very > much like to receive input from the django community on whether my > time is well spent on doing this or not. > > So the thing is that I have an application that updates a database > table. I'm currently working on this application and soon I will > start working on a web frontend for displaying this data. > > My question is whether Django is a good choice for me. What I'm > mostly worried about is if Django has some sort of a caching > mechanisme that is hard to "turn off", making it vulnerable to not > picking up changes to the data that is done by external processes. > > What I plan on doing is create my model in Django just like I > usually do and then use Django to create the tables and > everything... then I'll modify my external application so that it > pushes data into the db structure that Django produced. > > If anyone has some reading material on this or experience (s)he > would like to share, I'd very much appreciate it. I'm especially > looking for pitfalls that you guys might let me know of in advance > to avoid because of my looming deadline. > > Kind regards, Stefan Freyr. > > > --~--~-~--~~~---~--~~ 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: Manually setting an ImageField gives a SQL error
Thanks for the tip, I am using os.path.splitext() ! I think somehow the problem lies with psycopg and it's "auto-quoting" feature. I'm not sure how it figures out what needs to be quoted and what doesn't. Thanks for the help, RajeshD! Corey On Oct 12, 2006, at 4:07 PM, RajeshD wrote: > >> >> UPDATE "addocs_document" SET >> "doctype"=2,"ad_id"='123456',"height"=0,"width"=0,"image"=ad_document >> s/2006/10/12/123456_2_8..pdf,"submitted"='2006-10-12 >> 12:43:24',"received"='2006-10-12 12:57:12.155 598' WHERE "id"=8 >> >> As you can see in the UPDATE statement, it is relative to the >> MEDIA_ROOT folder, and it is not quoted. > > Right...as you have surmised, the lack of quoting is indeed the cause > of the error. > > Try this: > > doc.image = str(os.path.join(upload_to,'%s_%s_%s%s' % >(the_ad.ordernumber, doctype, doc.id, docext) ) ) > > > (I don't know why it has two >> periods, but that's my bug) > > If you are using os.path.splitext() to derive docext by any chance, > realize that the extension you get from that method already has the > dot in it i.e. '.pdf'. So, when you compose your filename from it you > just need '%s_%s_%s%s instead of '%s_%s_%s.%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: Manually setting an ImageField gives a SQL error
Here is the stack trace: --- psycopg.ProgrammingError Traceback (most recent call last) /home/django_dev/pennysaver/ /home/django_dev/pennysaver/addocs/processworkflows.py in start_check_workflows(debug) 137 for i in wflow[1].split(".")[1:]: 138 mod = getattr(mod, i) 139 function = getattr(mod, wflow[2]) --> 140 function(dds_file) 141 /home/django_dev/pennysaver/addocs/workflows.py in handle_layout (dds_xml_file) 150 return 151 --> 152 addoc, addocid = copy_to_db('Layout', dds_xml_file, ad, 2) 153 docname,docext = os.path.splitext(addoc) 154 copy_to_art(addoc, 'layouts', '%s.%s' % (addocid, docext)) /home/django_dev/pennysaver/addocs/workflows.py in copy_to_db (workflow, dds_xml_file, the_ad, doct ype) 120 (the_ad.ordernumber, doctype, doc.id, docext) 121 ) --> 122 doc.save() 123 return (dst_path, doc.id) 124 /usr/lib/python2.4/site-packages/django/db/models/base.py in save(self) 182 ','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks ]), 183 backend.quote_name (self._meta.pk.column)), --> 184 db_values + [pk_val]) 185 else: 186 record_exists = False /usr/lib/python2.4/site-packages/django/db/backends/util.py in execute (self, sql, params) 10 start = time() 11 try: ---> 12 return self.cursor.execute(sql, params) 13 finally: 14 stop = time() ProgrammingError: ERROR: syntax error at or near "_2_8" at character 118 UPDATE "addocs_document" SET "doctype"=2,"ad_id"='123456',"height"=0,"width"=0,"image"=ad_document s/2006/10/12/123456_2_8..pdf,"submitted"='2006-10-12 12:43:24',"received"='2006-10-12 12:57:12.155 598' WHERE "id"=8 As you can see in the UPDATE statement, it is relative to the MEDIA_ROOT folder, and it is not quoted. (I don't know why it has two periods, but that's my bug) Thanks for any help, Corey On Oct 12, 2006, at 3:12 PM, RajeshD wrote: > >> The sve() method gives an error tracing back to the UPDATE statement. > > Usually it helps get you better responses, if you include the actual > stack trace. > >> In the statement the 'image' field looks like >> "image"=/path/to/the/file.ext, ... >> >> What is the proper method to set this field? > > The ImageField's value is a string with the path of the image file > relative to your settings.MEDIA_ROOT. It is not the absolute path of > the image file. > > You can easily check this by uploading an image through this field > from > the Admin screen and then checking what the field contains for that > image. > > > > --~--~-~--~~~---~--~~ 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: long-running process. how to do it?
You, know I just found that utility last week. As far as just doing an os.spawn*, my recollection is that if your process ends, the spawned process ends, even if you are not waiting for it to return. In the case with a web server, as soon as you return from your view, the spawned process ends. The daemonize process, full detaches itself from the spawning process so it can survive after the spawning process ends. Corey On Oct 6, 2006, at 2:39 AM, Holger Schurig wrote: > >> I wrote a daemonize method that can be called by the view to >> spawn a new process that executes your code. > > Looks very similar to django.utils.daemonize :-) > > > --~--~-~--~~~---~--~~ 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: long-running process. how to do it?
I wrote a daemonize method that can be called by the view to spawn a new process that executes your code.It is part of this thread:http://groups.google.com/group/django-users/browse_frm/thread/b36f4ca10a424161/c5131410e5d548b1?lnk=gst&q=daemonize&rnum=2#c5131410e5d548b1I'm happy to give you any other tips/hints on how I've implemented it if you like.CoreyOn Oct 5, 2006, at 9:36 AM, Gábor Farkas wrote:hi,i have the following "problem".in my django app, at some point i have to send out a LOT of emails (several thousand).this sending takes a long time, so an usual web based approach (click the send-button, send the mail, and show the response to the user) does not work, because the browser usually timeouts the connection, and generally the waiting time is too long.so, how to handle this?my idea is/was to spawn a separate process (i'm on linux), which will do the mail sending, and then report somehow to the user the completion (by email, or by having a results-web-page in the django-app, which the user can visit, and check the progress...)...so, are there any other, more elegant/simpler solutions?gabor --~--~-~--~~~---~--~~ 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: HTTP response-code for missing querystring?
I see your point. In your example, if the query string is left off, I would just show a blank form, unless there is some overriding reason that they couldn't fill in one or more of the fields. But I guess sometimes you have to deviate from the rules. Corey On Sep 22, 2006, at 3:06 PM, gabor wrote: > > Corey Oordt wrote: >> I'm not sure I can appreciate why you would require a URL to have a >> query string. It seems to go against the anti-crufty URLs that Django >> is trying to avoid. >> >> Query strings, if I understand them correctly are really meant to >> provide a subset or context of an otherwise working page. >> >> So with that in mind, I would recommend that you show a page with >> empty results, such as "No results were found." > > generally i agree with you (URLs must be nice and simple). > > the problem i sometimes have is with data that is not hierarchic. > > imagine that you want to show a form, and you would like to prefill > some > of it's fields... > > one way is to do something like: > > http://bla.com/forms/[EMAIL PROTECTED]&urgent=1 > > how would you propose to do this without query-strings? > > gabor > > >> >> Corey >> >> On Sep 22, 2006, at 9:28 AM, Gábor Farkas wrote: >> >>> hi, >>> >>> imagine that you have a view function, that requires a parameter in >>> the >>> querystring. >>> >>> for example, it needs to have: >>> >>> http://foo.com/bla/?param=15 >>> >>> now, what should happen if it gets: >>> >>> http://foo.com/bla/ >>> >>> ? >>> >>> in this case, technically the user should not be able to have the >>> url >>> without the querystring, except if he is playing with the url :) >>> >>> i mean "what is the most standard-conformant and correct response"? >>> >>> http-404 certainly not imho. >>> http-500 seems also wrong, because there was no unexpected error in >>> the >>> server. >>> >>> http-400 bad request maybe? >>> >>> >>> simply returning a http-200 with an error page seems to be the wrong >>> thing to do. >>> >>> >>> gabor >>> >> >> >>> > > > > --~--~-~--~~~---~--~~ 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: HTTP response-code for missing querystring?
I'm not sure I can appreciate why you would require a URL to have a query string. It seems to go against the anti-crufty URLs that Django is trying to avoid. Query strings, if I understand them correctly are really meant to provide a subset or context of an otherwise working page. So with that in mind, I would recommend that you show a page with empty results, such as "No results were found." Corey On Sep 22, 2006, at 9:28 AM, Gábor Farkas wrote: > > hi, > > imagine that you have a view function, that requires a parameter in > the > querystring. > > for example, it needs to have: > > http://foo.com/bla/?param=15 > > now, what should happen if it gets: > > http://foo.com/bla/ > > ? > > in this case, technically the user should not be able to have the url > without the querystring, except if he is playing with the url :) > > i mean "what is the most standard-conformant and correct response"? > > http-404 certainly not imho. > http-500 seems also wrong, because there was no unexpected error in > the > server. > > http-400 bad request maybe? > > > simply returning a http-200 with an error page seems to be the wrong > thing to do. > > > gabor > > > --~--~-~--~~~---~--~~ 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 correct this error?
Believe it or not, latin1_swedish_ci is a default collation for MySQL. I recommend using PHPMyAdmin. It is the easiest way to see the collations and change the collations. (but you have to use PHP :( ) You can use the MySQL Administrator GUI but it is a pain as you have to do a lot more clicking to get into the tables and see the collations. I don't know how to do it from the command line, as I have always used PHPMyAdmin to do it. Wish I could be of more help, Corey On Sep 6, 2006, at 4:16 AM, PythonistL wrote: > > Corey, > Thank you for your reply. > The exception Value > > (1267, "Illegal mix of collations (utf8_czech_ci,IMPLICIT) and > (latin1_swedish_ci,COERCIBLE) for operation '='") > > > is from this command: > gallerys.get_list(Title__exact=new_data['Title']) > So, I would guess that Title field or new_data['Title'] has > (latin1_swedish_ci,COERCIBLE) collation. > But how can I find out which one is of (latin1_swedish_ci,COERCIBLE) > collation? > > Thank you for the reply > 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: Restrict amount of text in a TextField form
cyberco: If you want to do it in the interface, you will have to use some javascript. Here is a page that shows how to do it: http://www.felgall.com/ jstip20.htm Corey On Sep 5, 2006, at 8:50 AM, cyberco wrote: > > How can I set a maximum for the amount of text a user enters in a > TextField form? CharField has a 'maxlength' parameter, but TextField > not. > > > > --~--~-~--~~~---~--~~ 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 correct this error?
You can change to collation of your MySQL tables by table and by field. If you do it by table, all new fields are of that collation. If you already have fields of a collation, you will have to change all of them. I used PHPMyAdmin to do it as the interface is nice and simple. You probably will also be able to do it with the MySQL Admin tool that they have as a download. Corey On Sep 5, 2006, at 10:18 AM, PythonistL wrote: > > Thank you for the reply > I still use Django 0.91 and I could not find > django/db/backends/mysql/base.py > > I found only C:\Python23\Lib\site-packages\django\core\base.py > and C:\Python23\Lib\site-packages\django\core\db\mysql.py > > Which file should I change with > if self.connection.get_server_info() >= '4.1': > cursor.execute("SET NAMES utf8") ? > > Scater, > the erorr says: > Exception Value: (1267, "Illegal mix of collations > (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for > operation '='") > Exception Location: > C:\PYTHON23\lib\site-packages\MySQLdb\connections.py in > defaulterrorhandler, line 32 > > The exception Value is from this command: > gallerys.get_list(Title__exact=new_data['Title']) > So, how can I find out what has (latin1_swedish_ci,COERCIBLE) > collation? > Title field has that or new_data['Title'] has the > (latin1_swedish_ci,COERCIBLE) collation? > Thank you for the reply > 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: Advanced Admin Customization
mthorley: I think you just need to override the save() method of your model. You can do all the processing you need before it's saved. Corey On Sep 5, 2006, at 10:21 AM, mthorley wrote: > > Thanks for the tip Nate! > > Does any one know what method receives the data from the form when it > is submitted? I tried models.Field.get_db_prep_save but that doesn't > seem to be working. I need to process the form data before it is > passed > off to the database for saving. > > -- > mthorley > > > > --~--~-~--~~~---~--~~ 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: Directional Many-to-many
Take a look at: http://www.djangoproject.com/documentation/models/m2m_and_m2o/CoreyOn Aug 29, 2006, at 12:15 PM, Siah wrote:Hello,Given this model:class Person(models.Model): name = models.CharField(maxlength=200) children = models.ManyToManyField('self')I can do: FatherObj.children.add(ChildObj)Somehow though, if I go to ChildObj and ask for its children, I willget the FatherObj as well. What am I doing wrong?In my real example, the childObj can have many parent nodes, thusmany-to-many is required.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: Creating new apps
Charles,I've always seen a Project as a Site. Although there are situations that that may not be true, for most of us, it probably is.I've seen an App as a grouping of functionality. Examples would be Blog, Forums, News, Gallery, etc.Good design practices should keep as much internal within each App as possible, so you can use the app with other projects. That is why you would have a urls.py and a views.py in each App directory.Each App is linked into the main project by: INSTALLED_APPS in settings.py and configuring a base url (eg. /blog ) that then references the App's urls.py.For authentication, you can use the contrib.auth. They don't have access to the admin unless they are a member of staff.Hope that helps,CoreyOn Aug 29, 2006, at 12:16 PM, charles sibbald wrote:Hi Guillermo,Thanks for the help.I have been on your SVN, but how do i tell Django that each little app has its own urls.py? is putting it in the directory enough to automatically let django know that each little app has its own urls.py?Also for authenticating users, do i use django.contrib.auth, which is the same as the admin system.I dont want users to have access to my backend system.RegardsCharles- Original Message From: Guillermo Fernandez Castellanos <[EMAIL PROTECTED]>To: django-users@googlegroups.comSent: Tuesday, August 29, 2006 3:47:51 PMSubject: Re: Creating new appsHi,I did my own homepage (www.haruki.eu) where I have several"applications" done together.As I understood after asking in the list and looking at severalproject svn trees, the 2nd way seems to be prefered for a sizableapplication. It allows modularity and reusability.What I do is have a name for the general project and all the appsthere. Each app has its own urls.py, and I let users define their ownurls.py that will include the urls.py of each application depending ofthe ones they want to add or use.You can have a look at the code here:http://www.guindilla.eu:8000/guindilla/trunk/Hope it helps.GOn 8/29/06, casibbald <[EMAIL PROTECTED]> wrote:>> I have been through the Django tutorial, but there is something it does> not clearly outline.>> After creating a project, I have to create my first App, which in the> tutorial it was Polls.>> I now want to start working on my own Application and wonder what the> best structure is for a sizable application which I hope it will grow> to as I learn more.>> So option 1.>> Project --- App -- Views (multiple views for my whole project)>> Option 2.>> Project --- App1 -- Views> Project --- App2 -- Views> Project --- App3 -- Views> Project --- App4 -- Views>> Multiple component apps to the whole project?>> and if option 2 is the better route to go, then for example would the> following be a good example.>>> Project --- Auth-- Views - Registration> Login> Pass-Reminder> Project --- Dashboard -- Views - Welcome> Report 1 + n> Project --- Account -- Views> Address> Credit Details> Project --- App + n -- Views>>> The issue I have been having is this, how best to then setup my URLs?,> as the tutorial does not explain how to have many apps in the same> urls.py file>>> >> --~--~-~--~~~---~--~~ 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: Sending an html email
I've never done it before, but here are some places to look:http://code.djangoproject.com/ticket/1541http://www.rossp.org/blog/2006/jul/11/sending-e-mails-templates/CoreyOn Aug 26, 2006, at 8:59 PM, The Rem wrote:Hi,I am using the template to build the email content. I included linksin it but the email are sent in plain text, not in html. What is theway to go to send html email ? Eventually, i'd like to add images too.Thanks in advance for your helpRem --~--~-~--~~~---~--~~ 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: generic views for ajax ?
Dirk, I think that it's a great option. It doesn't advocate a specific framework or method even. AJAX views will be very similar to html views and I agree that having some generic views for AJAX is a great addition to the Django community, even if it doesn't get added to the core. Corey On Aug 26, 2006, at 12:58 PM, [EMAIL PROTECTED] wrote: > > Hi, > > I know the discussion about django and ajax compatible response. > The 'hardliners' say that you only need to implement your own kind > of template - which is true for all time, but I would prefer a much > more generic way to get the response from the views. > > I made a server-side django library for ajax response Json, > JsonRpc, or simple XmlRpc available here: http:// > svn.sourceforge.net/svnroot/django-userlibs/trunk/libs.ajax/ > > Currently I build generic date_based and generic list_detail views > for ajax-response. > > Like to here any comments. > > Regards, > Dirk > -- > > > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer > > > --~--~-~--~~~---~--~~ 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: included templates to load own objects
Mae, I think it may be because we're not sure of what you are asking for. I know it didn't really make sense to me when I red it the first time. What exactly are you trying to accomplish? Corey On Aug 25, 2006, at 10:35 AM, Mae wrote: > > Nobody? Is it because I asked the question wrong or because there > just > is no answer? > > Mae > > > > --~--~-~--~~~---~--~~ 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: Multiple rows in a form
Stewart:Take a look at http://www.djangoproject.com/documentation/forms/ for more on creating forms, and simplifying the process.You will need to have to figure out how you want to handle the item listings. You will either have to have a static set of items or use some fancy _javascript_/DHTML to dynamically create new item listings.Something like:CoreyOn Aug 22, 2006, at 5:59 AM, [EMAIL PROTECTED] wrote:Hi.I've just started with Django and I'm liking it! A little confusedabout one thing though...I am experimenting with a basic ordering system, the model for whichlook like this:class stock_item(models.Model): name = models.CharField(maxlength=200)class order(models.Model): ordered_by = models.CharField(maxlength=200)class order_item(models.Model): order = models.ForeignKey(order) stock_item = models.ForeignKey(stock_item) quantity = models.PositiveSmallIntegerField()This is all fine until I get to a form for placing orders. I envisioneda form something like this:{repeat for each stock_item} {end}But I'm having some trouble writing the view code for it, does anyonehave any pointers?Thanks,Stewart. --~--~-~--~~~---~--~~ 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: limit_choices_to Users in a Group
I think you need to include django.core.exceptions And I think that the exception is ObjectDoesNotExist Corey On Aug 21, 2006, at 4:24 PM, Waylan Limberg wrote: > > I figured this out, thanks to a suggestion in another thread. It seems > I was misunderstanding something about how limit_choices_to works. > Anyway, the following works: > > from django.contrib.auth.models import User, Group > > class Project(models.Model): > coordinator = models.ForeignKey( > User, > limit_choices_to={'groups__pk' : > Group.objects.get(name='Coordinator').id} > ) > > The only problem is that if there is no Group named "Coordinator" in > the db, I get an error so I tried the following; > > def limit_to_group(group_name): > try: > g = Group.objects.get(name=group_name).id > except DoesNotExist: > g = 0 # this should result in no users listed (I think/hope) > return g > > class Project(models.Model): > ... > limit_choices_to={'groups__pk' : limit_to_group > ('Coordinator')} > ... > > Which returns an error that DoesNotExist is not defined. What am I > missing here? > > On 8/16/06, Waylan Limberg <[EMAIL PROTECTED]> wrote: >> I'm not sure if my problem is related to this thread[1] or if I'm >> just >> misunderstanding something with regard to limit_choices_to. >> >> First I tried this (in relevant part): >> >> from django.contrib.auth.models import User >> >> class Project(models.Model): >> coordinator = models.ForeignKey( >> User, >> limit_choices_to={'id__in' : >> User.objects.filter(groups__name='Coordinator')} >> ) >> >> As explained in the previously referenced thread, that currently >> doesn't work so I tried this: >> >> from django.contrib.auth.models import User, Group >> >> def users_in_group(group): >> g = Group.objects.get(name=group) >> return User.objects.filter(groups=g) >> >> class project(models.Model): >> ... >> limit_choices_to={'id__in' : users_in_group('Coordinator')} >> ... >> >> but that generates the same error. The Docs say I can use any Q >> object, so I understood that to mean either of the above should work. >> Am I using limit_choices_to is ways it's not intended or should I >> wait >> for the previously mentioned bugs to be worked out? >> >> [1] http://groups.google.com/group/django-users/browse_thread/ >> thread/6460e63e0e6c88d8/ >> -- >> >> Waylan Limberg >> [EMAIL PROTECTED] >> > > > -- > > 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 -~--~~~~--~~--~--~---
Re: NULL for TextField
Why don't you: {% if form.myText.text %} My text: {{form.myText }} {% else %} No text yet. {% endif %} That will get a myText field passed in the post/get parameter. Corey On Aug 21, 2006, at 5:39 PM, cyberco wrote: > > Given the model: > === > myText = models.TextField(blank=True) > === > > In case this TextField has no text I want to hide it from my form. > Template code: > > === > {% if form.myText.text %} > My text: {{form.myText }} > {% else %} > No text yet. > {% endif %} > === > > But then saving the form gives an error saying it wants to save a NULL > value in a field that cannot be NULL. A solution could be adding > 'null=True' to the field: > > === > myText = models.TextField(blank=True, null=True) > === > > But this is discouraged by Django: > > http://www.djangoproject.com/documentation/model_api/#null > "Avoid using null on string-based fields such as CharField and > TextField unless you have an excellent reason. If a string-based field > has null=True, that means it has two possible values for "no data": > NULL, and the empty string. In most cases, it's redundant to have two > possible values for "no data;" Django convention is to use the empty > string, not NULL." > > What would be the proper way to do this? > > > > --~--~-~--~~~---~--~~ 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: Process forking issues
I wrote some code that might help you out: it in the thread:http://groups.google.com/group/django-users/browse_frm/thread/b36f4ca10a424161/c5131410e5d548b1Depending on how you spawn a process, it can either wait for each, or become a child process.Calling the daemonize method with the appropriate parameters, should launch a new independent process. You could call it several times and get several independent processes.CoreyOn Aug 21, 2006, at 1:06 PM, tomass wrote:Well, limited success. I was able to get the code working throughclosing the django db connection just after I'd forked my processes,but it seems that what I thought I was doing wasn't really what Ithought I was doing.Essentially I wanted to be able to run multiple tasks simultaneously. Ithought forking x numbers of processes would do this for me, but itseems not. It looks to me like what happens in this case is that if youtry to fork 10 processes simultaneously it actually waits for the firstforked process to finish before starting the second one.I think what I need to look into is multi-threading instead, but thatcould be kind of complicated... More investigation needed.Thanks, Tom --~--~-~--~~~---~--~~ 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: Process forking issues
I think I had this problem, at least it feels very familiar, and I do some process forking. I think that the problem is using the same connection more than once. I think that the cursor is being closed and then being used again. I took the habit of creating a new cursor and specifically closing it, and then creating a new one for each query, assuming you are doing some custom querying. I wish I could be of more help... Corey On Aug 17, 2006, at 7:23 AM, tomass wrote: > > Hi Folks, > > I know this topic has been brought up a few times, but I have a > slightly different issue here (I think). > > I have a backend process that runs a number of commands. It > connects to > the database (via the ORM) to check it's queue and then executes jobs. > All fine and dandy. > > My problem is that I have now got to the stage where I need to run > more > than one of these jobs at a time as there are so many scheduled and if > they run one after another it takes too long. > > I approached this by using this recipe to spawn a new process and then > run the backend processing function: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 > > Problem is, I'm getting database connection errors and I can't quite > see why. I pass an object to my backend processing function and have > verified that I can access the properties of that object in the > function. However, I get the following errors: > > Traceback (most recent call last): > File "/automator/utils/backend.py", line 503, in ? > run_backend(LOGLEVEL) > File "/automator/utils/backend.py", line 471, in run_backend > asyncRemoteCommand(c, l) > File "/automator/utils/backend.py", line 429, in asyncRemoteCommand > RemoteCommand(c, l) > File "/automator/utils/backend.py", line 193, in RemoteCommand > c.save() > File "/home/mthaddon/django/magic-removal/django/db/models/base.py", > line 150, in save > cursor = connection.cursor() > File > "/home/mthaddon/django/magic-removal/django/db/backends/postgresql/ > base.py", > line 42, in cursor > cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) > psycopg.OperationalError: server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. > > When I look at the postgresql logs I see: > > LOG: could not receive data from client: Connection reset by peer > LOG: unexpected EOF on client connection > > Seems like Python is blaming PostgreSQL and vice versa! > > Any help appreciated. > > Thanks, Tom > > > > --~--~-~--~~~---~--~~ 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: showing future events only?
I thought a change was made in the generic date views to show only future events. It is the allow_future parameter, I believe. Corey On Aug 16, 2006, at 1:38 PM, [EMAIL PROTECTED] wrote: > > I've got an app for user events, using the generic list view to > display > them. So far , so good. But I don't want to display them if the > date is > past. So, how would I filter those out. Here's the template code, so > you can sorta see what I'm getting at: > > {% for show in show_list|dictsort:"show_date" %} > > {{ show.user }} > {{ show.artist }} > {{ show.venue }} >{{ show.address }}, {{ show.city }}, {{ > show.state }} > {{ show.show_date.date|date:"F d, Y" }}, > {{show.show_date.time|time:"g a" }} > > {% endfor %} > > > > --~--~-~--~~~---~--~~ 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: OT: Sort messages by thread in OS X Mail
I was sorting by subject and it was doing an ok job. Thanks for pointing this out. I always feel stupid when there is such an obvious feature that I never noticed... Corey On Aug 15, 2006, at 10:04 PM, Sean Schertell wrote: > > Hey guys, > > I hope I'm not the only schmuck to arrive so late to the "sort by > thread" party. If any of you folks have a "django" mailbox for this > mailing list in OS X Mail and you haven't tried using the sort > message by thread feature -- you're really missing out! > > Just select your django mailbox, then choose "sort messages by > thread" from the View menu. Neato! I'm sure you can probably do this > in Thunderbird, Kmail, etc. But I didn't know OS X Mail had this > feature (and it's really nice too). > > Hope that helps someone. > > Sean > > > > > --~--~-~--~~~---~--~~ 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: geographic targeting with django
Ian,Try: http://www.maxmind.com/app/geolitecityCoreyOn Aug 15, 2006, at 8:17 PM, Ian Holsman wrote:Hi. does anyone know of a python module/interface to allow me to determine what state a given IP# is in? (Open source preferably) -- Ian Holsman [EMAIL PROTECTED] http://VC-chat.com It's what the VC's talk about --~--~-~--~~~---~--~~ 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 do I store project in subversion?
Don't store your .pyc in the repository. Create a settings.default.py and store it in the repository. Each user can then maintain slightly different settings On Aug 15, 2006, at 6:50 PM, alex kessinger wrote: > > I want to thank you for all your anwsers it has been very helpfull. I > also have another question. I am new to the python language, but is it > okay to store thre .pyc files in subversion. also how do you guys > handle different settings.py files amongest developers. > > > --~--~-~--~~~---~--~~ 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 do I store project in subversion?
I'm probably not the best person to be answering this, but I do have an internal subversion repository.If you don't have a working subversion server, follow the instructions at: http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html(Since it's an internal machine, I just use basic authentication.)To create a repository, follow the instructions at: http://svnbook.red-bean.com/en/1.0/ch05s02.htmlThis chapter gives some guidance on the layout or structure of the repository.An example, that should work (going from memory):$ svnadmin create /home/svn$ mkdir tmpdir$ cd tmpdir$ mkdir myproject$ mkdir myproject/trunk$ mkdir myproject/branch$ mkdir myproject/tags$ cp /path/to/real_project/* myproject/trunk/$ svn import . http://myserver/svn/ -m "Initial import."CoreyOn Aug 15, 2006, at 3:52 PM, [EMAIL PROTECTED] wrote:I was wondering if someone could tell me how they store the djangoproject in subversion. I am moving a php project I have already writtento django and I want to open source this project. So I am trying tofigure out the best way to store my project in a subversion repository.Anything would be helpfull. even if you just expalin how you store yourproject in cvs or subversion. --~--~-~--~~~---~--~~ 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: Where to store large SQL queries code
One idea is to create a package that would contain files of your queries. Each file could just be have an assignment : QUERY = """ """ You could then import them, like : from queries import update_this and access it by update_this.QUERY Corey On Aug 11, 2006, at 3:05 PM, Maciej Bliziński wrote: > > Hello Djangoers, > > I've got to write a set of large SQL queries. I'd like to avoid > putting > the whole pages of the SQL into the Python code. I'd like to store the > queries as separate files and load them when needed. > > How to do in a Django way? Create something similar to template > directory? What would you suggest? > > Keep swingin' > Maciej > > -- > Maciej Bliziński > http://automatthias.wordpress.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 -~--~~~~--~~--~--~---
Re: Searching in admin doesn't search -- returns everything
I'll be happy to. I did put in a track item for this (although I can't remember what the number is).I'm using PostgreSQL 8.1The models are at: http://paste.e-scribe.com/1125/This is actually a combination of two related errors: One that leads to a searching error (?e=1) and another that leads to a ProgrammingError (identified in the track item)Here is the scenario:1. Foreign Key in the ordering2. Foreign Key is not a typical "id" key (using primary_key=True) (I'm assuming this, BTW)If the Foreign key IS IN the search_fields, everything will return and you will see a ?e=1 in the query string of the results.If the Foreign key IS NOT IN the search_fields, you will get a ProgrammingError, missing FROM-clause (the foreign key is used in the ORDER BY clause but is not JOINed)In my models, the Address model is the problem. The ZIP_Code model is used as the primary ordering field. Really, I just need the zipcode number, but it obviously references the entire object.I had this exact same problem with my Route model, when I used the ZIP_Code model in the ordering and search_fields. I was able to get around it because the primary key is a concatenation of zipcode-carrier route.I hope I've given you enough information, and I really hope I just made a silly mistake somewhere. :)Thanks for the attention,CoreyOn Aug 11, 2006, at 11:01 AM, Adrian Holovaty wrote:On 8/10/06, Corey <[EMAIL PROTECTED]> wrote: I have a model with several foreign keys. Currently when I do a search,it returns everything. The query string shows ?e=1.The search_fields is set to a local field and a foreign key.If a remove the foreign key from the search fields, I get a programmingerror: FROM-clause is missing, relating to the foreign key I justremoved from the search_fields. This same foreign key is in theordering list. Hey Corey,That's really strange...Would you be willing to paste your model, sowe can try to recreate the error? Also, which database backend are youon?Adrian-- Adrian Holovatyholovaty.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 -~--~~~~--~~--~--~---
Re: How to log ALL queries
David,Not sure if this helps, but the only way I found (using postgresql) was to turn on query logging in postgresql. Then you truly see everything that is passed to the database.I'm not familiar with Oracle at all, but I'm sure it has a way to do that.Corey OordtOn Aug 11, 2006, at 8:38 AM, Hancock, David (DHANCOCK) wrote: I haven’t completely given up on getting Oracle and Django working together, but I did revert to 0.95 and installed MySQL, which are meeting my needs. To get to the next step with the Oracle patch, I’d really like to learn what to change to force ALL queries to be logged. The only thing I’ve found in the documentation looks like a way to see a query’s information right after it’s executed. Ideally, I’d like to get every query logged into a file that I can use to fix the SQL outside Django prior to trying to fix the code. So, I’d appreciate any pointers to documentation, code, etc. to let me log queries to a file. Cheers! -- David Hancock | [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 -~--~~~~--~~--~--~---
Re: show many2many data as comma-separated-text. fast/optimal solution?
I may be showing my ignorance of Django and python here but: in MySQL there is an aggregate function GROUP_CONCAT that will do precisely what you want. There is a PostgreSQL library that adds the functionality as well. I'm still getting used to the ORM is Django, so I'm not sure how you would add that in, but I'm sure there is a way. Otherwise raw SQL works, too. Corey On Aug 4, 2006, at 5:07 PM, gabor wrote: > > hi, > > i have a problem with a certain web-application, and wonder if someone > has an idea how to solve it the best way > > imagine the following situation.. > > > class Role(Model): > title = CharField(maxlength=100) > > class User(Model): > name = CharField(maxlength=100) > roles = ManyToManyField(Role) > > > now, i would like to list all the Users and their details on a page, > in a html-table, and in the column for the "roles" i would like all > the > roles's titles as comma-separated text. > > for example: > > Joe | pawn,bishop | > Bill | knight,rook,pawn| > Jane | queen | > > > as i assume this is a fairly common situation, how would you do it? > > of course there is the most straightforward version, where you simply > ask the user instance for it's all roles, and join them by ",". > > but this has the problem that if you have 100 users, then you will > make > 101 queries (1 to list all the users, and one for each user to > query the > roles). > > is there a faster/better way? > > there are 2 ways i have thought about: > > 1. execute a "raw" sql query which simply selects all the roles for > all > the users. then manually build a dictionary from this data (the key > being User.id, and the value is the comma-separated list). and then > access this data in the html page. > > 2. slightly faster: define an aggregate function for concatenating > text > in the database, and do a "raw" sql query which returns a much better > data structure (a list of (user_id,text) pairs), and then access this > data in the html page. > > are there any better ways? > > my biggest problem with these approaches is: > > a. i cannot use the generic view's pagination anymore, because i need > all the user_ids before i call the generic view > > b. it's complicated to access such data-structure in the html page. > the > best way i came up is to have a custom page-template that gets the > data > from the dictionary. at first it seems simple, but then you realize > that > if you have a dictionary where user_id => text, then it's not possible > (afaik) to ask in the page template for certain value in the > dictionary. > means i cannot do {{ user_roles.{{ user.id }} }} . or can i? > > as i said, this seems to be a common situation. how do you approach > this > problem? > > gabor > > > > --~--~-~--~~~---~--~~ 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: Code to spawn a new, independent process
Martina, Mostly because I'm new to python and in my research no one mentioned it! You are right, this does look like a better fit. Live and learn! Corey On Aug 6, 2006, at 12:40 PM, oefe wrote: > > > Corey wrote: >> Hey everyone, >> >> I've seen references and questions in previous posts about how to >> spawn >> a process to do some hefty processing. I had that need (processing of >> 1.6 million records at a time). >> >> I created this code with help from other places on the net and it >> seems >> to work pretty well. I'm putting it out there to get some further >> testing and hope it is useful for someone else. > > Hi corey! > > why don't you simply use python's subprocess module? > > ciao > Martina > > > > --~--~-~--~~~---~--~~ 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: Ajax and Django example application
Istvan, Thanks for the code. I can't wait to dive into it. Corey On Aug 4, 2006, at 12:12 AM, Istvan Albert wrote: > > Hello All, > > For those interested here is an AJAX based demo application using > django, developed with two different javascript libraries: Prototype > and with MochiKit > > http://www.personal.psu.edu/iua1/ajax-django-sandbox.htm > > cheers, > > Istvan > > > > --~--~-~--~~~---~--~~ 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: get many from multiple levels of one-to-many relations
Thanks, Andy. I'll give that a try! Corey On Jul 18, 2006, at 9:35 PM, Andrew wrote: > > Here's how I did it for a similar situation I had. > > class MyCategory(models.Model): > category = models.CharField(maxlength=50) > parent_category = models.ForeignKey('self', blank=True, > null=True, related_name='sub_categories') > > def all_items(self): > data = list(self.items.all()) > for cat in self.sub_categories.all(): > data.append(list(cat.all_items())) > return data > > class MyItem(models.Model): > name = models.CharField(maxlength=100) > categories = models.ManyToManyField(MyCategory, > related_name='items') > > This is not the most effecient way of doing things since the list > command forces the queryset to evaluate completely. Perhaps we should > consider adding a UNION function to combine QuerySets if it's not > already in there. > > Andy > > > > --~--~-~--~~~---~--~~ 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: More than one ForeignKey referencing the same model?
Take a look at this page for a start:http://www.djangoproject.com/documentation/models/m2o_recursive2/It's for one-to-many, but it might work...CoreyOn Jul 18, 2006, at 3:20 PM, Guillaume Pratte wrote:Hello,I have an error with a model and would like to know if it is something impossible to do in Django or should be considered a bug...I modeled a rudimentary inventory system : I have Hosts and Persons responsible for them (Admin class omitted).class Person(models.Model): name = models.CharField(maxlength=100)class OperatingSystem(models.Model): name = models.CharField(maxlength=100) version = models.CharField(maxlength=20)class Host(models.Model): name = models.CharField(maxlength=100) os = models.ForeignKey(OperatingSystem) ip = models.IPAddressField() person_in_charge = models.ForeignKey(Person) backup_person = models.ForeignKey(Person)Django gives me the following error when validating the models :Validating models...invs.host: Accessor for field 'person_in_charge' clashes with related field 'Person.host_set'. Add a related_name argument to the definition for 'person_in_charge'.invs.host: Accessor for field 'backup_person' clashes with related field 'Person.host_set'. Add a related_name argument to the definition for 'backup_person'.2 errors found.If I comment out "backup_person", it works.I don't want to use a ManyToMany relationship, because then would not be able to differentiate the principal from the backup.Is there a way around?Thanks,Guillaume Pratte --~--~-~--~~~---~--~~ 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: 'got multiple values for keyword argument' error
Man I hate silly errors! Thanks so much Rajesh! (It happens to be my first view, the generic views got me spoiled!) Corey On Jun 22, 2006, at 9:10 PM, [EMAIL PROTECTED] wrote: > > Ah..I should've noticed this earlier, but you are missing the > mandatory > first argument 'request' in your view function. That's causing Python > to assign pub as the first argument i.e. request, and then yet another > time with the actual value. That must be why you're getting this > error. > > > > --~--~-~--~~~---~--~~ 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: 'got multiple values for keyword argument' error
Nope, I get the same thing with: def select_date_for_pub(pub=None, template_name=None): But, interestingly, if I switch the arguments to: def select_date_for_pub(template_name=None, pub=None): I get the same error, but with template_name instead of pub! Any ideas? Thanks, Corey On Jun 22, 2006, at 8:53 PM, [EMAIL PROTECTED] wrote: > > The positional argument "pub" in your method is causing the problem, I > think. Replace it with pub=None and let me know if that fixes things: > > def select_date_for_pub(pub=None, template_name=None): > > > > --~--~-~--~~~---~--~~ 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: 'got multiple values for keyword argument' error
Here is the view: def select_date_for_pub(pub, template_name=None): """ Given a publication code, generate a view of a calendar with dates that can be selected """ date_list = Publication.objects.get (code=pub).reservation_set.filter(pub_date__gte=datetime.datetime.now ()).dates('pub_date', 'day') if not template_name: template_name = "select_date.html" t = template_loader.get_template(template_name) c = RequestContext(request, { 'date_list': date_list, }, context_processors) return HttpResponse(t.render(c), mimetype=mimetype) On Jun 22, 2006, at 6:30 PM, [EMAIL PROTECTED] wrote: > > I would still like to see the definition of the select_date_for_pub() > view method. I have seen errors similar to this where it was the > positional parameters defined in my method caused this. > > You see this exception in base.py because that's where it's first > trapped by Django. It could still be your view that caused it. > > > > --~--~-~--~~~---~--~~ 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: 'got multiple values for keyword argument' error
It doesn't happen in the view. That's the strange thing. Here is the full error:Request Method: GETRequest URL: http://localhost:8000/reservations/pubs/42/Exception Type: TypeErrorException Value: select_date_for_pub() got multiple values for keyword argument 'pub'Exception Location: /opt/local/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/handlers/base.py in get_response, line 74Thanks,CoreyOn Jun 22, 2006, at 5:10 PM, [EMAIL PROTECTED] wrote:Can you show the excerpt of your view including the line number atwhich this happens? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
'got multiple values for keyword argument' error
Hey All! I'm trying to debug a view but I'm getting an error that I can't trace. The error is: TypeError at /reservations/pubs/42/ select_date_for_pub() got multiple values for keyword argument 'pub' but the local vars in the error screen shows: callback_kwargs {'template_name': 'select_date.html', 'pub': '42'} The urls.py (simplified): urlpatterns = patterns('', (r'^pubs/(?P\d{1,2})/$', 'reservations.views.select_date_for_pub', {'template_name': 'select_date.html'}), ) Any ideas where I'm going wrong? Thanks! Corey --~--~-~--~~~---~--~~ 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: A template tag contribution
Thanks Malcolm,It's done and there!http://code.djangoproject.com/wiki/ColumnizeTagCoreyOn Jun 16, 2006, at 9:42 AM, Malcolm Tredinnick wrote:Hi Corey,On Fri, 2006-06-16 at 09:07 -0400, Corey Oordt wrote: I have no idea if this is the right place to post such a thing, but in an effort to give something back to the community, I would like to post a template tag I developed: A small collection of custom template tags is starting to collect in theWiki: http://code.djangoproject.com/wiki/CookBookTemplateTags .You may wish to add another link off that page for a more permanent homefor your tag. Posting here has its advantages, too (I don't want todiscourage that), since people will see it without effort, but it can bea bit hard to find later.Cheers,Malcolm --~--~-~--~~~---~--~~ 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 template tag contribution
I have no idea if this is the right place to post such a thing, but in an effort to give something back to the community, I would like to post a template tag I developed: Comments are appreciated, Thanks, Corey -- "Tags used by the reservation app" from django import template register = template.Library() def columnize(parser, token): """ Put stuff into columns. Can also define class tags for rows and cells Usage: {% columnize num_cols [row_class [,row_class2...]|'' [cell_class[,cell_class2]]] %} num_cols: the number of columns to format. row_class: can a comma (no spaces, please) separated list that cycles (utilizing the cycle code) can also put in '' for nothing, if you want no row_class, but want a cell_class. cell_class: same format as row_class, but the cells only loop within a row. Every row resets the cell counter. Typical usage: {% for o in some_list %} {% columnize 3 %} {{ o.name }} {% endcolumnize %} {% endfor %} """ nodelist = parser.parse(('endcolumnize',)) parser.delete_first_token() #Get the number of columns, default 1 columns = 1 row_class = '' cell_class = '' args = token.contents.split(None, 3) num_args = len(args) if num_args >= 2: #{% columnize columns %} if args[1].isdigit(): columns = int(args[1]) else: raise template.TemplateSyntaxError('The number of columns must be a number. "%s" is not a number.') % args[2] if num_args >= 3: #{% columnize columns row_class %} if "," in args[2]: #{% columnize columns row1,row2,row3 %} row_class = [v for v in args[2].split(",") if v]# split and kill blanks else: row_class = [args[2]] if row_class == "''": # Allow the designer to pass an empty string (two quotes) to skip the row_class and # only have a cell_class row_class = [] if num_args == 4: #{% columnize columns row_class cell_class %} if "," in args[3]: #{% columnize row_class cell1,cell2,cell3 %} cell_class = [v for v in args[3].split(",") if v]# split and kill blanks else: cell_class = [args[3]] if cell_class == "''": # This shouldn't be necessary, but might as well test for it cell_class = [] return ColumnizeNode(nodelist, columns, row_class, cell_class) class ColumnizeNode(template.Node): def __init__(self, nodelist, columns = 1, row_class = '', cell_class = ''): self.nodelist = nodelist self.columns = int(columns) self.counter = 0 self.rowcounter = -1 self.cellcounter = -1 self.row_class_len = len(row_class) self.row_class = row_class self.cell_class_len = len(cell_class) self.cell_class = cell_class def render(self, context): output = '' self.counter += 1 if (self.counter > self.columns): self.counter = 1 self.cellcounter = -1 if (self.counter == 1): output = '' if (self.counter == self.columns): output += '' return output register.tag('columnize', columnize) --~--~-~--~~~---~--~~ 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: Custom template tags not loading
I'm going to bow my head in shame I was SURE that I put it there! Thanks for making me look ivan! Corey On Jun 15, 2006, at 5:19 PM, [EMAIL PROTECTED] wrote: > > make sure your application exists in the project's settings file > INSTALLED_APPS > > > > --~--~-~--~~~---~--~~ 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: Custom template tags not loading
Don,Thanks for the reply. When I put in {% load reservations.reservationtags %} I get:'reservations.reservationtags' is not a valid tag library: Could not load template library from django.templatetags.reservationtags, No module named reservationtagsAny other ideas?Thanks,CoreyOn Jun 15, 2006, at 5:57 PM, Don Arbow wrote:On Jun 15, 2006, at 2:05 PM, Corey wrote: Hi All!I've written a custom template tag, but I get the error:'reservationtags' is not a valid tag library: Could not load templatelibrary from django.templatetags.reservationtags, No module namedreservationtagsI've looked in the archives and have tried everything I know so far:1. templatetags directory is in the same level as models.py2. templatetags has two files: __init__.py and reservationtags.py3. I ran python manage.py shell, and executed:from pennysaver.reservations.templatetags import reservationtagsand received no error.4. reservationtags.py has: register = template.Library() andregister.tag('columnize', do_columnize) The error is probably not in your module (note in the error, django is appending 'django' to its search path), but in the {% load %} tag in your template. You didn't specify what your template looks like. When you code the load, do not include 'templatetags' in the path, so in your template the load statement should look something like{% load reservations.reservationtags %}Don --~--~-~--~~~---~--~~ 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: Django on Intel mac?
I have MacBook, and although it was a challenge to get everything up and running, I ended up using darwinports to install apache 2, mysql 5 and python 2.4. Everything is working really well now Corey Oordt On Jun 6, 2006, at 9:36 PM, Greg Harman wrote: > > > Oliver Kiessler wrote: > >> --- >> >> I also tried MysqlDB which compiles fine but throws a runtime error: >> >> macbookpro:~/mysite oliver$ python manage.py runserverValidating >> models... >> Unhandled exception in thread started by > 0x77b930> >> Traceback (most recent call last): >> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ >> python2.4/site-packages/Django-0.91-py2.4.egg/django/core/ >> management.py", >> line 757, in inner_run >> validate() >> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ >> python2.4/site-packages/Django-0.91-py2.4.egg/django/core/ >> management.py", >> line 741, in validate >> num_errors = get_validation_errors(outfile) >> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ >> python2.4/site-packages/Django-0.91-py2.4.egg/django/core/ >> management.py", >> line 634, in get_validation_errors >> import django.models >> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ >> python2.4/site-packages/Django-0.91-py2.4.egg/django/models/ >> __init__.py", >> line 1, in ? >> from django.core import meta >> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ >> python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/ >> __init__.py", >> line 3, in ? >> from django.core import db >> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ >> python2.4/site-packages/Django-0.91-py2.4.egg/django/core/db/ >> __init__.py", >> line 23, in ? >> raise ImproperlyConfigured, "Could not load database backend: %s. >> Is your DATABASE_ENGINE setting (currently, %r) spelled correctly? >> Available options are: %s" % \ >> django.core.exceptions.ImproperlyConfigured: Could not load database >> backend: Failure linking new module: >> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ >> site-packages/_mysql.so: >> Symbol not found: _uncompress >> Referenced from: >> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ >> site-packages/_mysql.so >> Expected in: dynamic lookup >> . Is your DATABASE_ENGINE setting (currently, 'mysql') spelled >> correctly? Available options are: 'ado_mssql', 'mysql', 'postgresql', >> 'sqlite3' > > I'm fighting the same problem now trying to use MySQL with my Intel > Mac. This particular error is because > /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ > site-packages/_mysql.so > was compiled for the PPC chipset. > > I've tried compiling from source for the i386 architecture, but am > having no luck. :-( > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---