Re: How to handle this race condition?
Would something like UPDATE bid = new_bid WHERE id = id and bid < new_bid work for you? It is a more optimistic approach (it assumes that the case you describe is an exception rather than what usually happens) and I think it is simpler by not having to do any locking etc. Regards, Tamas On Tue, Nov 10, 2009 at 2:17 PM, Continuationwrote: > > Thanks Christophe and Kenneth! > > Let me make sure I understand this: > > If I write this vew function: > > @transaction.commit_on_success > def update_high_bid(request): > > cursor = connection.cursor() >cursor.execute("SELECT high_bid FROM auctionapp_auction WHERE > id=%s > FOR UPDATE", [auction.id]) > returned_rows = cursor.fetchall() >high_bid = returned_rows[0][0] >if new_bid > high_bid: >auction.high_bid = new_bid >auction.save() > > The entire function will be wrapped within a transaction. > SELECT FOR UPDATE will acquire a row-level lock > and that lock will not be released until the function update_high_bid > () returns successfully, or until the function raises an exception and > the whole transaction is rolled back. > > Is that right? > > Thanks. > > > On Nov 10, 12:45 am, Christophe Pettus wrote: > > On Nov 9, 2009, at 9:34 PM, Continuation wrote: > > > > > Also does django middleware acquire database lock on my behalf, or do > > > I need to explicitly perform the locking? > > > > In the example code, it's the SELECT ... FOR UPDATE that acquires the > > lock. Django doesn't currently have any explicit knowledge of > > locking, so you need to drop down to the custom SQL level to issue the > > right statement to acquire the lock on the row. > > > > The example I wrote assumed you were using PostgreSQL as the backend; > > you can get all sorts of details about locking in PostgreSQL here: > > > > > http://www.postgresql.org/docs/8.4/interactive/explicit-locking.html#... > > -- > > -- Christophe Pettus > > x...@thebuild.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
pre-save and check for existing value of image
Hi, I have this app which has an ImageField, where the image needs to be cropped, resized, and a few effects (all from PIL) are applied on it, the model looks something like this class MidPanel(models.Model): . image = models.ImageField(upload_to="images"): def save(self): if self.image: dosomething(self.image) Everything is fine, expect that every time someone makes a change to a field in the model, the images gets manipulated. The image manipulation is supposed to happen only once. What I want is somehow to apply the cmanipulation on self.image only if the image is changed, or its been created... Is pre_seave the right way, if so how do you actually use it where it need to compare previosly stored data and the newone and then only execute. Ramdas -- Ramdas S +91 9342 583 065 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: pre-save and check for existing value of image
You can check whether there is instance or not by self.instance .This will tell u that whether it is change (page)or a new object is added.And if it new object then only call ur custom functions.U can also use changeForm function On Tue, Nov 10, 2009 at 12:39 PM, Ramdas Swrote: > Hi, > > I have this app which has an ImageField, where the image needs to be > cropped, resized, and a few effects (all from PIL) are applied on it, the > model looks something like this > > class MidPanel(models.Model): > >. >image = models.ImageField(upload_to="imgs") > > def save(self): >if self.image: > dosomething(image) > doanother2(self.image) > > > All this is fine. Expect that every time the model is saved, it executes > the manipulation on the image. What I require is an idea where the image > manipulation happens only if the image field is changed, and not unless. How > do I achieve that. > > Someone suggested me to use pre_vae signal, but I am not able to figure an > effcient way.. > > Can someone help > > -- > Ramdas S > +91 9342 583 065 > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
pre-save and check for existing value of image
Hi, I have this app which has an ImageField, where the image needs to be cropped, resized, and a few effects (all from PIL) are applied on it, the model looks something like this class MidPanel(models.Model): . image = models.ImageField(upload_to="imgs") def save(self): if self.image: dosomething(image) doanother2(self.image) All this is fine. Expect that every time the model is saved, it executes the manipulation on the image. What I require is an idea where the image manipulation happens only if the image field is changed, and not unless. How do I achieve that. Someone suggested me to use pre_vae signal, but I am not able to figure an effcient way.. Can someone help -- Ramdas S +91 9342 583 065 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: domains vs sub-domains
On Mon, Nov 9, 2009 at 9:38 PM, Chriswrote: > > I've recently been in discussion about which is better to have. > > http://media.example.com OR > http://example.com/media/ > > 1) The first method, I've been told, allows you to make more requests. > IE for example can only make like 4 requests at a given time on a > given domain. but, if you use sub-domains, you can make additional > requests (4 additional in the example of IE). > > 2) The second method is a more canonical approach and to me is the > preferred approach. The person arguing this point says that the > additional requests cannot be made on sub-domains b/c browsers issue X > amount of requests on a per domain basis therefore sub-domains do > create additional requests. Browsers have a limit on simultaneous requests per host name, not per domain name. > > I've also been told that these arguments are really not that big of a > deal. Like nearly everything in computing, there is no absolute answer to this that is correct under all circumstances. But my experience is that downloading more media resources simultaneously will generally improve the user-perceived response time of the initial access to a media-rich page. And, given how important first impressions are, that is very much worth considering. After the first load of a given page, there will be less impact as long as the resources remain cached locally by the browser. > > Which method should I adopt? I personally like the second method, but > if it will effect performance/ loading times at all then I should go > with the first method. I will be serving things like media and API's > on a separate server or instance. Any thoughts? There are a couple additional of reasons to consider option (1). First, since you are serving static resources only, you don't need to serve them with Django -- you can pick a highly optimized web server like nginix or Apache for serving the media resources. Second, they don't have to be served by the same physical server, which can definitely improve your application's scalability. You can play configuration games and accomplish some of both of these benefits with option (2), but it's a *lot* more configuration work. As a final thought, it's instructive to note that the Ruby on Rails equivalent to media-serving template tags have built in support for spreading the media requests, even for a single page, across as many media asset hosts as you wish to configure, with no impact on the templates themselves. And, in a globally accessed application, you can even use asset host names on a content delivery network so that media resources get served from a geographically close server, which will (again) improve the user-perceived responsiveness of your application. Sounds like a few other people in the world have found approach (1) to be worth the effort. Craig PS: WIth regards to aesthetics, does the *user* of your application care what the media URLs look like? Nope, I didn't think so either. So, neither should *you* make that a primary decision criteria :-). > > Thanks in advance for input. > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: annotation with filter issue (left join needed)
Well, I didn't find solution yet. Except that filter condition must be placed in LEFT OUTER JOIN ... ON ( ), but i'm not sure if it's possible with Django ORM. I notices that Aggregate base class takes 'extra' argument in its constructor, but I'm not sure how to use it for such purpose. Any suggestions? 2009/11/6 Михаил Лукин> Hi Djangoers > > There is two models: task and report on this task. > > class Task(models.Model): > # some task fields here > > class Report(models.Model): > task = models.ForeignKey(Task) > time_spent = models.PositiveSmallIntegerField() > date_posted = models.DateField(auto_now_add=True) > # some report fields here > > I need to query time spent on every task within interval of time. Here is > how I do it: > Task.objects.all().annotate(time_spent=Sum('report__time_spent')).filter(report__date_posted__gte=start_date, > report__date_posted__lte=due_date) > > Without filtering reports by date I can query general time spent on task > even if there were no reports (it is None, and it's OK). But when using > filter by date, when there is no reports posted on task, it is not returned > by queryset. Is this LEFT JOIN issue or what? What can you suggest? > > Thanks > > -- > regards, > Mihail > > -- regards, Mihail --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
help with EmailMultiAlternatives attach_file() or attach()
I asked a question earlier about trying to send an outlook message as an attachment, but didn't get a response. I'm so confused ... so I'm going to see if I can some up with a simpler question. I've have a file called 'foo.mht' that begins like this: Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit x-mimeole: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="_=_NextPart_003_01CA61C6.4B387F54" ... lines removed ... This is a multi-part message in MIME format. The code I use to create the file is functionally equivalent to this: mailString = sys.stdin.read() # read mail message from stdin message = email.message_fom_string(string) # turn it into a message # find a node in the message that is rfc822, and save it to a file as a string for part in message.walk(): if part.get_content_type() == "message/rfc822": f = open("foo.mht", "w") print >>f, part.as_string() f.close() I am hazy on this email stuff, but I think that the foo.mht file represents an on-file version of an email that I should be able to now send out as an attachment. I think I should be able to do something like this: msg = EmailMultiAlternatives(subject, body, from, to) msg.attach_file("foo.mht") msg.send() But when send() is called, I get the error: *** TypeError: Expected list, got If I attach a gif or png my code works ok, so I've got the basics down, but I know I'm doing something wrong with this rfc822 type of attachment. I guess I need to somehow turn foo.mht back into a message prior to attaching it? Could anyone give me pointer? I've been reading through the doc, but this mail encoding stuff is still black magic to me and I can't find much in the way of example code. Margie --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: domains vs sub-domains
Chris wrote: > I've recently been in discussion about which is better to have. > > http://media.example.com OR > http://example.com/media/ > ... > Which method should I adopt? I personally like the second method, but > if it will effect performance/ loading times at all then I should go > with the first method. I will be serving things like media and API's > on a separate server or instance. Any thoughts? All things considered the choice here is probably more aesthetic (which looks "prettier" to you) than about performance. If you like the second, then go with the second. If performance is an issue and you think the first gives you better performance you can edit your HTML templates and switch... Personally I like the first because it is "prettier" to me. It is also much easier for "poor man's load balancing"... If one server gets to crowded on the very basic sites that I host, I can swap it to another server with "merely" a DNS change. But that is only but one load balancing technique among many... Another reason I use subdomains, particularly for media, is the ability to use "off-the-shelf cloud products". For instance, my media.worldmaker.net "server" is currently a CNAME for a 'cheap' Amazon S3 bucket. It could just as easily be on Rackspace CloudFiles, for all that it matters. Meanwhile, I'm also considering "upgrading" it to a CloudFront distribution, potentially without having to touch any of my HTML for "instant" bonus performance. Having all my static media hosted by good static media hosts saves me time to think about my dynamic content and tools. Your mileage may certainly vary. -- --Max Battcher-- http://worldmaker.net --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to handle this race condition?
Thanks Christophe and Kenneth! Let me make sure I understand this: If I write this vew function: @transaction.commit_on_success def update_high_bid(request): cursor = connection.cursor() cursor.execute("SELECT high_bid FROM auctionapp_auction WHERE id=%s FOR UPDATE", [auction.id]) returned_rows = cursor.fetchall() high_bid = returned_rows[0][0] if new_bid > high_bid: auction.high_bid = new_bid auction.save() The entire function will be wrapped within a transaction. SELECT FOR UPDATE will acquire a row-level lock and that lock will not be released until the function update_high_bid () returns successfully, or until the function raises an exception and the whole transaction is rolled back. Is that right? Thanks. On Nov 10, 12:45 am, Christophe Pettuswrote: > On Nov 9, 2009, at 9:34 PM, Continuation wrote: > > > Also does django middleware acquire database lock on my behalf, or do > > I need to explicitly perform the locking? > > In the example code, it's the SELECT ... FOR UPDATE that acquires the > lock. Django doesn't currently have any explicit knowledge of > locking, so you need to drop down to the custom SQL level to issue the > right statement to acquire the lock on the row. > > The example I wrote assumed you were using PostgreSQL as the backend; > you can get all sorts of details about locking in PostgreSQL here: > > > http://www.postgresql.org/docs/8.4/interactive/explicit-locking.html#... > -- > -- Christophe Pettus > x...@thebuild.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to handle this race condition?
On Nov 9, 2009, at 9:34 PM, Continuation wrote: > Also does django middleware acquire database lock on my behalf, or do > I need to explicitly perform the locking? In the example code, it's the SELECT ... FOR UPDATE that acquires the lock. Django doesn't currently have any explicit knowledge of locking, so you need to drop down to the custom SQL level to issue the right statement to acquire the lock on the row. The example I wrote assumed you were using PostgreSQL as the backend; you can get all sorts of details about locking in PostgreSQL here: http://www.postgresql.org/docs/8.4/interactive/explicit-locking.html#LOCKING-ROWS -- -- Christophe Pettus x...@thebuild.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to handle this race condition?
On Nov 9, 2009, at 9:30 PM, Continuation wrote: > Can you tell me which middleware/decorator should I use to make sure > all those run within a single transaction? I'm pretty new to this. The transaction middleware will work: http://docs.djangoproject.com/en/dev/topics/db/transactions/#tying-transactions-to-http-requests You can also use the @commit_on_success decorator: http://docs.djangoproject.com/en/dev/topics/db/transactions/#django-db-transaction-commit-on-success -- -- Christophe Pettus x...@thebuild.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
domains vs sub-domains
I've recently been in discussion about which is better to have. http://media.example.com OR http://example.com/media/ 1) The first method, I've been told, allows you to make more requests. IE for example can only make like 4 requests at a given time on a given domain. but, if you use sub-domains, you can make additional requests (4 additional in the example of IE). 2) The second method is a more canonical approach and to me is the preferred approach. The person arguing this point says that the additional requests cannot be made on sub-domains b/c browsers issue X amount of requests on a per domain basis therefore sub-domains do create additional requests. I've also been told that these arguments are really not that big of a deal. Which method should I adopt? I personally like the second method, but if it will effect performance/ loading times at all then I should go with the first method. I will be serving things like media and API's on a separate server or instance. Any thoughts? Thanks in advance for input. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to handle this race condition?
On Tuesday 10 Nov 2009 11:00:55 am Continuation wrote: > > """ Be sure this all runs inside a single transaction! Use the > > appropriate middleware or > > decorators... """ > > Thanks for your help. > > Can you tell me which middleware/decorator should I use to make sure > all those run within a single transaction? I'm pretty new to this. > transaction_commit_on_success - not too sure of the spelling. -- regards Kenneth Gonsalves Senior Project Officer NRC-FOSS http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to handle this race condition?
On Nov 10, 12:07 am, Christophe Pettuswrote: > Beware of deadlocks! Keep the number of tables on > which you acquire locks to a minimum, and acquire them in the same > order in all places in your code. Also does django middleware acquire database lock on my behalf, or do I need to explicitly perform the locking? 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to handle this race condition?
On Nov 10, 12:07 am, Christophe Pettuswrote: > """ Be sure this all runs inside a single transaction! Use the > appropriate middleware or > decorators... """ Thanks for your help. Can you tell me which middleware/decorator should I use to make sure all those run within a single transaction? I'm pretty new to this. Thanks again! --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to handle this race condition?
On Nov 9, 2009, at 8:36 PM, Continuation wrote: > When a new_bid comes in, I: > 1) retrieve the current_high_bid field of the Auction object > 2) compare it with the new_bid > 3) if the new bid is higher than current_high_bid, I update > current_high_bid to the value of the new_bid. > > but there's a (slight) chance that between steps (1) and (3) a > different user could've submitted an even higher bid which then become > the current_high_bid. In that case step 3 should not proceed. What can > I do to make sure such a situation does not arise? This is, of course, exactly what database locking what designed to handle (indeed, this is pretty much a textbook case). Right now, Django doesn't provide any built-in method of doing row-level locking through the model. (There's an open ticket that discusses this: http://code.djangoproject.com/ticket/2705 ) For now, you can write custom SQL (consider this pseudo-code rather than a drop-in replacement): """ Be sure this all runs inside a single transaction! Use the appropriate middleware or decorators... """ cursor = connection.cursor() cursor.execute("SELECT high_bid FROM auctionapp_auction WHERE id=%s FOR UPDATE", [auction.id]) """ Until this SELECT, other users could have modified the high bid, so do not trust the in-memory copy. """ returned_rows = cursor.fetchall() high_bid = returned_rows[0][0] if new_bid > high_bid: auction.high_bid = new_bid auction.save() If another user attempts to update the bid, it will block when doing the SELECT... FOR UPDATE until the first transaction closes, and will then continue. Beware of deadlocks! Keep the number of tables on which you acquire locks to a minimum, and acquire them in the same order in all places in your code. -- -- Christophe Pettus x...@thebuild.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to handle this race condition?
I'm working on an auction app. In an Auction object I store the current_high_bid for that auction. When a new_bid comes in, I: 1) retrieve the current_high_bid field of the Auction object 2) compare it with the new_bid 3) if the new bid is higher than current_high_bid, I update current_high_bid to the value of the new_bid. but there's a (slight) chance that between steps (1) and (3) a different user could've submitted an even higher bid which then become the current_high_bid. In that case step 3 should not proceed. What can I do to make sure such a situation does not arise? 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
TemplateSyntaxError
Hello, These are my tables: BEGIN; CREATE TABLE "wkw_school" ( "id" integer NOT NULL PRIMARY KEY, "school" varchar(200) NOT NULL ) ; CREATE TABLE "wkw_lawyer" ( "id" integer NOT NULL PRIMARY KEY, "first" varchar(20) NOT NULL, "initial" varchar(2) NOT NULL, "last" varchar(20) NOT NULL, "year_graduated" datetime NOT NULL, "school_id" integer NOT NULL REFERENCES "wkw_school" ("id") ) ; COMMIT; (I changed "Education" to "School" because in the admin panel it showed up as "Educations". I think "Schools" makes more sense.) I created the admin and I registered School and Lawyer. In the admin panel School link works fine but when I click on Lawyer link I get a "TemplateSyntaxError at /admin/wkw/lawyer/ Caught an exception while rendering: no such column: wkw_lawyer.school_id" But according to the above tables, school_id has been created. I tried to add in the shell, p = Lawyer(school_id=1) but p.save() throws an error. Any ideas why Lawyer link in the admin panel does not work? This is the offending line on the debug page: 78{% result_list cl %} Thank 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
MySQL and 'NoneType object is unsubscriptable' error
Hi, I've tried to install MySQL for an existing project, and I'm getting a strange error (see traceback below). Apparently "self.converter" is None, but I can't see why. I can access the database just fine using the 'mysql' command in the terminal or using PhpMyAdmin. Do you know how this could be fixed? Thanks a lot for you help. Julien Traceback (most recent call last): File "/Users/julien/Documents/Development/eclipse/workspace/ myproject/trunk/site/manage.py", line 13, in execute_manager(settings) File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/__init__.py", line 439, in execute_manager utility.execute() File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/__init__.py", line 380, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/base.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/base.py", line 222, in execute output = self.handle(*args, **options) File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/commands/runserver.py", line 84, in handle inner_run() File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/commands/runserver.py", line 48, in inner_run self.validate(display_num_errors=True) File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/core/management/validation.py", line 67, in get_validation_errors connection.validation.validate_field(e, opts, f) File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/db/backends/mysql/validation.py", line 15, in validate_field db_version = connection.get_server_version() File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/db/backends/mysql/base.py", line 297, in get_server_version self.cursor() File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/db/backends/__init__.py", line 81, in cursor cursor = self._cursor() File "/Users/julien/Documents/Development/eclipse/workspace/django/ django/db/backends/mysql/base.py", line 281, in _cursor self.connection = Database.connect(**kwargs) File "/opt/local/lib/python2.5/site-packages/MySQLdb/__init__.py", line 81, in Connect return Connection(*args, **kwargs) File "/opt/local/lib/python2.5/site-packages/MySQLdb/ connections.py", line 222, in __init__ self.converter[FIELD_TYPE.STRING].append((None, string_decoder)) TypeError: 'NoneType' object is unsubscriptable --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Another Django vs. Rails comparison
This is a helpful list of pros/cons. Thanks. Your "development philosophy" point especially matches up well with my own experience. A friend and I just wrote a website for a new small business ( http://www.final-draft-editing.com/) and chose Django -- after an initial trial of Ruby on Rails -- more or less for the same reason you ended up deciding on it: the Rails framework does many things by "magic" and you have to learn certain conventions to make sure the magic works for you. In django, the interface between application code and framework is much more explicit. Reasonably capable python coders can jump in without as much of a learning curve. (Also, Python is a much more pleasant language to work in than Ruby, IMO.) -Paul On Mon, Nov 9, 2009 at 4:47 PM, Jasonwrote: > > This is my first post to this group, but I've benefited from reading > other's posts and I'm looking forward to getting more involved. I just > picked Django/Python as the framework for a new company I just > started: FeedMagnet (http://feedmagnet.com). > > We want to get more involved in the community - we already have some > CouchDB integration code that we're going to open source in the next > couple weeks - and I thought a good way to get involved initially > would be to share my experience choosing between Django and Rails. > > I read a lot of other posts on the topic (many of which are linked > from my post) and talked with lots of other developers before making > the decision. The single sentence summary of my post is that Django > and Rails are both great frameworks and it is more important to get > the right team in place and let them pick the one they like best. > > While I definitely favor Django, I think I am still new enough to the > community that my opinions shouldn't be too biased. Hopefully this > post helps other make the right decision for their team/project. > > Here's the link: http://beta.feedmagnet.com/blog/django-vs-rails/ > > > > -- Paul Ragnar Eastlund Me: (relating a joke) "...so I said, 'I'm working at Google. I'm the guy who frantically does research when you type in a query.'" Lorraine: "Oh." (long pause) "But is that really what you do?" Sharon: "...And now, the joke is on 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: User class, change name of fields(like username with login name)
On Nov 9, 7:49 am, NMarcuwrote: > Hello all, > > I have a list of all users. My head table is made with the fields > from User class. So look like this: > > username first name last name > superuser status > > I want to make this head table editable. How can I change the caption > of the field, not the name of it. By ex: is_superuser field is build > like this: > > is_superuser = models.BooleanField(_('superuser status'), > default=False, help_text=_("Designates that this user has all > permissions without explicitly assigning them.")) > > In my table is list superuser status not is_superuser, this is good. > How can I change: "superuser status" in something else from a view. To make something this dynamic, you will need a model for your label, with some way to key it to the column you want to use it for - I can't think of a clean way to change the verbose name of the classes dynamically as the objects are instantiated per request. A simple, if somewhat brittle way to do it, would be to use the __name__ of the model in question and use that as a key to look up the label to use in your form. -Preston --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help about models
Hello Greg and Jirka, Thanks for the help. I was rereading the tutorial to understand the ForeignKey. It says that ForeignKey "tells Django each Choice is related to a single Poll." In my case, each lawyer is associated with 1 law school; and each law school is associated with 1 or more lawyers. Considering this I thought that ForeignKey should tell Django that "each lawyer is related to a single School" so I put ForeignKey under Lawyer: class Education(models.Model): school = models.CharField(max_length=200) class Lawyer(models.Model): first = models.CharField(max_length=20) initial = models.CharField(max_length=2) last = models.CharField(max_length=20) year_graduated = models.DateTimeField('Year graduated') education = models.ForeignKey(Education) Does this make sense? And, can you explain why this is needed in terms of searching the database? What happens if I don't use a foreign key? Thanks again. On Nov 9, 7:36 am, Jirka Vejrazkawrote: > > I commented out the ForeignKey because it caused an error. > > Just a small coding note - it was causing an error because you did not > specify the model name exactly (compare the character case) > > Jirka --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Templates,layout, css, ie and Pyjamas
Grant, Hi 2009/11/10 grant neale: > > Hi Ishwor, > > I'm in France I'm afraid. > Is there any solution out there for getting the basics up and running - Download a copy of Django and give it a go. - Extract it to a folder - Run 'python setup.py install'; - Go to django directory - python django-admin.py startproject - Go to - python manage.py startapp - Code away latest greatest app.. Your application logic in views.py, your database models in models.py and your Django template in some HTML file (say templates.html) - Fix your settings.py,urls.py accordingly. - python manage.py runserver - Point your browser to http://127.0.0.1:8000/ All the instructions are already there in the docs if you get confused or something... When you get to a point where you can't do something, ask in the list. Someone should be able to help you out real quick. > and then going into the "beauty contest" later? > Or are you just saying that it's hard, just eat your lunch? It's too easy to call label it 'hard'. This mail took me 2 mins to write. Imagine the possibility with what you can do with Django. Last week, wonderful Peter of SyPy Fame gave a talk on GeoDjango. Twas fun to say the least... > If you ever come to France, I can send you some links on where to > stay. :) Sure nice thing. Thanks. I'll keep note of that :-) -- Regards, Ishwor Gurung --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django internationalization problem: Error: errors happened while running xgettext on __init__.py /bin/sh: xgettext: command not found
2009/11/9 NMarcu: > > Hello all, > > When I run django-admin.py makemessages -l ro I got this: > Error: errors happened while running xgettext on __init__.py > /bin/sh: xgettext: command not found > > You know why, I need to install somethng else? > > > are you sure you have gettext installed on your computer? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
how to send an rfc822 email attachment
I am trying to write some add code to my app that accepts an email from the user that contains attachments, adds those attachments to the database and then sends an email containing those attachments. I am trying to get my code to work for the case were the attachment is an outlook mail (ie, an rfc822 content-type). For other cases it is working (ie, an msword doc or htm attachment), but there is something trickier about sending out an rfc822 I think. I've got a small example of what I'm doing in my code I'm wondering if anyone who understands email and FileFields could take a look. Basically, I'm just trying to take the attached message, save it to a django models.FileField, then send the contents of that FileField on to recipients. Here's my Attachment model: class Attachment(models.Model): file = models.FileField('File', upload_to=get_attachments_path) filename = models.CharField('Filename', max_length=100) mime_type = models.CharField('MIME Type', max_length=30) Here's my code that is parsing the message and encountering the rfc822 sub part: if message.get_content_type() == 'message/rfc822': name = message.get_param("name") content = message.as_string() # ??? this may be wrong? mime_type = message.get_content_type() a = Attachment(filename=name, mime_type=mime_type) a.file.save(name, ContentFile(content)) msg = EmailMultiAlternatives(subject, body, from_email, to, cc) msg.attach_file(a.file.path) msg.send() The problem I'm having is that when msg.send() gets called, I get an error associated with my attachment: File "/tools/aticad/1.0/platform/any/lib/python2.6/email/ message.py", line 189, in get_payload raise TypeError('Expected list, got %s' % type(self._payload)) I'm thinking that my argument to ContentFile() is wrong. I'm giving it message.as_string(), and I suspect that is wrong, but I can't figure out what it should be. Can anyone give me a hand? Thank you for any pointers! Margie --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Another Django vs. Rails comparison
This is my first post to this group, but I've benefited from reading other's posts and I'm looking forward to getting more involved. I just picked Django/Python as the framework for a new company I just started: FeedMagnet (http://feedmagnet.com). We want to get more involved in the community - we already have some CouchDB integration code that we're going to open source in the next couple weeks - and I thought a good way to get involved initially would be to share my experience choosing between Django and Rails. I read a lot of other posts on the topic (many of which are linked from my post) and talked with lots of other developers before making the decision. The single sentence summary of my post is that Django and Rails are both great frameworks and it is more important to get the right team in place and let them pick the one they like best. While I definitely favor Django, I think I am still new enough to the community that my opinions shouldn't be too biased. Hopefully this post helps other make the right decision for their team/project. Here's the link: http://beta.feedmagnet.com/blog/django-vs-rails/ --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Prevent brute-force password attacks?
Yes, teaching users to not choose stupid username/password combinations. That's the only correct/true fix. Are you worried about the traffic that it consumes? If so, you continue to play in dicey territory, since you're trying to deduce harmful bots from potentially stupid users that just can't remember their account information. Yes, it's easy to see in the aftermath with human eyes the difference, seeing it as it happens with code, and being right 100% (which is the only acceptable percentage in the case of usability) is difficult. I don't personally know if anything exists to do what you want to do, but it shouldn't be incredibly hard to write. You could log all the IPs to the database, compare the frequency, and then what you do with them from there is up to you. You could redirect the user elsewhere, or serve them 404s to make them think the content's gone (could have ill effects on SEO in rare cases). Then you could cron up a purge scenario, after so many days, or if you definitely don't like the IP you could write the IPs out to your firewall's blacklist (at least, easy to do in shorewall). Ironically, doing all that will create potentially more database calls and traffic than just weathering the storm. Your call. Btw, don't mean to be blunt/rude, as that's not my intention. Just dealt with a lot of these scenarios as a sys admin in a former life, and the answer is always to beat users over the head until they stop choosing "god/god" as their username/password combination. On Nov 9, 3:57 pm, Adam Seeringwrote: > Hi, > Does there exist any code for Django to help defeat brute-force login > attempts? Something like blocking IP addresses from logging in if they > try and fail too many times, etc. > > Adam --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Prevent brute-force password attacks?
Check http://code.google.com/p/django-axes/ Bye ! 2009/11/9 Adam Seering> > Hi, >Does there exist any code for Django to help defeat brute-force > login > attempts? Something like blocking IP addresses from logging in if they > try and fail too many times, etc. > > Adam > > > > > -- Benito Jorge Bastida jo...@thecodefarm.com thecodefarm SL Av. Gasteiz 21, 1º Derecha 01008 Vitoria-Gasteiz http://thecodefarm.com Tel: (+34) 945 06 55 09 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Prevent brute-force password attacks?
Hi, Does there exist any code for Django to help defeat brute-force login attempts? Something like blocking IP addresses from logging in if they try and fail too many times, etc. Adam --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: DRY: max length not taken from Model.field when using ModelForm
Tomasz, it was obvious for me too, however, I had defined a form, which had some fields overridden, but some not- I was hoping that options for fields that were not overridden were preserved, but due to specific way admin interface handles forms, required class wasn't added to my custom form fields. That's why I thought other field options were not taken into account. Reinis On 7 nov., 21:27, Tomasz Zielińskiwrote: > On 7 Lis, 18:25, fest wrote: > > > From my experience, max_length is not taken into account when you > > override modelfieldin formfield. > > This is (and was, when I first time faced it) quite obvious for me . > IfModelFormwas modifying overridden fields, the whole concept > of overriding would be useless. > > On the other hand it would be nice if we could write something like: > > first_name = forms.CharField(max_length=copy_from_model) > > -- > Tomasz Zielińskihttp://pyconsultant.eu --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django internationalization problem: Error: errors happened while running xgettext on __init__.py /bin/sh: xgettext: command not found
Hello all, When I run django-admin.py makemessages -l ro I got this: Error: errors happened while running xgettext on __init__.py /bin/sh: xgettext: command not found You know why, I need to install somethng else? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to create a faceted browser with Django
On Nov 9, 4:24 am, SeanBwrote: > Many web sites offer faceted browsing such that a series of categories > can be selected to narrow a large set of records down to a few (or > one). Such interfaces often show how many records match the various > category values, which sometimes helps direct the search. Likewise, > since only valid combinations of categories values are shown and > selectable, the problem problem of constraints with zero results are > mitigated. You can see this in action on lots of shopping sites: > Amazon's page on diamond wedding rings (http://www.amazon.com/gp/ > search/ref=sr_nr_n_2?rh=n%3A3367581%2Ck%3Adiamonds%2Cn%3A!3880591%2Cn > %3A3887251=3880591=diamonds=UTF8=1257740168=388059 1) > is a good example. > > I'm an intermediate-level Django user, and i'm trying to conceive how > to architect a faceted browsing application in Django. I can see > conceptually how a combination of constraints specified in the > interface could translate into a series of filter statements on a > model, and i can see how, with some constraints in place, the > remaining values and the number of records matching them could be > computed and presented. > > But I'm less sure how to provide a RESTful interface (since any of > several constraints can be selected independently) in an efficient > manner, or how to work out the template details. So i'm looking for > some direction. > > Are there any Django sites out there already that use an approach like > this? Or suggestions as to how to architect one? We've achieved faceted search by using the haystack project, which provides faceted search for Django out of the box in conjunction with an external search engine, Solr. Works well for us. -- DR. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to create a faceted browser with Django
as a follow-up: list_filter attributes in the admin interface provide part of what i mean, but only part. Given a set of restrictions, the admin interface: * shows all possible choices, rather than the only remaining choices that are possible * doesn't show counts Sean On Nov 8, 8:24 pm, SeanBwrote: > Many web sites offer faceted browsing such that a series of categories > can be selected to narrow a large set of records down to a few (or > one). Such interfaces often show how many records match the various > category values, which sometimes helps direct the search. Likewise, > since only valid combinations of categories values are shown and > selectable, the problem problem of constraints with zero results are > mitigated. You can see this in action on lots of shopping sites: > Amazon's page on diamond wedding rings (http://www.amazon.com/gp/ > search/ref=sr_nr_n_2?rh=n%3A3367581%2Ck%3Adiamonds%2Cn%3A!3880591%2Cn > %3A3887251=3880591=diamonds=UTF8=1257740168=3880591) > is a good example. > > I'm an intermediate-level Django user, and i'm trying to conceive how > to architect a faceted browsing application in Django. I can see > conceptually how a combination of constraints specified in the > interface could translate into a series of filter statements on a > model, and i can see how, with some constraints in place, the > remaining values and the number of records matching them could be > computed and presented. > > But I'm less sure how to provide a RESTful interface (since any of > several constraints can be selected independently) in an efficient > manner, or how to work out the template details. So i'm looking for > some direction. > > Are there any Django sites out there already that use an approach like > this? Or suggestions as to how to architect one? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How can I change the verbose_name of a field and save this in model, or db, from a view?
Hello, I want to change the verbose_name to is_superuser, on User class. The current one is superuser status, and I want to make this field editable, and I need to change this verbose_name from view, how can I 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User class, change name of fields(like username with login name)
Hello all, I have a list of all users. My head table is made with the fields from User class. So look like this: username first name last name superuser status I want to make this head table editable. How can I change the caption of the field, not the name of it. By ex: is_superuser field is build like this: is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_("Designates that this user has all permissions without explicitly assigning them.")) In my table is list superuser status not is_superuser, this is good. How can I change: "superuser status" in something else from a view. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Templates,layout, css, ie and Pyjamas
Hi Ishwor, I'm in France I'm afraid. Is there any solution out there for getting the basics up and running and then going into the "beauty contest" later? Or are you just saying that it's hard, just eat your lunch? If you ever come to France, I can send you some links on where to stay. :) Thanks' On Nov 9, 2009, at 3:08 PM, Ishwor Gurung wrote: > > Hi, > > 2009/11/10 grant neale: >> >> Hi, >> >> I'm a hobbyist and do not have a lot of time on my hands to do front >> end (templates, css) stuff. > Hire a professional to do you it for you. > >> I was looking around and saw that pyjamas takes care of the layout of >> the user interface. > > This is Django list FYI. > > [...] > >> Are there any other solutions out there that would let me develop the >> layout quicker or easier? > Templates are easy. If you know some HTML, it shouldn't take very long > to figure out django templates. > >> Obviously I'm not too thrilled about making sure that all the >> browsers >> look good. > If you can abstract out browser specific functionality, should be good > across all major browsers - Firefox, IE, Chrome > >> Can anyone help me? > Google - Django templates. If you leave in Sydney, drop me an email > off list. I can help you out for coupla beers ;-) > > -- > Regards, > Ishwor Gurung > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Stuck with csrf_token in the tutorial
On Nov 9, 3:38 pm, Karen Traceywrote: > On Mon, Nov 9, 2009 at 9:35 AM, wietse wrote: > > Running django 1.1.1 > > > I'm going through the tutorial and have run into trouble implementing > > a form, I get: > > TemplateSyntaxError at /polls/1/ > > Invalid block tag: 'csrf_token' > > csrf_token didn't exist in 1.1.1 -- it's new in the development version. > Please use the 1.1 docs: > > http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01 > > (There is an open ticket to get these properly linked from the documentation > page.) Ok, thanks for the quick response! Wietse --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Databrowse: Loading a large number of records
On Nov 9, 2009, at 7:49 AM, Ismail Dhorat wrote: > I also see there has been a ticket logged for this issue about 2 > years ago. > > http://code.djangoproject.com/ticket/4481 > > Has this been implemented? If not would would a simple paginate tag in > the template suffice? Have you tried applying the patch in the ticket to see whether it solves your specific case? 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Stuck with csrf_token in the tutorial
On Mon, Nov 9, 2009 at 9:35 AM, wietsewrote: > > Hello, > > Running django 1.1.1 > > I'm going through the tutorial and have run into trouble implementing > a form, I get: >TemplateSyntaxError at /polls/1/ >Invalid block tag: 'csrf_token' > > csrf_token didn't exist in 1.1.1 -- it's new in the development version. Please use the 1.1 docs: http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01 (There is an open ticket to get these properly linked from the documentation page.) Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Stuck with csrf_token in the tutorial
Hello, Running django 1.1.1 I'm going through the tutorial and have run into trouble implementing a form, I get: TemplateSyntaxError at /polls/1/ Invalid block tag: 'csrf_token' I've searched around but find it hard to grok what I need to do. In settings.py I have: MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.csrf.middleware.CsrfMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) The form has a `{% csrf_token %}`, and the view is as per the tutorial: def detail(request, poll_id): p = get_object_or_404(Poll, pk=poll_id) return render_to_response('polls/detail.html', {'poll': p}, context_instance=RequestContext(request)) Somewhere I read that if I get this kind of error it means I "have failed to use the tag loader", but I don't know what that means. Can somebody show me the way? Wietse --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django generic views w multiple models
Ok I think I've honed my problem down a bit further and more concisely: So I'm trying to create an Info object that is attached to a League object, but I can't do this through the urlconf the way I have it now because create_object() does not take an object id as an argument. Somehow, I need to grab the League id number when a user clicks on a league they want to enter their info for so that the user only signs up for that one particular league. Is there a way to write a wrapper to the generic create_object view to do this or do I need to scrap generic views altogether in this instance and write my own view? On Nov 8, 5:56 pm, Rosswrote: > 'm new to Django and programming in general. I'm trying to make a > simple site that allows players of a sport sign up for leagues that > have been created by the admin. In my models.py, I created two models: > `from django.db import models from django.forms import ModelForm > > class League(models.Model): league_name = models.CharField > (max_length=100) pub_date = models.DateTimeField('date published') > > class Info(models.Model): league = models.ManyToManyField(League) name > = models.CharField(max_length=50) phone = models.IntegerField() email > = models.EmailField() def unicode(self): return self.info > > class InfoForm (ModelForm): class Meta: model = Info exclude = > ('league')` > > From what I've read, I can probably use the Create/Update/Delete > generic views to display a form for the user to sign up for the > league. So with my app, I want the user to come to a simple homepage > that lists the leagues, be able to click on the league and enter their > info to sign up. Here's what my urlconf looks like:`from > django.conf.urls.defaults import * from mysite.player_info.models > import League, Info, InfoForm > > info_dict = { 'queryset': League.objects.all(), } > > InfoForm = {'form_class' : InfoForm} > > urlpatterns = patterns('', (r'^$', > 'django.views.generic.list_detail.object_list', info_dict), (r'^(?P\d > +)/$', 'django.views.generic.list_detail.object_detail', info_dict), > url(r'^(?P\d+)/results/$', > 'django.views.generic.list_detail.object_detail', dict(info_dict, > template_name='player_info/results.html'), 'league_results'), (r'^(?P\d > +)/info/create/$', 'django.views.generic.create_update.create_object', > InfoForm), )` > > Here's my problem: When I click on a league to sign up for on the > homepage with my current setup, I get this error: TypeError at /league/ > 1/info/create create_object() got an unexpected keyword argument > 'object_id'. What am I doing 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Templates,layout, css, ie and Pyjamas
Hi, 2009/11/10 grant neale: > > Hi, > > I'm a hobbyist and do not have a lot of time on my hands to do front > end (templates, css) stuff. Hire a professional to do you it for you. > I was looking around and saw that pyjamas takes care of the layout of > the user interface. This is Django list FYI. [...] > Are there any other solutions out there that would let me develop the > layout quicker or easier? Templates are easy. If you know some HTML, it shouldn't take very long to figure out django templates. > Obviously I'm not too thrilled about making sure that all the browsers > look good. If you can abstract out browser specific functionality, should be good across all major browsers - Firefox, IE, Chrome > Can anyone help me? Google - Django templates. If you leave in Sydney, drop me an email off list. I can help you out for coupla beers ;-) -- Regards, Ishwor Gurung --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: matplotlib usage problem
On Mon, Nov 9, 2009 at 8:36 AM, Oguz Yarimtepewrote: > > Hi, > > I was trying to use the matplotlib at my Django view. The version i was > trying is 0.98. What i did is to import the library and then plot a graph. > The problem is when i tried the "from pylab import *", i got "RuntimeError: > could not create GdkCursor object". This is most probably because of the > apache user is not able to access the X server. Indeed at my distro it > doesn't have shell account. > > I don't want to define X access to apache user. So what do you suggest? > > Don't use the pylab API from Django code. It assumes a GUI and also (if I remember correctly) is not thread-safe. You need to use the object-oriented API, as shown here for example: http://www.scipy.org/Cookbook/Matplotlib/Django Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: matplotlib usage problem
Hallöchen! Oguz Yarimtepe writes: > I was trying to use the matplotlib at my Django view. The version > i was trying is 0.98. What i did is to import the library and then > plot a graph. The problem is when i tried the "from pylab import > *", i got "RuntimeError: could not create GdkCursor object". This > is most probably because of the apache user is not able to access > the X server. Indeed at my distro it doesn't have shell account. > > I don't want to define X access to apache user. So what do you > suggest? Use the pure Agg backend instead of GtkAgg. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
matplotlib usage problem
Hi, I was trying to use the matplotlib at my Django view. The version i was trying is 0.98. What i did is to import the library and then plot a graph. The problem is when i tried the "from pylab import *", i got "RuntimeError: could not create GdkCursor object". This is most probably because of the apache user is not able to access the X server. Indeed at my distro it doesn't have shell account. I don't want to define X access to apache user. So what do you suggest? -- Oguz Yarimtepe--~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Templates,layout, css, ie and Pyjamas
Hi, I'm a hobbyist and do not have a lot of time on my hands to do front end (templates, css) stuff. I was looking around and saw that pyjamas takes care of the layout of the user interface. Is this a reasonable solution to use instead of Django's templates? Are there any other solutions out there that would let me develop the layout quicker or easier? Obviously I'm not too thrilled about making sure that all the browsers look good. Can anyone help me? Grant --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
[uploadify] passing user info to the signal handler
The django-uploadify app allows bulk file uploads and for each uploaded file, it fires a signal and passes the uploaded file data to the receiver. The author's example marks all the uploaded files with a boolean (new_upload=True) and then returns a list of files where new_upload=True to the user. If more than one user is uploading files at the same time, they could get a list of files from other users. I would like to pass a user ID or some sort of session ID to the signal receiver along with the file data so that it can be inserted into the ORM along with the file data. Does anyone know how I can do this? Thanks Mike --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Databrowse: Loading a large number of records
Hi Guys, I am currently testing the contrib app databrowse in Django ver 1.1.1, the current setup for testing purposes is: OS: Mac OsX 10.6 DB: Sqlite3 Django: 1.1.1 Python: 2.5 Here is what i have done, i have a model and i am trying to see what the capabilities and limits of this app (since i will most likely be working with a huge number of records), i loaded +- 300,000 records into the DB current SQLITE file size is 30mb When trying to access /databrowse i get errors, and the page refuses to load. It basically hangs, from the looks of it the page seems to be displaying all the contents. Here is the traceback: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 280, in run self.finish_response() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 320, in finish_response self.write(data) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 399, in write self.send_headers() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 463, in send_headers self.send_preamble() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 381, in send_preamble 'Date: %s\r\n' % http_date() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/socket.py", line 261, in write self.flush() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/socket.py", line 248, in flush self._sock.sendall(buffer) error: (32, 'Broken pipe') I also see there has been a ticket logged for this issue about 2 years ago. http://code.djangoproject.com/ticket/4481 Has this been implemented? If not would would a simple paginate tag in the template suffice? Regards, Ismail --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Display a view of a single record?
I have a really hard time understanding what do you need, and I suspect I'm not the only one. You are talking about the admin interface, right? It displays a list containing all records, and when you click on a record you go to a page that shows all fields for this record (and lets you change their values). Isn't that exactly what you want? If the problem is that you don't want the fields to be editable, because you just want to display read-only lists of records: re-think using admin interface. It is meant specifically for managing records on your website. Just use "django.views.generic.list_detail.object_list" (display list of records) and "django.views.generic.list_detail.object_detail" (display detailed view of a single record) generic views: http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-list-detail-object-list http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-list-detail-object-detail --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help about models
> I commented out the ForeignKey because it caused an error. Just a small coding note - it was causing an error because you did not specify the model name exactly (compare the character case) Jirka --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template Syntax Error: url config module not found
Ok, so I narrowed this down a bit: the problem was with get_absolute_url. I still do not understand why it would complain about the urls.py not being found. I'd still be happy about any hints, but in the meantime I changed my template code to a not-so-DRY but working version with explicit urls. On 9 Nov., 08:46, m3mitsuppewrote: > Hi all, > > I have a strange error on a website I developed (quite some time > ago...). > > The main url works:http://www.christina-kratzenberg.de > > So do all the links at the bottom except for the "portfolio" one. It's > of course the interesting part where a photo portfolio is shown. > > When I click on that link, Django issues a Template Syntax Error > saying that the module "tina.urls" cannot be importet. That's kind of > strange, because it must have been imported this exact module for > rendering the home page and the other pages that do work. > > As this happens during template rendering, I'm a bit at a loss here. > Can anyone provide me with ideas? I don't really understand where to > look for a solution. > > I'm on Django 1.0.2 with mod_python. Upgrading Django to a newer > version and/or migrating to mod_wsgi is possible, but I don't want to > start changing everything without understanding what's happening here. > > Thanks! > Eric --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
memcached isspace(3) on server start with any cache refference
Hey I'm getting: mcm_validate_key_func():3443: memcache(4) protocol error: isspace(3) returned true for character in key error when I start a server (right after the "Validating models" step). The weird and annoying part is - is that I've not yet implemented cache anywhere yet. Only in settings - where its set: CACHE_BACKEND = 'memcached://127.0.0.1:11211/' So http://code.djangoproject.com/ticket/7460 shouldn't apply (its not yet used!). In the python terminal the following works correctly: import cmemcache c = cmemcache.StringClient(['127.0.0.1:11211']) c.set('testkey', 'testval') c.get('testkey') >>> 'testval' so memcache seems to be working. Is there anywhere in the models which could be trying to write to the cache? I've tried all the usuals (flushing, restarting etc...). This has me stumped. Any ideas? Thanks in advance, - 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Collapsible fields
Daniel Roseman wrote: > On Nov 9, 8:47 am, Lars Stavholmwrote: >> Hi All, >> >> I'm looking to implement collapsible fields in a django powered >> page, so far with no luck. >> >> Any hints on the best way of doing it? >> >> In the mean time, I checked out how it's done in the admin interface, >> and came up with a simple test page as follows: >> >> >> >> > href="http://localhost:8000/media/css/forms.css; /> >> > src="http://localhost:8000/media/js/core.js"> >> >> > src="http://localhost:8000/media/js/admin/CollapsedFieldsets.js"> >> >> >> >> >> Job Details >> >> >> Jdate: >> > class="vTextField" maxlength="30" >> type="text" id="id_jdate" /> >> >> >> >> >> >> >> But for some reason, it does not work. The collapsed >> field shows up (I guess) by ways of the Job Details >> showing up, but nothing else. >> >> Any hints? >> >> I admit, I'm a newbie at these things, but still. >> >> Any advice appreciated. >> >> R >> /Lars > > None of the admin scripts will work without the 'jsi18n' script, which > is actually accessed via an admin view. Include this line before the > other scripts: > http://localhost:8000/admin/ > jsi18n/"> > and it should work. > > Firebug is great for debugging this sort of thing - it would have told > you 'gettext is not defined' which would have helped track down the > problem. Great advice, thank you.Just started using firebug and of course encountered the gettext error. I put the script link in there as you suggested, and it's all working very nicely now. Many thanks /Lars --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Collapsible fields
On Nov 9, 8:47 am, Lars Stavholmwrote: > Hi All, > > I'm looking to implement collapsible fields in a django powered > page, so far with no luck. > > Any hints on the best way of doing it? > > In the mean time, I checked out how it's done in the admin interface, > and came up with a simple test page as follows: > > > > href="http://localhost:8000/media/css/forms.css; /> > src="http://localhost:8000/media/js/core.js"> > > src="http://localhost:8000/media/js/admin/CollapsedFieldsets.js"> > > > > > Job Details > > > Jdate: > class="vTextField" maxlength="30" > type="text" id="id_jdate" /> > > > > > > > But for some reason, it does not work. The collapsed > field shows up (I guess) by ways of the Job Details > showing up, but nothing else. > > Any hints? > > I admit, I'm a newbie at these things, but still. > > Any advice appreciated. > > R > /Lars None of the admin scripts will work without the 'jsi18n' script, which is actually accessed via an admin view. Include this line before the other scripts: http://localhost:8000/admin/ jsi18n/"> and it should work. Firebug is great for debugging this sort of thing - it would have told you 'gettext is not defined' which would have helped track down the problem. -- DR. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Helsinki area djangonauts: Let's meet up
Count me in. Also sent the message to three djangonauts I know who are not on djangopeople. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django web flow
On 8 nov, 17:49, Lanawrote: > Hi! > > Does Django have some sort of web flow similar to the Spring web flow > in Java? Err... Do we have to read Spring's doc to find out what this means ? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Running doctests of app custom filters
Hi, first timer message here :) I'm discovering both Django and Python and loving them so far. I'm pretty excited by the abilities offered by doctests. I've written some custom template filters and would like their doctests to be executed when I run ./manage.py test myapp. I didn't find a way reading the documentation... Any hint? Thanks. -- Nicolas Perriault http://prendreuncafe.com - http://symfonians.net Mobile: +33 660 92 08 67 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Collapsible fields
Hi All, I'm looking to implement collapsible fields in a django powered page, so far with no luck. Any hints on the best way of doing it? In the mean time, I checked out how it's done in the admin interface, and came up with a simple test page as follows: http://localhost:8000/media/css/forms.css; /> http://localhost:8000/media/js/core.js"> http://localhost:8000/media/js/admin/CollapsedFieldsets.js"> Job Details Jdate: But for some reason, it does not work. The collapsed field shows up (I guess) by ways of the Job Details showing up, but nothing else. Any hints? I admit, I'm a newbie at these things, but still. Any advice appreciated. R /Lars --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---