#django

July 2nd, 2009

22:34 rozwell
benc1: then apply login_required to all of them, or write a middleware
22:34 benc1
rozwell: how do I apply @login_required to all of them?
22:35 rozwell
benc1: you put that in front of each view function definition
22:35 benc1
rozwell: so here it will only affect my_view ? http://dpaste.com/62680/
22:35 rozwell
benc1: yes
22:35 benc1
rozwell: thanks
22:42 Zitter
sorry, what can I do if I haven't /media/ dir. I've entered in admin cpanel but it is not styled
22:47 juanefren
When I attempt to access any url I get this error :
22:47 juanefren
Caught an exception while rendering: bad marshal data
22:47 juanefren
What could It be ? (I'm not sure what it means)
22:59 multigl
I'm trying to deploy new django project as a fastcgi module and I've never seen this error before trying to start the server (I have 13 other projects deployed in exactly the same fashion)
22:59 multigl
23:15 brett
I'm running a custom update query in my model object. However, when I self.save() the value gets overwritten with what's on self already
23:15 brett
E.g. I'm doing "update bar set val1=2"
23:15 brett
self.val1 is 3
23:16 brett
doing a self.save() results in 3 being written to the database
23:16 brett
Is there some way I can tell my model object to refresh itself? Or not to update self.val1 in the db?
23:16 aonweb
brett use commit=false during save
23:17 aonweb
that will update the object in mem but not in db
23:17 brett
ahh then the next save() will write everything correctly?
23:17 brett
Does the orm just update columns that have changed? Or everything in a row?
23:21 aonweb
§check it out , i am not sure. but i think whole table use django-debug-toolbar to see which queries get exec'd or use shell
23:23 benc1
when I delete a class from models.py of my app I get "cannot import name ClassName"
23:23 benc1
something related to __init__.py in autodiscover line 40
23:23 benc1
How can I fix it?
23:25 pm2
I want to be able to upload files with a size of several hundred MB to my django app. Is this possible using django's development server?
23:26 rozwell
pm2: yes
23:26 rozwell
pm2: serving them is a different story
23:26 pm2
rozwell: Yeah - I serve them from an apache server, I'm just having some trouble uploading files of that size
23:28 aonweb
@brett, i meant whole row..
23:29 benc1
anyone familiar with "cannot import name ClassName" in /pinax-env/lib/python2.6/site-packages/Django-1.0.2_final-py2.6.egg/django/contrib/admin/__init__.py in autodiscover, line 40 ?
23:29 benc1
I have a ClassName in my models.py. I don't need it any more but when I remove it I get the error
23:32 vIkSiT
hi all
23:33 vIkSiT
I'm facing an error rendering a template with some non ascii characters
23:34 vIkSiT
23:34 vIkSiT
#
23:34 vIkSiT
Caught an exception while rendering: 'ascii' codec can't encode character u'\xe9' in position 7: ordinal not in range(128)
23:34 vIkSiT
has anyone faced this before/know how to resolve it?
23:43 pm2
rozwell: it looks like the file uploads OK, but the server hangs before the request is completed, so the client doesn't know that it was successful
23:43 SmileyChris
vIkSiT: fix your template tag to use unicode instead of str
23:44 vIkSiT
oh damn
23:44 vIkSiT
somehow I completely missed that part of the stack trace!
23:45 vIkSiT
thanks SmileyChris :)
23:47 superdmp
I have pasted a very short and simple inclusion tag at http://dpaste.com/62697/
23:47 Jeromy_
Does anyone know if mysql works under jython+django?
23:47 superdmp
is anyone able to explain how it might return empty data as 'node'?
23:48 benc1
I want to look at django_session instance in the shell. How do I import it?
23:48 superdmp
I would not expect it to return anything empty under any circumstances
23:49 SmileyChris
superdmp: shouldn't it be changed to always return a dict?
23:49 SmileyChris
benc1: from django.contrib.session.models import Session
23:49 superdmp
I am not sure what you mean SmileyChris
23:50 superdmp
sometimes I don't want it to return anything
23:50 chrishartim
is it possible to specify templates in in urls.py without actually writing views?
23:50 SmileyChris
superdmp: it's an inclusion tag - it always renders the template afaik
23:50 SmileyChris
chrishartim: you can use the generic views
23:50 superdmp
oh, so even if there's nothing to return it will return... nothing!
23:51 superdmp
that's what must be happening
23:51 chrishartim
SmileyChris: thanks
23:51 benc1
SmileyChris: ImportError: No module named session.models
23:51 SmileyChris
benc1: sessions, sorry
23:52 multigl
is anyone familiar with hachoir? when I import anything from any of the hachoir libraries I can't start manage.py runfcgi
23:52 SmileyChris
benc1: then you'll want to run the get_decoded() method of the instance
23:53 superdmp
SmileyChris: I worked around it by doing a check {{ if data }} in the template
23:53 superdmp
thanks for your help
23:55 benc1
SmileyChris: what is get_decoded() ?
23:55 SmileyChris
benc1: it unpickles the session dictionary
23:56 Jeromy_
getting "Error loading MySQLdb module: No module named MySQLdb" when trying to use django with jython, I guess mysql is not an option w/ jython
23:57 benc1
SmileyChris: does get_decoded() for every model or just Session?
23:57 SmileyChris
benc1: just session - it's a model method
23:58 jim___
Can someone spare some time to help me with using forms.MultipleChoiceField with widget forms.CheckboxSelectMultiple
23:59 benc1
SmileyChris: how can I see all the attributes of a model instance without knowing what they are?
23:59 benc1
SmileyChris: is it possible?

