DEV Community

Cover image for Fullstack? Why not (Django + Vue-js) - episode 1
aderayevans
aderayevans

Posted on

2 2

Fullstack? Why not (Django + Vue-js) - episode 1

Table of Contents

  1. Django side
  2. Vue.js side

Implement episode 1


Django side


  • Create a new Django project

django-admin startproject {project}

  • Start the server with

python manage.py runserver

  • Add application

python manage.py startapp {app}

  • Migrate database

python manage.py migrate

Change settings before run server

  • Change the {django-project-dir}\{django-project-name}\settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'shark',
    'corsheaders',
]

CORS_ORIGIN_ALLOW_ALL = True

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'corsheaders.middleware.CorsMiddleware',
]
Enter fullscreen mode Exit fullscreen mode

shark is an application that I added with startapp

'corsheaders'  
CORS_ORIGIN_ALLOW_ALL = True  
'corsheaders.middleware.CorsMiddleware',
Enter fullscreen mode Exit fullscreen mode

These three line is used for the CORS purpose (Just think that it enabled CORS which allow you pass API between server-client)

  • Database settings Using sqlite3
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}
Enter fullscreen mode Exit fullscreen mode

or Oracle

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': 'localhost:1521/XEPDB1',
        'USER': 'django',
        'PASSWORD': 'django',
    }
}
Enter fullscreen mode Exit fullscreen mode

or Mysql

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'polling',
        'HOST': 'localhost',
        'USER': 'djangouser',
        'PASSWORD': 'djangopassword',

        'OPTIONS': {
            'sql_mode': 'traditional',
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

These 3 are patterns I have used in my testing projects.

Run python manage.py migrate to apply these changes

Vue.js side



vue create testfrontend
Enter fullscreen mode Exit fullscreen mode

testfrontend is my frontend project
step 1
step 2
step 3

  • Start the frontend with
$cd testfrontend
$npm run serve
Enter fullscreen mode Exit fullscreen mode

vue_run_serve

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay