# table blog\_post has no column named author\_id

**URL:** <https://forum.djangoproject.com/t/table-blog-post-has-no-column-named-author-id/22731>\
**Category:** Using the ORM\
**Created:** [August 2, 2023, 7:51pm UTC](https://forum.djangoproject.com/t/table-blog-post-has-no-column-named-author-id/22731 "2023-08-02T19:51:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![strikeouts27](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/strikeouts27/32/13899_2.png) [@strikeouts27](https://forum.djangoproject.com/u/strikeouts27)\
**Post date:** [August 2, 2023, 7:51pm UTC](https://forum.djangoproject.com/t/table-blog-post-has-no-column-named-author-id/22731/1 "2023-08-02T19:51:54Z")

</div>

Hello Django Forum!

I have a project that I am working on and the error message reads

# OperationalError at /admin/blog/post/add/

table blog\_post has no column named author\_id

| Request Method: | POST |
| --- | --- |
| Request URL: | [http://127.0.0.1:8000/admin/blog/post/add/](http://127.0.0.1:8000/admin/blog/post/add/) |
| Django Version: | 4.2.3 |
| Exception Type: | OperationalError |
| Exception Value: | table blog\_post has no column named author\_id |

Here is my models.py

```auto
from django.db import models
from django.urls import reverse 

# Create your models here.

class Post(models.Model):
    # primary key automatically placed here auto incrementing.
    title = models.CharField(max_length=200)
    author = models.ForeignKey(
        "auth.User",
        on_delete=models.CASCADE,
    )
    body = models.TextField()

    # this function will make a human readable version of the title field of any blog post.
    def __str__ (self):
        return self.title
    
    """We also add a get_absolute_url() method, which we haven't seen before, that tells Django how
    to calculate the canonical URL for our model object. It says to use the URL named post_detail and pass in the pk"""
    
    def get_absolute_url(self): # new 
        return reverse("post_detail", kwargs={"pk": self.pk})
    

```

I thought django gave id’s when they created tables. If I want to create an author id column for table\_blog post how would I do that?

Per the instructions it says that I will have an error if I DO NOT enter in an author name and that I can set the values to null.

When I access the Django admin interface to add a post it has me fill in a title box, an author box, and an body box. when i select the drop down for author it does not let me create a new author, it instead tells me I can add in users as authors. I try to complete the process of filling in the fields and using a user and it results in an error.

> **[Model field reference | Django documentation](https://docs.djangoproject.com/en/4.2/ref/models/fields/#field-options)**
>
> The web framework for perfectionists with deadlines.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 2, 2023, 8:11pm UTC](https://forum.djangoproject.com/t/table-blog-post-has-no-column-named-author-id/22731/2 "2023-08-02T20:11:47Z")

</div>

Did you run makemigrations and migrate after adding this column to your model?

Also in the future, if you’re requesting assistance with an error you are receiving, please post the complete error message with the traceback from the console where you’re running Django and _not_ the excerpt from the browser page showing the error.

---

<div class="post-metadata">

**Author:** ![strikeouts27](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/strikeouts27/32/13899_2.png) [@strikeouts27](https://forum.djangoproject.com/u/strikeouts27)\
**Post date:** [August 2, 2023, 10:19pm UTC](https://forum.djangoproject.com/t/table-blog-post-has-no-column-named-author-id/22731/3 "2023-08-02T22:19:00Z")

</div>

Drats. One minute I fail to post the error message at all, than I post the wrong error message, I am sorry I will try to create a step by step sheet to reference before posting on django chat.

Whenever I make a change to my models.py I need to make a migration? It seems I need to write that fact down when I troubleshoot.

Your solution worked, thank you Ken!

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 3, 2023, 1:43am UTC](https://forum.djangoproject.com/t/table-blog-post-has-no-column-named-author-id/22731/4 "2023-08-03T01:43:33Z")

</div>

> [@strikeouts27](#):
>
> Whenever I make a change to my models.py I need to make a migration?

Yes, it’s documented in the tutorial

See [Writing your first Django app, part 2 | Django documentation | Django](https://docs.djangoproject.com/en/4.2/intro/tutorial02/#activating-models)
