0
votes

There is no perfect explanation for this question, can any one please explain why this error is getting raised

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 324, in execute
    django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/ubuntu/project-root/DjangoWebProject5/app/views.py", line 11, in <module>
    from app.models import *
  File "/home/ubuntu/project-root/DjangoWebProject5/app/models.py", line 11, in <module>
    class Document(models.Model):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 94, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 239, in get_containing_app_config
    self.check_apps_ready()
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet

Edit 1 settings.py INSTALLED_APPS

INSTALLED_APPS = (
    'app',
    'app.views',
    #'bootstrap3_datetime',
    'djcelery',
    'kombu.transport.django',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)

Project Structure:

    Djangowebproject
                 -->Djangowebproject-->settings.py
                                    -->urls.py
                                    -->wsgi.py
                                    -->__init__.py
                 -->app-->migrations
                       -->static
                       -->templates
                       -->templatetags
                       -->admin.py
                       -->forms.py
                       -->models.py
                       -->urls.py
                       -->views.py

app/models.py is like

from django.db import models
from django.db.models import Sum

import datetime


class Document(models.Model):
    title = models.CharField(max_length=200, default='')  # title of the post
    news = models.TextField(default='')  # body of the news
    image = models.FileField(upload_to='documents/%d/%m/%Y', default='')  # image file included in it
    link = models.CharField(max_length=500, default='')  # video file url if present
    pubdate = models.DateTimeField("Date", default=datetime.datetime.now())  # this is date of scrapping
    approvedflag = models.CharField(max_length=200, default='-1')  # approved or not -1 for not and 1 for approved
    publishedfrom = models.CharField(max_length=100, default='')  # this includes domain of page eg: twitter, greatandhra
    type = models.CharField(max_length=100, default='direct post')  # published author for future use
    approvedby = models.CharField(max_length=200, default='')   # user name of the approved person
    parse_objectid = models.CharField(max_length=200, default='')   # unique id response
    source = models.CharField(max_length=200, default='')   # page/post link


class fb_pages_sync(models.Model):
    pagename = models.CharField(max_length=500, default='')
    sync_flag = models.CharField(max_length=2, default='-1')
    status_run = models.CharField(max_length=2, default='-1')
    src_pages = models.CharField(max_length=2,
                                 default='f')  # flag bit to know about whether the pages are form facebook or twitter
    verfied = models.CharField(max_length=2, default='-1')


class Poll(models.Model):
    """A poll object for use in the application views and repository."""
    text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def total_votes(self):
        """Calculates the total number of votes for this poll."""
        return self.choice_set.aggregate(Sum('votes'))['votes__sum']

    def __unicode__(self):
        """Returns a string representation of a poll."""
        return self.text


class Choice(models.Model):
    """A poll choice object for use in the application views and repository."""
    poll = models.ForeignKey(Poll)
    text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    def votes_percentage(self):
        """Calculates the percentage of votes for this choice."""
        total = self.poll.total_votes()
        return self.votes / float(total) * 100 if total > 0 else 0

    def __unicode__(self):
        """Returns a string representation of a choice."""
        return self.text
1
Not without seeing your code! The issue is likely to be in your AppConfig if you have one, otherwise something you have put in settings.py.solarissmoke
As @solarissmoke says, please provide us the info of you app structure and also settings.pyNagaraj Tantri
Thanks for editing@ruddraVenkat Ramana
As others have suggested before me , you need to show code. app/models.py ought to look interesting.e4c5
i have added app/models.py @e4c5Venkat Ramana

1 Answers

0
votes

Installed app should contain only the django apps that you want to include in your application, i see you have added app and app.views. views is not an app, it's a python file present in the app directory please remove that and try to migrate.

Also please add you custom apps after django's default apps for best practice.