things are ok.. I'm the only one in the office, and am writing extensive and pdenatic tests for a revised API using nap
limbera
i end up with raw strings in my HTML src
instead of <label> tags
is that normal ?
FunkyBob
limbera: how are you rendering it?
limbera
{{ field.label }}
cilkay
Tests... who needs 'em? :)
VinceZa has quit
SoftwareMaven has quit
FunkyBob
cilkay: this client... badly
limbera
in a {% for fields in form %}
desophos
FunkyBob: sorry, i'm still not totally clear on the terminology. i mean that there's a <select> dropdown with a list of different customers, and the user chooses one, which corresponds to a DB entry; then, the form text fields should be populated according to that entry's fields. once the form is populated, the user can select another customer from the <select> dropdown, which overwrites the existing form fields with its own data.
and i'm not sure of the best way to accomplish that
koobs joined the channel
FunkyBob
desophos: ok, so you want to use AJAX to populate your HTML form fields according to the instance selected by a select list
desophos
yes
NCS_One has quit
FunkyBob
so you need either: a) a view that returns the instance values as a JSON blob and b) JS to update your form inputs with this data
or (a) a view that returns the HTML for the form, and (b) JS to replace your form markup with what's returned
royendgel joined the channel
desophos
well, one more thing is that all the values for all the relevant instances are already in the context
FunkyBob
desophos: that's meaningless... you're talking about doing work in the browser... so there is no context any more
the template is rendered, the game is over...
desophos
oh, ok
in that case, i'm trying to do the former of the two options you mentioned
learner joined the channel
kunalg_ joined the channel
but isn't there another option? i.e. give the view the instance values and have it populate the form using instance=
limbera
FunkyBob: am i not rendering it correctly (regarding form labels)
FunkyBob
limbera: dpaste the actual template
limbera
ok
FunkyBob
desophos: as I said, you could have the view render the HTML for you
FunkyBob: oh right i see, what i just said was what you were referring to with the latter option
so then, which is the better choice?
kunalg_ is now known as kunalg
FunkyBob
desophos: well, that's the $64,000 question, innit? :)
if your app is likely to provide mroe of a RESTful interface to your data, then the JSON approach is probably best
kunalg has quit
mehola has quit
warrenjin has quit
desophos
hmm... unfortunately, the option values aren't enough information to find the correct instance in the DB (not unique identifiers). is it bad to include PKs in the HTML?
Derailed
'Allo. My client has asked for two things to be in an upcoming release: (a) upgrade to django 1.7 (b) include a fix that will require a data migration and a database schema migration. So I'm in the position of working out how to do a switch from south -> django migrations AND some migrations as well. On a scale of one to bad, how bad an idea is this?
FunkyBob
Django's default method of rendering selects is to use the object PK as the option value
Derailed: not bad
Derailed
FunkyBob -> you think it's workable?
FunkyBob
Derailed: my path would probably be: (a) make sure all existing deploys are fully migrated, (b) rename migrations/ to south_migrations/ in all apps, (c) create initial migrations for django 1.7, (d) create data/schema migrations in django 1.7
Derailed
FunkyBob, does the rename make them invisible to South, or does south still find them?
dray3 joined the channel
FunkyBob
Derailed: South 1.0+ will prefer south_migrations/
ras__: the nightmare of changing your PK type is you have to also update any other model that has a FK/1to1 to it
ras__
ah this is still in development with no real data to store, do you just suggest deleting the migrations and dropping the table?
nonny_t has quit
veb joined the channel
desophos
FunkyBob: if i were to go the form-repopulation-route with instance=, how would i re-render just the one form without messing up the other parts that depend on passed context?
FunkyBob
desophos: well, you wouldn't use instance=
bibhas has quit
unless you were trying to leverage a ModelForm as a cheap API serialiser tool [a valid approach]
desophos
oh, ok; the appeal of instance= for me was that it would automatically handle the fields, giving some degree of future-proofing
so i wouldn't have to fiddle with the fields manually every time i change the model
FunkyBob
desophos: I think you're confused about what's going on
desophos
probably
FunkyBob
and how things work
desophos
definitely
FunkyBob
instance= is an option for passing to a ModelForm
jarshwah has quit
but if you're passing JSON blobs.... typically you don't use the modelform
dray3 has quit
mliqu has quit
desophos
well, i mean instead of passing a JSON blob (for that i would just return an HttpResponse to an ajax GET request, right?)
uhh wait
FunkyBob
mmm?
if you don't return a JSON blob, what are you returning?
nimomo joined the channel
VinceZa joined the channel
telex joined the channel
desophos
well, instead of having the view serialize the instance, it would use the instance directly to recreate the ModelForm
FunkyBob
and then what?
what will your view return to your JS?
desophos
nothing; the view would re-render the template
FunkyBob
it's sounding increasingly like you have trouble understanding what's client side and what's server side
re-render the whole template?
ouch
I thought you were going with an AJAX solutino
to avoid re-rendering the whole page
desophos
right, i was also trying to figure out if there's a way to re-render just the one form