Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort_desc.png```,```sort_asc.png``` and other images not found error. That's because there is no static images downloaded with ```js``` and ```css``` file.
To fix the problem, you can download these images from Datables official github and place them at your static folder on your server.
Link ```https://github.com/DataTables/DataTables/tree/master/media/images```

After put these images on the server, you may open your downloaded ```datatables.min.css``` file and update the following section:
## Original version:
```css
.sorting{background-image:url("/DataTables-1.11.5/images/sort_both.png")}
.sorting_asc{background-image:url("/DataTables-1.11.5/images/sort_asc.png")}
.sorting_desc{background-image:url("/DataTables-1.11.5/images/sort_desc.png")}
.sorting_asc_disabled{background-image:url("/DataTables-1.11.5/images/sort_asc_disabled.png")}
```
## After update:
```css
.sorting{background-image:url("/static/img/sort_both.png")}
.sorting_asc{background-image:url("/static/img/sort_asc.png")}
.sorting_desc{background-image:url("/static/img/sort_desc.png")}
.sorting_asc_disabled{background-image:url("/static/img/sort_asc_disabled.png")}
```

Join query in Django


If we have two tables, virulence_genome and virulence_cds, and their schemas are as following:


                      Table "public.virulence_genome"
      Column      |         Type          | Collation | Nullable | Default
------------------+-----------------------+-----------+----------+---------
 genome_id        | integer               |           | not null |
 accession_number | character varying(50) |           | not null |
 strand           | integer               |           | not null |
 start_position   | integer               |           | not null |
 end_position     | integer               |           | not null |
 location         | character varying(20) |           | not null |


				Table "public.virulence_cds"
   Column    |  Type   | Collation | Nullable | Default
-------------+---------+-----------+----------+---------
 genome_id   | integer |           | not null |
 gene        | text    |           | not null |
 locus_tag   | text    |           | not null |
 note        | text    |           | not null |
 product     | text    |           | not null |
 cds_db_xref | text    |           | not null |


genome_id in virulence_cds is a foreign key of virulence_genome. What if we want to get gene names and their locations for genes that are not located on genome? Use sql query we could write something like:

select vc.gene,vg.location from virulence_cds vc join virulence_genome vg on vc.genome_id = vg.genome_id and vg.location !='genome';

What to do in Django view? I have propsed two ways to do it. Obvisouly one way is better than the other. So to find all CDs which are not located at genome, we could write:

def func(request):
	genome_ids=Genome.objects.filter(location='plasmid').values_list('genome_id')
	return Cds.objects.select_related('genome').filter(~Q(genome_id__in=genome_ids))

or

def func(request):
	return Cds.objects.select_related('genome').filter(~Q(genome__location='plasmid'))

Wrap text in a datatable

How to wrap long text in jQuery Datatable, Django Datable


I have seen different solutions on wrapping long text in datatable td, such as add wrap class into table property. But they all did not work sometimes.
The solution I proposed here is that add the following code to your site/page css property.

       

table.dataTable tbody td {
  	word-break: break-word; word-break: break-all; white-space: normal;
}
       
 
Because in the core, datatable is a standard table. So this solution also works on any html table, as long as it has table, tbody and td structure.

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...