#django

Sept. 3rd, 2010

03:24 davidcramer
e.g. no foreign keys
03:25 davidcramer
and in mysql :P
03:26 irc2samus
I knew InnoDB had support for FKs but don't remember if they have cascade options but I guess they're to be expected
03:27 irc2samus
in any case having an ORM that encourages you to write raw sql is really sad, but anyway I'll see what are my options
03:27 irc2samus
thanks guys!
03:37 cronosa
Anyone know how to deal with uploaded csv files that are utf-16 encoded? (like google contacts)
03:38 cronosa
I got it to work (finally) by running the chunk through smart_unicode, doing unicodedata.normalize('NFKD', uline).encode('utf-8','ignore') and then writing that to a temp file... but that is a crazy hack
03:39 cronosa
I just wonder how much my speed will suffer from making a tempfile (disc reading/writing )
03:45 davidcramer
cronosa: StringIO?
03:51 TankC
Hey all
03:51 TankC
I'm getting a "NotImplementedError" when attempting to use {{some_date|date:"B"}}, even though {{some_date|date:"b"}} works just fine. any thoughts?
03:52 cronosa
davidcramer: Yea, don't know why I didn't think of that... way better than a tempfile...
03:53 davidcramer
TankC: B must not be implemented
03:53 FunkyBob
TankC: wait... you're wondering why you get a "NotImplemented" error using B.. when the docs say it's Not Implemented ?
03:53 FunkyBob
03:54 TankC
Ah, didn't see that, I was looking at the date filter
03:54 TankC
thanks FunkyBob
03:58 eppa
hey all, if I have a local UploadedFile created by a custom upload handler, how can I save that to a FileField.FieldFile instance without a) reading the whole UploadedFile into RAM, or b) reading the file at all? Files are big
04:01 eppa
I think I could probably iterate over chunks of the UploadedFile and write them to the FieldFile, but it occurs to me there might be a less IO intensive way to achieve the same result
04:03 dobreira
Any idea why this: http://dpaste.com/238191/ returns a very cryptic 'Unhandled Exception' page?
04:03 dobreira
When I try to access /hub
04:04 irc2samus
dobreira: can't see much in that snippet, is it real code? in any case you're not returning from the view
04:04 irc2samus
also why throw back the request? and you sure it is str()able?
04:04 irc2samus
also, add ^ to hub/ on the patterns
04:05 jtiai
dobreira: Err... Your url patterns are pretty weird.
04:05 jtiai
dobreira: include means that you're including subset of urlpatterns from "dafk.hub.views.dispatcher" module.
04:05 dobreira
Probably - I think I got the error, it's telling me 'dispatcher' is not a valid module (ImportError)
04:05 irc2samus
oh good catch, you're include()ing the view itself xD
04:05 dobreira
so I should remove the include?
04:05 dobreira
ohh
04:05 dobreira
that makes sense
04:05 dobreira
:|
04:05 dobreira
Thanks guys.
04:06 dobreira
Also, is it correct to do: sitename.appname...
04:06 dobreira
or is it just appname. ...
04:06 jtiai
dobreira: That's totally up to you do you want to use in-project or out-of-project apps.
04:06 irc2samus
depends on your pythonpath, I prefer sitename.appname
04:07 jtiai
Basically if you're trying to make pluggable apps (which is more like a myth) it's more natural to use appname.something stuff.
04:07 dobreira
Ah, makes sense.
04:07 dobreira
Got it working great, thanks once again
04:07 jtiai
if it's tightly coupled project with project specific stuff it can be prefixed with a project.
04:08 jtiai
dobreira: And HttpResponse takes a string as a first parameter...
04:09 jtiai
(or iterator returning strings)
04:15 eppa
OK, I found the docs to help me :)
04:21 dstufft
anyone know offhand what version of oauth django-piston uses?
04:26 Bahman
Hi all!
04:54 mammique
Hi, is it possible to make a Template() loaded from a string (not a file) inherit another Template() loaded from a string in order to use {% block %} tags?
05:02 FunkyBob
mmalone: of course
05:02 FunkyBob
mmalone: in the end, they're all templates made from strings
05:02 FunkyBob
mammique: even
05:03 mammique
FunkyBob, yes, it sounds obivous to me as well at first, but i can't make it.
05:05 FunkyBob
oh, wait.... I re-read your question
05:05 mammique
like a template string with "{% block main %}hello you{% endblock main %}" that inherits another template string like: {% block main %}hello world{% endblock main %}"
05:05 FunkyBob
you can make a template loaded from a string extend one from a file...
05:05 FunkyBob
but it can't extend another from-string one...
05:05 mammique
Yes, I know ahow to do that.
05:05 FunkyBob
because extend will call get_template()
05:06 mammique
Yes :-/
05:06 mammique
So there is no solution ? At a lower level?
05:06 FunkyBob
is there a particular reason you're trying to do this?
05:06 FunkyBob
you could play games with a custom template loader... but ... well
05:07 mammique
FunkyBob, yes, one template is very dynamic (simple string that changes often), and the other one is loaded from DB (for conveingance)
05:07 mammique
So none are from filesystem.
05:08 jtiai
mammique: You can load templates from db through template loader...
05:08 jtiai
mammique: That's how I do it in my system.
05:09 jtiai
though, wonder where this "often changing template fragment" is coming from...
05:09 mammique
FunkyBob, it is not possible to insert a compiled template in the inheritance hierarchy of another one before rendering ?
05:09 mammique
jtiai, ha, you made a custom loader?
05:09 jtiai
mammique: Surely. For simple db based "static" templates is not a big trick. I can provide code if you want to.
05:10 millertime
gah i dont know why but setting my favicon and a page background are proving very challenging with cherokee
05:11 mammique
jtiai, I'd like to take a look yes if you can :-)
05:12 FunkyBob
anyone know how I verify in a clean() method that a filefield was given a value?
05:12 mmalone
you can write your own template loader
05:12 mmalone
it isn't that bad
05:13 FunkyBob
mammique: what's your use case for this?
05:13 jtiai
mammique: http://dpaste.com/238209/ almost all you need.
05:13 mmalone
05:16 jtiai
mammique: But likr FunkyBob asked, what's your particular usecase..?
05:16 mmalone
05:16 mmalone
add it to your TEMPLATE_LOADERS in settings.py
05:16 mmalone
and, tada!
05:16 lawgon
FunkyBob: that is a tough question!
05:17 FunkyBob
lawgon: from what I see in the code, it should be just as all other fields
05:17 FunkyBob
lawgon: and looking at firebug, it looks, in fact, like my page is only sending one file
05:18 FunkyBob
lawgon: ok, that time it did... fark!
05:19 DigitalKiwi
HI FunkyBob and lawgon
05:19 lawgon
as long as cleaned_data holds the information, it should be the same
05:20 lawgon
(never had occasion to check whether cleaned_data also covers request.FILES
05:29 john2x
hi
05:33 FunkyBob
hi
05:43 mammique
great ! thanks FunkyBob, jtiai, mmalone
05:44 mmalone
fo sho
05:52 FunkyBob
lawgon: so, the problem turned out to be some obscure modelform inheritance issues
05:52 john2x
how do I write the url config for browsing categories like 'browse/category1/category2/etc'?
05:55 FunkyBob
don't
05:55 FunkyBob
either pass your category filter values as GET params... or write your own URL splitter/parser
05:56 FunkyBob
r'^browse/(?P<category>.*)$' categories = filter(None, category.split('/') )
05:57 john2x
FunkyBob: thanks again!
05:58 FunkyBob
john2x: but really... don't do that :)
05:58 john2x
oh.. so I should just go with GET?