cos thats something I'll need to know about very soon
mattmcc
dmishe: Yeah, HttpResponseRedirect only supports http[s] and ftp.
jpadilla
Is there any way to detect if there was a 404 raised before running a Middleware?
dmishe
mattmcc thanks, I found the code for it, I can subclass and override that
jpadilla
I basicly want to halt a custom middleware if there was a 404 raised before it
like a URL was not found
kennethreitz joined the channel
briancray has quit
mattmcc
jpadilla: Assuming you're past process_view, you've got a response object that you can check the status code of.
__class__ joined the channel
thomasbartelmess joined the channel
jpadilla
mattmcc: I'm using process_request
let me try that
kvda has quit
mattmcc
Then you don't know if a 404 will result yet.
kvda joined the channel
chrisjones has quit
bwreilly has quit
jpadilla
mattmcc: is there anyway to check if request.path exists in urls.py?
andredieb joined the channel
mattmcc
It's not that simple, a view may raise a 404. You really can't predetermine the response type until the view's had a chance to run.
void
jpadilla: resolve() method
jpadilla: in django.core.urlresovers
urlwolf has quit
punkrawkR has quit
willie has quit
chrisstreeter joined the channel
TopRamen joined the channel
jroll|dupe joined the channel
jroll|dupe has quit
rvincent has quit
krassinger
i tried disabling the csrf middleware and it's still not working...
jroll|dupe joined the channel
hansy has quit
thomasbartelmess has quit
jroll has quit
F1skr has quit
void has quit
F1skr joined the channel
dmishe has quit
chrislkeller has quit
void joined the channel
ambar has quit
zatan has quit
neataroni has quit
merunner joined the channel
TopRamen has quit
CaptChaos joined the channel
CaptChaos
Hey everyone. I know that in Python builtin arrays are rarely used in favor of lists. What's the equivalent construct for instances of a Django model?
I searched the Django docs but could not seem to find this. Perhaps I was searching for the wrong thing?
arpegius has quit
FunkyBob
CaptChaos: perhaps you should explain what you want to use it for?
chutwig has quit
lists are a mutable, ordered sequence... tuples are immutable ordered sequences
CaptChaos: when you say 'array'... what sort of structure do you mean?
to me it's an ordered sequence of homogenous typed values... but in PHP land it's an ordered mapping
CaptChaos
I am reading in content from a CSV file that I want to store in a model I have created. I have the code technically working, but the overhead from constant writing the DB is causing a problem when I have ~100,000 records in a CSV. Instead, I want to store approximately 100-500 in memory (I would normally do this in a list) and then write the contents to the models in less frequent chunks.
FunkyBob
from my own experience...
I would use the csv.DictReader, pass its dicts into a ModelForm, and use a transaction to commit every few hundred records
RuslanPopov has quit
then you get nice, clean type conversion and validation... and models constructed for you...
kvda has quit
lambdaq joined the channel
kvda joined the channel
CaptChaos
thanks FunkyBob, I'll start looking into that. I wrote the code without thinking in advance and since I already have the parsing and saving done row by row I was looking for a lazy way to get it done. It's an intial setup step, not something that users will do frequently. My old C++ thinking had my going towards arrays but it's probably better the learn some more "Django-ish" ways of doing it. :)