July 3rd, 2009

00:10 jim___
I'm running mysql database and when I try to save a form which has a field impact = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=impact_choices) I an error because the sql is incorrect, it seems that the multiplechoice field is being stored as an array which is isn't valid sql. Can anyone help?
00:13 fynn
Yo.
00:13 fynn
We're developing a Django site, and have an open feature request to implement tracking for all logged in users, for all pages.
00:13 fynn
I.e., we need to be able the reproduce the navigation sequences of each individual logged in user: "user Foo started at the main menu at 11:00, proceeded to /bar at 11:01, then to /baz at 11:12"
00:13 fynn
What's a good way to approach this on Django?
00:14 fynn
Best of all if there's any exiting text describing such implementation, as many developers must have done it already.
00:14 drhodes
log parsing won't cut it?
00:14 fynn
drhodes: from what I've seen of our (ngnix) logs, they can't distinguish logged in users.
00:14 drhodes
I guess not
00:15 SmileyChris
benc1: instance._meta.fields
00:16 drhodes
fynn: well there is a logging module, and there is a @require_authentication decorator, maybe do a mash up of those.
00:17 benc1
SmileyChris: thanks
00:20 fynn
drhodes: you mean Python's logging module?
00:21 drhodes
fynn: yeah, I don't know of a django specific solution.
00:21 drhodes
that certainly doesn't mean there isn't one though! :)
00:22 FunkyBob
I've seen various people attach the logging problem
00:22 fynn
drhodes: right, which is why I was asking :)
00:22 FunkyBob
Pythons built in logging module is very flexible
00:22 fynn
FunkyBob: links to their blogs?
00:22 FunkyBob
pfft
00:22 FunkyBob
I've seen people _in here_ approach it
00:23 fynn
yeah, I'm versed in the logging module, looking for a more complete solution.
00:23 drhodes
fynn: there might be something here: http://www.djangosnippets.org/
00:23 fynn
just logging stuff is fine, but then you need to actually store and display that information.
00:23 fynn
drhodes: thanks.
00:23 fynn
anyone try this btw?:
00:23 fynn
00:33 benc1
why does django pickle and use md5 on the session string instead of just create a random string?