I can't see in those docs where it references a view called 404
HWJohn[TFE]
wtf, I don't remember choosing dev docs
FunkyBob
you are telling Django to use the function '404' in the views module in the Project module.
the docs shows : handler404 = 'mysite.views.my_custom_404_view'
xastey joined the channel
xastey
what is the correct way to hash and ImageField file.. such that if its updated later that it will use the previous created filename for saving?
FunkyBob
xastey: well, you could calculate the hash of it using somethign from the hash module...
xastey
sorry I ment is there an param I need to set or method to override that I could apply that logic to
FunkyBob
storage backend, probably
you want to include the hash in the filename?
xastey
yeah
sgo11
HWJohn[TFE], first, handler404 has to be defined in your root URLConfs if you want to use your custom 404 view. secondly, your DEBUG has to be false to use the view. third, why don't you just create 404.html template instead of using your custom 404 handler?
justinlilly joined the channel
xastey
say I upload foo.jpg.. I wan it to be hash to sha(timestamp+something else)
and later on use that same hash if that image is updated
in the second upload they would upload bar.jpg
mattmcc
You can specify the storage backend on a per-FileField basis. So you can switch from the default 'append integer' behavior to 'overwrite'
xastey
reason being is that I want to preserve the urls for already posted links to the image
ok.. let me check out the storage classes then
thanks a lot.. didn't know were I should make the change
I don't seem to understand why the error output for syncdb is telling me to add a "related_name" arguement to fix a Model_set issue
tensory joined the channel
how does related_name possible fix these types of clashes
*possibly
Or even worse, why would a clash exist
robertjpayne has quit
mattmcc
It's not a type clash it's a name clash.
When you use an M2M or FK, it creates a reverse relationship. By default, the name of that reverse manager is '<model>_set'. Well, more than one of those from a model of the same name means the names clash.
h6sidhu
<model> refers to the parent table correct?
mattmcc
Well, the other table. Whether or not it's a 'parent' is up to your schema's semantics.
atula joined the channel
tensory has left the channel
h6sidhu
I'm confused by the term "reverse relationship" that I keep hearing all the time. My understanding of this definition is Table B has a FK to Table A. Reverse Relationship is Table B-> Table A ?
FK or M2M
oisa
FunkyBob: Sorry, yes, I ended up writing something manually and doing get_or_create(**dict)... the NULLs in my CSVs from MySQL were causing errors I suppose, and I could set them to None this way
FunkyBob
so... were you not calling is_valid() on the forms before?
and a custom clean method could handle the NONE = None
sgo11
hi, I am just wondering if it's common to use ajax library directly in template eg: put <script src="js/jquery.js"></script> inside the template and use js directly instead of using other app like django-dajax ? Do people do this? thanks.
mattmcc
h6sidhu: Yeah, it's how you find out what models refer back to your model.
oisa
Oh! I was calling is_valid, but I got a generic error message and gave up. I didn't know you could write a custom clean method.
mattmcc
h6sidhu: So if Post FKs to Blog, you use the reverse manager to find out, given a blog instance, what posts it has.
FunkyBob
oisa: it's worth looking into.. "customising validation" in forms docs
h6sidhu
Blog.entry_set.
oisa
FunkyBob: thanks
h6sidhu
In my Model, I have Table B which has two FK's to Table A. Why would TableA.tableB_set have a clash? I know there are two columns with the same FK but couldn't it just concatenate the tableB_set query?
cewing joined the channel
mattmcc
h6sidhu: Then it'd be misrepresenting the relationships.
h6sidhu: If you're following a relationship between two models in this situation, you usually want to know which FK they're related by.
Not merely that they're related 'somehow'
xastey
is there a way to get the previous value of a model field before save besides quering the db?
fireh has quit
macabre has quit
FunkyBob
xastey: I believe it's added in 1.5
or something like that
xastey
doh.. guess time to overwrite the the save function :/
mintos joined the channel
jj0hns0n joined the channel
jj0hns0n has quit
lalit joined the channel
tmitchell has quit
mritz joined the channel
kvda joined the channel
FunkyBob
time to look at GFK vs. prefetch-related
Ronald_Reagan joined the channel
ezl joined the channel
mindlogger has quit
sgo11
sorry if my previous question does not make sense. retry my question. By googling, I know there are django apps such as dajax, which will let people use python code for ajax. but is that common not to use app and simply put <script src="/static/js/jquery.js"></script> to template and use <script> $(function()...</script> directly in template? Do people use this direct way? thanks.
FunkyBob
"use python code for ajax"?
Django can handle requets made using XHR (most common AJAX method)
but the AJAX is still initiated by JavaScript
gabrielo has quit
sgo11
FunkyBob, sorry, if that does not make sense. I saw some example of dajax, simply do dajax.alert("Hello World!") in views. I am just wondering if it's OK to use ajax directly in template html file just like normal html file? thanks.
FunkyBob
sgo11: careful not to confuse yourself about what happens where
sure, you can put javascript that makes AJAX calls in your templates... but it's not until it is processed by the browser that it "runs"
don't think about it running in your templates... it doesn't, and thinking like that will mess you up in time
wuwoot has quit
mritz has quit
I don't know what dajax does... but it if makes the split between server and client sides less clear, it's BAD
mritz joined the channel
gabrielo joined the channel
gbel has quit
sgo11
FunkyBob, sorry that I am bit confused. what if I want to use jquery directly without learning another app or another API, are there any tutorials that I can follow? so far, I simply treat the template html as a normal html and insert jquery code directly to the template. thanks.
telex has quit
ezl has quit
wenzhixue has quit
FunkyBob
sgo11: I don't understand why you think putting javascript in the template would be anything special.
sgo11: if it's not {{ }} or {% %} or {# #} .. the template language ignores it
sgo11
FunkyBob, I don't think that is special. that's why I put it directly to the template. my original question is basically asking whether this is fine (a normal process that people do) or not. does this make sense? thanks.
FunkyBob
yes, it's fine
the question really has nothign to do with Django
the reasons for and against it are common to all web sites
sgo11
FunkyBob, ok. got it. thanks. sorry if my words make you confuse.
FunkyBob
more that I'm worried you are confused.
FunkyBob goes back to playing with prefetch_related
telex joined the channel
Or1on has quit
this is painful... displaying 24 products can result in 3420 DB hits
but once the caches are warm, it's down to 108
mattmcc
Moar caching!
FunkyBob
more prefetch_relatd :)
but, yeah... most of it's discounts...
no idea if it works with InheritanceManager though :/
bennylope has quit
anybody joined the channel
really wish i'd moved that over to Polymorphic...
robertjpayne joined the channel
robertjpayne
Can you alter DEFAULT_DB_ALIAS at runtime or is database routing really the way to go?
FunkyBob
what are you hoping to achieve?
robertjpayne
FunkyBob syncdb seems to ignore the --database flag when a lot of the default apps go to populate default values. I'm trying to force a bit of obedience into it
mattmcc
That's really what routers are there for.
phildini joined the channel
robertjpayne
mattmcc: yeah figured as much just wasn't sure if there was a -easier- way.. trying to find root reason in django to submit a patch too
Mohsen_Hassani joined the channel
Guddu__ is now known as Guddu
atula has quit
phildini has quit
ambar has quit
anybody has left the channel
jonathanchu has quit
RaNa joined the channel
RaNa has left the channel
Mohsen_Hassani
The saved datetime is displayed correctly ONLY in Django admin as configured in settings.py. But in the shell or in Python codes like view it's retrieved as UTC.