Search Results

Search found 5 results on 1 pages for 'alj'.

Page 1/1 | 1 

  • Filtering results and pagination

    - by alj
    I have a template that shows a filter form and below it a list of the result records. I bind the form to the request so that the filter form sets itself to the options the user submitted when the results are returned. I also use pagination. Using the code in the pagination documentation means that when the user clicks for the next page, the form data is lost. What is the best way of dealing with pagination and filtering in this way? Passing the querystring to the paginiation links. Change the pagination links to form buttons and therefore submit the filter form at the same time, but this assumes that the user hasn't messed about with the filter options. As above but with the original data as hidden fields. ALJ

    Read the article

  • Partially flattening a list

    - by alj
    This is probably a really silly question but, given the example code at the bottom, how would I get a single list that retain the tuples? (I've looked at the itertools but it flattens everything) What I currently get is: ('id', 20, 'integer') ('companyname', 50, 'text') [('focus', 30, 'text'), ('fiesta', 30, 'text'), ('mondeo', 30, 'text'), ('puma', 30, 'text')] ('contact', 50, 'text') ('email', 50, 'text') what I would like is a single level list like: ('id', 20, 'integer') ('companyname', 50, 'text') ('focus', 30, 'text') ('fiesta', 30, 'text') ('mondeo', 30, 'text') ('puma', 30, 'text') ('contact', 50, 'text') ('email', 50, 'text') def getproducts(): temp_list=[] product_list=['focus','fiesta','mondeo','puma'] #usually this would come from a db for p in product_list: temp_list.append((p,30,'text')) return temp_list def createlist(): column_title_list = ( ("id",20,"integer"), ("companyname",50,"text"), getproducts(), ("contact",50,"text"), ("email",50,"text"), ) return column_title_list for item in createlist(): print item Thanks ALJ

    Read the article

  • Partially fattening a list

    - by alj
    This is probably a really silly question but, given the example code at the bottom, how would I get a single list that retain the tuples? (I've looked at the itertools but it flattens everything) What I currently get is: ('id', 20, 'integer') ('companyname', 50, 'text') [('focus', 30, 'text'), ('fiesta', 30, 'text'), ('mondeo', 30, 'text'), ('puma', 30, 'text')] ('contact', 50, 'text') ('email', 50, 'text') what I would like is a single level list like: ('id', 20, 'integer') ('companyname', 50, 'text') ('focus', 30, 'text') ('fiesta', 30, 'text') ('mondeo', 30, 'text') ('puma', 30, 'text') ('contact', 50, 'text') ('email', 50, 'text') def getproducts(): temp_list=[] product_list=['focus','fiesta','mondeo','puma'] #usually this would come from a db for p in product_list: temp_list.append((p,30,'text')) return temp_list def createlist(): column_title_list = ( ("id",20,"integer"), ("companyname",50,"text"), getproducts(), ("contact",50,"text"), ("email",50,"text"), ) return column_title_list for item in createlist(): print item Thanks ALJ

    Read the article

  • Dynamically create categories for SQLite pivot/crosstab

    - by alj
    I realise it is possible to create a crosstab within sqlite, but is it possible to dynamically determine the relevant categories/columns at runtime rather than hardcoding them? Given the following example, it can get rather tedious ... SELECT shop_id, sum(CASE WHEN product = 'Fiesta' THEN units END) as Fiesta, sum(CASE WHEN product = 'Focus' THEN units END) as Focus, sum(CASE WHEN product = 'Puma' THEN units END) as Puma, sum(units) AS total FROM sales GROUP BY shop_id I managed to do this in SQLServer in a stored proceedure before and wondered if there was anything equivalent.

    Read the article

  • Select distinct values from a table field

    - by alj
    I'm struggling getting my head around the Django's ORM. What I want to do is get a list of distinct values within a field on my table .... the equivalent of one of the following: SELECT DISTINCT myfieldname FROM mytable (or alternatively) SELECT myfieldname FROM mytable GROUP BY myfieldname I'd at least like to do it the Django way before resorting to raw sql.

    Read the article

1