# type object 'object' has no attribute '\_meta'

**URL:** <https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674>\
**Category:** Mystery Errors\
**Created:** [April 27, 2025, 7:37pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674 "2025-04-27T19:37:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![symphoneyyy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/symphoneyyy/32/28206_2.png) [@symphoneyyy](https://forum.djangoproject.com/u/symphoneyyy)\
**Post date:** [April 27, 2025, 7:37pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/1 "2025-04-27T19:37:54Z")

</div>

i just wanna have a similar logentry like history in admin page in my own page instead of admin pages. and now it just shows ‘type object ‘object’ has no attribute ‘\_meta’’.

view.py

```auto
    res = dict()
    res['objects'] = LogEntry.objects.all()  
    LogEntry.objects.log_action(
        user_id=request.user.pk,  
        content_type_id=get_content_type_for_model(object).pk, 
        object_id=object.pk, 
        object_repr=object. __repr__ (),
        action_flag=CHANGE,
        change_message=''oooops"
    )
    return render(request, 'homePage.html', {"objects": object})

```

html

```auto
<tbody>
                        {% for i in objects %}
                        <tr>
                            <td>{{ i.action_time }}</td>
                            <td>{{ i.object_repr }}</td>
                            <td>{{ i.object_id }}</td>
                            <td>{{ i.get_action_flag_display }}</td>
                            <td>{{ i.user }}</td>
                            <td>{{ i.change_message }}</td>
                        </tr> {% endfor %}
                    </tbody>

```

---

<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:** [April 27, 2025, 7:44pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/2 "2025-04-27T19:44:27Z")

</div>

When requesting assistance with an error.

- Please post the **complete** error message with the traceback (posted as preformatted text, just like code)
- Post the **complete** view and templates involved

> [@symphoneyyy](#):
>
> ```auto
> change_message=''oooops"
> 
> ```

You have mismatched quotes here. You have two apostrophes (') at the beginning of `oooops` instead of a quote character (").

---

<div class="post-metadata">

**Author:** ![symphoneyyy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/symphoneyyy/32/28206_2.png) [@symphoneyyy](https://forum.djangoproject.com/u/symphoneyyy)\
**Post date:** [April 27, 2025, 8:00pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/3 "2025-04-27T20:00:11Z")

</div>

Request Method: GET  
Request URL: [http://127.0.0.1:8000/](http://127.0.0.1:8000/)

Django Version: 5.1.6  
Python Version: 3.10.5  
Installed Applications:  
[‘django.contrib.admin’,  
‘django.contrib.auth’,  
‘django.contrib.contenttypes’,  
‘django.contrib.sessions’,  
‘django.contrib.messages’,  
‘django.contrib.staticfiles’,  
‘Bishe.apps.BisheConfig’,  
‘helloWorld.apps.HelloworldConfig’]  
Installed Middleware:  
[‘django.middleware.security.SecurityMiddleware’,  
‘django.contrib.sessions.middleware.SessionMiddleware’,  
‘django.middleware.common.CommonMiddleware’,  
‘django.middleware.csrf.CsrfViewMiddleware’,  
‘django.contrib.auth.middleware.AuthenticationMiddleware’,  
‘django.contrib.messages.middleware.MessageMiddleware’,  
‘django.middleware.clickjacking.XFrameOptionsMiddleware’]

Traceback (most recent call last):  
File “E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\core\handlers\exception.py”, line 55, in inner  
response = get\_response(request)  
File “E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\core\handlers\base.py”, line 197, in \_get\_response  
response = wrapped\_callback(request, \*callback\_args, \*\*callback\_kwargs)  
File “E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\auth\decorators.py”, line 60, in \_view\_wrapper  
return view\_func(request, \*args, \*\*kwargs)  
File “E:\DEV Tools\Workspace\djangoProject\Bishe\views.py”, line 25, in homePage  
content\_type\_id=get\_content\_type\_for\_model(object).pk, # 对应数据库Model的id  
File “E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\admin\options.py”, line 93, in get\_content\_type\_for\_model  
return ContentType.objects.get\_for\_model(obj, for\_concrete\_model=False)  
File “E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\contenttypes\models.py”, line 41, in get\_for\_model  
opts = self.\_get\_opts(model, for\_concrete\_model)  
File “E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\contenttypes\models.py”, line 29, in \_get\_opts  
return model.\_meta

Exception Type: AttributeError at /  
Exception Value: type object ‘object’ has no attribute ‘\_meta’

these are the full error message.  
and thx for finding bug in change\_message .i’ve gotten it right 🙂

---

<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:** [April 27, 2025, 8:03pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/4 "2025-04-27T20:03:08Z")

</div>

This is the summary page shown in the browser. It’s not as complete or as helpful as the traceback provided on the console.

And, we still need to see the complete view and template.

---

<div class="post-metadata">

**Author:** ![symphoneyyy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/symphoneyyy/32/28206_2.png) [@symphoneyyy](https://forum.djangoproject.com/u/symphoneyyy)\
**Post date:** [April 27, 2025, 8:06pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/5 "2025-04-27T20:06:02Z")

</div>

and if this error is related to Django version? i searched some tutorials they are using object\_repr, but in IDE it just shows no such Unresolved Reference object\_repr.

---

<div class="post-metadata">

**Author:** ![symphoneyyy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/symphoneyyy/32/28206_2.png) [@symphoneyyy](https://forum.djangoproject.com/u/symphoneyyy)\
**Post date:** [April 27, 2025, 8:10pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/6 "2025-04-27T20:10:58Z")

</div>

errors in console

```auto
Internal Server Error: /
Traceback (most recent call last):
  File "E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
  File "E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\auth\decorators.py", line 60, in _view_wrapper
    return view_func(request, *args, **kwargs)
  File "E:\DEV Tools\Workspace\djangoProject\Bishe\views.py", line 25, in homePage
    content_type_id=get_content_type_for_model(object).pk, # 对应数据库Model的id
  File "E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\admin\options.py", line 93, in get_content_type_for_model
    return ContentType.objects.get_for_model(obj, for_concrete_model=False)
  File "E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\contenttypes\models.py", line 41, in get_for_model
    opts = self._get_opts(model, for_concrete_model)
  File "E:\DEV Tools\Workspace\djangoProject\venv\lib\site-packages\django\contrib\contenttypes\models.py", line 29, in _get_opts
    return model._meta
AttributeError: type object 'object' has no attribute '_meta'
[28/Apr/2025 04:07:03] "GET / HTTP/1.1" 500 86315

```

html

```auto
<table class="table table-bordered" style="width: 60%;margin-left: 20%;text-align: center">
                    <caption style="text-align: center">
                    <span style="font-size: large;color: black">【<span style="color: pink">{{ client.name }}</span> </span>
                    </caption>
                    <thead>
                        <tr style="background-color: #cdd8e5">
                        <th style="width: 100px;text-align: center">操作时间</th>
                        <th style="width: 200px;text-align: center">操作对象</th>
                        <th style="width: 50px;text-align: center">对象id</th>
                        <th style="width: 100px;text-align: center">动作标志</th>
                        <th style="width: 100px;text-align: center">操作用户</th>
                        <th style="width: 300px;text-align: center">修改内容</th>
                    </tr>
                    </thead>
                    <tbody>
                        {% for i in objects %}
                        <tr>
                            <td>{{ i.action_time }}</td>
                            <td>{{ i.object_repr }}</td>
                            <td>{{ i.object_id }}</td>
                            <td>{{ i.get_action_flag_display }}</td>
                            <td>{{ i.user }}</td>
                            <td>{{ i.change_message }}</td>
                        </tr> {% endfor %}
                    </tbody>
                </table>

```

view

```auto
def homePage(request):
    res = dict()
    res['objects'] = LogEntry.objects.all()
    LogEntry.objects.log_action(
        user_id=request.user.pk, 
        content_type_id=get_content_type_for_model(object).pk,  
        object_id=object.pk,  
        object_repr=object_repr, 
        action_flag=CHANGE, 
        change_message='ooops' 
    )
    return render(request, 'homePage.html')

```

---

<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:** [April 27, 2025, 8:12pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/7 "2025-04-27T20:12:50Z")

</div>

> [@symphoneyyy](#):
>
> ```auto
> content_type_id=get_content_type_for_model(object).pk,
> ^^^^^^
> 
> ```

The variable named “object” isn’t defined in this function.

---

<div class="post-metadata">

**Author:** ![symphoneyyy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/symphoneyyy/32/28206_2.png) [@symphoneyyy](https://forum.djangoproject.com/u/symphoneyyy)\
**Post date:** [April 27, 2025, 8:23pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/9 "2025-04-27T20:23:24Z")

</div>

thx a lot. i have known what i need to do.

btw, may i have your idea about how to achieve my purpose about showing the operation history in my own page?

---

<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:** [April 27, 2025, 8:28pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/10 "2025-04-27T20:28:13Z")

</div>

You would need to provide specific details about what _exactly_ it is you’re looking to do here.

(Just referring to the “admin’s operation history” doesn’t provide nearly enough information about what you’re looking to show. For example, are you just looking to dump _all_ admin activity? Activity on specific models? Are you looking to track activities performed outside the admin?)

---

<div class="post-metadata">

**Author:** ![symphoneyyy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/symphoneyyy/32/28206_2.png) [@symphoneyyy](https://forum.djangoproject.com/u/symphoneyyy)\
**Post date:** [April 27, 2025, 8:33pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/11 "2025-04-27T20:33:06Z")

</div>

yes, i just want to have a form to show all users’ activity like auth change or delete a account with their name, id ,when did this activity.  
it’s quite simple to show in admin page, but i got no idea about how to do it in my own page ☹

---

<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:** [April 27, 2025, 8:36pm UTC](https://forum.djangoproject.com/t/type-object-object-has-no-attribute-meta/40674/12 "2025-04-27T20:36:32Z")

</div>

The [LogHistory model is a model like any other](https://github.com/django/django/blob/0ee06c04e0256094270db3ffe8b5dafa6a8457a3/django/contrib/admin/models.py#L57). You would query it and render the results of the query exactly like any other model.
