I have a django blog project which has the following core models:

> 
> Models.py
> 
> 
> 

```
class Category(models.Model):

    parentCategoryName = models.ForeignKey('self', blank=True, 
         null=True)
    parentCatSlug = models.SlugField(null=True, blank=True)
    categoryName = models.CharField(max_length=200, null=True)
    categorySlug = models.SlugField(null=True, blank=True)

    def __str__(self):

        full_path = [self.categoryName]               
        k = self.parentCategoryName                          

        while k is not None:
            full_path.append(k.categoryName)
        k = k.parentCategoryName

        return ' -> '.join(full_path[::-1])

    class Meta:
        verbose_name_plural = "categories"

    def save(self, *args, **kwargs):
         self.categorySlug = slugify(self.categoryName)
         self.parentCatSlug = slugify(self.parentCategoryName)
         super(Category, self).save(*args, **kwargs)

class Post(models.Model):

    title = models.CharField(max_length=200)
    category = models.ForeignKey('Category', null=True, blank=True)
    summary = models.CharField(max_length=500, default=True)
    body = RichTextUploadingField()
    pub_date = models.DateTimeField(default=timezone.now)
    author = models.ForeignKey(User, default=True)
    titleSlug = models.SlugField(blank=True)
    authorSlug = models.SlugField(blank=True)
    editedimage = ProcessedImageField(upload_to="primary_images", 
        null=True,
                            processors = [Transpose()],
                            format="JPEG")
   show_in_posts = models.BooleanField(default=True)

    def save(self, *args, **kwargs):
        self.titleSlug = slugify(self.title)
        self.authorSlug = slugify(self.author)
        super(Post, self).save(*args, **kwargs)

    def __str__(self):
        return self.title

```

When I run makemigrations and migrate, all works fine initially, but then after a while, I get the error above. I've posted a question on this previously, and the solution was to drop the database and re-create it. This still works, but it happens frequently, so I keep having to drop and re-create. Can anyone help explain why this is seemingly sporadically happening?

> 
> Traceback
> 
> 
> 

```
File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)

The above exception (column posts_post.category_id does not exist
LINE 1: SELECT "posts_post"."id", "posts_post"."title", "posts_post"...
                                                        ^
) was the direct cause of the following exception:

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/davidmellor/code/nomadpad/posts/views.py" in getPosts
  27.     return render(request, 'posts/getPosts.html', context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/shortcuts.py" in render
  30.     content = loader.render_to_string(template_name, context, request, using=using)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/loader.py" in render_to_string
  68.     return template.render(context, request)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in render
  207.                     return self._render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/loader_tags.py" in render
  72.                 result = block.nodelist.render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/template/defaulttags.py" in render
  321.             if match:

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/models/query.py" in __bool__
  254.         self._fetch_all()

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/models/query.py" in _fetch_all
  1118.             self._result_cache = list(self._iterable_class(self))

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/models/query.py" in __iter__
  53.         results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  894.             raise original_exception

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  884.             cursor.execute(sql, params)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  80.             return super(CursorDebugWrapper, self).execute(sql, params)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/utils/six.py" in reraise
  685.             raise value.with_traceback(tb)

File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /
Exception Value: column posts_post.category_id does not exist
LINE 1: SELECT "posts_post"."id", "posts_post"."title", "posts_post"...
                                                        ^

```

> 
> Migrations
> 
> 
> 

```
from __future__ import unicode_literals

import ckeditor_uploader.fields
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import imagekit.models.fields

class Migration(migrations.Migration):

initial = True

dependencies = [
    migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
    migrations.CreateModel(
        name='Category',
        fields=[
            ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('parentCatSlug', models.SlugField(blank=True, null=True)),
            ('categoryName', models.CharField(max_length=200, null=True)),
            ('categorySlug', models.SlugField(blank=True, null=True)),
            ('parentCategoryName', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='posts.Category')),
        ],
        options={
            'verbose_name_plural': 'categories',
        },
    ),
    migrations.CreateModel(
        name='Comment',
        fields=[
            ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('title', models.CharField(max_length=200)),
            ('pub_date', models.DateTimeField(default=django.utils.timezone.now)),
            ('body', models.CharField(max_length=200)),
            ('approved_comment', models.BooleanField(default=True)),
            ('author', models.ForeignKey(default=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
        ],
    ),
    migrations.CreateModel(
        name='Post',
        fields=[
            ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('title', models.CharField(max_length=200)),
            ('summary', models.CharField(default=True, max_length=500)),
            ('body', ckeditor_uploader.fields.RichTextUploadingField()),
            ('pub_date', models.DateTimeField(default=django.utils.timezone.now)),
            ('titleSlug', models.SlugField(blank=True)),
            ('authorSlug', models.SlugField(blank=True)),
            ('editedimage', imagekit.models.fields.ProcessedImageField(null=True, upload_to='primary_images')),
            ('show_in_posts', models.BooleanField(default=True)),
            ('author', models.ForeignKey(default=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='posts.Category')),
        ],
    ),
    migrations.CreateModel(
        name='Profile',
        fields=[
            ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('bio', models.TextField(blank=True, max_length=500)),
            ('location', models.CharField(blank=True, max_length=30)),
            ('birth_date', models.DateField(blank=True, null=True)),
            ('slug', models.SlugField(default='', unique=True)),
            ('profile_picture', models.ImageField(blank=True, upload_to='profile_images')),
            ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
        ],
    ),
    migrations.AddField(
        model_name='comment',
        name='post',
        field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='posts.Post'),
    ),
]

```