Hey guys, how do I get the data from a json object in my view? request.POST['mylist'] doesnt work, and request.POST.get['mylist'] returns None. But when I print (item) for item in request.POST.items(), it gives me the list I want, but the values are off.
No, I'm passing the list through in the data field of the ajax POST
data: { 'mylist':mylist }
mylist is an array
flobin joined the channel
FunkyBob
if it showed in request.POST... then you are not doing that
not passing JSON that is
show me how you're passing the data
request.POST is only populated if one of the two form encoding formats is posted
haber joined the channel
zivester joined the channel
if you're just passing data to $.post or $.ajax... it won't use JSON, AFAIK
ubuntu_aze has quit
ubuntu_aze joined the channel
jfisk87 has quit
bochecha has quit
ycon_
Hi all, I'm wondering if this is a good way to setup my model. Basically the user will only ever have ONE of the following types at a time. http://dpaste.com/1SQ0JTT
flobin has quit
mehola has quit
greg_f joined the channel
so my model has a Text field (mainly for HTML), JSON field, and File field
pratyushprakash joined the channel
and there will only every be one on the model
flobin joined the channel
nkuttler
ycon_: seems kind of redundant to store the type, unless you need it for performance?
besides, you don't validate your requirements
gannetson joined the channel
flobin has quit
doubitchou joined the channel
flobin joined the channel
ycon_
nkuttler: i thought that might be better to filter the data via the API?
so I can just query via the integer- basically I only want the API returning the data of the field that applies
nkuttler
sure
gannetson has quit
ycon_
ok cool thanks.
doubitchou has quit
I'm also trying to return some data in the admin.py
(and you wouldn't usually capitalize method names in python)
ycon_
whats the callable itself?
nkuttler
list_display = (Test,)
pyface has quit
ycon_
nkuttler: hmm that returns (None)
nethop joined the channel
themediator
Is there a way to rerun all migrations from scratch?
I think I messed up some of mine
reisio
you can always backup your db and make a new one
orf_ joined the channel
themediator
reisio, that just gets rid of all the data entries I have made, right? Or users as well?
FunkyBob
themediator: you can run your migrations back to "zero" .. but that, too, will lose all your data
themediator
I'm fine with losing my data
reisio
themediator: everything, in the db
themediator
It's all just test data right now
FunkyBob
python manage.py migrate zero
reisio
I figured
FunkyBob
but dropping the db is probably quicker
reisio
non-interpreted? :p
themediator
says app "zero" does not have migrations
is there more to that command?
Or just instruct me on how to drop the DB
reisio
are you using sqlite?
(the default, basically)
themediator
i guess so
reisio
there's probably a file with a name like 'db.sqlite3' at the top of your project hierarchy
mv it elsewhere
adsworth joined the channel
themediator
Okay. Do I need to do anything else?
reisio
nope
you're back to zero
migrate away
ubuntu_aze1 joined the channel
themediator
well that didn't fix my issue
reisio
cool
what's the issue?
themediator
I think I need to try to zero my migrations instead
reisio
I don't think that will help if mv'ing the db didn't
:D
themediator
ValueError: invalid literal for int() with base 10: 'milk'
reisio
sounds like a good old fashioned python error
themediator
This comes from me deleting a foreignkey value, forgetting about it, running migrations a few times over time, and then eventually it popping up telling me it needs a value, so I just put in the string 'milk'
reisio
heh
themediator
Now, something is looking for that value that I put in
ubuntu_aze has quit
ubuntu_aze1 is now known as ubuntu_aze
slav0nic joined the channel
and I don't know whyu
I thought it just wrote it into the migrations
reisio
yeah, well, just fix it
themediator
-.-
reisio
why would you be converting the string 'milk' to an int :p
orf_ has quit
themediator
It's not me. It's all on django end
flobin has quit
I'm just running migration
reisio
sure... but initially it's definitely your code
where's the 'milk' occur?
themediator
there is no 'milk' in my code
It's what I input when prompted while running migrations earler
it told me it needed a value for it or something
I figured it would be okay with anything, because I deleted it
reisio
okay find the int then
themediator
I thought that int was a model object instance
I deleted the db, but not all references to it, apparently