A folder for multiple django apps - python

I'm trying to change the structure of my project. In fact, I would like to have an apps folder where I can stock all my project's apps.
In this case I making a member app into the given folder. If I try to run the project I have this error:
django.core.exceptions.ImproperlyConfigured: Cannot import 'member'. Check that 'apps.member.apps.MemberConfig.name' is correct.
In my settings.py I configured my INSTALLED_APPS as follow:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'apps.member.apps.MemberConfig',
]
Basically, I just want to have the following folder structure:
project_folder/
___ apps/
___ config/
For the rest of the settings folder here is the GIST
More information:
Django version : 1.11
Python version: 3.5.2
OS: Ubuntu 16

Change "apps.member.apps.MemberConfig" to "apps.member"

Related

how to solve this problem in virtual environment?

i want to activate my models in my files, my code in terminal:
(env) PS C:\Users\MadYar\Desktop\code.py\learning_log> python manage.py makemigrations learning_logs
error:
No changes detected in app 'learning_logs'
im using django to make a web application and i add models in my settings.py like that:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'learning_logs'
]
i dont know why it sais no changes detected in app 'learning_logs'
add empty __init__.py in learning_logs folder.
check if you have any models.py in learning_logs folder.
add some models, which inherited from django.models.Model:
from django import models
class MyModel(models.Model):
myfield = models.Charfield(max_length=255)
call python manage.py makemigrations learning_logs
if you see No changes detected in app 'learning_logs' again, try to read the tutorial, especially this part: https://docs.djangoproject.com/en/4.0/intro/tutorial02/

No changes detected in app 'learning_logs'

I ran the code settings.py and went to INSTALLED APPS and added learning_logs:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'learning_logs',
Then in the terminal I ran 'python manage.py makemigrations learning_logs'
However it results in 'No changes detected in app 'learning_logs'
Note that I read some other articles and got no good answer
Also note that the end bracket is supposed to be in the dictionary
You can try this:
Add __init__.py file into the app folder.
Make sure you have some models classes created in models.py file in the app
Please check your model definition and make sure that it inherits from django models.Model!
from django.db import models
class MyCustomModel(models.Model):
...

Django 1.10: Flatpage site migration runtime error

I'm currently beginning a project in Django 1.10, trying to use the included flat pages application. After installing the apps within my (base) settings file:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'first_app']
SITE_ID = 1 # for use with 'django.contrib.sites'
Yet when I run python manage.py migrate, the console returns the following error:
RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an
explicit app_label and isn't in an application in INSTALLED_APPS.
Can someone explain to me what is causing this error, when I clearly declared the app in my 'INSTALLED_APPS' list?
Thanks in advance for any advice!
NOTE: It may be worth noting that I'm using multiple settings files, but this code is within the base settings file (the other files change small things such as the DEBUG variable), but i've had no problems running the server or any other errors.

how to setup sites framework in django

I am trying to setup multiple sites from a single project in django. I was trying to set this up following https://docs.djangoproject.com/en/1.8/ref/contrib/sites/ but there is no mention of setup only how to use the sites framework once implemented.
I have implmented sites before and I added sites to my installed apps like this:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
)
I tried to issue the command: python manage.py makemigrations but it says:
No Changes detected
I'm using django 1.8 , does the sites framework setup still create a table called django_site ?
How do I do the initial setup to have this table created?
I guess I needed to just migrate instead of make migrate like this:
python manage.py migrate

Test Django app using models from a second app

When I run my Django tests for an app, only the models for that app are loaded.
My app has a dependency on a second app and requires that the tables for the second app's models be present in the database.
How is this achieved?
Each time your create an app, you need to add it to the installed apps, for do that open your setting file, and add your app to installed apps:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'your_test_app',
'here_goes_your_other_app'
)
Then close the server, run python manage.py syncdb and try.

Categories