Author: ai7pz

A first tutorial to learn Basic sql commands – SQL cheatsheet

You can enter the mysql console with: mysql -u root -p   Then you can select a database show databases;use my_db; Then you can see the tables show tables; To see the content of a given table: select * from my_table; To add a column named ’email’ to the table ALTER TABLE table_name ADD email […]

A Django tutorial on Debian – part 5: implementing the frontend

Django logo (Photo credit: Wikipedia) In Django the essential part of any project consists in defining the data structures. Then, implementing a webpage to a web application consists in nothing more than providing a “view” on these data structures. We will define such view for our web application in the file textModif/views.py from django.http import […]

A Django tutorial on Debian – part 4: creating the web administration portal

Django logo (Photo credit: Wikipedia) .Django creates automatically a web admin portal for our web app. We just have to edit the settings.py file and to uncomment “django.contrib.admin” in the INSTALLED_APPS setting. # Uncomment the next line to enable the admin: ‘django.contrib.admin’, # Uncomment the next line to enable admin documentation: ‘django.contrib.admindocs’,    We need […]

How to solve the duplicate entry errors in Django

Sometimes when saving an object in Django, one faces the following kind of errors: File “/home/alan/virtualenv_1/lib/python2.6/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler raise errorclass, errorvalueIntegrityError: (1062, “Duplicate entry ’18’ for key ‘PRIMARY'”)   To solve such error, the easiest way is often to just delete the object that was previously stored, with the following command: TextModification.objects.filter(id=18).delete()   […]

Discovering django on Debian – part 2: configuring django databases

MySQL (Photo credit: Wikipedia) In the previous Django tutorial, we left when a website run locally. Now, we will fill it with content. As always with python, we do not like to repeat ourselves. So if our website has several pages with common information elements, we will not repeat them. Instead, we will store all […]