you want
Note the capitalization of Model.
class Choice(models.Model):
By convention, class names in python should be capitalized.
On Sat, Jan 16, 2016 at 5:56 PM, ofeyofey <shanegibney@gmail.com> wrote:
hi,
I see the error there was dateTimeField.... and corrected that but now I get
pi@raspberrypi ~/DjangoPi/mathGenerator $ python manage.py migrate
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 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/pi/DjangoPi/mathGenerator/generator/models.py", line 8, in <module>
class Choice(models.model):
AttributeError: 'module' object has no attribute 'model'
Thanks,
On Saturday, 16 January 2016 21:27:31 UTC, ofeyofey wrote: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/generator
Next 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,
ThanksTo view this discussion on the web visit https://groups.google.com/d/msgid/django-users/19804990-53d9-4317-862f-dfc3ac0bee41%40googlegroups.com.--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2By5TLaz7LM4U_xRcpmtqNh8OzCCqHaSG3F0ZjU%2BoHj%2B6d3Ksg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment