Hi,
I am following the Django tutorial on the Django site. Getting errors when i try to make migrations after adding the app to the list of apps in mathGenerator/settings.py
Setting up Django on a raspberry Pi. I don't think the fact that it is on api should make any difference becasue it is basically running.
It is here
https://docs.djangoproject.com/en/1.9/intro/tutorial02/In the previous tutorial I created a project calles mathGenerator and a app called generator.
Created the project with django_admin startproject mathGenerator
Ran the server with $python manage.py runserver
And i can see the site in my browser. So this ia working fine.
Then I created an app called generator using
$python manage.py startapp generator
In generator/nviews.py I put
from django.http import HttpResponse
code = "<html><head><style>body{background-color:rgb(100,0,200);}</style></head><body><br>Django test site <br><br>Hosted on a Raspberry Pi<br><br><button>Press me!</button></body></html>"
# Create your views here.
def index(request):
return HttpResponse(code)
and in generator/urls.py I put
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
In mathGenerator/urls.py I put
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^generator/', include('generator.urls')),
url(r'^admin/', include(admin.site.urls)),
]
This works find when I go to
127.0.0.1:8000/generatorNext I used
$python manage.py migrate
Then i created a model in generator/models.py
from django.db import models
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimefield('date published')
class Choice(models.model):
question = models.FioreignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
Adding to app to the list of apps in mathGenerator/settings.py
INSTALLED_APPS = [
'generator.apps.generatorConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Then I try to make migrations and I get this error,
pi@raspberrypi ~/DjangoPi/mathGenerator $ python manage.py makemigrations generator
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 328, 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 112, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named apps
What am I doing wrong?
Any help would be greatly appreciated,
Thanks