0

I have a python application that uses Django models for easy storage of data. It is NOT a django app, I'm just attempting to use models from django.db, JSONField from django.contrib.postgres.fields and other useful parts.

When I attempt to run python manage.py makemigrations, the terminal stalls. How do I debug this?

Here are some snippets of my code:

manga_shell/models.py

import os, django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "manga_project.settings")
django.setup()


from django.db import models
from django.contrib.postgres.fields import JSONField


class Manga(models.Model):
    # fields

class Chapter(models.Model):
    # fields

class Page(models.Model):
    # fields

manga_project/settings.py

import dj_database_url, os


SECRET_KEY = #secret :P

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

INSTALLED_APPS = (
    'django.contrib.postgres',
    'manga_shell',
)

DATABASES = {'default': dj_database_url.config(default='postgres://MyUserName:MyPassword@localhost:5432/manga_project_db')}

TIMEZONE = 'Asia/Kolkata'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

If more code is required, I'll post it. I'm not entirely clear on what might cause manage.py to stall, so I don't know for sure which snippets of code are needed. Thanks in advance for the help.

NJay
  • 130
  • 8
  • It *is* a Django app. (with an unconventional layout...) - You're importing django and calling `django.setup()`... – ohrstrom Jun 29 '16 at 20:36
  • Is that so. :P The point of this was to use Django models in my python standalone script. Would it work if I imported from these apps into my script? – NJay Jun 29 '16 at 20:50
  • eventually :) - I dont' know... they are just python modules - so try it out... but if you want to use `manage.py` and django migrations i'm not sure if this really is an intended use-case :)... if you just need an ORM library it likely would be better to use something like [SQLAlchemy](http://www.sqlalchemy.org/) – ohrstrom Jun 29 '16 at 21:03
  • Alright, I'll look into that... Thanks! :) – NJay Jun 30 '16 at 18:41

0 Answers0