Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Select a subset of foreign key elements in inlineformset_factory in Django -


i have model 2 foreign keys:

class model1(models.model):   model_a = models.foreignkey(modela)   model_b = models.foreignkey(modelb)   value = models.integerfield() 

then, create inline formset class, so:

an_inline_formset = inlineformset_factory(modela, model1, fk_name="model_a") 

and instantiate it, so:

a_formset = an_inline_formset(request.post, instance=model_a_object) 

once formset gets rendered in template/page, there choicefield associated model_b field. problem i'm having elements in resulting drop down menu include of elements found in modelb table. need select subset of based on criteria modelb. @ same time, need keep reference instance of model_a_object when instantiating inlineformset_factory and, therefore, can't use this example. suggestions?

what need change modelchoicefield's queryset

the easiest way may monkey-patch formset's form. should able right after constructing formset with:

an_inline_formset.form.base_fields['model_b'].queryset = modelb.objects.filter(whatever=true) 

not prettiest, should work.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -