GithubHelp home page GithubHelp logo

blogweb's Introduction

The 2nd Django project will be building a complete blog. Django provides a command that allows you to create an initial project fle structure. Run the following command from your shell:

django-admin startproject mysite

You will create a blog application from scratch. From the project's root directory, run the following command:

python manage.py startapp blog

Model Design

First, you need to defne a Post model. Add the following lines to the models.py file of the blog application:

Activating the application

In order for Django to keep track of your application and be able to create database tables for its models, you have to activate it. To do this, edit the settings.py fle and add blog.apps.BlogConfig to the INSTALLED_APPS setting. It should look like this:

INSTALLED_APPS = [
	'django.contrib.admin',
	'django.contrib.auth',
	'django.contrib.contenttypes',
	'django.contrib.sessions',
	'django.contrib.messages',
	'django.contrib.staticfiles',
	'blog.apps.BlogConfig',
]

The BlogConfig class is your application confguration. Now Django knows that your application is active for this project and will be able to load its models.

python manage.py makemigrations blog

Let's take a look at the SQL code that Django will execute in the database to create the table for your model. The sqlmigrate command takes the migration names and returns their SQL without executing it. Run the following command to inspect the SQL output of your frst migration:

python manage.py sqlmigrate blog 0001

Let's sync your database with the new model. Run the following command to apply existing migrations:

python manage.py migrate

Creating a superuser

First, you will need to create a user to manage the administration site. Run the following command:

python manage.py createsuperuser

user name: admin e-mail: [email protected] password: 123456

pip install django_taggit

Run ./manage.py migrate.

Custom template flters

pip install markdown

guest1 whKrPi3kJMQCcX2

blogweb's People

Contributors

coderastrid avatar

Watchers

 avatar

blogweb's Issues

not recognition the 'taggit' package

I was install the package follow as:

pip install django-taggit
and
pip install django-taggit==0.23.0

and added 'taggit' in the INSTALLED_APPS.
but occurred error 'from taggit.managers import TaggableManager' at 'model.py'
what's the matter?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.