Wednesday, June 8, 2011

Django is easy to learn

Today I made simple webpages with text from a mysql database and format that follows a template.

Learning Notes

- once mysql was stuck, it could not "mysql.server stop" or start or anything
netstat -anl look for "*.3306" for mysql
told me that mysql was still running, so "ps -ax" and "kill -9" to start it again

- The Django tutorial is awesome, very useful in copy/pasting ideas

- django's settings.py could be replaced with settings_local.py. See if it is so in manage.py. Add settings_local.py to .gitignore to not publish passwords on github



- models.py --> makes database
- urls.py --> views.py --> templates

-  urls.py's views. It renders the urls by putting in appropriate values into templates 
-  each def  
              - corresponds to a template's html  
              - must return a HttpResponse. Simplest one is `return HttpResponse("Hello World!")`


- django tutorial's "p = Poll.objects.get(pk=poll_id)" or "p = get_object_or_404(poll, pk=poll_id)" are actually analogous  to Poll.objects.filter. "pk" is the model's attribute name (i.e. the corresponding column in the model table), poll_id is the value. If there exists a row whose pk column in the model's db table is that value, then that row object is returned.

- Dimples orange is the sweetest thing on earth.

No comments:

Post a Comment