No changes detected in app 'learning_logs' - python

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):
...

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/

The model TokenProxy is already registered in app 'authtoken'

I am facing this problem with migrating in Django admin after I updated the app name 'rest_framework.authtoken' in django project settings.
It gives me error The model TokenProxy is already registered in app 'authtoken'.
I know I should have added this and migrate before creating super user but now I have already created the project and migrated lots of models and there is a data in it. Can help me how I can resolve this problem.
I also tried to undo migrations with command python manage.py migrate books but it again does not recognize the word books.
Please help me with this.
Here is my apps in settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts',
'traderskamp_app',
'rest_framework.authtoken',
'rest_framework',
'corsheaders',
]
Here is the exact error:
File "C:\Python39\lib\site-packages\rest_framework\authtoken\admin.py", line 51, in
admin.site.register(TokenProxy, TokenAdmin)
File "C:\Users\Anwar\AppData\Roaming\Python\Python39\site-packages\django\contrib\admin\sites.py", line 126, in register
raise AlreadyRegistered(msg)
django.contrib.admin.sites.AlreadyRegistered: The model TokenProxy is already registered in app 'authtoken'.
might be a bit late but I would search your project for this.
admin.site.register(TokenProxy)
you are likely registering TokenProxy somewhere in your code and that is causing a conflict with authtoken

A folder for multiple django apps

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"

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.

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