2008-7-6
| 00:36 | targaryen | SQS + pickles = tasty |
| 01:06 | doodlewarrior | rather than pass in a whole slew of keyword args in a constructor, |
| 01:06 | doodlewarrior | can i build a dict and pass it instead? |
| 01:06 | doodlewarrior | eg will it be interpretted as kwargs? |
| 01:16 | poing_ | is django's supplied comments app the preferred one? |
| 01:20 | wattz | evening everyone |
| 01:22 | wattz | anyone tell me how i can let my urls support - (dashes) in my named param? -- (r'^article/(?P<article>\w+)/$', 'wattz.main.views.article'), |
| 01:23 | aaronfay | how can I save an image within a view (posted data) that is in a generic relation? Example, I have a post with images=generic.GenericRelation(Image) and in my view I want to add the image from the posted form |
| 01:29 | aaronfay | okay, nevermind, answered my own question... thanks for looking :) |
| 01:39 | Tem | I did a project with django a while back and really enjoyed it. I'm going to be starting another pretty soon, and I'll probably use django again. |
| 01:40 | doodlewarrior | anyone know how to determine the class/type of a parameter |
| 01:40 | Tem | Is there a good place (like besides wading through commit logs) to see the changes to the dev version since the last time I used it? |
| 01:40 | doodlewarrior | i know in actionscript it if (value is String) |
| 01:40 | doodlewarrior | but i just googled the is keywork and it appears to check where something is in memory, not its type |
| 01:41 | Tem | like, in python? |
| 01:41 | doodlewarrior | yeah |
| 01:41 | doodlewarrior | i want to know if something is a key or a model |
| 01:41 | Tem | isinstance |
| 01:41 | doodlewarrior | so i can get the model if its a key |
| 01:41 | doodlewarrior | thanks |
| 01:48 | wattz | anyone tell me how i can let my urls support - (dashes) in my named param? -- (r'^article/(?P<article>\w+)/$', 'wattz.main.views.article'), |
| 01:49 | ubernostrum | Same way you support them in any regular expression? |
| 01:49 | wattz | that's what i mean |
| 01:51 | ubernostrum | Well, suppose you have a set of characters you want to support. |
| 01:51 | ubernostrum | What's the regular-expression construct for that? |
| 01:51 | Tem | \- |
| 01:51 | yogi_ | whoa, ubernostrum. thank you for your blog! |
| 01:52 | ubernostrum | Suppose you want to match, say, the letter 'a' or the letter 'q'. |
| 01:52 | ubernostrum | [aq] |
| 01:52 | ubernostrum | Suppose you want to match, say, a dash or the letter 'x'. |
| 01:52 | ubernostrum | [-x] |
| 01:52 | ubernostrum | Suppose you want to match, say, a dash or a word character. |
| 01:52 | ubernostrum | [-\w] |
| 01:52 | Tem | that probably won't work |
| 01:53 | Tem | since - is also a non-greedy expansion |
| 01:53 | Tem | you will probably need to escape it with a \ |
| 01:53 | Tem | However, you may not need to escape it inside of a character class |
| 01:53 | ubernostrum | Actually, it works just fine. |
| 01:54 | Tem | does it work if you try it outside of a class? |
| 01:55 | ubernostrum | Yes. |
| 01:55 | Tem | kerwhat? |
| 01:56 | Tem | does python's regex not have the non-greedy match? |
| 01:56 | Haitek | I think you'd have to escape the - in the [] since it's an interpreted character. Because you can do [a-z], and that doesn't mean a z and - |
| 01:56 | ubernostrum | import re |
| 01:56 | ubernostrum | pat = re.compile('\w-\w') |
| 01:56 | ubernostrum | pat.match('a-q') |
| 01:56 | ubernostrum | ^-- returns a match |
| 01:56 | yogi_ | it does have non-greedy matching |
| 01:56 | ubernostrum | pat.match('aq') |
| 01:56 | ubernostrum | ^-- returns no match. |
| 01:56 | ubernostrum | Welcome to regular expressions. |
| 01:56 | Tem | every implementation is so different I never know exactly what to expect >< |
| 01:57 | Tem | the one I've used recently has a meaning for - |
| 01:57 | yogi_ | adding a ? after the qualifiers make them non-greedy |
| 01:57 | zomg | Tem: what flavor was that? |
| 01:57 | Tem | Lua |
| 01:58 | yogi_ | as in *? , +? , and ?? |
| 01:58 | zomg | Tem: ah.. well, I've found that googling for "<languagename> regular expressions" usually yields a page with the complete syntax reference =) |
| 01:59 | yogi_ | |
| 01:59 | zomg | I'd never heard of any regex flavor using - outside character classes |
| 01:59 | Tem | you're absolutely right, but usually I just go on memory until I end up with a frustrating bug |
| 02:00 | zomg | I actually use a tool called RegexBuddy to do my more complex regexes since it can export the regex in quite many different flavors and has some other helpful features |
| 02:01 | Tem | that sounds handy |
| 02:02 | Tem googles | |
| 02:04 | targaryen | RegexBuddy is really nice |
| 02:04 | Tem | oh |
| 02:04 | Tem | it's not free |
| 02:04 | Tem | also windows |
| 02:04 | Tem sighs | |
| 02:04 | targaryen | It's the best $40 I spent |
| 02:04 | targaryen | It works with WIne |
| 02:05 | Tem | I haven't yet messed with wine |
| 02:05 | zomg | Yep, it's worth it easily =) |
| 02:05 | targaryen | The current version has a bug where it doesn't assign a window properly in wine, but I emailed the developer and he fixed that within a couple of days with the debug version |
| 02:05 | Haitek | If you use MySQL, mysql query browser has a nice regex tool in it as well. And it's free. |
| 02:06 | targaryen | So if you use it on wine, grab the debug version to get around the problem with it now showing up in the task panel or window selector |
| 02:07 | targaryen | Other than that it runs perfectly on linux |
| 02:09 | targaryen | I like being able to save my regexes to a library for future use |
| 02:12 | Haitek | In the meantime, I think you could swapout your \w+ for \S+ |
| 02:13 | yogi_ | What's the proper way to assign permissions to a user? |
| 02:13 | yogi_ | via code, not the admin interface |
| 02:15 | Haitek | |
| 02:15 | yogi_ | I looked, it doesn't say AFAICT |
| 02:15 | Haitek | myuser.user_permissions.add(permission, permission, ...) |
| 02:15 | yogi_ | Cool, thanks. |
| 02:17 | yogi_ | Ah, it is there — sorry 'bout that. |
| 02:35 | Esko | hello |
| 02:52 | neanton | can someone give a hint how to implement sql request and page generation time counter? |
| 02:59 | neanton | ok, about sql queries number and time i found. but how can i count full page generation time? when should i start counter? |
| 03:00 | irish | I'm looking for you, neanton, but I don't know off the top of my head |
| 03:01 | Magus- | you can't really do that easily |
| 03:02 | neanton | I think this is exactly what I need.. http://www.djangosnippets.org/snippets/358/ |
| 03:02 | Magus- | unless you don't need it displayed on a page |
| 03:04 | Magus- | hmm, that's an interesting way of doing it in that middleware |
| 03:05 | neanton | Magus-, can I register a new template tag in a middleware? |
| 03:05 | Magus- | of course not |
| 03:05 | neanton | ;( |
| 03:05 | ben | Hey. Has anyone tried putting a simple FreeComment page up in AppEngine? |
| 03:05 | Magus- | you can't use django models in GAE |
| 03:05 | neanton | replacing comment text sucks to my mind |
| 03:05 | Magus- | so no comments |
| 03:05 | ben | I'm interested in extending a single, simple HTML page with a comment roll. |
| 03:05 | ben | oh, bummer. |
| 03:06 | Magus- | and appengine questions belong in appengine help channels/mailing lists :) |
| 03:06 | ben | I'm looking for an option and I was hoping that was it. |
| 03:06 | neanton | Magus-, what is GAE?.. |
| 03:06 | ben | Good point, but the Django people are so much smarter! ;) |
| 03:06 | Magus- | google app engine, neanton..... |
| 03:09 | ben | Alright. I went and bugged them. Thanks for the direction, crew. |
| 03:09 | ben | If anyone knows of a good solution for what I'm after, I'd appreciate a PM if you have the time/generosity. |
| 03:10 | Magus- | unless someone wrote a comments app for GAE, you get to write your own |
| 03:10 | Magus- | there isn't much leeway there ;) |
| 03:11 | ben | word. you're the man. thanks. |
| 03:11 | neanton | Magus-, can I define some variable in middleware that will be accessible in my template? |
| 03:11 | Magus- | no |
| 03:12 | irish | Magus, you do realize you've become one of my heroes, right? |
| 03:13 | irish | you're always on here, being so helpful |
| 03:13 | irish | I'm trying to find documentation for establishing foreign keys from one app's model to another |
| 03:13 | irish | does anybody know where that documentation is? |
| 03:14 | neanton | irish, field = models.ForeighnKey(OtherModel) |
| 03:14 | irish | that works from one app to another? |
| 03:15 | neanton | yes |
| 03:15 | Magus- | if you import the other model, of course |
| 03:15 | irish | ah! |
| 03:15 | irish | what happens if two models have a same-name class defined and one imports the other? |
| 03:16 | neanton | i think that naming model with the same name is not good |
| 03:16 | irish | I agree |
| 03:16 | irish | but I have a ton of models |
| 03:16 | irish | I wouldn't be surprised if I had a few models that were named similarly, at this point |
| 03:16 | neanton | but maybe from bla.bla import User as UserObj |
| 03:17 | neanton | this is just a guess |
| 03:17 | irish | understood |
| 03:17 | irish | oh, and does anybody have any experience using the openID standard with django? |
| 03:17 | Magus- | |
| 03:17 | Magus- | plenty of people do :) |
| 03:18 | Magus- | and things are already written for it |
| 03:18 | irish | oh man, that makes my day |
| 03:18 | irish | why is my google fu so weak lately? |
| 03:22 | metvop | has anyone heard of the Django (v0.96) production server and Firefox being a slow combination on Windows? It's weird, I'm testing at simple project with IE7 and it loads pages nearly instantly while both FF3 and FF2.x take a second to connect to prod. server. |
| 03:25 | Magus- | there is no django production server |
| 03:26 | metvop | haha, woops.. just read that |
| 03:26 | metvop | meant development server, sorry |
| 04:12 | Kaell_ | any way to pass request context through to a filter? or otherwise gain access to it from within a filter? |
| 04:12 | Alex_Gaynor | No, only tags can get context |
| 04:14 | Kaell_ | so if i want to have my filters behavior depend on the logged in user, i'll have to do soemthing like pass the users name as a param? and then the filter can just look up that user?? |
| 04:14 | Alex_Gaynor | Sure, you can give filters arguments, so you could pass user to the filter |
| 04:19 | neanton | is 12 requests per second sounds good for devserver? |
| 04:20 | schmichael | neanton: i would think so |
| 04:20 | schmichael | "good" is pretty subjective though |
| 04:21 | schmichael | definitely "adequate" ;-) |
| 04:21 | neanton | i heared about ~500+ rquests in production |
| 04:21 | neanton | so this seems too slow for me ;) |
| 04:21 | Magus- | well you can't benchmark runserver... |
| 04:21 | Magus- | it's isngle threaded |
| 04:21 | Magus- | its for dev |
| 04:21 | Magus- | DO NOT worry about its performance |
| 04:21 | schmichael | what is 12/sec... 80ms? |
| 04:22 | neanton | schmichael, yes |
| 04:22 | neanton | Magus-, oh, if its not threaded, that i understand why is it so slow |
| 04:22 | Magus- | exactly |
| 04:23 | Magus- | so don't ever think that performance in runserver will translate to production |
| 04:23 | Magus- | benchmark later |
| 04:23 | neanton | ok |
| 04:31 | japheth | sorry to ask what must be such a noobish question, but how do I tell django/mod_python to ignore certain directories where I have PHP apps? |
| 04:31 | Magus- | using a <Location> block, same as for media |
| 04:31 | Magus- | probably different commands inside it though, for php |
| 04:32 | japheth | might've known you'd be here to answer, Magus- :) |
| 04:32 | japheth | thanks |
| 04:35 | daaku | is there a way to put newlines in a url regex for readability? |
| 04:36 | Magus- | daaku: probably not, unless you do something like 'part of it' + \ <newline> 'other part' |
| 04:36 | hylje | ('part' 'another part' \n 'yet another part') |
| 04:37 | Magus- | you can just do a newline for a string? O.o |
| 04:37 | daaku | indeed, implicit + |
| 04:39 | Alex_Gaynor | As long as it's in parens |
| 04:42 | Erik___ | anyone done anything with "nameless users" using contrib.auth? I'd like to create a user and log them in automatically when certain operations are undertaken, then they'd have the option of finishing the registration later. |
| 04:46 | jimmygoon | !paste |
| 04:47 | jimmygoon | http://dpaste.com/60935/ What silly thing am I missing here. I keep getting told that ContentItem does not contain 'p' or 'e'e |
| 04:47 | Qayos | inside of a filter i am running the input through a re.sub which sends each match to a function.... within that function, i'd like to track the number of calls made in a counter variable... any good way to do this? |
| 04:48 | jimmygoon | ugh, that trailing comma makes a difference??? |
| 04:49 | Magus- | ('foo') == string |
| 04:49 | Magus- | ('foo',) = tuple |
| 04:49 | jimmygoon | ooh, I bet its doing a for ... in ... and if it doesn't get a list it does each letter - which is why it was trying 'p' from 'pub_date' and 'e' from 'enable_comment' |
| 04:49 | Magus- | its because ('foo') is a string |
| 04:49 | Magus- | but still iterable |
| 04:50 | jimmygoon | Magus-: thanks :) |
| 04:52 | irish | http://dpaste.com/60936/ what's wrong with my __init__? |
| 04:53 | irish | do I need to change the size_x and size_y to the same as the original definitions? |
| 04:53 | irish | meaning x_dimension and y_dimension? |
| 04:54 | FatalError^ | your __init__ doesn't have a self parameter |
| 04:54 | ubernostrum | That's one problem. |
| 04:54 | ubernostrum | There's also the fact that there are a bunch of non-nullable fields there which aren't being set in your __init__ and which can't be passed into it at all. |
| 04:54 | irish | so just add that as one more parameter, or add it as self.size_x, etc? |
| 04:54 | ubernostrum | Which means that, e.g., the admin interface will never work. |
| 04:54 | ubernostrum | irish: perhaps you should try a Python tutorial ;) |
| 04:55 | Magus- | irish: its almost always a bad idea to touch __init__ on a model |
| 04:55 | irish | that makes sense |
| 04:55 | ubernostrum | (unless you're quite sure of what you're doing) |
| 04:56 | Magus- | hence 'almost always' :) |
| 04:56 | ubernostrum | (and even then, proceed with caution) |
| 04:56 | sterna | there's another way to do it afaik |
| 04:56 | irish | I'm definitely not quite sure |
| 04:56 | irish | heehee, I wouldn't be asking questions |
| 04:56 | Magus- | not to mention the fact that even if it was ok, your function wouldn't even do anything :) |
| 04:56 | irish | I'm definitely open to other ways |
| 04:56 | Magus- | you never save the new models |
| 04:56 | sterna | but i've been up for a few days and can't really tell anymore |
| 04:56 | ehc | I am going through ubernostrum's practical django projects and I have created a simple cms, search app, and templates. if I want to add an index view that lists all the pages in the database, what would be a good location to place it? create another app? |
| 04:56 | Magus- | ehc: why would you make an app for an index page? |
| 04:57 | Magus- | index sounds like it fits right in the cms app |
| 04:57 | ehc | Magus-, I am not sure where to place it ,that's my question |
| 04:57 | ubernostrum | Indeed. |
| 04:57 | Magus- | the logical place |
| 04:57 | Magus- | like the cms |
| 04:57 | Magus- | since its listing cms pages |
| 04:57 | Magus- | pretty clear fit there :) |
| 04:58 | ehc | Magus-, the book's cms is set up as a project with flatpages. so as a project it doesn't have a specific model and view, right? |
| 04:59 | ubernostrum | ehc: for now, put it in the same views file as the search function. |
| 04:59 | ubernostrum | ehc: later on when you learn about generic views (IIRC, Chapter 4) you'll see how you could do it without writing a view at all, just by adding to the project's root URL configuration. |
| 05:00 | ehc | ubernostrum, okay |
| 05:00 | Kamu | okay, so I have a table full of columns that are figures, and I want to create a view that will allow me to easily present a table by sorting through those fields |
| 05:01 | ehc | ubernostrum, thanks, that makes sense to use the root url conf. |
| 05:01 | Kamu | what would be the best way of doing this, rather than writing tons of if filtername == "population": blahblah etc etc |
| 05:03 | westymatt | I am using ModelForm and I keep getting "Attribute: 'str' object has no attribute '_default_manager' |
| 05:04 | westymatt | anyone know what this is regarding? |
| 05:04 | Magus- | sounds like you're using a string where it wants a model, somewhere |
| 05:04 | westymatt | the thing is that it is preventing the server from starting up |
| 05:04 | westymatt | no view code is running |
| 05:05 | westymatt | it errors as runserver starts |
| 05:08 | Magus- | so stop using a string where it wants a model |
| 05:27 | westymatt | weird i moved the ModelForm out of models.py into it's own forms.py and the problem went away |
| 05:27 | Magus- | were you defining the form above the model and quoting the name? |
| 05:27 | Magus- | that doesn't work for a form, only relations, if so |
| 05:37 | westymatt | i defined ModelForm just underneath the model and referencing it as an object |
| 06:22 | Kamu | can someone explain why this is so: 'list' object has no attribute 'order_by' | stats = get_list_or_404(CityStats, country=countryid, snapshot=period).order_by('city__name') |
| 06:22 | Magus- | because it's get_list_or_404 |
| 06:22 | Magus- | it does not return a queryset |
| 06:22 | Kamu | god dang it |
| 06:23 | Kamu | is there a get_queryset_or_404 |
| 06:23 | Kamu | or something that 404s if query set is empty? |
| 06:23 | Magus- | no |
| 06:23 | Qayos | http://dpaste.com/60946/ <--- the url for my form goes to "" instead of /django/wiki/MyArticleOne/graph/slugname/ any ideas? |
| 06:23 | Kamu | well that's err ... interesting |
| 06:24 | Magus- | Qayos: well you have no regex match in the graph_name param, of course |
| 06:24 | Qayos | graph_view_slug.html is manually inserted as the result of a template filter |
| 06:24 | Magus- | so it gets nothing |
| 06:24 | Magus- | nor can anything be put there |
| 06:24 | Magus- | you're also missing a $ after it |
| 06:25 | Qayos | derr |
| 06:25 | Qayos | thanks |
| 06:25 | Kamu | I thought it was said 'duh' |
| 06:26 | Magus- | Kamu: it would be very easy to write your own helper to get a qs or 404 though |
| 06:26 | Kamu | Magus-: which i am doing at the moment ;) |
| 06:27 | Kamu | seem weird that it is absent |
| 06:27 | Kamu | maybe because it would have to hit the database.. |
| 06:28 | Magus- | uh, it has to anyway |
| 06:28 | Magus- | its probably just an old bit of code that nobody's updated |
| 06:28 | Magus- | I'd file a ticket for it if there isn't one already |
| 06:29 | Kamu | but i mean in order for it to check if it is empty, it would have to hit the database |
| 06:29 | Kamu | rather than being able to chain the queries (?) |
| 06:29 | Kamu | I will search the tickets now |
| 06:30 | Kamu | I will not be able to offer a decent patch though |
| 06:31 | rozwell | |
| 06:31 | Kamu | rozwell: I have it open at the moment and staring at the same bit of code |
| 06:31 | rozwell | Kamu: remove the list() from line 59 and on line 60 replace with- if not obj_list.count(): |
| 06:32 | Kamu | genius |
| 06:32 | Magus- | Kamu: it has to hit the db to find out if its empty /no matter what/ |
| 06:32 | Magus- | you could do it with a count() instead of just 'if not' though |
| 06:33 | Kamu | if count()==0, surely? |
| 06:33 | Magus- | yes |
| 06:34 | Kamu | bingo! and she works! |
| 06:34 | Kamu | I don't suppose this is already a ticket? |
| 06:34 | Kamu | thanks Magus-, rozwell |
| 06:44 | Jeff_ | hi, all |
| 06:44 | Jeff_ | anyone install postgresql on OS x? |
| 06:45 | Jeff_ | I can't seem to get a working environmetn for Django up an running |
| 06:46 | Jeff_ | well, ok then... lol |
| 06:47 | Jeff_ | I'll try Django some other time, ASP.NET is imperfect, but it's easy to install |
| 06:47 | Alex_Gaynor | Can you even run ASP.NET on OSX :/ |
| 06:48 | Magus- | well that was an idiotic statement |
| 06:48 | hylje | you should say PHP is so much easier to set up instead |
| 06:48 | Magus- | (jeff's I mean) |
| 06:48 | Magus- | as if its django's fault he can't install postgres |
| 06:48 | Alex_Gaynor | regardless SQLite is better for development IMO |
| 06:50 | Qayos | if i want to extend a django app but keep things organized, so i want to make a graph_models.py, what is the best method to accomplish this? just toss an import graph_models.py at the start of models.py? |
| 06:50 | Magus- | no... |
| 06:50 | Magus- | importing a module won't magically put the classes in that module in scope :) |
| 06:51 | Qayos | from graph_models import * |
| 06:51 | Magus- | and models still have some finicky things that need set sometimes if you split models |
| 06:51 | Magus- | app_label in the Meta inner class may need set to the app name |
| 06:51 | Magus- | but that might only be if you make a models dir |
| 06:52 | Qayos | so its looking like i should just dump it all in the models.py? |
| 06:58 | Magus- | ...no |
| 06:58 | Magus- | that's not what I said at all |
| 07:04 | FunkyBob | Qayos: since it's your own extension, why do you feel the need to import it into the existing models file, anyway? |
| 07:05 | Qayos | it logically fits as a new sub-part of the existing app |
| 07:06 | Qayos | i'd like to just add a "graph_models.py" but it is not sounding like anyone here is certain what i'll need to avoid any problems with doing this, and i can find nothing in the docs i've searched |
| 07:06 | Magus- | I just told you |
| 07:06 | Magus- | the only possible issue is you might have to set app_label |
| 07:07 | Qayos | i didnt think you were sure that it was required, and that it was the only thing... you seemed to indicate a plural 'things' which may cause issues, so i was reluctant |
| 07:07 | Magus- | the other thing you already knew - importing them into the models module |
| 07:10 | Qayos | ok, thanks, i'll be much happier with this separation of files |
| 07:43 | omp | http://pastebin.ca/1063613 <-- How would I rewrite this to avoid creating a blank list and appending to it? |
| 07:45 | Alex_Gaynor | s = ", ".join(c.name for c in Company.objects.filter(users_username__contains=request.user)); if not s: s = "N/A" |
| 07:45 | omp | Alex_Gaynor: thank you |
| 07:46 | Alex_Gaynor | Obviously you'll want to format that in a more python way :P |
| 07:46 | omp | yes. :) |
| 07:47 | Qayos | i sometimes wish python supported brackets and semicolons |
| 07:48 | Alex_Gaynor | Oh god no, I can't stand writing JS for prolonged periods for time for just that reason |
| 07:49 | ubernostrum | Qayos: open a Python interpreter. |
| 07:49 | ubernostrum | Qayos: type |
| 07:49 | ubernostrum | from __future__ import braces |
| 07:49 | Alex_Gaynor | :) |
| 07:51 | ubernostrum | Or, you know, just use the block delimiter support. |
| 07:53 | ubernostrum | (which also works for arbitrary comment syntax) |
| 07:55 | Qayos | sometimes its useful, it presents a better organization or method of communicating intent |
| 07:55 | hylje | some people have used an braceful encoding |
| 07:55 | Qayos | sometimes a thing will easilly fit on one line if you have block delimiters and such.... |
| 07:55 | hylje | braces are good for mostly non-crippled lambdas |
| 07:56 | hylje | Qayos: yes, will fit, but is it clear? |
| 07:56 | Qayos | sometimes yes, sometimes no |
| 07:56 | ubernostrum | Gee, this is fun. |
| 07:56 | Qayos | when yes, and it is easier to communicate like that, i wish python supported it as an option |
| 07:56 | ubernostrum | Because, you know, nobody's ever had this discussion before in the entire history of the Python language. |
| 07:57 | ubernostrum | And I'm sure there will be lots of brand-new, never-before-heard arguments brought up. |
| 07:57 | hylje | the answer you seek is that mostly theres no use. python is abbout the culture, so discouraging bad practices is right on |
| 07:57 | ubernostrum | Python uses whitespace as a block delimiter. Always has, always will. |
| 07:58 | Alex_Gaynor likes it, the BDFL likes it, and I don't give a damn what anyone else thinkgs :P | |
| 07:58 | hylje | also that. dogma goes a long way |
| 07:58 | ubernostrum | Indeed. |
| 07:58 | ubernostrum | I don't care if somebody likes it or doesn't. |
| 07:59 | ubernostrum | But if you don't, don't waste my time complaining about it when you could just use another language. |
| 07:59 | Qayos | i wasnt expecting some sort of spanish inquisition.... just saying... sometimes i wish it supported it |
| 07:59 | hylje | nobody expects it, its okay |
| 07:59 | ubernostrum | And sometimes I wish Google would buy my blog out for a hundred million dollars. |
| 07:59 | hylje | hundred billion perhaps? |
| 08:00 | ubernostrum | You want to put your whole app on a single line of code? Go use Ruby. |
| 08:00 | hylje | or go all the way and use perl |
| 08:00 | Qayos | out many weapons include: "straw men, ...." |
| 08:00 | Qayos | *our |
| 08:00 | ubernostrum | Nah, Perl people actually tend to have style guides. |
| 08:00 | Kamu | hahaha! |
| 08:00 | hylje | doesnt discount the language ability |
| 08:00 | ubernostrum | Ruby people feel that such things would cramp their style. |
| 08:01 | Alex_Gaynor wonders if the perl interpretter is one giant regex | |
| 08:01 | ubernostrum | The Perl interpreter has scary fucking black magic in it. |
| 08:01 | hylje | elaborate please |
| 08:01 | ubernostrum | Some of it's useful black magic, but still. |
| 08:01 | ubernostrum | Of course, Python's got some of that too. |
| 08:01 | ubernostrum | Look at stuff like Python's sorting code ;) |
| 08:01 | hylje | type -> type |
| 08:02 | hylje | omg the circularity |
| 08:02 | ubernostrum | |
| 08:02 | ubernostrum | ^-- Tim makes sorting work so you don't have to. |
| 08:02 | hylje | tim makes batteries |
| 08:03 | Kamu | is there a 'profiler' app/middleware for django? where it shows the number of queries, time they took, what they were etc? |
| 08:03 | ubernostrum | http://www.djangosnippets.org/snippets/93/ <-- like this, you mean? |
| 08:03 | ubernostrum | There's more complex stuff out there too, but that one covers what you just asked for. |
| 08:04 | Kamu | ah yes, that is it, thanks |
| 08:04 | Kamu | I was just wondering if there was something you plugged in and it concatted it to every template etc |
| 08:04 | Kamu | but this will do nicely |
| 08:04 | ubernostrum | Well, you follow the instructions there. |
| 08:05 | ubernostrum | And you put that code in your base template that everything else extends. |
| 08:05 | ubernostrum | Et voila! |
| 08:05 | Kamu | looks like i have to shake up my code a bit seeing as I don't use RequestContext |
| 08:12 | amigo | "return render_to_response('main.html',{'site_title': 'simple unicode string'})" have error "Non-ASCII character '\xd0'" how to solute it? |
| 08:14 | FunkyBob | amigo: stop handing it non-ascii chars? |
| 08:14 | FunkyBob | is that a literal unicode string? |
| 08:14 | FunkyBob | if so, mark it as such... use u'' not just '' |
| 08:16 | amigo | FunkyBob, i'm sorry. return render_to_response('main.html',{'site_title': u'Привет'}) it's not work :( |
| 08:16 | Alex_Gaynor | What version of django are you using? |
| 08:16 | FunkyBob | amigo: can you pastebin the full error? |
| 08:17 | amigo | Django version 0.96.2 |
| 08:17 | FunkyBob | ah |
| 08:17 | amigo | need svn? |
| 08:17 | FunkyBob | svn is a lot cleaner when it comes to unicode |
| 08:18 | Alex_Gaynor | There is no formal support for Unicode in .96 |
| 08:18 | amigo | ok thanks, peoples |
| 08:20 | is_null | hello everybody, any idea how to useunordered parameters in the url? |
| 08:21 | tuirq | can i paginate the results of a custom sql query? |
| 08:22 | tuirq | i mean, does django provide a paginator for that |
| 08:23 | FunkyBob | tuirq: the paginator is somewhat abstracted... |
| 08:23 | FunkyBob | is_null: parse them yourself |
| 08:25 | tuirq | aw |
| 08:27 | tuirq | i could do this without custom sql if i could just use the "SELECT DISTINCT ON (field1, field2, .., fieldN)" feature of postgres |
| 08:28 | tuirq | then use the regular paginators |
| 08:29 | Kamu | oh dang my django skills suck |
| 08:30 | FunkyBob | tuirq: what is the query? |
| 08:30 | Kamu | my database is being hit with 14 queries (7 queries are duplicates of the other 7) |
| 08:30 | FunkyBob | Kamu: and? |
| 08:30 | Kamu | isn't that bad? |
| 08:30 | FunkyBob | depends |
| 08:30 | Kamu | |
| 08:31 | FunkyBob | Kamu: but what's _causing_ those queries? |
| 08:31 | pagenoare | 'Entries' object has no attribute 'get' |
| 08:31 | pagenoare | O_o |
| 08:31 | pagenoare | GetEntry = Entries.objects.get(id=id) |
| 08:31 | pagenoare | O_o |
| 08:32 | pagenoare | why it doesn't work? O-o |
| 08:32 | Kamu | FunkyBob: I am amafraid to show you my code for fair of mockery! |
| 08:32 | tuirq | FunkyBob: it's a complicated query that joins some table A to a table B of prefixes, using a "DISTINCT ON ()" clause to return the match in table B with the longest prefix |
| 08:32 | FunkyBob | Kamu: then how can we help? though my guess is a judiciously placed "select_related" will help |
| 08:33 | Kamu | FunkyBob: I was kidding, I updated the paste http://pastie.org/private/rchupp5bm6qrvzvisnaq |
| 08:33 | FunkyBob | tuirq: gah... with all this talk of prefixes and longest matches, I'm starting to feel like we're talking data compression :P |
| 08:33 | tuirq | FunkyBob: hehe |
| 08:34 | Kamu | the template displays pretty much all fields |
| 08:34 | tuirq | FunkyBob: like i said though, it could be done with the ORM if i could just insert that "DISTINCT ON ()" to the query |
| 08:34 | tuirq | then i could benefit from the pagination magic |
| 08:34 | FunkyBob | Kamu: why do you have so many sets when you only appear to care about a single value? |
| 08:35 | Kamu | at the time it seemed like a good idea to split those fields into 3 seperate tables |
| 08:35 | Kamu | different related stats.. |
| 08:36 | FunkyBob | hmm |
| 08:36 | FunkyBob | if you had a latest_FOO for each as a fkey, I think a select_related() would kill a lot of those extra queries... |
| 08:36 | FunkyBob | however |
| 08:37 | FunkyBob | a manager on each model would also help... one that returned only snapshot=latest records |
| 08:37 | Kamu | yes it would.. |
| 08:38 | Kamu | latest_FOO as a fkey? |