Python/Django debugging: print model’s containing data

If you have the model instance(s) you can simply call: model_queryset.all().values() https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.values For just the list of fields using the model class itself see Django: Get list of model fields? or directly the documentation – for Django 1.10 there is a dedicated section on how to work with fields: https://docs.djangoproject.com/en/1.10/ref/models/meta/#retrieving-all-field-instances-of-a-model

Printing code with syntax highlighting? [closed]

You can use Vim! It’s probably installed already if you’re on modern Linux/MacOS and an easy install if not. :syntax will turn syntax highlighting on and :hardcopy will print it. There’s syntax highlighting definitions for many languages out there. The default look is usually optimised for screen display, but you can fix that. Simply open … Read more

print every nth line into a row using gawk

To print every second line, starting with the first: awk ‘NR%2==1’ file.txt To print every tenth line, starting with the tenth line: awk ‘NR%10==0’ file.txt To use this in a script, add the following to a file called script.awk: BEGIN { print “Processing file” } NR%10==0 END { print “Finished processing” } Then execute: awk … Read more

How can I insert a Print button that prints a form in a webpage

Print the whole page Try adding a button that calls window.print() <input type=”button” value=”Print this page” onClick=”window.print()”> Print a specific portion/container in a page <div id=”print-content”> <form> <input type=”button” onclick=”printDiv(‘print-content’)” value=”print a div!”/> </form> </div> then in the HTML file, add this script code <script type=”text/javascript”> function printDiv(divName) { var printContents = document.getElementById(divName).innerHTML; w=window.open(); w.document.write(printContents); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)