Git Product home page Git Product logo

djongo-tracks's Introduction

Getting started

create a virtual environment

python3 -m venv './venv'

activate it

source venv/bin/activate.fish

initialize a poetry project

poetry init

install django and hte latest version of djongo as well as graphene-django

poetry add django
poetry add git+ssh://[email protected]:nesdis/djongo.git
poetry add graphene-django

create a django project with

django-admin startproject app .

create a new tracks app

python manage.py startapp tracks

define your model, then include your app in settings and make migrations

python manage.py makemigrations
python manage.py migrate

spin up the server

python manage.py runserver 0:4000

Setup and manage MongoDB

pull mongo image

docker pull mongo

start mongo instance

docker run -it -v mongodata:/data/db -p 27017:27017 --name mongodb -d mongo

double check, that it is running

docker ps

check logs if necessary

docker logs mongodb -f

check into container

docker exec -it mongodb bash

connect to mongo, simply by running mongo

mongo -host localhost -port 27017

stop or start container

docker stop mongodb
# or
docker start mongodb

If you prefer some gui data visualization, than you can install MongoDB Compass

sudo dpkg -i ~/Downloads/mongodb-compass_1.26.0_amd64.deb

Create new data from shell

open up django shell

python manage.py shell

create new data

from tracks.models import Track
track1 = Track(title='Track 1', description='Track 1 description', url='https://localhost/track1')
track1.save()
# or
track2 = Track.objects.create(title='Track 2', description='Track 2 description', url='https://localhost/track2')

Dump data from database

export data from app's database

python manage.py dumpdata --indent 2 tracks > tracks/fixtures/tracks.json

Load data from fixtures into database

Load data based on matching fixture file name tracks.json

python manage.py loaddata tracks

Create superuser from django shell

from django.contrib.auth.models import User
user=User.objects.create_user('foo', password='bar')
user.is_superuser=True
user.is_staff=True
user.save()

Create superuser

python manage.py createsuperuser

djongo-tracks's People

Contributors

ibqn avatar

Watchers

 avatar  avatar  avatar

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.