Standalone Project using django ORM

76 views
Skip to first unread message

ADEWALE ADISA

unread,
Oct 27, 2015, 6:35:46 PM10/27/15
to django...@googlegroups.com

Hello;
I have being having issues trying to use django orm in my application. This issues occur when using django 1.85. The application run perfectly well on django 1.50. Bellow are the snippet :

Model.py:
from django.db import models

class Person(models.Model):
    name = models.CharField(max_length=100)
    email = models.CharField(max_length=100)
    birthdate = models.DateField()
    class Meta:
        app_label = 'runnable'
   
    def __unicode__(self):
        return u'%d: %s' % (self.id, self.name)

app.py:

import sys
from os import path
import collections
import datetime
sys.path.insert(0, path.abspath(path.join(path.dirname(__file__), '..')))

from django.core.management import call_command
from django.conf import settings

#print(sys.path)
if not settings.configured:
    settings.configure(
       DEBUG=True,
        DATABASES={
            'default': {
                # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
                'ENGINE': 'django.db.backends.sqlite3',
                # Or path to database file if using sqlite3.
                'NAME': ':memory:',
            }
        },
        INSTALLED_APPS=("runnable", )
       
    )

import django
django.setup()
#call_command('syncdb')
call_command('makemigrations')
call_command('migrate')
call_command('inspectdb')
from models import Person
print("PERSON: "+ Person)

Console msg:
p.py", line 28, in <module>
    django.setup()
  File "/data/data/com.hipipal.qpy3/files/lib/python3.2/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/data/data/com.hipipal.qpy3/files/lib/python3.2/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/data/data/com.hipipal.qpy3/files/lib/python3.2/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/data/data/com.hipipal.qpy3/files/lib/python3.2/python32.zip/importlib/__init__.py", line 124, in import_module

Note:
The application run successfully with django 1.50  by uncomment syncdb and comment out migration, make migrations.

Thanks.

Dheerendra Rathor

unread,
Oct 27, 2015, 7:27:10 PM10/27/15
to django...@googlegroups.com
Is this the full stacktrace? Looks like error message is missing in stacktrace. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy9BSMrgqw8uMgp3kd9eBu5fTdF4DCB9%3Di-8r6EmZmN-WA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

ADEWALE ADISA

unread,
Oct 27, 2015, 7:39:06 PM10/27/15
to django...@googlegroups.com

The screen shot is attached. There is no error message but the trace. But the program seem stop at django.setup(). Though it ran smoothly in django 1.50

2015_10_28_00.31.57_crop.png

Collin Anderson

unread,
Nov 5, 2015, 10:24:16 AM11/5/15
to Django users
Hi,

It looks like you stack trace is somehow getting cut off.

My guess is it's trying to import something that either doesn't exist or has a syntax error.

Collin
Reply all
Reply to author
Forward
0 new messages