This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
DATABASES = { | |
'default': { | |
'ENGINE': 'djongo', | |
'NAME': 'db', | |
} | |
} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
DATABASES = { | |
'default': { | |
'ENGINE': 'djongo', | |
'NAME': 'db', | |
'HOST': 'mongodb://mongo-primary.service.consul', | |
'PORT': 27017, | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from djongo import models | |
class Blog(models.Model): | |
name = models.CharField(max_length=100) | |
tagline = models.TextField() | |
class Meta: | |
abstract = True | |
class Entry(models.Model): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from.models import Entry | |
admin.site.register(Entry) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from pymongo import MongoClient | |
def home(request): | |
client = MongoClient("mongo-primary.service.consul") | |
replica_set = client.admin.command('ismaster') | |
return render(request, 'home.html', { | |
'mongo_hosts': replica_set['hosts'], | |
'mongo_primary_host': replica_set['primary'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from tweetapp import views | |
urlpatterns = [ | |
path('', views.home, name='home'), | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.urls import path, include | |
from django.conf import settings | |
from django.conf.urls.static import static | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
path('web', include('tweetapp.urls')), | |
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | |
<link href="https://fonts.googleapis.com/css?family=Armata" rel="stylesheet"> | |
<title>Django-Mongo-Consul</title> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python ./manage.py migrate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python ./manage.py collectstatic --noinput |