Yotam Yotam - 1 year ago 38
Python Question

setting setting apps value in django for a new application

So I've been following django tutorial and things worked well, but then I decided to try and write my own apps following the tutorial. I created a view, and updated the /

file with this section


However, when I save the file, I get an error from the running server:

ImportError: No module named PressentConfig

If I change the first line above to only


I get no error message. On the other hand, with the tutorial example, things work with the line


version is supposed to be 1.9.6

>>> import django
>>> django.VERSION
(1, 9, 6, 'final', 0)

What is going on here?

The solution was to edit
and add

class PressentConfig(AppConfig):
name = 'pressent'

The reason to the problem was I changed the folder name.


I'm going to presume pressent is your django application name (project name I think is pysent), so there's a directory named pressent and inside it has a apps.py file, and finally that file has a class named PressentConfig.

PressentConfig class example:

from django.apps import AppConfig

class PressentConfig(AppConfig):
    name = 'pressent'

    # Exec some configs for this app. Maybe overriding the ready method