H Abdullah
H Abdullah

Reputation: 53

Module in django

this error comes to me when i try to makemigrations in cmd:

ModuleNotFoundError: No module named 'homsapp.app'

virtualenv_name: repro project_name: homspro app_name:homsapp

models.py:

from django.db import models

class location(models.Module):
        location_name=models.CharField(max_length=200)
        location_type=models.CharField(max_length=200)

class propertyview(models.Model):
        location = models.ForeignKey(location,on_delete=models.CASCADE)
        property_name = models.CharField(max_length=200)
        property_area=models.CharField(max_length=200)

installed _apps in setting.py:

INSTALLED_APPS = [
    'homsapp.app.HomsappConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

Upvotes: 1

Views: 59

Answers (2)

cizario
cizario

Reputation: 4269

it's apps and NOT app

INSTALLED_APPS = [
    'homsapp.apps.HomsappConfig',
    ..
]

refer to https://docs.djangoproject.com/en/3.0/ref/applications/#for-application-users

Update

as @Alasdair stated in comments below, you've made a typo in this line

class location(models.Module):

it's Model and NOT Module

class location(models.Model):

and as good coding practices, it's recommended to capitalize your models' names since they are after all a classes, i.e. Location and PropertyView

Upvotes: 1

H Abdullah
H Abdullah

Reputation: 53

from django.db import models

class location(models.Model):

Upvotes: 0

Related Questions