#django
July 31st, 2010
| 22:16 | lux` | so do you know or not which one is faster apollo13 |
| 22:16 | lux` | yes or nop? |
| 22:16 | apollo13 | if no I would throw a compiler at it |
| 22:17 | apollo13 | well depends on how many objects you are looping over |
| 22:17 | lux` | 2k |
| 22:17 | apollo13 | how many times are you looping through it? |
| 22:18 | apollo13 | cause the iterator will only work once iirc |
| 22:18 | lux` | ...ofc |
| 22:18 | lux` | just asked which one if faster apollo13 ! |
| 22:19 | apollo13 | well that depends, if you want to use it more than once, some of the choices aren't an option |
| 22:19 | apollo13 | so what do you expect… |
| 22:19 | lux` | I just asked which one is faster not a lesson about iterators list and whateva apollo13 |
| 22:19 | vreon | ... |
| 22:19 | apollo13 | … |
| 22:19 | lux` | seriously I'm happy you trying to help me but it looks like you're trolling me really |
| 22:20 | lux` | I just asked one thing and this discussion is already long 30lines~ |
| 22:20 | apollo13 | it looks like you are trolling |
| 22:20 | lux` | I just asked which implementation is faster not which one I should use |
| 22:20 | apollo13 | well that depends on how many times you want to use that fucking queryset during one view, and now stop trolling |
| 22:21 | lux` | ONCE... if I gave myself that option there is some reason |
| 22:21 | apollo13 | well for once, iterator might perfom best |
| 22:21 | lux` | okay thx, finally :P |
| 22:22 | apollo13 | or the other one without list |
| 22:22 | apollo13 | I would profile that if I were you |
| 22:22 | lux` | okay |
| 22:22 | apollo13 | but I doubt that is your botteneck |
| 22:22 | lux` | don't they both give an iterator? |
| 22:22 | lux` | well I'm just optimizing everything I can apollo13 |
| 22:22 | apollo13 | |
| 22:22 | lux` | there is no big probem with the site, got over 60k pageviews per day and the site is still fast even being on a celeron server |
| 22:23 | apollo13 | well then I would refrain from such changes |
| 22:24 | apollo13 | optimise where needed, not were you think it might cause problems someday |
| 22:25 | JordiGH | Is there a way to break up long lines inside a {% %} block in a template? |
| 22:25 | seanc | how do you test a model method to see if it's empty or not? trying to write a merge function and want to see if my src object has a method or is still empty |
| 22:26 | apollo13 | seanc: ?! you are sure you are talking about methods and not attributes? |
| 22:26 | seanc | apollo13: err.. yeah, attribute. foo = models.CharField(...) |
| 22:27 | apollo13 | well the easiest is to check if the pk is None |
| 22:27 | seanc | apollo13: it's actually for a ForeignKey attribute on a new object... what's the default value |
| 22:27 | apollo13 | None I'd assume |
| 22:27 | seanc | apollo13: but I want to do it on a per-attribute basis... drat, I'm testing None but that's clearly not right |
| 22:28 | lux` | looks like it would be faster w/o iterator() |
| 22:28 | lux` | because the query would get cached |
| 22:28 | lux` | am I right? |
| 22:28 | seanc | if src.foo is not None results in something... was hoping that it was a simple method call for the attribute |
| 22:28 | JordiGH | Man, the problem is that asking google "django linebreaks between {% %}" won't work. |
| 22:28 | apollo13 | lux`: yes, but why would you wan't the query to get cached if you'd only use it ONCE (see the point in my questions now?) |
| 22:29 | vreon | JordiGH: Found a stackoverflow response that says Django's template syntax has no concept of escape characters |
| 22:29 | apollo13 | seanc: none that I am aware of, cause fields can give you pretty much everything they want |
| 22:29 | JordiGH | vreon: Hm, link? |
| 22:29 | lux` | I already cache it for 1hour with memcached, the result but it might be unchanged for more than 1hour apollo13 |
| 22:29 | lux` | also I meant it's used once in the view |
| 22:29 | vreon | |
| 22:30 | vreon | It talks about {{ and such, but I'd think you'd need a way to escape the line breaks |
| 22:30 | apollo13 | lux`: just make sure to cache the results and not the qs itself ;) |
| 22:31 | JordiGH | vreon: Hmm.... |
| 22:31 | JordiGH | I guess I can live without linebreak in one verbose {% %} block. |
| 22:31 | apollo13 | and well if it's unchanged for a longtime I would set memcached to infinity (kinda) and manually clear memcache if your data changes |
| 22:35 | seanc | wow... nested try blocks are the only way to go. Kinda makes merging objects of the same type a bit of a PITA. Ah well. |
| 22:37 | entp | what is better practice, making separate apps for login / registration / profile edit .. or bundle them together into one user management app? |
| 22:38 | vreon | I'm using django auth's login and django-registration, so mine are separate |
| 22:38 | marcosmoyano | separate |
| 22:40 | entp | cool thanks |
| 22:56 | fink_ | anybody having trouble building the 1.2.1 docs with sphinx 1.0.1? |
| 23:04 | wahnfrieden | hi |
| 23:05 | wahnfrieden | whats a good way to separate GET/POST/PUT/DELETE view functions for one URL? use a class with a dispatcher, or some decorator system? |
| 23:09 | savid | Does anyone know why setting DATETIME_FORMAT in settings.py won't update the format shown in the change list? |
| 23:14 | awilcox | um |
| 23:14 | awilcox | I just wanted to let you know that your site is down |
| 23:14 | awilcox | when I go to http://docs.djangoproject.org/ I get "<h1>404 - Not Found</h1> Not Found (no configured vhost)" |
| 23:15 | ericholscher | |
| 23:15 | marcosmoyano | awilcox: s/org/com/ |
| 23:15 | vreon | .com |
| 23:15 | awilcox | ...oh. |
| 23:16 | savid | It seems impossible in django to change the format of date fields shown in the change list (without resorting to a callable, which would kill sort functionality). |
| 23:16 | awilcox | thanke you ericholscher, marcosmoyano, and vreon. |
| 23:16 | awilcox | it works now >.> |
| 23:22 | savid | Ugh. The dates in my admin look like this: "2010-07-31 14:33:39.814855". Looks like poo. Django docs say the default is "N j, Y, P", which apparently it's not following. Any ideas? |
| 23:25 | marcosmoyano | savid: there's a reference to USE_L10N in there. Have you tried that already ? |
| 23:25 | savid | marcosmoyano, yeah, I've set it to False |
| 23:33 | savid | What's odd is they said they fixed it here: http://code.djangoproject.com/ticket/2203 |
| 23:53 | FunkyBob | apart from the milliseconds.. what's wrong with that date format? |
| 23:54 | savid | FunkyBob, um nothing. The seconds & milliseconds is what I don't like -- makes it more difficult to read, more cluttered. |
| 23:56 | fink_ | savid: chop off the end with a template tag? |
| 23:56 | savid | fink_, no, can't use a templatetag for the change list -- unless I want to override a ton of code |
| 23:57 | fink_ | :( |
| 23:57 | savid | At any rate, I think I've found the issue. It seems like there's still a bug in django, and I'm filing a ticket now. |
| 23:57 | savid | ... and a patch :-P |
Aug. 1st, 2010
| 00:03 | FunkyBob | savid: how are you formatting it? by what mechanism? |
| 00:03 | FunkyBob | because if all you've done is str(datetimevalue) you'll get it in ISO format... it's how Python datetimes work |
| 00:04 | savid | FunkyBob, The documentation says I can use DATETIME_FORMAT to set the format for anywhere datetimes are used in the admin. |
| 00:04 | FunkyBob | in admin.. ok [hadn't read back far enough to see that] |
| 00:04 | savid | yeah, this is in the change list. |
| 00:04 | savid | (and elsewhere) |
| 00:09 | FunkyBob | wait... are you using date/time format strings as from the date tag? |
| 00:09 | FunkyBob | or real Python ones? |
| 00:10 | FunkyBob | eep... looks like they use their 'now' format |
| 00:10 | mynnx | hey, I need to store a list of (float, float) pairs to define the boundaries of a polygon. what would be the best way to store them in my model? |
| 00:11 | mynnx | (order matters, otherwise I'd just use a foreign key) |
| 00:13 | FunkyBob | mynnx: considered the GIS extensions? I hear they have coordinate fields |
| 00:13 | dwsBeta2 | mynnx: store the bounding box in fields, and store serialized blob of the polygon points? |