Forums

Page is not showing after model changes

hi,

I have modified my model for post, I added "bodyszort = FroalaField()":

from froala_editor.fields import FroalaField
class Post(models.Model):
    title = models.CharField(max_length = 140)
    bodyszort = FroalaField()
    body = FroalaField()
    date = models.DateTimeField()
    #category = models.ManyToManyField(Category, verbose_name='Kategoria')
    img = models.ImageField(upload_to='admina',null=True, blank=True)

now when I start page I got error::

File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such column: blog_post.bodyszort

it seems that I need to run migration, but when I tried this I got:

00:10 ~/My-stuff/mysite (master)$ python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 316, in execute
    settings.INSTALLED_APPS
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 97, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named mysite.settings
00:10 ~/My-stuff/mysite (master)$ python3.5 manage.py makemigrations
No changes detected
00:11 ~/My-stuff/mysite (master)$

when I run with 3.5 - no changes detected without 3.5 - error message

Do you know what is hapenning

it definitely sounds like you need to run makemigrations + migrate. are you using the PythonAnywhere system python3.5 or a virtualenv?

I am not sure if I am getting correctly, but I use python 3.5 and not use virtual env

seems like you were running manage.py from within a virtualenv from the traceback. try doing it again?

same story:

drwxrwxr-x 8 dzikuss98 registered_users 4096 Feb  6 18:35 mysite
16:52 ~/My-stuff (master)$ cd mysite/
16:52 ~/My-stuff/mysite (master)$ ls
blog  db.sqlite3  images  manage.py  media  mysite  personal  ranger
16:52 ~/My-stuff/mysite (master)$ python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 316, in execute
    settings.INSTALLED_APPS
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 97, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named mysite.settings
16:52 ~/My-stuff/mysite (master)$

Work through this to work out what is going on.

this helped

20:21 ~/My-stuff/mysite (master)$ **python3.5 manage.py makemigrations blog**
Migrations for 'blog':
  blog/migrations/0006_auto_20170221_2021.py:
    - Remove field name from category
    - Remove field slug from category
    - Remove field category from post
    - Alter field body on post
    - Alter field img on post
20:21 ~/My-stuff/mysite (master)$ python3.5 manage.py migrate blog                                                                                  
Operations to perform:
  Apply all migrations: blog
Running migrations:
  Applying blog.0006_auto_20170221_2021... OK

So the change was to use python3.5 instead of python? That makes sense -- thanks for posting that.

it was rather adding app name at end of command: python3.5 manage.py makemigrations blog

That's odd. Do you still get the same error if you run the command without blog at the end?

I stil get that error, but page works now:

**blog  db.sqlite3  images  manage.py  media  mysite  personal  ranger
20:17 ~/My-stuff/mysite (master)$ python3.5 manage.py makemigrations
No changes detected
20:17 ~/My-stuff/mysite (master)$ python3.5 manage.py makemigratio
Unknown command: 'makemigratio'
Type 'manage.py help' for usage.
20:17 ~/My-stuff/mysite (master)$ 
20:17 ~/My-stuff/mysite (master)$ python manage.py makemigrations                                                                                   
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 316, in execute
    settings.INSTALLED_APPS
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 97, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named mysite.settings
20:17 ~/My-stuff/mysite (master)$**

I see an Import error there. Have another go at the debugging steps on this page, and let us know what you discover?

http://help.pythonanywhere.com/pages/DebuggingImportError/