Webframeworks2019.files.wordpress.com
SETTING UP THE ENVIRONMENTmkdir djangowdcd djangowdpython3 virtualenv myvenvpython -m virtualenv myvenvcd myvenvcd Scriptsactivatecd ..pip install djangoCREATING PROJECT AND APPdjango-admin startproject myprojectcd myprojectpython manage.py startapp addbook**************************************open settings.py and include the 'addbook' app in the 'INSTALLED APPS'**************************************Start the serverpython manage.py runserver************************************Check if it is working***********************************Apply initial migrationspython manage.py migrate**************************************Create a modelopen models.pyclass ToDo (models.Model):title=models.CharField(max_length=20) def _str_(self):return self.title other fields available include TextField, BooleanField***********************************Migratepython manage.py makemigrations addbookpython manage.py migrate addbook**********************************ADMIN Check if admin page is accessibleCreate superuserpython manage.py createsuperuserOpen admin.py and register your modelfrom .models import AddBooklogin as admin and add four addressess**********************************URLSurls.pyAdd the addbook urls fileTo do this import includeThen usepath('addbook/', include('addbook.urls'))create urls.py file in addbookimport views to the url.py file.Views is available in the current folderGive a path for homepage and another for list******************************VIEWSOpen the views.py filecreate a function call home that returns an HttpResponse. Remember to import HttpResponse from django.httpTest the homepage URLNext create another function call list.This function uses render. This includes the request, template******************************TemplateIn the base directory create a folder called templates. In it create an html file called list.htmlIn settings.py under Templates include this line'DIRS': [os.path.join(BASE_DIR, 'templates')],Invoke this template in the render functionTest if this is working******************************In views import the AddBook Modelin the list function retrieve the list of all addresses in the modelAddBook.objects.allCreate a context with this query set and pass to the render {'adds':adds}**********************Open the template type {{adds}} and see if something is displayed.The rest is python and HTML. Try by yourself.*****************************Separate out base.html and list.html{% block content %}{% endblock %}*********************CSSCSS and other static files need to be served.Create a folder called static in base directoryCreate a css folder and put a css file in there.In the base file {% load static %}<link rel="stylesheet" href="{% static 'css/todo.css' %}">If your CSS takes effect you can go home. See you next Friday!! ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- wordpress passing data between pages
- wordpress business templates
- wordpress rss feed not working
- wordpress jquery is not defined
- create wordpress blog
- wordpress roles editor
- wordpress full rss feed
- wordpress rss feed settings
- wordpress rss feed plugin
- wordpress display rss feed
- wordpress rss feed link
- wordpress rss feed to post