Django and the Twitter Bootstrap offers the ultimate environment for web development for multiple devices.
Create the project.
django-admin startproject yourAppName
Allow the appropriate access by updating the following in settings.py file.
ALLOWED_HOSTS = ['109.203.114.78', 'localhost', 'archbrooks.us']
Now configure the desired database. Special imports are required for MySQL.
import pymysql
pymysql.install_as_MySQLdb()
Now include the database configuration parameters.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'YourDB',
'USER' : 'YourUser',
'PASSWORD' : 'Password',
'HOSTS' : '',
'PORT' : '',
}
}
At this point I would start the server to check for errors.
python manage.py runserver 0.0.0.0:8000
The next step is to install the Twitter Bootstrap.
pip install django-twitter-bootstrap
The following is generated after sucessful install of bootstrap.
Enter root@server:~/django/nws# pip install django-twitter-bootstrap
Collecting django-twitter-bootstrap
Downloading django-twitter-bootstrap-3.3.0.tar.gz (156kB)
100% |████████████████████████████████| 163kB -276578bytes/s
Building wheels for collected packages: django-twitter-bootstrap
Running setup.py bdist_wheel for django-twitter-bootstrap ... done
Stored in directory: /root/.cache/pip/wheels/7b/b2/e7/93eebb9195c2f80c83ce543768b99629c3da5ec89fb81bfb1b
Successfully built django-twitter-bootstrap
Installing collected packages: django-twitter-bootstrap
Successfully installed django-twitter-bootstrap-3.3.0
code here
Now create the first application of the site.
django-admin startapp myapp
At this point I would start the server to check for errors.
python manage.py runserver 0.0.0.0:8000
If no errors were reported you are now ready to activate the first page of your site.
Modify the urls.py file for the application to reflect the following:
from django.conf.urls import include, url
from django.contrib import admin
from mws import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^admin/', include(admin.site.urls)),
]
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.