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.

django - Get all object with empty set of related ones -


i've got 2 models:

class content(models.model):     content_type = models.foreignkey(contenttype)     object_id = models.positiveintegerfield(db_index=true)     content_object = generic.genericforeignkey()     show = models.booleanfield(default=false)  class foo(models.model):     rel = generic.genericrelation(content) 

and want foo methods that's related content object (there one) has show==true or doesn't have related object @ all. like:

foo.objects.filter(q(rel__show=true) | q(rel__hasnone=true)) 

but of course there's nothing hasnone in django.

is there other way in can accomplish (unfortunately aggregation doesn't work generic relations , can't count items).

ok, think i've answer satisfy of (unfortunately not me).

what need left outer join django doesn't support (all joins declared user inner ones), like:

select *, `foobar_bar`.`show` `show` `foobar_foo` left outer join `foobar_bar`      on (`foobar_foo`.`id` = `foobar_bar`.`object_id` ,          ctype = `foobar_bar`.`content_type_id`)      show=true or show=null 

i assumed both models in foobar application , ctype content_type of model foo. haven't found way such query can like:

select *, `foobar_bar`.`show` `show` `foobar_foo` left outer join `foobar_bar`      on (`foobar_foo`.`id` = `foobar_bar`.`object_id`     (show=true or show=null) , ctype = `foobar_bar`.`content_type_id` 

it's not satisfactory exclusive (could join tuples different ctype basing on object's id) still useful. way such query found @ link text. it'll like:

qs = foo.objects.all()  qs.query.join((none, 'foobar_foo', none, none)) qs.query.join(('foobar_foo', 'foobar_bar', 'id', 'object_id'), promote=true) foos. qs = qs.extra(select = {'show': 'foobar_bar.show',},               = "(show=true or show=null) , ctype = `foobar_bar`.`content_type_id`") 

generally using query.join((,), promote=true) gets left query join instead of inner, can pass 1 on argument, less solve problem still useful.


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 -