I am trying to deploy my app to heroku and I keep getting this error even though when I run locally it works perfectly fine. I have added django-pwa==1.0.10 to my requirments.txt file also so that heroku installs the package. Here are my 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',
'pwa',
# 'embed_video',
'whitenoise.runserver_nostatic',
'courses.apps.CoursesConfig',
'accounts.apps.AccountsConfig',
'announcements.apps.AnnouncementsConfig',
'students.apps.StudentsConfig',
'home.apps.HomeConfig',
'event_calendar.apps.EventCalendarConfig',
]
Here is my directory
Not really sure what to do as I am not very experienced with heroku.
By default Heroku will try to install every app from your requirements.txt, so before going any further make sure of the following:
You have run pip freeze > requirements.txtto reflect the change
Your path for the Procfile is correct
If it does not work after the troubleshooting, add your log from heroku to your first question, your procfile and requirements.txt.
Learning about procfile
Related
Those are my installed applications:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'stu',
'stu2',
]
When using magane.py makemigrations I get those errors (I'm using Ubuntu):
ashish#ashish-MS-1050:~/Desktop/aculance/test1$ python3 manage.py makemigrations stu
No installed app with label 'stu'.
ashish#ashish-MS-1050:~/Desktop/aculance/test1$ python3 manage.py makemigrations stu2
No installed app with label 'stu2'.
I tried many times to apply migrations but it can't recognise my app
and gives me this error:
No installed app with label 'stu'.
I am attempting Django Channels for the first time. I am following this tutorial - https://www.youtube.com/watch?v=cw8-KFVXpTE&t=21s - which basically explains Channels basics. I installed Channels in my virual environment using pip install channels and it installed the latest version, which is 4.0.0. I have laid out the basic setup. But when I run python manage.py runserver, I get -
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
January 10, 2023 - 02:37:40
Django version 4.1.3, using settings 'BrokerBackEnd.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
when I shoul be getting this -
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
January 10, 2023 - 02:37:40
Django version 4.1.3, using settings 'BrokerBackEnd.settings'
Starting ASGI/Channels version 4.0.0 development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
I cannot figure out what I might be doing wrong here and I cannot find any relevant solution anywhere. I would really appreciate any suggestions anyone might have.
settings.py
INSTALLED_APPS = [
'channels',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework',
'Orders',
]
ASGI_APPLICATION = "BrokerBackEnd.asgi.application"
asgi.py
import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
import Orders.routing as route
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'BrokerBackEnd.settings')
application = ProtocolTypeRouter({
'http': get_asgi_application(),
'websocket': URLRouter(
route.websocket_urlpatterns
)
})
consumer.py
class OrderConsumer(WebsocketConsumer):
def connect(self):
self.accept()
def receive(self, text_data=None, bytes_data=None):
self.send(text_data="Message = " + text_data)
def disconnect(self, code):
return super().disconnect(code)
routing.py
websocket_urlpatterns = [
re_path(r"socket/order/", OrderConsumer.as_asgi())
]
As of django-channels 4.0.0 the daphne server was decoupled from the rest of channels. Now, you need to include daphne in your settings.py INSTALLED_APPS if you wish to use it. Include this at the top of your installed apps. The tutorial you are looking at uses an older version of channels.
INSTALLED_APPS = [
'daphne',
'channels',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework',
'Orders',
]
ASGI_APPLICATION = "BrokerBackEnd.asgi.application"
Also, make sure daphne is actually installed:
pip install -U channels["daphne"]
I am trying to set up django-toolbar in my production site, so just certain IPs can use it. I have followed the official documentation (install and quick setup), but I can't see the toolbar.
The app is installed:
$ yolk -l | grep toolbar
django-debug-toolbar - 0.11.0 - active
I have added the required settings:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.sitemaps',
'modeltranslation',
'djangocms_text_ckeditor',
'cms',
'mptt',
'menus',
'south',
'sekizai',
'debug_toolbar',
# more stuff...
)
INTERNAL_IPS = ('---.---.---.---',) # my current ip, taken from the server logs so I'm sure it's correct
STATIC_URL = '/static/'
DEBUG = True
There's no error message. I have also run collectstatic just in case. No success.
Any suggestion? Thanks :-)
EDIT: it seems that the order within INSTALLED_APPS matters. Moving 'debug_toolbar' right after all 'django.contrib.*' and before 'modeltranslation' and the others solved the issue.
Have you set the INTERNAL_IPS to what is in request.META['REMOTE_ADDR'] (second answer here)?
I had a similar problem, the toolbar wasn't displaying and I couldn't figure out why. But when I printed request.META['REMOTE_ADDR'] my IP wasn't what I thought it was! (because I was using port forwarding and virtual box).
I found out the reason. Within INSTALLED_APPS, 'debug_toolbar' must appear as soon as possible. I had placed some other applications before ('modeltranslation', 'cms', etc.). Placing it just after all 'django.contrib.*' and before the others works fine.
I am trying to follow the Django tutorial and I faced the following error when I enter python manage.py makemigrations polls
Unknown command: 'makemigrations'
Here's the link to the tutorial and I accomplished all the previous steps successfully and I am not sure what's going wrong now or how to fix it.
P.S.: I have already included "polls" in the INSTALLED_APPS!
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
'South',
)
Answer: I had to modify INSTALLED_APPS to :
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
)
and also used this command: python manage.py syncdb
Migrations were first added in version 1.7, officially released on September 2, 2014. You need to make sure your tutorial matches the version of Django you're working with. For instance, this version of the tutorial covers 1.9:
https://docs.djangoproject.com/en/1.9/intro/tutorial01/
Or, if you're using an older version of Django, you can change the "1.9" in that URL to whatever version you're on (back to 1.3). Or use the dropdown on the docs page to pick the version and search for "tutorial".
Find out what version of django you're running (thanks #BradyEmerson):
python -c "import django; print(django.get_version())"
If older than 1.8:
pip install --upgrade django
I was using version 1.9 and still getting this error. I had unapplied migrations and that was the root cause in my case. I ran 'python manage.py migrate' to apply them and it worked for me.
In django makemigration added after 1.7 so if you are using older version of Django then you have to change settings.py and add your application in installed app like
INSTALLED_APPS = (
'Demo',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
and then you can run command
python manage.py syncdb
You need to load the virtual environment before doing it.
Use below code for Linux/OSX:
source venv/bin/active
And the following code for Windows
source venv/Scripts/activate
I did following (for python version 3.6.4) to get this issue resolved:
install virtualenv
Activate virtualenv
Cheers
This worked for me: using ubuntu 20.04, Django 3.2
First after creating the model and addind to the setting, I did:
python manage.py makemigrations
I obtained the migration number here.
After that I did:
python manage.py sqlmigrate [NAME_OF_MODEL] [NUMBER_OF_THE_MIGRATION]
Finally:
python manage.py migrate
First time I add following piece of code into project_name\settings.py file.
`INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#Django REST Framework
'rest_framework',
#Games application
'games.apps.GamesConfig',
]`
After save it, when run following code I got error.
`python manage.py makemigrations games`
Then I check the settings.py file I realize that there are two INSTALLED_APPS and second one has not followings. When I added these the code worked.
`#Django REST Framework
'rest_framework',
#Games application
'games.apps.GamesConfig',`
I'm trying to install Django Gerbi-CMS and getting no luck. I've got through the installation a couple of times and not getting anywhere. When I run the server I get the error:
No module named pages.urls
When I install it tells me that it's installed correctly. However I look in the python2.7/site-packages and pages is not in there.
I installed on an existing site a while ago and I can't see what different other than pages and the other depencencies not showing in the above directory.
The last command I ran to install the package was:
$ sudo pip install django-page-cms
which like I said installed but nothing showing up in my site-packages.
Link to site - http://packages.python.org/django-page-cms/installation.html
SETTINGS:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
#'authority',
'pages',
'south',
'blog',
)
URLs:
if settings.DEBUG:
urlpatterns += patterns('',
# Trick for Django to support static files (security hole: only for Dev environement! remove this on Prod!!!)
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
url(r'^admin_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.ADMIN_MEDIA_ROOT}),
)
urlpatterns += patterns('',
(r'^', include('pages.urls')),
)
If you need any other info please let me know.
Thanks!
After going through the installtion process several times I worked out that because I was using 'sudo' it was installing on the server and not inside the virtualenv!
So when you install the app you need to Install it without sudo, otherwise it will install outside of the virtualenv!
Did you included the application in your settings.py file in the section called
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'mptt',
'tagging',
'pages', # You have to include it here
)