|
JoeNotCharles posted:Try "print test.var1" and "print test.var2". (It'll be more clear if you initialize var1 to "default" instead of "".) Whoops, I forgot to say thanks for this. That's an interesting behavior, one that I obviously did not expect. So, thank you for the help.
|
# ? Nov 26, 2007 16:25 |
|
|
# ? May 11, 2024 16:42 |
|
For anyone using Django who doesn't regularly read James Bennett's blog, he recently put up a good three-part post on the new forms stuff (which has been in the SVN for a while but isn't in any release yet). Though if you're a Django user, I'd suggest reading his blog regularly along with Malcolm Tredinnick's blog (though it's less Django-dense) No Safe Word fucked around with this message at 01:09 on Nov 27, 2007 |
# ? Nov 26, 2007 19:46 |
|
Haha, found this PEP on reddit, laffed. http://www.python.org/dev/peps/pep-3117/
|
# ? Nov 26, 2007 22:25 |
|
We're onto the third page and I can't believe this hasn't been asked yet: what is everyone's favorite windows development tool for Python (text editor or full IDE)? I've been using textpad which is awesome for small scripts as its very fast but I'd like to find something that has integrated projects and debugging support. I've heard a lot about eclipse but it was a little too slow for me the last time I used it.
|
# ? Nov 28, 2007 14:33 |
|
I use VIM. But as far as IDEs go PyDev is best free, Wing is best commercial.
|
# ? Nov 28, 2007 15:02 |
|
Yeah. I tend to use pydev, partly because I basically try and use eclipse for everything. Its just what I'm used to. Its a loving shame that boa-constructor got shanked by a dev who doesn't seem interested in letting anyone else contribute. It would of been a spectacular IDE had it been allowed to flourish.
|
# ? Nov 28, 2007 16:27 |
|
I use nano through Cygwin. Yes, I apparently do hate myself. I think I'm going to try to get used to using PyDev now though.
|
# ? Nov 28, 2007 16:36 |
|
Git posted:I use nano through Cygwin. Yes, I apparently do hate myself. god, notepad++ is probably 100x better than nano through cygwin.
|
# ? Nov 28, 2007 16:41 |
|
I use textmate and Eclipse+Pydev. Textmate when I'm not working on our huge work-projects in house (autocomplete is a must on large projects).
|
# ? Nov 28, 2007 17:19 |
|
WingIDE does everything I need, and more. You can get like 20 days of free evaluation, so go ahead and try it to see if it works for you.
|
# ? Nov 28, 2007 17:24 |
|
Didn't see anyone mention it, but The Definitive Guide to Django: Web Development Done Right is (finally) out. I bought it in ebook format, but I'm sure it'll be at djangobook.com soon enough.
|
# ? Nov 28, 2007 17:36 |
|
Typh posted:Didn't see anyone mention it, but The Definitive Guide to Django: Web Development Done Right is (finally) out. I've pre-ordered a copy from amazon. One question: How have they covered form generation in the book? My django knowledge is very limited but I understand there's oldforms and newforms (which will just be forms when it's ready).
|
# ? Nov 29, 2007 09:58 |
|
If you want an excellent newforms walkthrough, check out the intro to newforms posts on James Bennett's blog: http://www.b-list.org/weblog/2007/nov/22/newforms/ http://www.b-list.org/weblog/2007/nov/23/newforms/ http://www.b-list.org/weblog/2007/nov/25/newforms/
|
# ? Nov 29, 2007 12:09 |
|
I have a Django question: I'm re-building my Paste Monkey app from scratch using Django, and I found the Pygments syntax highlighting library. What I do with a paste is store the paste as plain text in the database, and I want to format it to the view. Here is my code:code:
|
# ? Nov 29, 2007 13:24 |
|
Have you tried casting the object to a string or maybe use __str__ (which should do the same thing)? Looking at the Pygments documentation real quick does that object have a name property perhaps?
Horn fucked around with this message at 14:11 on Nov 29, 2007 |
# ? Nov 29, 2007 14:08 |
|
Are you doing something like {{ object.language }} in your template? If so you need to define a __unicode__ method in your Language class that returns whatever property contains the name.
unclefu fucked around with this message at 14:24 on Nov 29, 2007 |
# ? Nov 29, 2007 14:21 |
|
unclefu posted:Are you doing something like {{ object.language }} in your template? If so you need to define a __unicode__ method in your Language class that returns whatever property contains the name. Ok, I worked the language bit out by enclosing it in a str() but, the paste still comes out duff. I've checked the DB, and it's definitely plain text I should be passing with str(p.paste), but I am getting this instead: code:
|
# ? Nov 29, 2007 16:14 |
|
Digital Spaghetti posted:Ok, I worked the language bit out by enclosing it in a str() but, the paste still comes out duff. I've checked the DB, and it's definitely plain text I should be passing with str(p.paste), but I am getting this instead: That's a 3-tuple - ("big string", <pygments Lexer object>, <pygments Formatter object>). If that's the contents of p.paste, you can get just the string with p.paste[0]. One idiom I like to use is "(pasteStr, lexer, formatter) = p.paste", which puts each part of the tuple into its own variable. I presume you're supposed to use the lexer and formatter objects to turn the string into HTML, but you'll have to check the pygments docs to find out how.
|
# ? Nov 29, 2007 16:40 |
|
JoeNotCharles posted:That's a 3-tuple - ("big string", <pygments Lexer object>, <pygments Formatter object>). If that's the contents of p.paste, you can get just the string with p.paste[0]. One idiom I like to use is "(pasteStr, lexer, formatter) = p.paste", which puts each part of the tuple into its own variable. Thanks JoeNotCharles, that got rid of the extra objects in the tupple - but yea, there still seems to be an issue with it not parsing the text and formatting it, I'll dig deeper on that one. Edit: Oh man, I had a typo in my code that I completely missed as it didn't throw any errors :/ Well I've got it returning the code as parsed HTML now, but instead of rendering as HTML it renders as text (and weird in Firebug it looks fine). Thanks anyway, at least it pointed me in the right direction, and I learned a new thing in Python Digital Spaghetti fucked around with this message at 16:55 on Nov 29, 2007 |
# ? Nov 29, 2007 16:45 |
|
Django templates automatically escape all output now. It sounds like you need to pass that highlighted output through the 'safe' filter. Here's more info about it.
|
# ? Nov 29, 2007 17:41 |
|
unclefu posted:Django templates automatically escape all output now. It sounds like you need to pass that highlighted output through the 'safe' filter. Here's more info about it. Yea, after much searching I eventually found this, works a treat
|
# ? Nov 29, 2007 18:22 |
|
m0nk3yz posted:If you want an excellent newforms walkthrough, check out the intro to newforms posts on James Bennett's blog: No Safe Word at the top of this page posted:For anyone using Django who doesn't regularly read James Bennett's blog, he recently put up a good three-part post on the new forms stuff (which has been in the SVN for a while but isn't in any release yet).
|
# ? Nov 29, 2007 18:39 |
|
No Safe Word posted:Dangit, he asked though. He should have read the thread!
|
# ? Nov 29, 2007 22:50 |
|
m0nk3yz posted:Dangit, he asked though. He should have read the thread! Apologies, I'd actually read the newform articles you'd previously linked to. My question was more in the direction of how the book specifically handles it, since it seems to me the book has been written when quite a lot is still in flux. i.e. is this book(in paper form) going to be outdated within a month?
|
# ? Nov 30, 2007 00:31 |
|
I'm getting into pygame right now and I think it's pretty cool, although does anyone else think that the documentation is lacking? It just seems that the function descriptions aren't as clear as they could be and there's never any example of usage. For instance, there are key constans listen in the documentation for pygame.key but it doesn't say anywhere in exactly which namespace they are. I looked everywhere through the pygame.key namespace only to see that they're defined in the main module namespace.
|
# ? Nov 30, 2007 00:41 |
|
Bonus posted:I'm getting into pygame right now and I think it's pretty cool, although does anyone else think that the documentation is lacking? It just seems that the function descriptions aren't as clear as they could be and there's never any example of usage. pygame.locals has all of the constants, I think.
|
# ? Nov 30, 2007 06:13 |
|
Bonus posted:I'm getting into pygame right now and I think it's pretty cool, although does anyone else think that the documentation is lacking? It just seems that the function descriptions aren't as clear as they could be and there's never any example of usage. Yes, the pygame documentation sucks quite bad. But it is a great library.
|
# ? Dec 1, 2007 03:20 |
|
I'm trying to set up Apache mod_python to serve my Django website, but I'm having problems getting it working. To explain, my project is under /home/digitalspaghetti/workspace/digitalspaghetti. Here is my apache conf file: code:
code:
|
# ? Dec 2, 2007 14:26 |
|
I had to add this to my <Location "/"> directive:code:
unclefu fucked around with this message at 15:37 on Dec 2, 2007 |
# ? Dec 2, 2007 15:33 |
|
Yea, I eventually tried it and it worked - although some of my 3rd party apps are having problems so I've had to disable them until I can work them out
|
# ? Dec 2, 2007 15:41 |
|
I came in here today to ask about IDEs with Django, to see that it has already been addressed. At work I primarily use ASP.NET with visual studio, and although at home I prefer to use Django, I'm a bit spoilt by how easy it is in VS to trace through my code. I've downloaded WingIDE for the trial, but anything less than the professional version is next to useless for me, and it's a bit much to pay considering I'm just tinkering with it at home. Have people had any good experiences with Eclipse + pydev? The pydev author has a guide on getting it going for Django here, but it's the only IDE I haven't tried yet as I remember Eclipse as slow and bloated a few years ago. I'm sure it's better now.
|
# ? Dec 3, 2007 02:32 |
|
Here's a good post from a guy who extended a function in C and got it to run from 30 seconds to 0.7 seconds. Pretty cool. http://www.ginstrom.com/scribbles/2007/12/02/extending-python-with-c-a-case-study/
|
# ? Dec 3, 2007 11:55 |
|
deep square leg posted:Have people had any good experiences with Eclipse + pydev? The pydev author has a guide on getting it going for Django here, but it's the only IDE I haven't tried yet as I remember Eclipse as slow and bloated a few years ago. I'm sure it's better now. I managed to get Eclipse+Pydev to run the django development server, do autocomplete, syntax highlighting etc. but it completely ignores my breakpoints and watches. These work fine in WingIDE, which is frustrating because now I want to use Eclipse.
|
# ? Dec 3, 2007 15:31 |
|
deep square leg posted:I came in here today to ask about IDEs with Django, to see that it has already been addressed. At work I primarily use ASP.NET with visual studio, and although at home I prefer to use Django, I'm a bit spoilt by how easy it is in VS to trace through my code. I've downloaded WingIDE for the trial, but anything less than the professional version is next to useless for me, and it's a bit much to pay considering I'm just tinkering with it at home. While maybe not a full blown IDE, Komodo Edit is really nice for both python and django. It works with django out of the box and allows you to make projects for easy organization, code completion, and custom highlighting. I really like it. Also, it is free unlike it's partner Komodo IDE.
|
# ? Dec 4, 2007 06:32 |
|
I'm building a basic blog application in Django to replace Wordpress on my site eventually - it's nothing too fancy, but allows me to take PHP off my server. At the moment, I am building a blog app with 2 models, Category and Entry. What I am trying to do is in my template for entry_detail.html (I'm using Generic views) I want to show in the sidebar a Related Entries section. What I'm having problems with is coming up with getting related entries from the DB. Here is my model code: code:
1) When the entry is displayed, do a query to grab all entries in the database. 2) Do a for loop on our entry to get each category is belongs to 3) Inside the loop, do another loop for each entry from the database 4) Inside that loop, compare the categories and see if they match, if they do add the entry to be an array 5) Stop after finding 5 matching and pass the array to the template To me, that seems rather complicated, so I'm wondering anyone with more Django/Python experience if you could think of an easier design pattern for this. Another line I am thinking is doing a {% tag %} like I have with my latest entries (I do {% latest_entries "10" %}) but I'm not sure how I would pass in the id (as {% related_entries "object.id" %} would pass the string object.id and not the actual id??)
|
# ? Dec 4, 2007 18:28 |
|
Make a manager for entries and use a filter: categories__in=[ list of categories on current entry instance ] and slice it to the first 5, it generates two queries. Actually a manager is not needed for this, but it's the django way. edit: not sure now, you might have to categories__id__in = [ list of category ids on current entry instance ] deimos fucked around with this message at 20:22 on Dec 4, 2007 |
# ? Dec 4, 2007 20:14 |
|
I ended up learning about inclusion tags:code:
code:
|
# ? Dec 4, 2007 23:35 |
|
xkcd is awesome.
|
# ? Dec 5, 2007 06:16 |
|
LOLLERZ posted:by the way, try matching this:
|
# ? Dec 6, 2007 15:39 |
|
|
# ? May 11, 2024 16:42 |
|
Sgt. Raisins posted:While maybe not a full blown IDE, Komodo Edit is really nice for both python and django. It works with django out of the box and allows you to make projects for easy organization, code completion, and custom highlighting. I really like it. Also, it is free unlike it's partner Komodo IDE. Thanks for this, but I was really after the advanced debugging features of a full-blown IDE. For the record, I just couldn't get pydev to recognise breakpoints in eclipse, so I went with Wing IDE. The personal version does appear to have most of what I want, anyway.
|
# ? Dec 6, 2007 16:05 |