title: Django AttributeError: type object 'Rooms' has no attribute 'objects'
body: <p>When trying to query or adding any data in the modals, I get the error saying <code>type object 'Rooms' has no attribute 'objects'</code>. Here's what I have:</p>
  
  <p>Home/models.py:</p>
  
  <pre><code>class Rooms(models.Model):
      room_no = models.AutoField(primary_key=True)
      room_name = models.TextField(max_length=40)
  </code></pre>
  
  <p>Home/url.py:</p>
  
  <pre><code>from django.urls import path
  from .views import HomePage, EnergyGeneration, RoomPage
  
  urlpatterns = [
      path('', HomePage.as_view(), name='homepage'),
      path('energy', EnergyGeneration.as_view(), name='energygeneration'),
      path('room/&lt;int:room_no&gt;/', RoomPage.as_view(), name='roompage'),
  ]
  </code></pre>
  
  <p>MainProjectApp/urls.py:</p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path, include
  from .forms import UpdatedLoginView
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('', include('Home.url')),
      path('accounts/login/', UpdatedLoginView.as_view()),
      path('accounts/', include('django.contrib.auth.urls')),
  ]
  </code></pre>
  
  <p>Home/views.py:</p>
  
  <pre><code>from Home.models import Rooms, Plugs, PlugElectricityConsumption, EnergyGeneration, EnergyMode, Battery, PowerTransaction, PowerGeneration
  
  class HomePage(TemplateView):
      template_name = 'home/index.html'
  
      def get(self, request, *args, **kwargs):
          rooms = Rooms.objects.all()
          ......
          ......
          return render(request, self.template_name)
  </code></pre>
  
  <p>Here's a full stacktrace of the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "E:\Uni\Year 3\Professional Development\Esteem_v2\venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
      response = get_response(request)
    File "E:\Uni\Year 3\Professional Development\Esteem_v2\venv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
      response = self.process_exception_by_middleware(e, request)
    File "E:\Uni\Year 3\Professional Development\Esteem_v2\venv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File "E:\Uni\Year 3\Professional Development\Esteem_v2\venv\lib\site-packages\django\views\generic\base.py", line 71, in view
      return self.dispatch(request, *args, **kwargs)
    File "E:\Uni\Year 3\Professional Development\Esteem_v2\venv\lib\site-packages\django\views\generic\base.py", line 97, in dispatch
      return handler(request, *args, **kwargs)
    File "E:\Uni\Year 3\Professional Development\Esteem_v2\Home\views.py", line 62, in get
      rooms = Rooms.objects.all()
  
  Exception Type: AttributeError at /
  Exception Value: type object 'Rooms' has no attribute 'objects'
  </code></pre>
  
  <p>If I try to query these modals from Python console, it works:</p>
  
  <pre><code>from Home.models import Rooms
  Rooms.objects.all()
  &lt;QuerySet [&lt;Rooms: Rooms object (1)&gt;]&gt;
  </code></pre>
  
  <p>But in Django it doesn't. I cannot figure out what is going on.</p>
  
  <h2>Edit</h2>
  
  <p>Here is the result of print(type(Rooms)) and print(dir(Rooms)):</p>
  
  <pre><code>&lt;class 'type'&gt;
  
  ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__mod
  ule__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_allowed_methods', 'as_view', 'content_type', 'dis
  patch', 'extra_context', 'get', 'get_context_data', 'get_template_names', 'http_method_names', 'http_method_not_allowed', 'options', 'render_to_response', 'response_class', 'setup', 'template_engine
  ', 'template_name']
  </code></pre>