Last active
December 20, 2015 10:09
-
-
Save mroswell/6113173 to your computer and use it in GitHub Desktop.
notes while learning django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"import django; print(django.get_version())" | |
$ python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)" | |
python -c " | |
import sys | |
sys.path = sys.path[1:] | |
import django | |
print(django.__path__)" | |
django is located in: /home/action/.local/lib/python2.7/site-packages/django | |
~/.local/lib/python2.7/site-packages/django/contrib/admin/templates/admin | |
django-admin.py startproject mysite | |
outerdirectory name doesn't matter to application | |
python manage.py runserver 0.0.0.0:3000 | |
visit: | |
http://helianthus-19958.use1.actionbox.io:3000/ | |
python manage.py syncdb | |
Creating tables ... | |
Creating table auth_permission | |
Creating table auth_group_permissions | |
Creating table auth_group | |
Creating table auth_user_groups | |
Creating table auth_user_user_permissions | |
Creating table auth_user | |
Creating table django_content_type | |
Creating table django_session | |
Creating table django_site | |
thesuper | |
\dt (PostgreSQL), | |
SHOW TABLES; (MySQL), or | |
.schema (SQLite) | |
to display the tables Django created. | |
python manage.py startapp polls | |
# polls/models.py | |
from django.db import models | |
class Poll(models.Model): | |
question = models.CharField(max_length=200) | |
pub_date = models.DateTimeField('date published') | |
class Choice(models.Model): | |
poll = models.ForeignKey(Poll) | |
choice = models.CharField(max_length=200) | |
votes = models.IntegerField() | |
Edit the settings.py file again, and change the INSTALLED_APPS setting to include the string 'polls'. | |
python manage.py sql polls | |
django.contrib.contenttypes – A framework for content types. (maybe like CCK?) | |
this search yielded this interesting thread on why leave drupal behind: https://news.ycombinator.com/item?id=4604555 | |
CREATE INDEX "auth_user_groups_6340c63c" ON "auth_user_groups" ("user_id"); | |
CREATE INDEX "auth_user_user_permissions_6340c63c" ON "auth_user_user_permissions" ("user_id"); | |
CREATE INDEX "auth_user_user_permissions_83d7f98b" ON "auth_user_user_permissions" ("permission_id"); | |
CREATE INDEX "django_session_b7b81f0c" ON "django_session" ("expire_date"); | |
sqlite> .schema auth_user | |
CREATE TABLE "auth_user" ( | |
"id" integer NOT NULL PRIMARY KEY, | |
"password" varchar(128) NOT NULL, | |
"last_login" datetime NOT NULL, | |
"is_superuser" bool NOT NULL, | |
"username" varchar(30) NOT NULL UNIQUE, | |
"first_name" varchar(30) NOT NULL, | |
"last_name" varchar(30) NOT NULL, | |
"email" varchar(75) NOT NULL, | |
"is_staff" bool NOT NULL, | |
"is_active" bool NOT NULL, | |
"date_joined" datetime NOT NULL | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment