Deploying application media files
I have always used a symbolic link to deploy with apache all my django libraries media files. But now I need a more solid way to deploy those files, without concerning about symlinks I need to make after libraries install. What solution do you use? Apache aliases? As far as I know, it's not possible to serve static files from inside an egg file. It would be very nice to pack a library (like, for example, filebrowser), and have python unpack it on cache and serve also javascript and image files. Is it possible? -- Alessandro Ronchi http://www.soasi.com Hobby & Giochi http://hobbygiochi.com http://www.facebook.com/hobbygiochi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Issue with loading fixtures in tests with multi database in Django 1.2
Hi Russ, I opened #14068. I can not think of an easy fix as those I would choose will have side effects on other multi database settings. If the core team can come with a design decision on the fix, I'll be happy to implement it. Regards, Xavier. Le 5 août 2010 à 13:31, Russell Keith-Magee a écrit : > On Thu, Aug 5, 2010 at 3:44 PM, Xavier Ordoquy wrote: >> Hi Russ, >> >> Indeed, my investigations have lead me to #14025 which fixed the major issue. >> >> If I remember correctly the corrupted file part was due to the fact that I >> was still using an "old style" fixture filename - ie .json instead of >> ..json with data on both databases. >> If you find it useful, I can investigate further about this message and make >> a patch in order to output an appropriate message. > > "Old style" fixture names should still be valid -- if a database name > isn't specified, the fixture will be loaded on all available > databases. If you've got a test case where this fails, it should be > reported. > > Yours, > Russ Magee %-) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Linkedin Search
On 08/05/2010 05:22 PM, kostia wrote: Yes, Linkedin mostly is written on Java. Did you see its menu and the search to the right? People, Jobs, Answers, Groups. I would like to add something similar to this on my site. In the end, it are all just database queries. So java or python doesn't really matter. Grab all persons having the same company names as I have: just a database query. Search? Well, again database queries. In the linkedin example they're mostly looking for exact matches, so that's relatively straightforward. If you need more "fuzzy" searching: there are specialized databases for that. Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: portable apps problem
On 08/05/2010 09:34 PM, bax...@gretschpages.com wrote: I try to make my apps portable between the various sites/projects that use them, but I'm running into some problems doing so. I'm hoping there's some good way to handle this I just don't understand or know about. In a nutshell, I've got multiple sites/projects, and I'd like them to all use the same articles app. Problem is, the articles app was originally written for site A,and has at least one M2M relationship with another app that site B does not have, need, or really want. So, how do I give site A what it needs without cluttering up Site B with a bunch of unwanted extras, while using the same app? Can you write the articles app without the functionality needed by A but not B? You could have site A handle the M2M relationship to that other app, probably. The M2M relation probably results in a couple of extra links in the web interface, right? Have a generic template in the articles app and override it in site A. Could work. Another thing to think of: the view method for the articles? Allow a couple of optional keyword arguments ("extra_relation=other_app_thingy") for things that need customizing for the various sites. Have you seen the "reusable apps" talk by James Bennett? http://www.youtube.com/watch?v=A-S0tqpPga4 If not: 45 minutes of highly recommended information that'll give you lots of ideas :-) Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 comments problem
On 08/06/2010 01:15 AM, ignacio.arriaga wrote: Hello, I have a problem with django.contrib comments application. I have installed the applicacion and made the synchronization with the database. I create a comment form in this way: {% render_comment_form for project %} When I push either preview or submit I get a 403 error related with csrf protection. I have the Csrf middleware activated. I am using django 1.2 with python 2.6. You're probably missing the csrf_token tag in your form. From http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ : In any template that uses a POST form, use the csrf_token tag inside the element if the form is for an internal URL, e.g.: {% csrf_token %} So just add that csrf_token tag and you're probably done. Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Deploying application media files
On 08/06/2010 09:54 AM, Alessandro Ronchi wrote: I have always used a symbolic link to deploy with apache all my django libraries media files. But now I need a more solid way to deploy those files, without concerning about symlinks I need to make after libraries install. What solution do you use? Apache aliases? As far as I know, it's not possible to serve static files from inside an egg file. It would be very nice to pack a library (like, for example, filebrowser), and have python unpack it on cache and serve also javascript and image files. Is it possible? Yes, it is :-) Django-staticfiles is an application that can do it for you. In DEBUG mode, django-staticfiles handles those files for you directly. DEBUG=False, so in production: the "manage.py build_static" grabs all your media files and puts them in a directory, ready for apache to serve. Behind the scenes, you have to have a /media directory in your applications, just like that /template directory that's already there. It basically works in the same way. I've written a blog entry about it with some setup code and an example apache config: http://reinout.vanrees.org/weblog/2010/05/19/django-css-javascript-files.html (http://tinyurl.com/377g9l9). Read it and you'll know if django-staticfiles is what you're looking for. Note: at djangocon.eu in Berlin, there were voices to make this django-staticfiles solution standard in django 1.3. Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 comments problem
I have been checking the template that generates the form, and the csrf_token is included on it, but when the page is renderized to html the token does not appear. Also I have tried to do this: {% load comments %} {% get_comment_form for project as cform %} {% csrf_token %} {{ cform.as_p }} And the result is the same csfr error. Thanks On 6 ago, 10:12, Reinout van Rees wrote: > On 08/06/2010 01:15 AM, ignacio.arriaga wrote: > > > > > Hello, > > > I have a problem with django.contrib comments application. I have > > installed the applicacion and made the synchronization with the > > database. I create a comment form in this way: > > > {% render_comment_form for project %} > > > When I push either preview or submit I get a 403 error related with > > csrf protection. I have the Csrf middleware activated. > > > I am using django 1.2 with python 2.6. > > You're probably missing the csrf_token tag in your form. > > Fromhttp://docs.djangoproject.com/en/dev/ref/contrib/csrf/: > > In any template that uses a POST form, use the csrf_token tag > inside the element if the form is for an internal URL, e.g.: > > {% csrf_token %} > > So just add that csrf_token tag and you're probably done. > > Reinout > > -- > Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org > Programmer athttp://www.nelen-schuurmans.nl > "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 comments problem
Hello, I have solved this issue. I to put the RequestContext in the render_to_response call. Thank you all. Greetings On 6 ago, 10:34, "ignacio.arriaga" wrote: > I have been checking the template that generates the form, and the > csrf_token is included on it, but when the page is renderized to html > the token does not appear. > > Also I have tried to do this: > > {% load comments %} > {% get_comment_form for project as cform %} > > > {% csrf_token %} > {{ cform.as_p }} > value="Preview"> > > > And the result is the same csfr error. > > Thanks > > On 6 ago, 10:12, Reinout van Rees wrote: > > > > > On 08/06/2010 01:15 AM, ignacio.arriaga wrote: > > > > Hello, > > > > I have a problem with django.contrib comments application. I have > > > installed the applicacion and made the synchronization with the > > > database. I create a comment form in this way: > > > > {% render_comment_form for project %} > > > > When I push either preview or submit I get a 403 error related with > > > csrf protection. I have the Csrf middleware activated. > > > > I am using django 1.2 with python 2.6. > > > You're probably missing the csrf_token tag in your form. > > > Fromhttp://docs.djangoproject.com/en/dev/ref/contrib/csrf/: > > > In any template that uses a POST form, use the csrf_token tag > > inside the element if the form is for an internal URL, e.g.: > > > {% csrf_token %} > > > So just add that csrf_token tag and you're probably done. > > > Reinout > > > -- > > Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org > > Programmer athttp://www.nelen-schuurmans.nl > > "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Deploying application media files
2010/8/6 Reinout van Rees : > Yes, it is :-) Django-staticfiles is an application that can do it for you. ... > Note: at djangocon.eu in Berlin, there were voices to make this > django-staticfiles solution standard in django 1.3. I'll try that. I think it's the perfect solution, and I hope it will become standard in next django. -- Alessandro Ronchi http://www.soasi.com Hobby & Giochi http://hobbygiochi.com http://www.facebook.com/hobbygiochi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
database object initialization versus python object initalization
Hi all, I have two models (Person, PersonUpdate) with a many-to-many field (properties). The properties of a personupdate should be initialized (copied) from that of the corresponding person. But before I can add a list of properties to a new personupdate, it must have an id, and therefore be saved in the database. If I create a personupdate using PersonUpdate.objects.create or ~.get_or_create, I don't mind saving the object, but I don't want to call 'self.save()' in PersonUpdate.__init__. How should I handle this? Cheers, Roald -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Interpolation and comparation between 2 dates: easy and difficult at the same time
M the third case coul be this, for example: |---A-| |--A| --- |B| |-B| If I directly apply (his_diff/my_diff) I think that I'm assuming that A = 2B and it isn't the case... I need to get my range and her range and deleter the union between them with a substraction. range(A) - range(B) 17000s - 13000s for example: --- = 0.2352 = 23% range(A) 17000s What do you think about? Perhaps I'm mading mistakes and can't understand your reply. Anyway, thanks for reply :) Bye! Álex González On Fri, Aug 6, 2010 at 02:09, Paulo Almeida wrote: > In the third case, I didn't understand why you didn't divide (his_to - > his_from) / (my_to - my_from). Bearing that in mind, this made sense in my > head, but analyze it carefully: > > def match(mf,mt,hf,ht): > mydiff = diff_in_seconds(mf,mt) > if (mf >= hf and mt <= ht) or (mf < hf and mt > ht): > mydiff = diff_in_seconds(mf,mt) > hisdiff = diff_in_seconds(hf,ht) > return min(1, hisdiff / mydiff) > else: > case1 = max(0, diff_in_seconds(hf, mt)) > case2 = max(0, diff_in_seconds(mf, ht)) > diff = min(case1, case2) > return (diff / mydiff) > > def diff_in_seconds(d1,d2): > timedelta = d2 - d1 > return float(timedelta) > > print match(0,100,40,90) > > > 2010/8/5 Alexandre González > >> I've develope a "simple" function to calculate the difference between 2 >> dates, and the time that they are interpolated. >> >> I need it to: I arrive to a site at a hour (my_from), I go out from the >> site at a hour (my_to). Some friend arrive at the site at a hour (his_from) >> and let it at a hour (his_to) >> >> If I stay in the site after he arrives and before he goes out, the >> "probability" of match is 1, if I let the site after he arrives, the >> probability of match is 0... You can see the samples in the documentation. >> >> I need to know if this is a good way to do, and if compare all the kinds >> of matching (I've found 6). This is the code: >> >> def time_match(self, my_from, my_to, his_from, his_to): >> """ >> I've found 6 general kinds of time matching. It's better to >> explain it with graphics: >> >> (my_from)--A--(my_to) >> - >> (his_from)--B--(his_to) >> """ >> >> #|-A-| |-A-| >> # or >> # |--B--||--B--| >> if my_to < his_from or his_to < my_from: >> return 0 >> >> # |--A--| >> # >> # |--B---| >> elif my_from >= his_from and my_to <= his_to: >> return 1 >> >> #|-A---| >> # >> #|-B-| >> elif my_from < his_from and my_to > his_to: >> my_diff_to_reuse = diff_in_seconds(my_from, my_to) >> diff = my_diff_to_reuse - self.diff_in_seconds(his_from, >> his_to) >> >> return (diff / my_diff_to_reuse) >> >> # |---A---| >> # >> # |---B---| >> elif my_from <= his_from and my_to <= his_to: >> diff = self.diff_in_seconds(his_from, my_to) >> >> return (diff / self.diff_in_seconds(my_from, my_to)) >> >> # |---A---| >> # >> #|---B---| >> elif my_from >= his_from and my_to >= his_to: >> diff = self.diff_in_seconds(my_from, his_to) >> >> return (diff / self.diff_in_seconds(my_from, my_to)) >> >> # If I'm here I have a problem >> return 0 >> >> >> def diff_in_seconds(date1, date2): >> # Initial from: http://www.bytemycode.com/snippets/snippet/304/ >> timedelta = date2 - date1 >> diff = timedelta.days*24*3600 + timedelta.seconds >> >> return abs(float(diff)) >> >> Thanks! >> -- >> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, >> .ppt and/or .pptx >> http://mirblu.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-us...@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. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > djang
Re: Python question about subprocess.Popen() and stdout
On Thu, Aug 5, 2010 at 10:53 PM, Steve Holden wrote: > On 8/5/2010 7:16 PM, Joshua Russo wrote: > > On Aug 4, 6:49 pm, Hassan wrote: > >>> Ok, so it appears that (in Python 2.5 at least) there is no way to > capture > >>> the stdout of subprocess.Popen() > >> > >> just do this > >> > >> from subprocess import Popen, PIPE > >> p = Popen([cmd], stdout=PIPE) > >> p.stdout.readlines() > >> > >> thats it! > > > > The problem is that it waits for the process to end to output > > anything. Unless I was doing something wrong, but I think I was doing > > just what you describe here. > > > Well, readlines() inherently has to see the end of the data stream > before it can return a list of all the lines that the data stream > contains, so that's hardly surprising is it? > > Try using readline() in a loop and see if that gives you better results. > I don't guarantee it will, but at least you will have some chance if > subprocess.open() *isn't* buffering the whole stream. > > regards > Steve Tried that too and even putting the reading of them in their own thread as someone else suggested on Stackoverflow. I just can't find anyway to capture stdout in real-time from Popen. The problem is that everything uses readline() that buffers the output. http://stackoverflow.com/questions/874815/how-do-i-get-real-time-information-back-from-a-subprocess-popen-in-python-2-5 http://stackoverflow.com/questions/2082850/real-time-subprocess-popen-via-stdout-and-pipe The way I got it to work with out Popen is to use a text box control as the stdout object. This works great, utilizing the object's write() method. The problem with Popen is that it expects the stdout object to have a fileno() method also, which the text box control does not have. So I tried extending the text box to add the fileno() and had it return 1 like the standard stdout, but still no dice. I didn't let the process (unit tests) finish but it definitely was not giving real time output, through it did accept the control with the fileno() method added. It really seems like that should have worked and I may have been able to dig further into Popen to make it work but I figured that I had spent too much time on it as it was. If anybody has more suggestions I'd love to hear them. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
extends templates with the same name
It's useful to have some templates with the same name of another one, like you can do with YOURPROJECT/templates/admin/base_site.html that override the base site django default. but If I want to add a word in the title of my base_site.html I need to copy the entire content of the base_site.html I am overriding, and I cannot extend it to avoid that with am {% extend "admin/templates/base_site.html" %} or an {% extend super %} I wrote a custom base_site.html with some common code for all my projects. Now I need an app to add a single template_tag in a block. Is it possible without copying ALL the previous base_site? I cannot change the name of the parent template, or admin will not use it when I don't install that app. I moved YOURPROJECT/templates/admin/base_site.html to YOURPROJECT/templates/admin/_base_site.html and created an empty YOURPROJECT/templates/admin/base_site.html with only {% extends "_base_site.html" %} but it's not clean. Is there any other cleaner way to do that? -- Alessandro Ronchi http://www.soasi.com Hobby & Giochi http://hobbygiochi.com http://www.facebook.com/hobbygiochi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Question on databases
Thanks Steve, that was really helpful. I don't have the problem of scaling yet but one of our clients is looking to sell their product into another set of companies so I want to be able to give them advice that will keep the product robust. It will mean new developments for the product and with more than one company involved their will probably be questions raised about where data should live. I know this is perhaps a little off topic for this group but I knew people here would be able to answer those questions! Thanks. On Aug 5, 1:02 pm, Steve Holden wrote: > On 8/5/2010 7:53 AM, cootetom wrote:> Is it better to have one large database > with all the data for a web > > site in it or many smaller databases that hold data for specific > > area's of a web site in it? > > > Thinking that one database with some sort of clustering technology is > > better than trying to manage many smaller databases? > > I'm not sure why clustering technology would be necessary to support a > single database ... > > Most database engines (including MySQL, PostgreSQL and MS SQL Server) > will allow a single instance to support multiple databases if you need > that. There isn't really any reason why you should have separate > database for a single site, though. What advantage would you perceive to > this? Were they going to be on distinct server machines? > > > Also, if data needs to be linked should multiple databases be avoided > > all together? > > It's certainly going to be slow to join data from tables in two > different databases, and you may end up having to do this in your > application code. > > > Asking these questions because I've not faced the issue of scaling > > massively as yet and would value the knowledge from those who have. > > Define "massive". It's usually best to start with one database, and > optimize as the load requires. Otherwise you might find yourself > optimizing areas where performance is already adequate. > > regards > Steve > > -- > I'm no expert. > "ex" == "has-been"; "spurt" == "drip under pressure" > "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Python question about subprocess.Popen() and stdout
"Joshua Russo" wrote: >On Thu, Aug 5, 2010 at 10:53 PM, Steve Holden wrote: > >> On 8/5/2010 7:16 PM, Joshua Russo wrote: >> > On Aug 4, 6:49 pm, Hassan wrote: >> >>> Ok, so it appears that (in Python 2.5 at least) there is no way to >> capture >> >>> the stdout of subprocess.Popen() >> >> >> >> just do this >> >> >> >> from subprocess import Popen, PIPE >> >> p = Popen([cmd], stdout=PIPE) >> >> p.stdout.readlines() >> >> >> >> thats it! >> > >> > The problem is that it waits for the process to end to output >> > anything. Unless I was doing something wrong, but I think I was doing >> > just what you describe here. >> > >> Well, readlines() inherently has to see the end of the data stream >> before it can return a list of all the lines that the data stream >> contains, so that's hardly surprising is it? >> >> Try using readline() in a loop and see if that gives you better results. >> I don't guarantee it will, but at least you will have some chance if >> subprocess.open() *isn't* buffering the whole stream. >> >> regards >> Steve > > >Tried that too and even putting the reading of them in their own thread as >someone else suggested on Stackoverflow. I just can't find anyway to capture >stdout in real-time from Popen. The problem is that everything uses >readline() that buffers the output. > >http://stackoverflow.com/questions/874815/how-do-i-get-real-time-information-back-from-a-subprocess-popen-in-python-2-5 >http://stackoverflow.com/questions/2082850/real-time-subprocess-popen-via-stdout-and-pipe > >The way I got it to work with out Popen is to use a text box control as the >stdout object. This works great, utilizing the object's write() method. > >The problem with Popen is that it expects the stdout object to have a >fileno() method also, which the text box control does not have. So I tried >extending the text box to add the fileno() and had it return 1 like the >standard stdout, but still no dice. I didn't let the process (unit tests) >finish but it definitely was not giving real time output, through it did >accept the control with the fileno() method added. It really seems like that >should have worked and I may have been able to dig further into Popen to >make it work but I figured that I had spent too much time on it as it was. > >If anybody has more suggestions I'd love to hear them. > >-- >You received this message because you are subscribed to the Google Groups >"Django users" group. >To post to this group, send email to django-us...@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. > If I understand your issue correctly, in ran into something similar a while back. The problem is not in subprocess, but in how stdout works. The output is buffered by default, so it only gets written on a line-by-line basis. If you want to catch it one character at a time, you have to explicitly flush the output after each character using sys.stdout.flush(). Then, of course, you'll also have to read it from subprocess one character at a time, too, using .read(1) instead of .readline() I hope that addresses your issue. Cheers, Cliff -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
"python manage.py syncdb" help
Hi, I'm new to django. I've just installed django-db-log module and ran the following command. I got the following error. I searched online and most of the people who encountered the same issue said they had a postgresql running on port 5433. I did a "nmap localhost" and only port 5432 is open for postgresql. I could also login postgresql with psql either on local machine or from remote machine. I do not have a /var/run/postgresql directory. Could someone with more experience point out what I need to do to make it working? thanks. JF $ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 438, in execute_manager utility.execute() File "/usr/local/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ base.py", line 220, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ base.py", line 351, in handle return self.handle_noargs(**options) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ commands/syncdb.py", line 52, in handle_noargs cursor = connection.cursor() File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ __init__.py", line 75, in cursor cursor = self._cursor() File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ postgresql_psycopg2/base.py", line 136, in _cursor self.connection = Database.connect(**conn_params) psycopg2.OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/ postgresql/.s.PGSQL.5432"? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
widget DateTimeInput
Django 1.2 In forms widget=forms.DateTimeInput(attrs={'id':'dateTimeCustom'}, format='%Y-%m-%d %H:%M:%S', ) This is default django format in widgets.py. When I try to set custom format, it doesn't work in validation. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Multipart and Content-Type
Dear all, I'm posting a multipart/mixed message to Django 1.1.1 using the development web server (a binary file and a textual part -- it's not a Form) and I need to get the Content-Type of the textual part. How do I accomplish this?? I was trying to get it from request.raw_post_data but it is coming empty... Any ideas? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
ForeignKey to_field problem
I have my models declared in this way: class Person(models.Model): name = models.CharField(max_length=50, unique=True) class Pet(models.Model): owner = models.ForeignKey(Person, to_field='name') name = models.CharField(max_length=30) def __unicode__(self): return self.name I got empty list when trying to get pets from its owner. >>> person = Person(name='A') >>> person.save() >>> pet = Pet(owner=person, name='B') >>> pet.save() >>> Pet.objects.filter(owner=person) [] >>> Pet.objects.filter(owner__in=Person.objects.all()) [] It works as expected with explicit id >>> Pet.objects.filter(owner__id=person.id) [] >>> Pet.objects.filter(owner__id__in=Person.objects.all().values_list('id', flat=True)) [] Setting owner to the name of the person works also >>> Pet.objects.filter(owner=person.name) [] I didn't find any document on this, is this a convention, or this is a bug? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Specifying column names for ManyToMany fields
I haven't dug around in Django enough to know if there is a Django solution, but from the database side a view might do what you want? I have not tried this myself. http://msdn.microsoft.com/en-us/library/ms187956.aspx So define a view that follows the Django naming convention, backed by a table that follows your DBAs preference. Depends on your SQL Server version, of course, as older versions may not allow you to update the view. > It has to stay in MSSQL for various other reasons, so just using our > normal Postgres stuff won't work. > > Or would it be a LOT more difficult than just telling > the DBA that we have to be slightly inconsistent in our naming schemes? It sounds like you already have an inconsistency in the choice of database so why not go the whole hog ;-) Steven. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: extends templates with the same name
On 08/06/2010 12:22 PM, Alessandro Ronchi wrote: It's useful to have some templates with the same name of another one, like you can do with YOURPROJECT/templates/admin/base_site.html that override the base site django default. but If I want to add a word in the title of my base_site.html I need to copy the entire content of the base_site.html I am overriding, and I cannot extend it to avoid that with am {% extend "admin/templates/base_site.html" %} or an {% extend super %} I'm not sure if it's what you want, but... I've got a base ui application with a ui/base.html. Several blocks for the title, logo, the sidebar, footer, javascript, etc. Several applications extend that base template. But multiple sites also want to extend it to change the global logo and footer... The sites effectively have to override the base template. The solution: in my ui project I have a ui/realbase.html that is extended by ui/base.html. The only code in ui/base.html is the "extends" line! So overriding that one is inexpensive. The other applications can happily extend ui/base.html and fill in the blocks that are really from ui/realbase.html. And my site can override ui/base.html and fill in the logo block and the footer block (which are normally not touched by the applications). I hope I'm clear enough without a code example. The code, should you want to take a look, is at http://pypi.python.org/pypi/lizard-ui Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Multipart and Content-Type
On 08/06/2010 07:54 AM, Henrique Teófilo wrote: Dear all, I'm posting a multipart/mixed message to Django 1.1.1 using the development web server (a binary file and a textual part -- it's not a Form) and I need to get the Content-Type of the textual part. How do I accomplish this?? I was trying to get it from request.raw_post_data but it is coming empty... I've seen cases where you cannot grab data from the request after you've already grabbed it. So if that raw_post_data is called after the "regular" grab... I totally don't know how this works in Django, but I've seen this happen once elsewhere, so it might have bitten you too. Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: extends templates with the same name
2010/8/6 Reinout van Rees : > The solution: in my ui project I have a ui/realbase.html that is extended by > ui/base.html. The only code in ui/base.html is the "extends" line! So > overriding that one is inexpensive. I've used the same solution, but it would be nice to have a tag to enable those extends without empty templates, for DRY principle and because usually you don't want to change a library template at all, and with this you have to move to realbase.html. -- Alessandro Ronchi http://www.soasi.com Hobby & Giochi http://hobbygiochi.com http://www.facebook.com/hobbygiochi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Amazon S3 Boto
Hi there, I am a total beginner to programming and Django so I'd appreciate help that beginner can get his head round! I was following a tutorial to show how to upload images to an Amazon S3 account with the Boto library but I think it is for an older version of Django (I'm on 1.1.2 and Python 2.65) and something has changed. I get an error: Exception Type: TypeError Exception Value:'InMemoryUploadedFile' object is unsubscriptable My code is: Models.py from django.db import models from django.contrib.auth.models import User from django import forms from datetime import datetime class PhotoUrl(models.Model): url = models.CharField(max_length=128) uploaded = models.DateTimeField() def save(self): self.uploaded = datetime.now() models.Model.save(self) views.py import mimetypes from django.http import HttpResponseRedirect from django.shortcuts import render_to_response from django.core.urlresolvers import reverse from django import forms from django.conf import settings from boto.s3.connection import S3Connection from boto.s3.key import Key def awsdemo(request): def store_in_s3(filename, content): conn = S3Connection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY) b = conn.create_bucket('almacmillan-hark') mime = mimetypes.guess_type(filename)[0] k = Key(b) k.key = filename k.set_metadata("Content-Type", mime) k.set_contents_from_strong(content) k.set_acl("public-read") photos = PhotoUrl.objects.all().order_by("-uploaded") if not request.method == "POST": f = UploadForm() return render_to_response('awsdemo.html', {'form':f, 'photos':photos}) f = UploadForm(request.POST, request.FILES) if not f.is_valid(): return render_to_response('awsdemo.html', {'form':f, 'photos':photos}) file = request.FILES['file'] filename = file.name content = file['content'] store_in_s3(filename, content) p = PhotoUrl(url="http://almacmillan-hark.s3.amazonaws.com/"; + filename) p.save() photos = PhotoUrl.objects.all().order_by("-uploaded") return render_to_response('awsdemo.html', {'form':f, 'photos':photos}) urls.py (r'^awsdemo/$', 'harkproject.s3app.views.awsdemo'), awsdemo.html {{form.file.label}} {{form.file}} I'd really appreciate help. I hope I have provided enough code. Kind regards AL -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
HttpResponseRedirect
I have two pages with two different forms. Each, if validated, redirects to "thanks" page. I want to customize this behavior, so "thanks" page should display different message, regarding witch form was invoked, or redirects to "/' if no redirection took place (like user typed in browser "test.com/thanks") Unfortunately, HttpResponseRedirect takes only one argument. How can i pass right message anyway? Or mb there is some workaround, like i could check in "thanks" view, from what page it was redirected? -- Linux user -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Beautiful popup windows
Do we know some alternatives for using popups in python/django? Here is the SqueezeBox from Mootools JS library - http://digitarald.de/project/squeezebox/ I used it in Joomla / php. I would like to create a great popup form to prevent the user from redirecting to the new page. It will be awesome. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Python question about subprocess.Popen() and stdout
On Aug 6, 9:57 am, "J. Cliff Dyer" wrote: > "Joshua Russo" wrote: > >On Thu, Aug 5, 2010 at 10:53 PM, Steve Holden wrote: > > >> On 8/5/2010 7:16 PM, Joshua Russo wrote: > >> > On Aug 4, 6:49 pm, Hassan wrote: > >> >>> Ok, so it appears that (in Python 2.5 at least) there is no way to > >> capture > >> >>> the stdout of subprocess.Popen() > > >> >> just do this > > >> >> from subprocess import Popen, PIPE > >> >> p = Popen([cmd], stdout=PIPE) > >> >> p.stdout.readlines() > > >> >> thats it! > > >> > The problem is that it waits for the process to end to output > >> > anything. Unless I was doing something wrong, but I think I was doing > >> > just what you describe here. > > >> Well, readlines() inherently has to see the end of the data stream > >> before it can return a list of all the lines that the data stream > >> contains, so that's hardly surprising is it? > > >> Try using readline() in a loop and see if that gives you better results. > >> I don't guarantee it will, but at least you will have some chance if > >> subprocess.open() *isn't* buffering the whole stream. > > >> regards > >> Steve > > >Tried that too and even putting the reading of them in their own thread as > >someone else suggested on Stackoverflow. I just can't find anyway to capture > >stdout in real-time from Popen. The problem is that everything uses > >readline() that buffers the output. > > >http://stackoverflow.com/questions/874815/how-do-i-get-real-time-info... > >http://stackoverflow.com/questions/2082850/real-time-subprocess-popen... > > >The way I got it to work with out Popen is to use a text box control as the > >stdout object. This works great, utilizing the object's write() method. > > >The problem with Popen is that it expects the stdout object to have a > >fileno() method also, which the text box control does not have. So I tried > >extending the text box to add the fileno() and had it return 1 like the > >standard stdout, but still no dice. I didn't let the process (unit tests) > >finish but it definitely was not giving real time output, through it did > >accept the control with the fileno() method added. It really seems like that > >should have worked and I may have been able to dig further into Popen to > >make it work but I figured that I had spent too much time on it as it was. > > >If anybody has more suggestions I'd love to hear them. > > >-- > >You received this message because you are subscribed to the Google Groups > >"Django users" group. > >To post to this group, send email to django-us...@googlegroups.com. > >To unsubscribe from this group, send email to > >django-users+unsubscr...@googlegroups.com. > >For more options, visit this group > >athttp://groups.google.com/group/django-users?hl=en. > > If I understand your issue correctly, in ran into something similar a while > back. The problem is not in subprocess, but in how stdout works. The output > is buffered by default, so it only gets written on a line-by-line basis. > > If you want to catch it one character at a time, you have to explicitly flush > the output after each character using sys.stdout.flush(). Then, of course, > you'll also have to read it from subprocess one character at a time, too, > using .read(1) instead of .readline() > > I hope that addresses your issue. > > Cheers, > Cliff Thanks for the tip, I'll check it out. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: HttpResponseRedirect
On Aug 6, 1:33 pm, bagheera wrote: > I have two pages with two different forms. Each, if validated, redirects > to "thanks" page. I want to customize this behavior, so "thanks" page > should display different message, regarding witch form was invoked, or > redirects to "/' if no redirection took place (like user typed in browser > "test.com/thanks") > Unfortunately, HttpResponseRedirect takes only one argument. How can i > pass right message anyway? Or mb there is some workaround, like i could > check in "thanks" view, from what page it was redirected? > > -- > Linux user Store something in the session when you validate the form before redirecting. -- 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-us...@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: HttpResponseRedirect
So when returning HttpResponseRedirect django returns 302 status code for the client, which indicates that the client browser should navigate to another url. Then you have at last 2 options: 1) before returning save at session data information about form that you want to thans form - but it's not very good, because it can work wrong when same user will be entering 2 different forms at the same session 2) return address with get parameters inside, and then in thanks page's view check that get parameters to determine the form from which the user was redirected On 6 Sie, 14:33, bagheera wrote: > I have two pages with two different forms. Each, if validated, redirects > to "thanks" page. I want to customize this behavior, so "thanks" page > should display different message, regarding witch form was invoked, or > redirects to "/' if no redirection took place (like user typed in browser > "test.com/thanks") > Unfortunately, HttpResponseRedirect takes only one argument. How can i > pass right message anyway? Or mb there is some workaround, like i could > check in "thanks" view, from what page it was redirected? > > -- > Linux user -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: HttpResponseRedirect
Daniel, I think it can work incorrectly when user would be filling more than one form of the same type at the same time. My suggestion is to use passing get parameters while returning HttpResponseRedirect. It of course have disadvantage that the address would not be always same (get params will be different for different types of forms) but it won't cause problems described above. On 6 Sie, 15:20, Daniel Roseman wrote: > On Aug 6, 1:33 pm, bagheera wrote: > > > I have two pages with two different forms. Each, if validated, redirects > > to "thanks" page. I want to customize this behavior, so "thanks" page > > should display different message, regarding witch form was invoked, or > > redirects to "/' if no redirection took place (like user typed in browser > > "test.com/thanks") > > Unfortunately, HttpResponseRedirect takes only one argument. How can i > > pass right message anyway? Or mb there is some workaround, like i could > > check in "thanks" view, from what page it was redirected? > > > -- > > Linux user > > Store something in the session when you validate the form before > redirecting. > -- > 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-us...@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: Beautiful popup windows
On 08/06/2010 03:13 PM, kostia wrote: Do we know some alternatives for using popups in python/django? Here is the SqueezeBox from Mootools JS library - http://digitarald.de/project/squeezebox/ I used it in Joomla / php. I would like to create a great popup form to prevent the user from redirecting to the new page. It will be awesome. Basically all the external javascript goodie libraries. Django is javascript-library-agnostic, so take your pick. Personally, I'm using "jquery tools" for the overlay: http://flowplayer.org/tools/overlay/index.html Note that Plone (big python CMS) also uses jquery tools because it doesn't have its own css: the UI library doesn't fight your existing css. That's a big difference with for instance jqueryui (which I also use and like, btw :-) Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Programmer at http://www.nelen-schuurmans.nl "Military engineers build missiles. Civil engineers build targets" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Beautiful popup windows
On 8/6/2010 8:13 AM, kostia wrote: Do we know some alternatives for using popups in python/django? I bookmarked these a while back but haven't yet used them: http://trentrichardson.com/Impromptu/index.php http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/ Michael -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 on Mac OS X
Hi, I'm still get error trying to run my project on Mac =( Now the standalone server is running fine, but when I try to create a new user I get the error: "Can't adapt type 'US/Eastern", I tried to change my TIME_ZONE in setting, but no success. I can simulate this error in console, and here's the output: >>> from django.contrib.auth.models import User >>> new_user = User.objects.create_user("daniel", "daniel.fra...@gmail.com", "daniel") Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", line 129, in create_user user.save(using=self._db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 435, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 543, in save_base created=(not record_exists), raw=raw) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 162, in send response = receiver(signal=self, sender=sender, **named) File "/Users/danielfranca/workspace/django/view/tint/apps/account/models.py", line 60, in create_account account, created = Account.objects.get_or_create(user=instance) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", line 135, in get_or_create return self.get_query_set().get_or_create(**kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 373, in get_or_create obj.save(force_insert=True, using=self.db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 435, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 528, in save_base result = manager._insert(values, return_id=update_pk, using=using) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert return insert_query(self.model, values, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 1479, in insert_query return query.get_compiler(using=using).execute_sql(return_id) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 783, in execute_sql cursor = super(SQLInsertCompiler, self).execute_sql(None) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 727, in execute_sql cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", line 15, in execute return self.cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute return self.cursor.execute(query, args) DatabaseError: can't adapt type 'US/Eastern' Anyone have any ideia what it can be? my python version is 1.2.1 On Mon, Jul 19, 2010 at 9:01 AM, Shawn Milochik wrote: > Daniel, > > Glad to help. If you're new to the Mac and have questions just let me know. > > Shawn > > sh...@milochik.com > Google Chat: shawn.m...@gmail.com > > 2010/7/19 Daniel França > >> thanks a lot, now it's working.. at least this part. >> =) >> >> On Sun, Jul 18, 2010 at 11:10 PM, Shawn Milochik wrote: >> >>> This is a known (and common) problem. Here's an easy fix that I've used >>> many times. >>> >>> http://shawnmilo.blogspot.com/2009/11/psycopg2-on-snow-leopard.html >>> >>> Incidentally, you can replace "make install" with "make altinstall" to >>> add Python 2.7 to your system without replacing the default Python. >>> >>> Shawn >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-us...@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. >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@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=e
i18n form not working when in site root
Hi there, I have put the form with a select box with languages in the template header: {% for lang in LANGUAGES %} {{ lang.1 }} {% endfor %} When I change the language from any site's page it works like it should, but when I go to the homepage (site's root) the "django_language" cookie is reset and the language form doesn't work anymore; it makes the POST request but it doesn't change the language. Any help is welcome! 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-us...@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: i18n form not working when in site root
FIXED :) It was an issue with FeinCMS. On Aug 6, 5:26 pm, Florin wrote: > Hi there, > > I have put the form with a select box with languages in the template > header: > > > > {% for lang in LANGUAGES %} > {{ lang.1 }} > {% endfor %} > > > > > When I change the language from any site's page it works like it > should, but when I go to the homepage (site's root) the > "django_language" cookie is reset and the language form doesn't work > anymore; it makes the POST request but it doesn't change the language. > > Any help is welcome! > 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-us...@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 is not creating all the tables
Hi everybody, I am working in a project using django, which has about 20 apps's. There is no tests written and It was decided that tests would have to be written for the whole project. To start testing, I runned: "python manage.py test" And a database was created, tables and stuff... But one table wasnt created, so I got this error: "Error: Database test_febrace couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid. Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run. The full error: (1146, "Table 'test_febrace.submissao_projeto' doesn't exist")" Trying to discover what the problem was, I deleted all my tables and runned: "python manage.py syncdb" And... 2 of the tables weren't created in my mysql database. Both of them are from the same app, which has other models and the other models tables were succesfully created. I tryed "python manage.py sqlall *appname*" and I executed the returned sql statements in my mysql server, so the tables were created. Any suggestion? For the project, it is ok to create manually executing the sqlall commands for me, but this way I cant test. 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-us...@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: i18n form not working when in site root
On Fri, Aug 06, 2010 at 07:26:33AM -0700, Florin wrote: > When I change the language from any site's page it works like it > should, but when I go to the homepage (site's root) the > "django_language" cookie is reset and the language form doesn't work > anymore; it makes the POST request but it doesn't change the language. Difficult to tell, Should Work(tm). Do you {% load i18n %} in your root template, pass context_instance=RequestContext(Request) to render_to_response and actually have translatable strings and translations for them? If you already have that, publishing a minimal example of the problem and stating Django version could help people help you. With kind regards, Baurzhan. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
what do you do to take your site down?
Could anyone give me some pointers as to how you deal with taking your site down for maintenance? Is there some standard thing that people do to redirect all page requests to some sort of "Sorry, the site is down" page?Do you do this directly via apache or do you do it via django? I additionally have a situation where when our mail server goes down, I would like to allow people to do GETS, but not POSTS. If you have any ideas on this I would be interested. Thanks 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-us...@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 on Mac OS X
Hi daniel, I doubt your python version is 1.2.1, maybe it's rather Django version :) However, the issue django stated looks pretty clear to me. You created a database with a wrong encoding type. You should have a look at: http://docs.djangoproject.com/en/1.2/ref/unicode/ Regards, Xavier. On Fri, 6 Aug 2010 11:13:40 -0300, Daniel França wrote: > Hi, I'm still get error trying to run my project on Mac =(Now the > standalone server is running fine, but when I try to create a new user I > get the error: "Can't adapt type 'US/Eastern", I tried to change my > TIME_ZONE in setting, but no success. I can simulate this error in > console, and here's the output: from django.contrib.auth.models import User >>> new_user = > User.objects.create_user("daniel", "daniel.fra...@gmail.com [1]", > "daniel") Traceback (most recent call last): File "", line 1, in > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", > line 129, in create_user user.save(using=self._db) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 435, in save self.save_base(using=using, > force_insert=force_insert, force_update=force_update) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 543, in save_base created=(not record_exists), > raw=raw) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > line 162, in send response = receiver(signal=self, sender=sender, > **named) File > "/Users/danielfranca/workspace/django/view/tint/apps/account/models.py", > line 60, in create_account account, created = > Account.objects.get_or_create(user=instance) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", > line 135, in get_or_create return > self.get_query_set().get_or_create(**kwargs) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", > line 373, in get_or_create obj.save(force_insert=True, > using=self.db) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 435, in save self.save_base(using=using, > force_insert=force_insert, force_update=force_update) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 528, in save_base result = manager._insert(values, > return_id=update_pk, using=using) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", > line 195, in _insert return insert_query(self.model, values, > **kwargs) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", > line 1479, in insert_query return > query.get_compiler(using=using).execute_sql(return_id) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", > line 783, in execute_sql cursor = super(SQLInsertCompiler, > self).execute_sql(None) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", > line 727, in execute_sql cursor.execute(sql, params) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", > line 15, in execute return self.cursor.execute(sql, > params) File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", > line 44, in execute return self.cursor.execute(query, > args)DatabaseError: can't adapt type 'US/Eastern' > Anyone have any ideia what it can be?my python version is 1.2.1 > > On Mon, Jul 19, 2010 at 9:01 AM, Shawn Milochik wrote: > Daniel, > Glad to help. If you're new to the Mac and have questions just let me > know. > Shawn > sh...@milochik.com [3] Google Chat: shawn.m...@gmail.com [4] > > 2010/7/19 Daniel França > thanks a lot, now it's working.. at least this part.=) > > On Sun, Jul 18, 2010 at 11:10 PM, Shawn Milochik wrote: > This is a known (and common) problem. Here's an easy fix that I've used > many times. > > http://shawnmilo.blogspot.com/2009/11/psycopg2-on-snow-leopard.html [7] > > Incidentally, you can replace "make install" with "make altinstall" to > add Python 2.7 to your system without replacing the default Python. > > Shawn > > -- > 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 [8]. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com [9]. > For more options, visit this group at > http://
Re: HttpResponseRedirect
Why not use the Messages framework for this? http://docs.djangoproject.com/en/dev/ref/contrib/messages/ ./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-us...@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: what do you do to take your site down?
On 6 elo, 18:36, Margie Roginski wrote: > Could anyone give me some pointers as to how you deal with taking your > site down for maintenance? Is there some standard thing that people > do to redirect all page requests to some sort of "Sorry, the site is > down" page? Do you do this directly via apache or do you do it via > django? Make a simple model for notifications and use that on your front page to notify upcoming maintenance breaks. I also use this style to inform updates done etc. The model could be something like this: class Notification(models.Model): notification = models.TextField() show_from = models.DateTimeField() show_until = models.DateTimeField() def __unicode__(self): return self.notification Put notifictions = Notification.objects.filter(show_from__lte=datetime.now(), show_until__gte=datetime.now()) into your template and show the notification list there. Use apache to show the actual maintenance break message when the site is down. > I additionally have a situation where when our mail server goes down, > I would like to allow people to do GETS, but not POSTS. If you have > any ideas on this I would be interested. One approach is to use middleware, and in the middleware check: if request.method == 'POST' and email_is_down(): return error page. You could also use a default context processor which puts posts_allowed variable in the context and then in base.html have {% if not posts_allowed %} Technical problems... saving not allowed {% endif %}. You could also wrap your submit buttons in {% if posts_allowed %}. Maybe disable also the edit links... - Anssi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 is not creating all the tables
It seems to be a django bug. I changed the apps order in INSTALED_APPS in settings.py and everything started to work correctly. On 6 ago, 11:55, Thales wrote: > Hi everybody, > > I am working in a project using django, which has about 20 apps's. > There is no tests written and It was decided that tests would have to > be written for the whole project. > > To start testing, I runned: > "python manage.py test" > > And a database was created, tables and stuff... But one table wasnt > created, so I got this error: > "Error: Database test_febrace couldn't be flushed. Possible reasons: > * The database isn't running or isn't configured correctly. > * At least one of the expected database tables doesn't exist. > * The SQL was invalid. > Hint: Look at the output of 'django-admin.py sqlflush'. That's the > SQL this command wasn't able to run. > The full error: (1146, "Table 'test_febrace.submissao_projeto' > doesn't exist")" > > Trying to discover what the problem was, I deleted all my tables and > runned: > "python manage.py syncdb" > And... 2 of the tables weren't created in my mysql database. Both of > them are from the same app, which has other models and the other > models tables were succesfully created. > > I tryed > "python manage.py sqlall *appname*" and I executed the returned sql > statements in my mysql server, so the tables were created. > > Any suggestion? For the project, it is ok to create manually executing > the sqlall commands for me, but this way I cant test. > > 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-us...@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.
Generic ManyToMany lockup
Hello! I'm setting up a blog, and for learning purposes I want to make everything as generic as possible. My tagging app looks like this -- class Tag(models.Model): name = models.SlugField(max_length=30, unique=True) class TagRelation(models.Model): tag = models.ForeignKey(Tag) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') -- When showing one post, it's easy to get the tags using this method: http://docs.djangoproject.com/en/1.2/ref/contrib/contenttypes/#reverse-generic-relations But how can I do the same when I want to show more than one post in a single page and all of them shows which tags are attached to the post. Thanks in advance -Anders -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 pagination
I can't find a mistake :-(( {{ autopaginate product 2 }} is working, because of only two products I see, but {{ paginate }} is NOT, its returns just nothing Here my template: {% load i18n %} {% load pagination_tags %} {% autopaginate product 2 %} Delete All | Another Action {{ paginate }} {% for p in product %} {{ p.name_english }} {% if p.fob_price_from %} {{ p.fob_price_from }} {% else %} - {% endif %} {% if p.min_order_quantity %} {{ p.min_order_quantity }} {% else %} - {% endif %} {% trans "Edit" %} {% trans "Delete" %} {% 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-us...@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: what do you do to take your site down?
Thank you very much - that all makes perfect sense. Margie On Aug 6, 9:09 am, akaariai wrote: > On 6 elo, 18:36, Margie Roginski wrote: > > > Could anyone give me some pointers as to how you deal with taking your > > site down for maintenance? Is there some standard thing that people > > do to redirect all page requests to some sort of "Sorry, the site is > > down" page? Do you do this directly via apache or do you do it via > > django? > > Make a simple model for notifications and use that on your front page > to notify upcoming maintenance breaks. I also use this style to inform > updates done etc. The model could be something like this: > > class Notification(models.Model): > notification = models.TextField() > show_from = models.DateTimeField() > show_until = models.DateTimeField() > > def __unicode__(self): > return self.notification > > Put notifictions = > Notification.objects.filter(show_from__lte=datetime.now(), > show_until__gte=datetime.now()) into your template and show the > notification list there. Use apache to show the actual maintenance > break message when the site is down. > > > I additionally have a situation where when our mail server goes down, > > I would like to allow people to do GETS, but not POSTS. If you have > > any ideas on this I would be interested. > > One approach is to use middleware, and in the middleware check: > if request.method == 'POST' and email_is_down(): > return error page. > > You could also use a default context processor which puts > posts_allowed variable in the context and then in base.html have {% if > not posts_allowed %} Technical problems... saving not allowed {% endif > %}. You could also wrap your submit buttons in {% if posts_allowed %}. > Maybe disable also the edit links... > > - Anssi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
For tag fails in template
What is wrong? My view function: def project(request, project_id): try: project_id = int(project_id) except ValueError: raise Http404 myProject = get_object_or_404(Project, id = project_id) events = Event.objects.filter(project = myProject) return render_to_response('project.html', context_instance=RequestContext(request, {'project': myProject, 'events': events})) And in the template I do: {% for event in events %} {{ event.title }} {% empty %} {% trans "There are no events yet." %} {% endfor %} If there are no events, everything is fine. If some event exists, it shows an error: Caught NoReverseMatch while rendering: Reverse for 'event' with arguments '(1,)' and keyword arguments '{}' not found. and points to the for tag. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 pagination
I don't have time to watch your code, but... Take a look here http://www.tummy.com/Community/Articles/django-pagination/ I set up this cool pagination in 15 minutes without errors! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
queryset field order
Hi All, I was just wondering is there a way to get queryset to return result of a database lookup to list the fields in the same order as it is defined in the database table? so for example in my TABLE A -- A B C the query set result will return exactly [ {A: some value, B: some value, C: some value},.] -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: queryset field order
use table = ModelName.objects.all().order_by("filter_name") It is ordered by id field apriori. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Amazon S3 Boto
Take a look at django-storages, it's what we use to store audio files in S3. It's a pretty robust django storage backend with decent community support. On Aug 6, 2010, at 5:06 AM, almacmillan wrote: > Hi there, > > I am a total beginner to programming and Django so I'd appreciate help > that beginner can get his head round! > > I was following a tutorial to show how to upload images to an Amazon > S3 account with the Boto library but I think it is for an older > version of Django (I'm on 1.1.2 and Python 2.65) and something has > changed. I get an error: >Exception Type:TypeError >Exception Value: 'InMemoryUploadedFile' object is unsubscriptable > > My code is: > >Models.py > >from django.db import models >from django.contrib.auth.models import User >from django import forms >from datetime import datetime > >class PhotoUrl(models.Model): > url = models.CharField(max_length=128) > uploaded = models.DateTimeField() > > def save(self): > self.uploaded = datetime.now() > models.Model.save(self) > >views.py >import mimetypes >from django.http import HttpResponseRedirect >from django.shortcuts import render_to_response >from django.core.urlresolvers import reverse >from django import forms >from django.conf import settings >from boto.s3.connection import S3Connection >from boto.s3.key import Key > >def awsdemo(request): > def store_in_s3(filename, content): > conn = S3Connection(settings.AWS_ACCESS_KEY_ID, > settings.AWS_SECRET_ACCESS_KEY) > b = conn.create_bucket('almacmillan-hark') > mime = mimetypes.guess_type(filename)[0] > k = Key(b) > k.key = filename > k.set_metadata("Content-Type", mime) > k.set_contents_from_strong(content) > k.set_acl("public-read") > > photos = PhotoUrl.objects.all().order_by("-uploaded") > if not request.method == "POST": > f = UploadForm() > return render_to_response('awsdemo.html', {'form':f, > 'photos':photos}) > > f = UploadForm(request.POST, request.FILES) > if not f.is_valid(): > return render_to_response('awsdemo.html', {'form':f, > 'photos':photos}) > > file = request.FILES['file'] > filename = file.name > content = file['content'] > store_in_s3(filename, content) > p = PhotoUrl(url="http://almacmillan-hark.s3.amazonaws.com/"; + > filename) > p.save() > photos = PhotoUrl.objects.all().order_by("-uploaded") > return render_to_response('awsdemo.html', {'form':f, > 'photos':photos}) > >urls.py > >(r'^awsdemo/$', 'harkproject.s3app.views.awsdemo'), > >awsdemo.html > > > {{form.file.label}} > > {{form.file}} > > > > > I'd really appreciate help. I hope I have provided enough code. > > Kind regards > AL > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: queryset field order
I checked it and the field order still not the same. Just to clarify. I want the to do this A.objects.all().values() and still get the each list in the result to have the same "field order" as the database table defined. On Aug 6, 9:57 am, kostia wrote: > use table = ModelName.objects.all().order_by("filter_name") > > It is ordered by id field apriori. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: For tag fails in template
On Aug 6, 5:46 pm, kostia wrote: > What is wrong? > > My view function: > def project(request, project_id): > > try: > > project_id = int(project_id) > > except ValueError: > > raise Http404 > > myProject = get_object_or_404(Project, id = project_id) > events = Event.objects.filter(project = myProject) > > return render_to_response('project.html', > > context_instance=RequestContext(request, {'project': > myProject, 'events': events})) > > And in the template I do: > > > {% for event in events %} > {{ event.title > }} > {% empty %} > {% trans "There are no events yet." %} > {% endfor %} > > > > If there are no events, everything is fine. If some event exists, it > shows an error: > > Caught NoReverseMatch while rendering: Reverse for 'event' with > arguments '(1,)' and keyword arguments '{}' not found. > > and points to the for tag. Do you have a URL named 'event'? Does it take a single non-keyword parameter? Show your urls.py. -- 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-us...@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: queryset field order
On Aug 6, 6:08 pm, owidjaya wrote: > I checked it and the field order still not the same. > Just to clarify. I want the to do this A.objects.all().values() > and still get the each list in the result to have the same "field > order" as the database table defined. `values()` returns a set of dictionaries. Dictionaries are unordered by definition. `values_list()` returns a set of tuples, which should be in the same order as the model definition, however you don't get the fieldnames. -- 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-us...@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: For tag fails in template
Part of my urls.py: ... url(r'^project/(?P\d+)/event/(?P\d+)$', views.event, name="event"), url(r'^project/(?P\d+)/event/edit/(?P\d+)$', views.edit_event, name="edit_event"), url(r'^project/(?P\d+)/event/new/$', views.edit_event, name="new_event"), ... I see, I need to write this: {% url event project.pk event.pk %} But why django shows me for tag, and not a url. I was pointed on a wrong way) Thanks btw. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: For tag fails in template
The question of clarity: What is the best way to do: project.pk or project.id ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: queryset field order
is there a way that i can get the a list of dictionaries as a result with the dictionary having the same field order as the table? On Aug 6, 10:18 am, Daniel Roseman wrote: > On Aug 6, 6:08 pm, owidjaya wrote: > > > I checked it and the field order still not the same. > > Just to clarify. I want the to do this A.objects.all().values() > > and still get the each list in the result to have the same "field > > order" as the database table defined. > > `values()` returns a set of dictionaries. Dictionaries are unordered > by definition. > > `values_list()` returns a set of tuples, which should be in the same > order as the model definition, however you don't get the fieldnames. > -- > 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-us...@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: For tag fails in template
On 8/6/2010 1:23 PM, kostia wrote: > The question of clarity: > > What is the best way to do: > project.pk > or > project.id > ? > Well, pk will always work no matter what the field is named, so I tend to prefer that. It's mostly a matter of style, though. regards Steve -- I'm no expert. "ex" == "has-been"; "spurt" == "drip under pressure" "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: queryset field order
You can't use a dictionary if you expect a certain order of key/value pairs. Given model A you could get a list of field objects in the same order (I think) as defined in the model class A._meta.fields At least with that information you could programatically produce a list of data in matching order with a little code. On Fri, Aug 6, 2010 at 1:34 PM, owidjaya wrote: > is there a way that i can get the a list of dictionaries as a result > with the dictionary having the same field order as the table? > > On Aug 6, 10:18 am, Daniel Roseman wrote: > > On Aug 6, 6:08 pm, owidjaya wrote: > > > > > I checked it and the field order still not the same. > > > Just to clarify. I want the to do this A.objects.all().values() > > > and still get the each list in the result to have the same "field > > > order" as the database table defined. > > > > `values()` returns a set of dictionaries. Dictionaries are unordered > > by definition. > > > > `values_list()` returns a set of tuples, which should be in the same > > order as the model definition, however you don't get the fieldnames. > > -- > > 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-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: queryset field order
On 8/6/2010 1:34 PM, owidjaya wrote: > is there a way that i can get the a list of dictionaries as a result > with the dictionary having the same field order as the table? > What do you regard as the "field order" of the dictionary? If you are talking about the order Python iterates over the field, this is not predictable or controllable: it is an artefact of the dict implementation, whose primary focus is on speed of operation. But you can get the list of field names from the model using model._meta.get_all_field_names(), create a set of (name, value) tuples with zip() and then iterate over that? http://stackoverflow.com/questions/2170228/django-iterate-over-model-instance-field-names-and-values-in-template might give you some ideas. regards Steve > On Aug 6, 10:18 am, Daniel Roseman wrote: >> On Aug 6, 6:08 pm, owidjaya wrote: >> >>> I checked it and the field order still not the same. >>> Just to clarify. I want the to do this A.objects.all().values() >>> and still get the each list in the result to have the same "field >>> order" as the database table defined. >> >> `values()` returns a set of dictionaries. Dictionaries are unordered >> by definition. >> >> `values_list()` returns a set of tuples, which should be in the same >> order as the model definition, however you don't get the fieldnames. >> -- >> DR. > -- I'm no expert. "ex" == "has-been"; "spurt" == "drip under pressure" "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
CheckBoxInput widget: check_test
Having difficulty getting the check_test to work. Can't find any examples out there that help. I'll probably have to give a little background. I simplified where able to... class Cat: name = CharField class Category: name = ForeignKey(Cat) weight = DecimalField item = ForeignKey('Item') class Item: name = CharField Basically Cat is a model of all categories and Category is a model of which Cat's are assigned to an item. I did it this way because I want to have a "master list" of categories, then have the mapping done in other models. So now I want to build a form at run-time. def get_form(item): fields = dict() cat_choices = [(c.id, c.name) for c in Cat.objects.all()] for c in cat_choices: id, name = c checked = bool(item.categoty_set.filter(pk=id).count()) fields['item_cat_%d' % id] = forms.ChoiceField( label = name, required = False, choices = cat_choices, widget = forms.CheckboxInput( attrs={'value': checked}, check_test = lambda a: a == checked ) ) return type('CatSelectForm', (forms.BaseForm,), {'base_fields': fields}) So how can I get the correct checkboxes checked at runtime when the template is rendered? Thx. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: queryset field order
okay that's great but is there a way to get the list of fields from a model instance instead of from the Model class itself? My thought is that if I pass in the list of model instance into the template, the order should be still there. so why pass in another variable which contains the model fields. On Aug 6, 11:04 am, Alec Shaner wrote: > You can't use a dictionary if you expect a certain order of key/value pairs. > > Given model A you could get a list of field objects in the same order (I > think) as defined in the model class > > A._meta.fields > > At least with that information you could programatically produce a list of > data in matching order with a little code. > > On Fri, Aug 6, 2010 at 1:34 PM, owidjaya wrote: > > is there a way that i can get the a list of dictionaries as a result > > with the dictionary having the same field order as the table? > > > On Aug 6, 10:18 am, Daniel Roseman wrote: > > > On Aug 6, 6:08 pm, owidjaya wrote: > > > > > I checked it and the field order still not the same. > > > > Just to clarify. I want the to do this A.objects.all().values() > > > > and still get the each list in the result to have the same "field > > > > order" as the database table defined. > > > > `values()` returns a set of dictionaries. Dictionaries are unordered > > > by definition. > > > > `values_list()` returns a set of tuples, which should be in the same > > > order as the model definition, however you don't get the fieldnames. > > > -- > > > 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-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: what do you do to take your site down?
Also, see "Maintenance Mode for Django Sites" http://www.weavingtheweb.com/professional-blogs/78-maintenance-mode and this related link http://pypi.python.org/pypi/django-maintenancemode/ HTH, John On Aug 6, 9:24 am, Margie Roginski wrote: > Thank you very much - that all makes perfect sense. > > Margie > > On Aug 6, 9:09 am, akaariai wrote: > > > On 6 elo, 18:36, Margie Roginski wrote: > > > > Could anyone give me some pointers as to how you deal with taking your > > > site down for maintenance? Is there some standard thing that people > > > do to redirect all page requests to some sort of "Sorry, the site is > > > down" page? Do you do this directly via apache or do you do it via > > > django? > > > Make a simple model for notifications and use that on your front page > > to notify upcoming maintenance breaks. I also use this style to inform > > updates done etc. The model could be something like this: > > > class Notification(models.Model): > > notification = models.TextField() > > show_from = models.DateTimeField() > > show_until = models.DateTimeField() > > > def __unicode__(self): > > return self.notification > > > Put notifictions = > > Notification.objects.filter(show_from__lte=datetime.now(), > > show_until__gte=datetime.now()) into your template and show the > > notification list there. Use apache to show the actual maintenance > > break message when the site is down. > > > > I additionally have a situation where when our mail server goes down, > > > I would like to allow people to do GETS, but not POSTS. If you have > > > any ideas on this I would be interested. > > > One approach is to use middleware, and in the middleware check: > > if request.method == 'POST' and email_is_down(): > > return error page. > > > You could also use a default context processor which puts > > posts_allowed variable in the context and then in base.html have {% if > > not posts_allowed %} Technical problems... saving not allowed {% endif > > %}. You could also wrap your submit buttons in {% if posts_allowed %}. > > Maybe disable also the edit links... > > > - Anssi > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: CheckBoxInput widget: check_test
Forgo the most important part. I want to be prompted with a checkboxes that show which categories are selected, as well as the ones that aren't. On Aug 6, 2:13 pm, lingrlongr wrote: > Having difficulty getting the check_test to work. Can't find any > examples out there that help. I'll probably have to give a little > background. I simplified where able to... > > class Cat: > name = CharField > > class Category: > name = ForeignKey(Cat) > weight = DecimalField > item = ForeignKey('Item') > > class Item: > name = CharField > > Basically Cat is a model of all categories and Category is a model of > which Cat's are assigned to an item. I did it this way because I want > to have a "master list" of categories, then have the mapping done in > other models. > > So now I want to build a form at run-time. > > def get_form(item): > fields = dict() > cat_choices = [(c.id, c.name) for c in Cat.objects.all()] > for c in cat_choices: > id, name = c > checked = bool(item.categoty_set.filter(pk=id).count()) > > fields['item_cat_%d' % id] = forms.ChoiceField( > label = name, > required = False, > choices = cat_choices, > widget = forms.CheckboxInput( > attrs={'value': checked}, > check_test = lambda a: a == checked > ) > ) > return type('CatSelectForm', (forms.BaseForm,), {'base_fields': > fields}) > > So how can I get the correct checkboxes checked at runtime when the > template is rendered? > > Thx. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: intermediate table in manytomany relationship not created
Thanks, Carlos! Brian On Aug 5, 12:59 pm, Carlos Daniel Ruvalcaba Valenzuela wrote: > There is an option to default to InnoDB tables on the configuration: > > http://docs.djangoproject.com/en/dev/ref/databases/#creating-your-tables > > Regards, > Carlos Daniel Ruvalcaba Valenzuela > > On Thu, Aug 5, 2010 at 12:48 PM, bksfu wrote: > > When Django created the above tables, they were created with the > > MyISAM engine. If the intermediate table has to have foreign keys > > back to the Phone and Room tables, this would be illegal from MySQL's > > perspective, which can apparently only form foreign key constraints > > between InnoDB tables. If this is the reason that the intermediate > > table wasn't created, how do I force Django to create tables in MySQL > > with the InnoDB engine? - Brian > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: CheckBoxInput widget: check_test
There is a CheckBoxSelectMultiple widget in django.forms, suitable for use with a forms.ModelMultipeChoiceField, and probably with other stuff.Doesn't it do what you need? Or are you just reinventing the wheel. And, of course, your code as shown doesn't work because Cat and Category are not based on django.db.models.Model . On Fri, Aug 6, 2010 at 2:41 PM, lingrlongr wrote: > Forgo the most important part. I want to be prompted with a > checkboxes that show which categories are selected, as well as the > ones that aren't. > > On Aug 6, 2:13 pm, lingrlongr wrote: >> Having difficulty getting the check_test to work. Can't find any >> examples out there that help. I'll probably have to give a little >> background. I simplified where able to... >> >> class Cat: >> name = CharField >> >> class Category: >> name = ForeignKey(Cat) >> weight = DecimalField >> item = ForeignKey('Item') >> >> class Item: >> name = CharField >> >> Basically Cat is a model of all categories and Category is a model of >> which Cat's are assigned to an item. I did it this way because I want >> to have a "master list" of categories, then have the mapping done in >> other models. >> >> So now I want to build a form at run-time. >> >> def get_form(item): >> fields = dict() >> cat_choices = [(c.id, c.name) for c in Cat.objects.all()] >> for c in cat_choices: >> id, name = c >> checked = bool(item.categoty_set.filter(pk=id).count()) >> >> fields['item_cat_%d' % id] = forms.ChoiceField( >> label = name, >> required = False, >> choices = cat_choices, >> widget = forms.CheckboxInput( >> attrs={'value': checked}, >> check_test = lambda a: a == checked >> ) >> ) >> return type('CatSelectForm', (forms.BaseForm,), {'base_fields': >> fields}) >> >> So how can I get the correct checkboxes checked at runtime when the >> template is rendered? >> >> Thx. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: CheckBoxInput widget: check_test
On Aug 6, 7:13 pm, lingrlongr wrote: > Having difficulty getting the check_test to work. Can't find any > examples out there that help. I'll probably have to give a little > background. I simplified where able to... > > class Cat: > name = CharField > > class Category: > name = ForeignKey(Cat) > weight = DecimalField > item = ForeignKey('Item') > > class Item: > name = CharField > > Basically Cat is a model of all categories and Category is a model of > which Cat's are assigned to an item. I did it this way because I want > to have a "master list" of categories, then have the mapping done in > other models. > > So now I want to build a form at run-time. > > def get_form(item): > fields = dict() > cat_choices = [(c.id, c.name) for c in Cat.objects.all()] > for c in cat_choices: > id, name = c > checked = bool(item.categoty_set.filter(pk=id).count()) > > fields['item_cat_%d' % id] = forms.ChoiceField( > label = name, > required = False, > choices = cat_choices, > widget = forms.CheckboxInput( > attrs={'value': checked}, > check_test = lambda a: a == checked > ) > ) > return type('CatSelectForm', (forms.BaseForm,), {'base_fields': > fields}) > > So how can I get the correct checkboxes checked at runtime when the > template is rendered? > > Thx. The closure isn't acting the way you think. Each lambda is bound to the same `checked` variable, whose value is changed each time through the loop - so when it is actually evaluated, it has the value of the last time through. One way of fixing this is to use a nested function, rather than a lambda, with a default value: for c in cat_choices: ... checked = bool(item.category_set.filter(pk=id).count()) def is_checked(a, checked=checked): return a == checked widget = forms.CheckboxInput( attrs={'value': checked}, check_test = is_checked ) This creates a new function each time, with the default parameter set to the value of `checked` at the time it was defined. -- 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-us...@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.
Why can't I set debug = False and have django log to stderr?
folks - This is really annoying me. I want to set DEBUG=False for production and catch all errors logs (in my case, 500) in the servers log file. Sounds simple enough, but not the case here. DJango seems to only want to send such errors via email. When I generate a 500 error, then 500.html gets displayed, but No error log as to what the root cause it. Whats up with that? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 is not creating all the tables
Hi, maybe there are some dependencies between this reordered apps? Could you describe a bit more them? best regards, On Fri, Aug 6, 2010 at 6:15 PM, Thales wrote: > It seems to be a django bug. I changed the apps order in INSTALED_APPS > in settings.py and everything started to work correctly. > > On 6 ago, 11:55, Thales wrote: >> Hi everybody, >> >> I am working in a project using django, which has about 20 apps's. >> There is no tests written and It was decided that tests would have to >> be written for the whole project. >> >> To start testing, I runned: >> "python manage.py test" >> >> And a database was created, tables and stuff... But one table wasnt >> created, so I got this error: >> "Error: Database test_febrace couldn't be flushed. Possible reasons: >> * The database isn't running or isn't configured correctly. >> * At least one of the expected database tables doesn't exist. >> * The SQL was invalid. >> Hint: Look at the output of 'django-admin.py sqlflush'. That's the >> SQL this command wasn't able to run. >> The full error: (1146, "Table 'test_febrace.submissao_projeto' >> doesn't exist")" >> >> Trying to discover what the problem was, I deleted all my tables and >> runned: >> "python manage.py syncdb" >> And... 2 of the tables weren't created in my mysql database. Both of >> them are from the same app, which has other models and the other >> models tables were succesfully created. >> >> I tryed >> "python manage.py sqlall *appname*" and I executed the returned sql >> statements in my mysql server, so the tables were created. >> >> Any suggestion? For the project, it is ok to create manually executing >> the sqlall commands for me, but this way I cant test. >> >> 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-us...@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. > > -- Bogusław Faja tel. (+48) 691544955 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: CheckBoxInput widget: check_test
@Bill Thanks. I just stumbled across that widget. I know models.Model weren't there, I was trying to simplify thinking we'd all know they were there. I guess, never assume ;) Looks like I don't even have to worry about that check_test field after all. Using initial worked perfectly. def get_form(item): fields = {} choices = [(c.id, c.name) for c in Cat.objects.all()] selections = [c.name.id for c in item.category_set.all()] fields['cat'] = forms.MultipleChoiceField( label=item, required=False, choices = choices, initial=selections, widget = forms.CheckboxSelectMultiple() ) return type('CatForm', (forms.BaseForm,), {'base_fields': fields}) () On Aug 6, 3:09 pm, Bill Freeman wrote: > There is a CheckBoxSelectMultiple widget in django.forms, suitable > for use with a forms.ModelMultipeChoiceField, and probably with > other stuff. Doesn't it do what you need? Or are you just reinventing > the wheel. > > And, of course, your code as shown doesn't work because Cat and > Category are not based on django.db.models.Model . > > On Fri, Aug 6, 2010 at 2:41 PM, lingrlongr wrote: > > Forgo the most important part. I want to be prompted with a > > checkboxes that show which categories are selected, as well as the > > ones that aren't. > > > On Aug 6, 2:13 pm, lingrlongr wrote: > >> Having difficulty getting the check_test to work. Can't find any > >> examples out there that help. I'll probably have to give a little > >> background. I simplified where able to... > > >> class Cat: > >> name = CharField > > >> class Category: > >> name = ForeignKey(Cat) > >> weight = DecimalField > >> item = ForeignKey('Item') > > >> class Item: > >> name = CharField > > >> Basically Cat is a model of all categories and Category is a model of > >> which Cat's are assigned to an item. I did it this way because I want > >> to have a "master list" of categories, then have the mapping done in > >> other models. > > >> So now I want to build a form at run-time. > > >> def get_form(item): > >> fields = dict() > >> cat_choices = [(c.id, c.name) for c in Cat.objects.all()] > >> for c in cat_choices: > >> id, name = c > >> checked = bool(item.categoty_set.filter(pk=id).count()) > > >> fields['item_cat_%d' % id] = forms.ChoiceField( > >> label = name, > >> required = False, > >> choices = cat_choices, > >> widget = forms.CheckboxInput( > >> attrs={'value': checked}, > >> check_test = lambda a: a == checked > >> ) > >> ) > >> return type('CatSelectForm', (forms.BaseForm,), {'base_fields': > >> fields}) > > >> So how can I get the correct checkboxes checked at runtime when the > >> template is rendered? > > >> Thx. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Python question about subprocess.Popen() and stdout
On Fri, Aug 6, 2010 at 12:17 PM, Joshua Russo wrote: > On Aug 6, 9:57 am, "J. Cliff Dyer" wrote: > > "Joshua Russo" wrote: > > >On Thu, Aug 5, 2010 at 10:53 PM, Steve Holden > wrote: > > > > >> On 8/5/2010 7:16 PM, Joshua Russo wrote: > > >> > On Aug 4, 6:49 pm, Hassan wrote: > > >> >>> Ok, so it appears that (in Python 2.5 at least) there is no way to > > >> capture > > >> >>> the stdout of subprocess.Popen() > > > > >> >> just do this > > > > >> >> from subprocess import Popen, PIPE > > >> >> p = Popen([cmd], stdout=PIPE) > > >> >> p.stdout.readlines() > > > > >> >> thats it! > > > > >> > The problem is that it waits for the process to end to output > > >> > anything. Unless I was doing something wrong, but I think I was > doing > > >> > just what you describe here. > > > > >> Well, readlines() inherently has to see the end of the data stream > > >> before it can return a list of all the lines that the data stream > > >> contains, so that's hardly surprising is it? > > > > >> Try using readline() in a loop and see if that gives you better > results. > > >> I don't guarantee it will, but at least you will have some chance if > > >> subprocess.open() *isn't* buffering the whole stream. > > > > >> regards > > >> Steve > > > > >Tried that too and even putting the reading of them in their own thread > as > > >someone else suggested on Stackoverflow. I just can't find anyway to > capture > > >stdout in real-time from Popen. The problem is that everything uses > > >readline() that buffers the output. > > > > >http://stackoverflow.com/questions/874815/how-do-i-get-real-time-info. > .. > > >http://stackoverflow.com/questions/2082850/real-time-subprocess-popen. > .. > > > > >The way I got it to work with out Popen is to use a text box control as > the > > >stdout object. This works great, utilizing the object's write() method. > > > > >The problem with Popen is that it expects the stdout object to have a > > >fileno() method also, which the text box control does not have. So I > tried > > >extending the text box to add the fileno() and had it return 1 like the > > >standard stdout, but still no dice. I didn't let the process (unit > tests) > > >finish but it definitely was not giving real time output, through it did > > >accept the control with the fileno() method added. It really seems like > that > > >should have worked and I may have been able to dig further into Popen to > > >make it work but I figured that I had spent too much time on it as it > was. > > > > >If anybody has more suggestions I'd love to hear them. > > > > >-- > > >You received this message because you are subscribed to the Google > Groups "Django users" group. > > >To post to this group, send email to django-us...@googlegroups.com. > > >To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > >For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > > > If I understand your issue correctly, in ran into something similar a > while back. The problem is not in subprocess, but in how stdout works. The > output is buffered by default, so it only gets written on a line-by-line > basis. > > > > If you want to catch it one character at a time, you have to explicitly > flush the output after each character using sys.stdout.flush(). Then, of > course, you'll also have to read it from subprocess one character at a time, > too, > > using .read(1) instead of .readline() > > > > I hope that addresses your issue. > > > > Cheers, > > Cliff > > Thanks for the tip, I'll check it out. Nope, still no dice. Below is what I did. I modified the worker() function from one of the Stackoverflow examples. Let me know if I'm using flush properly. Keep in mind that everything you see here is already running in a separate thread from the wxPython GUI so I can update the GUI while all my tests run in the background. import threading import subprocess as sp import sys class ThreadWorker(threading.Thread): def __init__(self, callable, *args, **kwargs): super(ThreadWorker, self).__init__() self.callable = callable self.args = args self.kwargs = kwargs self.setDaemon(True) def run(self): try: self.callable(*self.args, **self.kwargs) except wx.PyDeadObjectError: pass except Exception, e: print e def worker(pipe): sys.stdout.write('**start worker**\n') line = [] while True: pipe.flush() blob = pipe.read() if blob == '': sys.stdout.write('**break**\n') break for c in blob: line.append(c) if c == '\n': sys.stdout.write(''.join(line)) line = [] tstP = sp.Popen("python.exe manage.py test --noinput --settings=adminTributaria.settings.test", stdout=sp.PIPE, stderr=sp.PIPE) stdout_worker = ThreadWorker(worker, tstP.stdout) stdout_worker.start() tstP.wait() -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send e
Django and WebShell
I'm trying to setup Webshell in one of my Django Password protected pages. Webshell is a python script which starts its own server and your designated port it displays a shell on ava enabled web browser that connect to localhost. It tests good when i display it with an Iframe http://webshellurl.net:9881"; width="100%" height="300"> But i would like to set it up so that you have to be logged into my django app to view it. I can start the webshell on the localhost interface, but that wouldn't work with an Iframe tag. Is there a django way to connect the server and display the contents on my django protected page? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 on Mac OS X
ops, sorry. python 2.7 django 1.2.1 =} thanx, I'll look at this On Fri, Aug 6, 2010 at 1:02 PM, wrote: > Hi daniel, > > I doubt your python version is 1.2.1, maybe it's rather Django version :) > However, the issue django stated looks pretty clear to me. You created a > database with a wrong encoding type. > You should have a look at: > http://docs.djangoproject.com/en/1.2/ref/unicode/ > > Regards, > Xavier. > > On Fri, 6 Aug 2010 11:13:40 -0300, Daniel França > wrote: > > Hi, I'm still get error trying to run my project on Mac =(Now the > > standalone server is running fine, but when I try to create a new user I > > get the error: "Can't adapt type 'US/Eastern", I tried to change my > > TIME_ZONE in setting, but no success. I can simulate this error in > > console, and here's the output: > from django.contrib.auth.models import User >>> new_user = > > User.objects.create_user("daniel", "daniel.fra...@gmail.com [1]", > > "daniel") Traceback (most recent call last): File "", line 1, in > > File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", > > line 129, in create_user user.save(using=self._db) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > > line 435, in save self.save_base(using=using, > > force_insert=force_insert, force_update=force_update) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > > line 543, in save_base created=(not record_exists), > > raw=raw) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > > line 162, in send response = receiver(signal=self, sender=sender, > > **named) File > > "/Users/danielfranca/workspace/django/view/tint/apps/account/models.py", > > line 60, in create_account account, created = > > Account.objects.get_or_create(user=instance) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", > > line 135, in get_or_create return > > self.get_query_set().get_or_create(**kwargs) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", > > line 373, in get_or_create obj.save(force_insert=True, > > using=self.db) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > > line 435, in save self.save_base(using=using, > > force_insert=force_insert, force_update=force_update) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > > line 528, in save_base result = manager._insert(values, > > return_id=update_pk, using=using) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", > > line 195, in _insert return insert_query(self.model, values, > > **kwargs) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", > > line 1479, in insert_query return > > query.get_compiler(using=using).execute_sql(return_id) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", > > line 783, in execute_sql cursor = super(SQLInsertCompiler, > > self).execute_sql(None) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", > > line 727, in execute_sql cursor.execute(sql, params) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", > > line 15, in execute return self.cursor.execute(sql, > > params) File > > > > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", > > line 44, in execute return self.cursor.execute(query, > > args)DatabaseError: can't adapt type 'US/Eastern' > > Anyone have any ideia what it can be?my python version is 1.2.1 > > > > On Mon, Jul 19, 2010 at 9:01 AM, Shawn Milochik wrote: > > Daniel, > > Glad to help. If you're new to the Mac and have questions just let me > > know. > > Shawn > > sh...@milochik.com [3] Google Chat: shawn.m...@gmail.com [4] > > > > 2010/7/19 Daniel França > > thanks a lot, now it's working.. at least this part.=) > > > > On Sun, Jul 18, 2010 at 11:10 PM, Shawn Milochik wrote: > > This is a known (and common) problem. Here's an easy fix that I've used > > many times. > > > > http://shawnmilo.blogspot.com/2009/11/psycopg2-on-snow-leopard.html [7] > > > > Incidentally, you can replace "make install" with "make altinstall" to > > add Python 2.7 to your system without replacing the default Python. > > > > Shawn > > > > -
Re: CheckBoxInput widget: check_test
It's always a hazzard to simplify the code because you can make errors simplifying, causing folks to spend time trying to figure out the wrong stuff. If the code is big it may be appropriate to excerpt, but other than sanitizing out sensitive information, it's best not to edit the stuff you do paste in. On Fri, Aug 6, 2010 at 3:26 PM, lingrlongr wrote: > @Bill > > Thanks. I just stumbled across that widget. I know models.Model > weren't there, I was trying to simplify thinking we'd all know they > were there. I guess, never assume ;) > > Looks like I don't even have to worry about that check_test field > after all. Using initial worked perfectly. > > def get_form(item): > fields = {} > choices = [(c.id, c.name) for c in Cat.objects.all()] > selections = [c.name.id for c in item.category_set.all()] > fields['cat'] = forms.MultipleChoiceField( > label=item, > required=False, > choices = choices, > initial=selections, > widget = forms.CheckboxSelectMultiple() > ) > return type('CatForm', (forms.BaseForm,), {'base_fields': fields}) > () > > > > > On Aug 6, 3:09 pm, Bill Freeman wrote: >> There is a CheckBoxSelectMultiple widget in django.forms, suitable >> for use with a forms.ModelMultipeChoiceField, and probably with >> other stuff. Doesn't it do what you need? Or are you just reinventing >> the wheel. >> >> And, of course, your code as shown doesn't work because Cat and >> Category are not based on django.db.models.Model . >> >> On Fri, Aug 6, 2010 at 2:41 PM, lingrlongr wrote: >> > Forgo the most important part. I want to be prompted with a >> > checkboxes that show which categories are selected, as well as the >> > ones that aren't. >> >> > On Aug 6, 2:13 pm, lingrlongr wrote: >> >> Having difficulty getting the check_test to work. Can't find any >> >> examples out there that help. I'll probably have to give a little >> >> background. I simplified where able to... >> >> >> class Cat: >> >> name = CharField >> >> >> class Category: >> >> name = ForeignKey(Cat) >> >> weight = DecimalField >> >> item = ForeignKey('Item') >> >> >> class Item: >> >> name = CharField >> >> >> Basically Cat is a model of all categories and Category is a model of >> >> which Cat's are assigned to an item. I did it this way because I want >> >> to have a "master list" of categories, then have the mapping done in >> >> other models. >> >> >> So now I want to build a form at run-time. >> >> >> def get_form(item): >> >> fields = dict() >> >> cat_choices = [(c.id, c.name) for c in Cat.objects.all()] >> >> for c in cat_choices: >> >> id, name = c >> >> checked = bool(item.categoty_set.filter(pk=id).count()) >> >> >> fields['item_cat_%d' % id] = forms.ChoiceField( >> >> label = name, >> >> required = False, >> >> choices = cat_choices, >> >> widget = forms.CheckboxInput( >> >> attrs={'value': checked}, >> >> check_test = lambda a: a == checked >> >> ) >> >> ) >> >> return type('CatSelectForm', (forms.BaseForm,), {'base_fields': >> >> fields}) >> >> >> So how can I get the correct checkboxes checked at runtime when the >> >> template is rendered? >> >> >> Thx. >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: TemplateDoesNotExist: 500.html error when trying to run server
Hi Steve, I do have the DEBUG setting on False. The reason is that when I set DEBUG to True, I get the following message: Page not found (404) Request Method: GET Request URL:http://127.0.0.1:8000/ Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: 1. ^admin/ The current URL, , didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. And thanks for your response! Regards Meenakshi On Aug 5, 3:50 pm, Steve Holden wrote: > On 8/5/2010 6:27 PM, meenakshi wrote: > > > > > I am a beginner working through the Django tutorial. When I try to > > run the development server athttp://127.0.0.1:8000/, I get a > > TemplateDoesNotExist: 500.html error. > > I have no problems linking tohttp://127.0.0.1:8000/admin, > > however. Whats going on? > > > Here is what I get when I try to run the server : > > > ^CMacintosh:mysite mroy$ python2.6 manage.py runserver > > Validating models... > > 0 errors found > > > Django version 1.1.1, using settings 'mysite.settings' > > Development server is running athttp://127.0.0.1:8000/ > > Quit the server with CONTROL-C. > > > Traceback (most recent call last): > > > File "/sw/lib/python2.6/site-packages/django/core/servers/ > > basehttp.py", line 279, in run > > self.result = application(self.environ, self.start_response) > > > File "/sw/lib/python2.6/site-packages/django/core/servers/ > > basehttp.py", line 651, in __call__ > > return self.application(environ, start_response) > > > File "/sw/lib/python2.6/site-packages/django/core/handlers/wsgi.py", > > line 241, in __call__ > > response = self.get_response(request) > > > File "/sw/lib/python2.6/site-packages/django/core/handlers/base.py", > > line 122, in get_response > > return self.handle_uncaught_exception(request, resolver, > > sys.exc_info()) > > > File "/sw/lib/python2.6/site-packages/django/core/handlers/base.py", > > line 166, in handle_uncaught_exception > > return callback(request, **param_dict) > > > File "/sw/lib/python2.6/site-packages/django/views/defaults.py", > > line 23, in server_error > > t = loader.get_template(template_name) # You need to create a > > 500.html template. > > > File "/sw/lib/python2.6/site-packages/django/template/loader.py", > > line 81, in get_template > > source, origin = find_template_source(template_name) > > > File "/sw/lib/python2.6/site-packages/django/template/loader.py", > > line 74, in find_template_source > > raise TemplateDoesNotExist, name > > > TemplateDoesNotExist: 500.html > > > I am using python2.6 and Django version 1.1. What's wrong? I > > apologize for this newbie question. Would really appreciate some > > help. > > Do you have the DEBUG setting at False? I thought 500 errors would give > a traceback rather than print a 500 response when DEBUG was true. > > You appear to be getting the error because some part of your logic is > raising an uncaught exception. In order to return the necessary HTTP > response (with status code 500) Django looks for a specific template. > Defining it will be useful for production, but for testing you want to > see the traceback from the error so you know what is going wrong in your > logic. > > regards > Steve > -- > I'm no expert. > "ex" == "has-been"; "spurt" == "drip under pressure" > "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
ImproperlyConfigured: Error importing middleware django.middleware.csrf: "No module named csrf" on Windows XP
Hi everybody, I am working on windows XP with django 1.2, I have downloaded a django web aplication but I continuely get a message error like this: "ImproperlyConfigured: Error importing middleware django.middleware.csrf: "No module named csrf" I have not idea why this is happening, could you help please ??? How could I fix that ??? Regards, Ariel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: TemplateDoesNotExist: 500.html error when trying to run server
On 8/6/2010 3:59 PM, meenakshi wrote: > Hi Steve, > I do have the DEBUG setting on False. The reason is that when I > set DEBUG to True, I get the following message: > > > Page not found (404) > Request Method: GET > Request URL: http://127.0.0.1:8000/ > > Using the URLconf defined in mysite.urls, Django tried these URL > patterns, in this order: > >1. ^admin/ > > The current URL, , didn't match any of these. > That indicates that there is something missing from your urls.py - you don't have anything that will match the URL of the site's home page. As to why youo are getting a 500 error with DEBUG on when you get a 404 with DEBUG off, may be someone else will have more idea than me. regards Steve > You're seeing this error because you have DEBUG = True in your Django > settings file. Change that to False, and Django will display a > standard 404 page. > > > And thanks for your response! > > Regards > Meenakshi > > > On Aug 5, 3:50 pm, Steve Holden wrote: >> On 8/5/2010 6:27 PM, meenakshi wrote: >> >> >> >>> I am a beginner working through the Django tutorial. When I try to >>> run the development server athttp://127.0.0.1:8000/, I get a >>> TemplateDoesNotExist: 500.html error. >>>I have no problems linking tohttp://127.0.0.1:8000/admin, >>> however. Whats going on? >> >>> Here is what I get when I try to run the server : >> >>> ^CMacintosh:mysite mroy$ python2.6 manage.py runserver >>> Validating models... >>> 0 errors found >> >>> Django version 1.1.1, using settings 'mysite.settings' >>> Development server is running athttp://127.0.0.1:8000/ >>> Quit the server with CONTROL-C. >> >>> Traceback (most recent call last): >> >>> File "/sw/lib/python2.6/site-packages/django/core/servers/ >>> basehttp.py", line 279, in run >>> self.result = application(self.environ, self.start_response) >> >>> File "/sw/lib/python2.6/site-packages/django/core/servers/ >>> basehttp.py", line 651, in __call__ >>> return self.application(environ, start_response) >> >>> File "/sw/lib/python2.6/site-packages/django/core/handlers/wsgi.py", >>> line 241, in __call__ >>> response = self.get_response(request) >> >>> File "/sw/lib/python2.6/site-packages/django/core/handlers/base.py", >>> line 122, in get_response >>> return self.handle_uncaught_exception(request, resolver, >>> sys.exc_info()) >> >>> File "/sw/lib/python2.6/site-packages/django/core/handlers/base.py", >>> line 166, in handle_uncaught_exception >>> return callback(request, **param_dict) >> >>> File "/sw/lib/python2.6/site-packages/django/views/defaults.py", >>> line 23, in server_error >>> t = loader.get_template(template_name) # You need to create a >>> 500.html template. >> >>> File "/sw/lib/python2.6/site-packages/django/template/loader.py", >>> line 81, in get_template >>> source, origin = find_template_source(template_name) >> >>> File "/sw/lib/python2.6/site-packages/django/template/loader.py", >>> line 74, in find_template_source >>> raise TemplateDoesNotExist, name >> >>> TemplateDoesNotExist: 500.html >> >>> I am using python2.6 and Django version 1.1. What's wrong? I >>> apologize for this newbie question. Would really appreciate some >>> help. >> >> Do you have the DEBUG setting at False? I thought 500 errors would give >> a traceback rather than print a 500 response when DEBUG was true. >> >> You appear to be getting the error because some part of your logic is >> raising an uncaught exception. In order to return the necessary HTTP >> response (with status code 500) Django looks for a specific template. >> Defining it will be useful for production, but for testing you want to >> see the traceback from the error so you know what is going wrong in your >> logic. >> >> regards >> Steve >> -- >> I'm no expert. >> "ex" == "has-been"; "spurt" == "drip under pressure" >> "expert" == "has-been drip under pressure". > -- I'm no expert. "ex" == "has-been"; "spurt" == "drip under pressure" "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Multipart and Content-Type
OK, I appreciate your message. Actually I've already saw some messages about it, but with no satisfatory answers. The line in the code that cleans the field raw_post_data when content-type is "multipart*" screws everything up. But the major problem seems to be do not handle multipart messages very well... what is a pity. :( Henrique On Fri, Aug 6, 2010 at 8:53 AM, Reinout van Rees wrote: > On 08/06/2010 07:54 AM, Henrique Teófilo wrote: > >> Dear all, >> >> I'm posting a multipart/mixed message to Django 1.1.1 using the >> development web server (a binary file and a textual part -- it's not a >> Form) and I need to get the Content-Type of the textual part. How do I >> accomplish this?? >> >> I was trying to get it from request.raw_post_data but it is coming >> empty... >> > > I've seen cases where you cannot grab data from the request after you've > already grabbed it. So if that raw_post_data is called after the "regular" > grab... > > I totally don't know how this works in Django, but I've seen this happen > once elsewhere, so it might have bitten you too. > > > > > Reinout > > > -- > Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org > Programmer at http://www.nelen-schuurmans.nl > "Military engineers build missiles. Civil engineers build targets" > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Footer dynamic data
I have a footer on my site. It has to be filled in with data which comes from the database. Each view will have to load this common footer data. How can I organise such a behaviour in my views.py file? I guess it is a separate function, but I'm django newbie, so please, keep your pulse. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: TemplateDoesNotExist: 500.html error when trying to run server
To clarify - I get a 404 message with DEBUG on (i.e. DEBUG=True), and a 500 message with DEBUG off (DEBUG=False), not the other way around. Regards Meenakshi On Aug 6, 1:21 pm, Steve Holden wrote: > On 8/6/2010 3:59 PM, meenakshi wrote: > > > Hi Steve, > > I do have the DEBUG setting on False. The reason is that when I > > set DEBUG to True, I get the following message: > > > Page not found (404) > > Request Method: GET > > Request URL: http://127.0.0.1:8000/ > > > Using the URLconf defined in mysite.urls, Django tried these URL > > patterns, in this order: > > > 1. ^admin/ > > > The current URL, , didn't match any of these. > > That indicates that there is something missing from your urls.py - you > don't have anything that will match the URL of the site's home page. > > As to why youo are getting a 500 error with DEBUG on when you get a 404 > with DEBUG off, may be someone else will have more idea than me. > > regards > Steve > > > > > You're seeing this error because you have DEBUG = True in your Django > > settings file. Change that to False, and Django will display a > > standard 404 page. > > > And thanks for your response! > > > Regards > > Meenakshi > > > On Aug 5, 3:50 pm, Steve Holden wrote: > >> On 8/5/2010 6:27 PM, meenakshi wrote: > > >>> I am a beginner working through the Django tutorial. When I try to > >>> run the development server athttp://127.0.0.1:8000/, I get a > >>> TemplateDoesNotExist: 500.html error. > >>> I have no problems linking tohttp://127.0.0.1:8000/admin, > >>> however. Whats going on? > > >>> Here is what I get when I try to run the server : > > >>> ^CMacintosh:mysite mroy$ python2.6 manage.py runserver > >>> Validating models... > >>> 0 errors found > > >>> Django version 1.1.1, using settings 'mysite.settings' > >>> Development server is running athttp://127.0.0.1:8000/ > >>> Quit the server with CONTROL-C. > > >>> Traceback (most recent call last): > > >>> File "/sw/lib/python2.6/site-packages/django/core/servers/ > >>> basehttp.py", line 279, in run > >>> self.result = application(self.environ, self.start_response) > > >>> File "/sw/lib/python2.6/site-packages/django/core/servers/ > >>> basehttp.py", line 651, in __call__ > >>> return self.application(environ, start_response) > > >>> File "/sw/lib/python2.6/site-packages/django/core/handlers/wsgi.py", > >>> line 241, in __call__ > >>> response = self.get_response(request) > > >>> File "/sw/lib/python2.6/site-packages/django/core/handlers/base.py", > >>> line 122, in get_response > >>> return self.handle_uncaught_exception(request, resolver, > >>> sys.exc_info()) > > >>> File "/sw/lib/python2.6/site-packages/django/core/handlers/base.py", > >>> line 166, in handle_uncaught_exception > >>> return callback(request, **param_dict) > > >>> File "/sw/lib/python2.6/site-packages/django/views/defaults.py", > >>> line 23, in server_error > >>> t = loader.get_template(template_name) # You need to create a > >>> 500.html template. > > >>> File "/sw/lib/python2.6/site-packages/django/template/loader.py", > >>> line 81, in get_template > >>> source, origin = find_template_source(template_name) > > >>> File "/sw/lib/python2.6/site-packages/django/template/loader.py", > >>> line 74, in find_template_source > >>> raise TemplateDoesNotExist, name > > >>> TemplateDoesNotExist: 500.html > > >>> I am using python2.6 and Django version 1.1. What's wrong? I > >>> apologize for this newbie question. Would really appreciate some > >>> help. > > >> Do you have the DEBUG setting at False? I thought 500 errors would give > >> a traceback rather than print a 500 response when DEBUG was true. > > >> You appear to be getting the error because some part of your logic is > >> raising an uncaught exception. In order to return the necessary HTTP > >> response (with status code 500) Django looks for a specific template. > >> Defining it will be useful for production, but for testing you want to > >> see the traceback from the error so you know what is going wrong in your > >> logic. > > >> regards > >> Steve > >> -- > >> I'm no expert. > >> "ex" == "has-been"; "spurt" == "drip under pressure" > >> "expert" == "has-been drip under pressure". > > -- > I'm no expert. > "ex" == "has-been"; "spurt" == "drip under pressure" > "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 not creating intermediary tables for m2m relations
Hi All, When I run manage.py sqlall test, I get the proper MySQL create statements for my models, (Phone,Room). Room has a ManyToManyField(Phone) field, so I also get the proper intermediate Room_phones table: BEGIN; CREATE TABLE `Phone` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY , blah, blah ); CREATE TABLE `Room_phones` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `room_id` integer NOT NULL, `phone_id` integer NOT NULL, UNIQUE (`room_id`, `phone_id`) ); ALTER TABLE `Room_phones` ADD CONSTRAINT `phone_id_refs_id_61361b28` FOREIGN KEY (`phone_id`) REFERENCES `Phone` (`id`); CREATE TABLE `Room` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY , blah, blah ); ALTER TABLE `Room_phones` ADD CONSTRAINT `room_id_refs_id_71507c04` FOREIGN KEY (`room_id`) REFERENCES `Room` (`id`); COMMIT; models.py contains: class Phone(models.Model): type = models.CharField(max_length=1, db_column='Type', null=False, blank=False) ... class Room(models.Model): ... phones = models.ManyToManyField(Phone) manage.py syncdb doesn't create the Room_phones table though. Just the Room and Phone. I thought it would create it automagically, even though I don't have a model in models.py for it?? I'm working with MySQL, the db engine is set to InnoDB. When I put the intermediary table model explicitly in models.py and use the 'through' clause on the ManyToManyField, there is no problem, syncdb works perfectly. I can do this, but ... TIA, Brian -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Footer dynamic data
On 8/6/2010 5:03 PM, kostia wrote: > I have a footer on my site. It has to be filled in with data which > comes from the database. Each view will have to load this common > footer data. How can I organise such a behaviour in my views.py file? > > I guess it is a separate function, but I'm django newbie, so please, > keep your pulse. > The usual way to do this is by using a context processor. This is very well explained in the following bog post by James Bennett: http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/ regards Steve -- I'm no expert. "ex" == "has-been"; "spurt" == "drip under pressure" "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Footer dynamic data
Great, it works and is easy to understand. And that is despite an old article. Thank you, man. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Footer dynamic data
On 8/6/2010 5:40 PM, kostia wrote: > Great, it works and is easy to understand. And that is despite an old > article. > Thank you, man. > No problem. I found out about them pretty much the same way you just have :) -- I'm no expert. "ex" == "has-been"; "spurt" == "drip under pressure" "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Override queryset for admin Inline
I have an admin set up with three inlines. I would like to filter the inline's editable options by a variable that is defined in a settings file. I can over ride the actual admin pieces for each of the inlines (they all have full admin screens of their own). But I can't seem to get the standard def queryset(self, request): etc. over ride to work for inlines. I have seen a little talk about how inlines require you to create a new manager to filter the list of options. Here is my inline admin code: class CandidateInline(admin.TabularInline): model = Candidate fields = ['%s_vote' % (race_type)] extra = 0 ordering = ('party', 'last_name') ## here is where the trouble is starting, I'd like to get rid of everything that isn't status 1 ### def queryset(self, request): qs = super(CandidateInline, self).queryset(request) return qs.filter(status="1").exclude(party="Independent") and here is the primary admin model that this inline is attached to: class RaceAdmin(admin.ModelAdmin): inlines = [ CandidateInline, PrecinctInline, ] form = RaceForm fieldsets = ( ('General Race Information', { 'fields': ('name', 'office_name', 'type', 'county', 'general_winner') }), ('Partisan Race Outcomes (Runoff)', { 'classes': ('collapse',), 'fields': ('runoff_winner_d', 'runoff_winner_r', 'primary_advance_d', 'primary_advance_r'), }), ('Non Partisan Race Outcomes (Runoff)', { 'classes': ('collapse',), 'fields': ('runoff_winner_np',) }), ) list_display = ('name', 'type', 'county', ) list_filter = ('type', 'office_name', 'county') ordering = ['name'] # redefine the queryset to get rid of finals def queryset(self, request): qs = super(RaceAdmin, self).queryset(request) return qs.filter(type="2") -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: what do you do to take your site down?
On Aug 6, 2010, at 8:36 AM, Margie Roginski wrote: > Could anyone give me some pointers as to how you deal with taking your > site down for maintenance? Is there some standard thing that people > do to redirect all page requests to some sort of "Sorry, the site is > down" page?Do you do this directly via apache or do you do it via > django? > We have the front end web server redirect all web traffic to a static maintenance page. If we are upgrading the site, it typically means that the database or the django app server is unavailable. -- Eric Chamberlain, Founder RF.com - http://RF.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-us...@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.
Front-End Python/Django Web Developer role in the Bay Area
Hello, all; I wanted to reach out to the list regarding a full-time Front-End Web Development role that I have with a stealth-mode startup that is looking to change the way that people are protected online. They’re well & recently funded, and have a small core group in place, so this is very good time to get in at the ground-floor level, and really help drive the direction of the company’s future. With regards to the position itself, the candidate would participate in the selection of development tools, design and implementation of the presentation layer, in addition to some back-end integration work. The ideal candidate would need to have experience with *Django/Python*, in addition to *HTML*, *CSS*, *Javascript* (using one or more Javascript framework) and *AJAX*. Since they’re still in stealth-mode, I can’t say much else regarding what they’re working on without an NDA, although one of the components of the UI is based on social gaming/game mechanics, so candidates that have experience with *Facebook platforms* or *social gaming* is a *HUGE plus*. This is *NOT* an “equity-only” position, and the salary range for this role may top out at around $115K-$120K or so, although it’s dependent upon the candidate in question. I’ve got a great relationship with the Founder, so this is not just a position where a recruiter is “putting bodies over the fence and hoping something sticks.” They’re looking to get someone on board very quickly, so if this position sounds interesting to you, please feel free to respond to me directly, and I’ll answer any questions that you may have. Thanks, everyone. -Donald -- ** *Donald James* *Recruiter* *Office:* 310-414-6808 *Fax:* 310-414-6804 www.digitalartistmanagement.com www.linkedin.com/in/dkjames www.twitter.com/dam_agents -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
[JOB] Front-End Python/Django Web Developer role in the Bay Area
Hello, all; I wanted to reach out to the list regarding a full-time Front-End Web Development role that I have with a stealth-mode startup that is looking to change the way that people are protected online. They’re well & recently funded, and have a small core group in place, so this is very good time to get in at the ground-floor level, and really help drive the direction of the company’s future. With regards to the position itself, the candidate would participate in the selection of development tools, design and implementation of the presentation layer, in addition to some back-end integration work. The ideal candidate would need to have experience with Django/ Python, in addition to HTML, CSS, Javascript (using one or more Javascript framework) and AJAX. Since they’re still in stealth-mode, I can’t say much else regarding what they’re working on without an NDA, although one of the components of the UI is based on social gaming/game mechanics, so candidates that have experience with Facebook platforms or social gaming is a HUGE plus. This is NOT an “equity-only” position, and the salary range for this role may top out at around $115K-$120K or so, although it’s dependent upon the candidate in question. I’ve got a great relationship with the Founder, so this is not just a position where a recruiter is “putting bodies over the fence and hoping something sticks.” They’re looking to get someone on board very quickly, so if this position sounds interesting to you, please feel free to respond to me directly (digitalartistmgmt [at] gmail [dot] com), and I’ll answer any questions that you may have. Thanks, everyone. -Donald -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 on Mac OS X
My database is UTF-8, it's fine, doesn't?. I'm afraid to reinstall everything from ports and start to get a lot 64-32 bits incompatible issues like happened before =/ 2010/8/6 Daniel França > ops, sorry. python 2.7 django 1.2.1 =} > thanx, I'll look at this > > > On Fri, Aug 6, 2010 at 1:02 PM, wrote: > >> Hi daniel, >> >> I doubt your python version is 1.2.1, maybe it's rather Django version :) >> However, the issue django stated looks pretty clear to me. You created a >> database with a wrong encoding type. >> You should have a look at: >> http://docs.djangoproject.com/en/1.2/ref/unicode/ >> >> Regards, >> Xavier. >> >> On Fri, 6 Aug 2010 11:13:40 -0300, Daniel França > > >> wrote: >> > Hi, I'm still get error trying to run my project on Mac =(Now the >> > standalone server is running fine, but when I try to create a new user I >> > get the error: "Can't adapt type 'US/Eastern", I tried to change my >> > TIME_ZONE in setting, but no success. I can simulate this error in >> > console, and here's the output: >> from django.contrib.auth.models import User >>> new_user = >> > User.objects.create_user("daniel", "daniel.fra...@gmail.com [1]", >> > "daniel") Traceback (most recent call last): File "", line 1, in >> > File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", >> > line 129, in create_user user.save(using=self._db) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", >> > line 435, in save self.save_base(using=using, >> > force_insert=force_insert, force_update=force_update) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", >> > line 543, in save_base created=(not record_exists), >> > raw=raw) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", >> > line 162, in send response = receiver(signal=self, sender=sender, >> > **named) File >> > "/Users/danielfranca/workspace/django/view/tint/apps/account/models.py", >> > line 60, in create_account account, created = >> > Account.objects.get_or_create(user=instance) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", >> > line 135, in get_or_create return >> > self.get_query_set().get_or_create(**kwargs) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", >> > line 373, in get_or_create obj.save(force_insert=True, >> > using=self.db) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", >> > line 435, in save self.save_base(using=using, >> > force_insert=force_insert, force_update=force_update) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", >> > line 528, in save_base result = manager._insert(values, >> > return_id=update_pk, using=using) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", >> > line 195, in _insert return insert_query(self.model, values, >> > **kwargs) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", >> > line 1479, in insert_query return >> > query.get_compiler(using=using).execute_sql(return_id) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", >> > line 783, in execute_sql cursor = super(SQLInsertCompiler, >> > self).execute_sql(None) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", >> > line 727, in execute_sql cursor.execute(sql, params) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", >> > line 15, in execute return self.cursor.execute(sql, >> > params) File >> > >> >> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", >> > line 44, in execute return self.cursor.execute(query, >> > args)DatabaseError: can't adapt type 'US/Eastern' >> > Anyone have any ideia what it can be?my python version is 1.2.1 >> > >> > On Mon, Jul 19, 2010 at 9:01 AM, Shawn Milochik wrote: >> > Daniel, >> > Glad to help. If you're new to the Mac and have questions just let me >> > know. >> > Shawn >> > sh...@milochik.com [3] Google Chat: shawn.m...@gmail.com [4] >> > >> > 2010/7/19 Daniel França >> > thanks a lot, now it's working.. at least this part.=) >> > >> > On Sun, Jul 18, 2010 at 11:10 PM, Shawn Milochik wrote: >> > This is a known (and common) prob
Re: Footer dynamic data
On Fri, 2010-08-06 at 14:03 -0700, kostia wrote: > I have a footer on my site. It has to be filled in with data which > comes from the database. Each view will have to load this common > footer data. How can I organise such a behaviour in my views.py file? try templatetags -- regards Kenneth Gonsalves -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.