Struggling with adding app to INSTALLED_APPS Django - django

I have no idea, this always worked for me, but without motivation, it's not working now.
what i did:
I created my project
I created my app
I added my config to INSTALLED_APPS
I get this error: django.core.exceptions.ImproperlyConfigured: 'champ.apps' does not contain a class 'ChampConfigcorsheaders'. Choices are: 'ChampConfig'.
My project looks like this:
Championship_3bi
champ
all the files of the app
Championship_3bi
all the files of the project
This is my settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'champ.apps.ChampConfig' #this is the line that create the "error"
'corsheaders',
]
I've also tried to do champ.apps.ChampConfigcorsheaders but it didnt work.
This is my champ/apps.py:
from django.apps import AppConfig
class ChampConfig(AppConfig):
name = 'champ'
i searched for everything but looks like i was the only one who get this error.
The reason why it does not work is for the weird name of my project?
Why it is not working for only this project?
im done

You are missing a ,:
'champ.apps.ChampConfig',
'corsheaders',

Related

AUTH_USER_MODEL reference in settings.py Django

I have a installed an app called 'Login', who have a folder 'models' inside, with a custom_user model. The problem occurs when I tried to configure settings.py, specially auth_user_model.
in installed apps I have the following:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'project_app.login'
]
and below
AUTH_USER_MODEL = 'login.models.CustomUser'
But I have the following error: "Invalid model reference. String model references must be of the form 'app_label.ModelName'." I put the .models in AUTH_USER_MODEL, because I want to reference the app that the CustomUser is inside the folder "models" in Login.
Also, I tried with declare like this:
AUTH_USER_MODEL = 'login.CustomUser'
but the error is this: 'AUTH_USER_MODEL refers to model 'login.CustomUser' that has not been installed'
The issue is with the way that your app is installed - based on your AUTH_USER_MODEL, login should be the name of the app. It is acceptable to contain Django apps within folders for organisation purposes - however, your parent folder is project_app which from the name also appears to be an app. It's hard to say for certain what the issue is without knowing your project structure but I would expect changing your installed apps to just project_app and your AUTH_USER_MODEL to project_app.CustomerUser should work.
If your app name is "login", you can proceed as follows:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
#apps
'login.apps.LoginConfig']
I think the model in your login application is as follows:
class CustomUser(AbstractBaseUser):
#some fields for customuser
and in settings.py:
AUTH_USER_MODEL = 'user.CustomUser'
AUTH_USER_MODEL = 'app_name.ModelName'

One Django app in a separate python package

Django==3.2.5
Have a look at this picture:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'clients',
'general',
'images',
'themes',
'omnibus',
'staticassets',
'categories',
'tags',
'articles',
]
When I run this, I get:
ModuleNotFoundError: No module named 'articles'
It is predictable as Django doesn't know where to find the app.
Then I tried like this:
INSTALLED_APPS = [
'dependencies.articles',
]
No success.
Here 'articles' is just an ordinary Django app like categories or clients. But I'd like to move it to 'depencencies' package. Why? I'd like to organize the code structure like this for as personal preferences. How can I cope with this problem, assuming it is technically possible?
cut the articles directory back to the main block project directory
as of now :
blog_project
|
|---dependencies
|
----- articles
needs to be :
blog_project
|
|---articles
get rid of the dependencie directory it no use

improperly configured app in settings.py of django

Tying to register my djano app in the settings section of my django project. but when i run the server i am getting an error in the terminal.
django.core.exceptions.ImproperlyConfigured: 'site1app.apps' does not contain a class 'Site1appConfig'. Choices are: 'Site1AppConfig'.
I dont know what's going wrong as i just added it to the list of installed apps in settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'site1app.apps.Site1appConfig',
]
This looks like a miss on the capitalization for your class
Change:
'site1app.apps.Site1appConfig'
To:
'site1app.apps.Site1AppConfig'

Django 1.10 - Plug new app into django

I have a trouble with plugging recently created app called pages into a django project.
My pages apps.py
from django.apps import AppConfig
class PagesConfig(AppConfig):
name = 'pages'
My settings.py, installed apps:
INSTALLED_APPS = [
'pages.apps.PagesConfig' # pages.apps.pages fails too
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
ImportError: No module named 'pages.apps.PagesConfigdjango';
'pages.apps' is not a package
Does anyonw knows what is wrong there? I did everything according the docs, but django still cannot to plug my app. Any insights appreciated.
You are missing a comma after your entry.
'pages.apps.PagesConfig',

django gravatar not getting picked up as a module - what am i doing wrong?

so here is my problem - the gravatar app (from google projects - here! http://code.google.com/p/django-gravatar/) in my django project crashed everything on startup.
i get this error Error: No module named gravatar
this is my installed apps:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'dumpstown.dumpstownapp',
'bootstrap_toolkit',
'registration',
'gravatar'
)
and from the console when i run this:
>> import sys
>> print sys.path
['', 'C:\\development\\python\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
'C:\\development\\python\\lib\\site-packages\\pip-1.1-py2.7.egg', 'C:\\developm
ent\\PycharmProjects\\lib\\gravatar', 'C:\\Windows\\system32\\python27.zip', 'C:
\\development\\python\\DLLs', 'C:\\development\\python\\lib', 'C:\\development\\
python\\lib\\plat-win', 'C:\\development\\python\\lib\\lib-tk', 'C:\\development
\\python', 'C:\\development\\python\\lib\\site-packages']
what am i missing here?
UPDATE
huh, weird. I've checked the gravatar folder, and i have
templatetags dir
__init__.py
models.py
views.py
also, if i change the installed apps section to read:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'dumpstown.dumpstownapp',
'bootstrap_toolkit',
'registration',
'templatetags'
)
then the server starts up fine and runs. But i... i'm all confused now! Am i meant to import the templatetags? or something else? how do i refer to the gravatar stuff if i'm importing templatetags??
EDIT: Solved.
I just don't understand how python works, it would seem! I was totally adding the wrong item to the pythonpath - i was adding C:\\development\\PycharmProjects\\lib\\gravatar, where i should have really been adding C:\\development\\PycharmProjects\\lib
this solved the problem, and now i can use gravatar as i want. The settings.py entry is as above in my first example (that is, just 'gravatar') and the way i use it is i just {% load gravatar %}
hurrah!
Possibly you checked out the trunk folder and have a structure like ..\gravatar\gravatar? The setup.py script should install it somewhere your path but you could also try changing C:\developm ent\PycharmProjects\lib\gravatar to C:\developm ent\PycharmProjects\lib\gravatar\gravatar
Totally adding the wrong item to the pythonpath - i was adding C:\development\PycharmProjects\lib\gravatar, where i should have really been adding C:\development\PycharmProjects\lib