OS: Windows 10
Now, for the project where the runserver command works I get this:
Here is my project structure. i have install all the requirements for this project but still getting this error. I've found something where there were errors with the run server command, but none were satisfying. If this is a duplicate, I do apologies, but I'm pretty sure it isn't. If there's a need for other files and snippets of code, I'll put here everything. Thank you so much.
D:.
| main.py
|
| README.md
|
+---BLL
| | asgi.py
| | requirements.txt
| | settings.py
| | urls.py
| | wsgi.py
| | __init__.py
| |
| \---__pycache__
| settings.cpython-37.pyc
| settings.cpython-39.pyc
| urls.cpython-37.pyc
| urls.cpython-39.pyc
| __init__.cpython-37.pyc
| __init__.cpython-39.pyc
|
+---DAL
| | db.sqlite3
| | __init__.py
| |
| +---account
| | | admin.py
| | | apps.py
| | | forms.py
| | | models.py
| | | tests.py
| | | views.py
| | | __init__.py
| | |
| | +---migrations
| | | | 0001_initial.py
| | | | __init__.py
| | | |
| | | \---__pycache__
| | | 0001_initial.cpython-38.pyc
| | | __init__.cpython-38.pyc
| | |
| | \---__pycache__
| | admin.cpython-37.pyc
| | admin.cpython-38.pyc
| | admin.cpython-39.pyc
| | apps.cpython-37.pyc
| | apps.cpython-38.pyc
| | apps.cpython-39.pyc
| | forms.cpython-38.pyc
| | models.cpython-37.pyc
| | models.cpython-38.pyc
| | models.cpython-39.pyc
| | views.cpython-38.pyc
| | __init__.cpython-37.pyc
| | __init__.cpython-38.pyc
| | __init__.cpython-39.pyc
| |
| \---chatbot
| | admin.py
| | apps.py
| | data.pickle
| | loadAI.py
| | models.py
| | session.json
| | tests.py
| | trainAI.py
| | views.py
| | __init__.py
| |
| +---migrations
| | 0001_initial.py
| | __init__.py
| |
| +---model
| | testmodel.h5
| |
| \---__pycache__
| admin.cpython-37.pyc
| admin.cpython-39.pyc
| apps.cpython-37.pyc
| apps.cpython-39.pyc
| models.cpython-37.pyc
| models.cpython-39.pyc
| trainAI.cpython-37.pyc
| trainAI.cpython-39.pyc
| views.cpython-37.pyc
| views.cpython-39.pyc
| __init__.cpython-37.pyc
| __init__.cpython-39.pyc
|
+---TESTS
| test.py
|
\---UI
| admin.py
| apps.py
| models.py
| tests.py
| urls.py
| views.py
| __init__.py
|
+---images
| 1.PNG
| 10.PNG
| 2.PNG
| 3.PNG
| 4.PNG
| 5.PNG
| 6.PNG
| 7.PNG
| 8.PNG
| 9.PNG
| chatbot.GIF
|
+---static
| \---UI
| +---audio
| | audio0.mp3
| | audio1.mp3
| | audio2.mp3
| | audio3.mp3
| |
| +---css
| | css-main.css
| | css-responsive.css
| |
| \---images
| bg.jpg
| landscape1.jpg
| logo.ico
| logo.jpg
| user.png
|
+---templates
| \---UI
| | base.html
| | index.html
| |
| +---errors
| | 404.html
| | 500.html
| |
| \---pages
| about.html
| account.html
| changepass-done.html
| changepass.html
| chatbot.html
| FAQs.html
| login.html
| signup.html
| update.html
|
\---__pycache__
admin.cpython-37.pyc
admin.cpython-39.pyc
apps.cpython-37.pyc
apps.cpython-39.pyc
models.cpython-37.pyc
models.cpython-39.pyc
urls.cpython-37.pyc
urls.cpython-39.pyc
views.cpython-37.pyc
views.cpython-39.pyc
__init__.cpython-37.pyc
__init__.cpython-39.pyc
I have clone this project from git hub when i use python main.py runserver command it givs me this error:
D:\Covid19Chatbot-master>python main.py runserver
Watching for file changes with StatReloader
Performing system checks...
2021-01-22 17:20:47.257952: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2021-01-22 17:20:47.263540: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
[nltk_data] Downloading package punkt to
[nltk_data] C:\Users\mehra\AppData\Roaming\nltk_data...
[nltk_data] Package punkt is already up-to-date!
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 395, in check
include_deployment_checks=include_deployment_checks,
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 407, in check
for pattern in self.url_patterns:
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Covid19Chatbot-master\BLL\urls.py", line 21, in <module>
path('', include('UI.urls')),
File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Covid19Chatbot-master\UI\urls.py", line 4, in <module>
from chatbot.views import (
File "D:\Covid19Chatbot-master\DAL\chatbot\views.py", line 6, in <module>
ai = TrainAI()
File "D:\Covid19Chatbot-master\DAL\chatbot\trainAI.py", line 24, in __init__
jsonContent = json.loads(res.content.decode())
File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The Error is from Lines 22-24 in trainAI
website = r"https://coronavirus-ph-api.herokuapp.com/total/"
res = requests.get(website)
jsonContent = json.loads(res.content.decode())
this website has no content and returns no json, thats why it cannot iterate through it and throws an error
Related
I want to get a django app running using djongo with mongo, and docker.
My setup looks like this:
docker-compose.yml
version: '3.7'
services:
webserver:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./webserver:/webserver
command: sh -c "python manage.py runserver 0.0.0.0:8000"
environment:
- DEBUG=1
links:
- mongo
depends_on:
- migration
mongo:
image: mongo:latest
restart: unless-stopped
volumes:
- ./mongo/data/db:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: mongoadmin
MONGO_INITDB_DATABASE: raspicam
ports:
- "27017:27017"
migration:
build: .
image: app
command: sh -c "python manage.py migrate"
volumes:
- ./webserver:/webserver
links:
- mongo
depends_on:
- make_migrations
make_migrations:
build: .
image: app
command: sh -c "python manage.py makemigrations"
volumes:
- ./webserver:/webserver
links:
- mongo
depends_on:
- mongo
Dockerfile:
FROM python:3.8-alpine
ENV PATH="/scripts:${PATH}"
ENV LIBRARY_PATH=/lib:/usr/lib
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache --virtual .tmp gcc libc-dev linux-headers jpeg-dev libjpeg-turbo
RUN apk add build-base python3-dev zlib-dev
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r /requirements.txt
RUN apk add libjpeg
RUN apk del .tmp
RUN mkdir /webserver
COPY ./webserver /webserver
WORKDIR /webserver
COPY ./scripts /scripts
RUN chmod +x /scripts/*
RUN mkdir -p /vol/web/media
RUN mkdir -p /vol/web/
RUN adduser -D user
RUN chown -R user:user /vol
RUN chmod -R 755 /vol/web
USER user
CMD ["entrypoint.sh"]
settings.py
DATABASES = {
"default": {
"ENGINE": "djongo",
"NAME": "raspicam",
"CLIENT": {
"host": "mongodb://mongodb:27017",
"username": "root",
"password": "mongoadmin",
"authSource": "admin",
"authMechanism": "SCRAM-SHA-1",
},
}
}
I already test on my local and it works.
but I try to dockerizing it. The issue is that when I 'docker-compose up' I get the following error.
Creating server_mongo_1 ... done
Creating server_make_migrations_1 ... done
Creating server_migration_1 ... done
Creating server_webserver_1 ... done
mongo_1 | Successfully added user: {
mongo_1 | "user" : "root",
mongo_1 | "roles" : [
mongo_1 | {
mongo_1 | "role" : "root",
mongo_1 | "db" : "admin"
mongo_1 | }
mongo_1 | ]
mongo_1 | }
mongo_1 | Error saving history file: FileOpenFailed Unable to open() file /home/mongodb/.dbshell: No such file or directory
make_migrations_1 | Traceback (most recent call last):
make_migrations_1 | File "manage.py", line 21, in <module>
make_migrations_1 | main()
make_migrations_1 | File "manage.py", line 17, in main
make_migrations_1 | execute_from_command_line(sys.argv)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
make_migrations_1 | utility.execute()
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
make_migrations_1 | self.fetch_command(subcommand).run_from_argv(self.argv)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
make_migrations_1 | self.execute(*args, **cmd_options)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
make_migrations_1 | output = self.handle(*args, **options)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped
make_migrations_1 | res = handle_func(*args, **kwargs)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
make_migrations_1 | loader.check_consistent_history(connection)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/loader.py", line 283, in check_consistent_history
make_migrations_1 | applied = recorder.applied_migrations()
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
make_migrations_1 | if self.has_table():
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 56, in has_table
make_migrations_1 | return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/introspection.py", line 48, in table_names
make_migrations_1 | return get_names(cursor)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/introspection.py", line 43, in get_names
make_migrations_1 | return sorted(ti.name for ti in self.get_table_list(cursor)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/djongo/introspection.py", line 47, in get_table_list
make_migrations_1 | for c in cursor.db_conn.list_collection_names()
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/database.py", line 863, in list_collection_names
make_migrations_1 | for result in self.list_collections(session=session, **kwargs)]
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/database.py", line 825, in list_collections
make_migrations_1 | return self.__client._retryable_read(
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1460, in _retryable_read
make_migrations_1 | server = self._select_server(
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1278, in _select_server
make_migrations_1 | server = topology.select_server(server_selector)
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 241, in select_server
make_migrations_1 | return random.choice(self.select_servers(selector,
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 199, in select_servers
make_migrations_1 | server_descriptions = self._select_servers_loop(
make_migrations_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 215, in _select_servers_loop
make_migrations_1 | raise ServerSelectionTimeoutError(
make_migrations_1 | pymongo.errors.ServerSelectionTimeoutError: mongodb:27017: [Errno -2] Name does not resolve, Timeout: 30s, Topology Description: <TopologyDescription id: 5fb23c4bc9495116fef1072a, topology_type: Single, servers: [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('mongodb:27017: [Errno -2] Name does not resolve')>]>
migration_1 | Traceback (most recent call last):
migration_1 | File "manage.py", line 21, in <module>
migration_1 | main()
migration_1 | File "manage.py", line 17, in main
migration_1 | execute_from_command_line(sys.argv)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
migration_1 | utility.execute()
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
migration_1 | self.fetch_command(subcommand).run_from_argv(self.argv)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
migration_1 | self.execute(*args, **cmd_options)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
migration_1 | output = self.handle(*args, **options)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped
migration_1 | res = handle_func(*args, **kwargs)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 87, in handle
migration_1 | executor = MigrationExecutor(connection, self.migration_progress_callback)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/executor.py", line 18, in __init__
migration_1 | self.loader = MigrationLoader(self.connection)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/loader.py", line 49, in __init__
migration_1 | self.build_graph()
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/loader.py", line 212, in build_graph
migration_1 | self.applied_migrations = recorder.applied_migrations()
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
migration_1 | if self.has_table():
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 56, in has_table
migration_1 | return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/introspection.py", line 48, in table_names
migration_1 | return get_names(cursor)
migration_1 | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/introspection.py", line 43, in get_names
migration_1 | return sorted(ti.name for ti in self.get_table_list(cursor)
migration_1 | File "/usr/local/lib/python3.8/site-packages/djongo/introspection.py", line 47, in get_table_list
migration_1 | for c in cursor.db_conn.list_collection_names()
migration_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/database.py", line 863, in list_collection_names
migration_1 | for result in self.list_collections(session=session, **kwargs)]
migration_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/database.py", line 825, in list_collections
migration_1 | return self.__client._retryable_read(
migration_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1460, in _retryable_read
migration_1 | server = self._select_server(
migration_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1278, in _select_server
migration_1 | server = topology.select_server(server_selector)
migration_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 241, in select_server
migration_1 | return random.choice(self.select_servers(selector,
migration_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 199, in select_servers
migration_1 | server_descriptions = self._select_servers_loop(
migration_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 215, in _select_servers_loop
migration_1 | raise ServerSelectionTimeoutError(
migration_1 | pymongo.errors.ServerSelectionTimeoutError: mongodb:27017: [Errno -2] Name does not resolve, Timeout: 30s, Topology Description: <TopologyDescription id: 5fb23c4c69a8bce7b564bf46, topology_type: Single, servers: [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('mongodb:27017: [Errno -2] Name does not resolve')>]>
server_make_migrations_1 exited with code 1
server_migration_1 exited with code 1
webserver_1 | Exception in thread django-main-thread:
webserver_1 | Traceback (most recent call last):
webserver_1 | File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
webserver_1 | self.run()
webserver_1 | File "/usr/local/lib/python3.8/threading.py", line 870, in run
webserver_1 | self._target(*self._args, **self._kwargs)
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/utils/autoreload.py", line 54, in wrapper
webserver_1 | fn(*args, **kwargs)
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
webserver_1 | self.check_migrations()
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 453, in check_migrations
webserver_1 | executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/executor.py", line 18, in __init__
webserver_1 | self.loader = MigrationLoader(self.connection)
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/loader.py", line 49, in __init__
webserver_1 | self.build_graph()
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/loader.py", line 212, in build_graph
webserver_1 | self.applied_migrations = recorder.applied_migrations()
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
webserver_1 | if self.has_table():
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 56, in has_table
webserver_1 | return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/introspection.py", line 48, in table_names
webserver_1 | return get_names(cursor)
webserver_1 | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/introspection.py", line 43, in get_names
webserver_1 | return sorted(ti.name for ti in self.get_table_list(cursor)
webserver_1 | File "/usr/local/lib/python3.8/site-packages/djongo/introspection.py", line 47, in get_table_list
webserver_1 | for c in cursor.db_conn.list_collection_names()
webserver_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/database.py", line 863, in list_collection_names
webserver_1 | for result in self.list_collections(session=session, **kwargs)]
webserver_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/database.py", line 825, in list_collections
webserver_1 | return self.__client._retryable_read(
webserver_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1460, in _retryable_read
webserver_1 | server = self._select_server(
webserver_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1278, in _select_server
webserver_1 | server = topology.select_server(server_selector)
webserver_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 241, in select_server
webserver_1 | return random.choice(self.select_servers(selector,
webserver_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 199, in select_servers
webserver_1 | server_descriptions = self._select_servers_loop(
webserver_1 | File "/usr/local/lib/python3.8/site-packages/pymongo/topology.py", line 215, in _select_servers_loop
webserver_1 | raise ServerSelectionTimeoutError(
webserver_1 | pymongo.errors.ServerSelectionTimeoutError: mongodb:27017: [Errno -2] Name does not resolve, Timeout: 30s, Topology Description: <TopologyDescription id: 5fb23c4d6fa2c64607ec6aee, topology_type: Single, servers: [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('mongodb:27017: [Errno -2] Name does not resolve')>]>
How can I solve this problem....
p.s what does this picture means?! is mongo working with docker?!
enter image description here
I have completed my Django Project using cookiecutter-django.
If I just locally run:
$ docker-compose -f local.yml build
$ docker-compose -f local.yml up
My project launches just fine in http://0.0.0.0:8000
Nonetheless, now I am trying to deploy it following this guide: https://realpython.com/development-and-deployment-of-cookiecutter-django-via-docker/
I have been able to create the local docker-machine with docker-machine create --driver virtualbox dev, activate it eval $(docker-machine env dev) and build the image, but if I run docker-compose -f local.yml up then I get the following error:
Attaching to innovacion_innsai_postgres_1, innovacion_innsai_django_1, innovacion_innsai_node_1
postgres_1 | 2020-03-12 09:14:42.686 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2020-03-12 09:14:42.686 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2020-03-12 09:14:42.688 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2020-03-12 09:14:42.702 UTC [21] LOG: database system was shut down at 2020-03-11 10:05:23 UTC
postgres_1 | 2020-03-12 09:14:42.732 UTC [1] LOG: database system is ready to accept connections
django_1 | PostgreSQL is available
django_1 | Traceback (most recent call last):
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
django_1 | return self.cursor.execute(sql, params)
django_1 | psycopg2.errors.UndefinedTable: relation "innovation_sector" does not exist
django_1 | LINE 1: ...n_sector"."id", "innovation_sector"."sector" FROM "innovatio...
django_1 | ^
django_1 |
django_1 |
django_1 | The above exception was the direct cause of the following exception:
django_1 |
django_1 | Traceback (most recent call last):
django_1 | File "manage.py", line 30, in <module>
django_1 | execute_from_command_line(sys.argv)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
django_1 | utility.execute()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
django_1 | self.fetch_command(subcommand).run_from_argv(self.argv)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
django_1 | self.execute(*args, **cmd_options)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 361, in execute
django_1 | self.check()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
django_1 | include_deployment_checks=include_deployment_checks,
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 65, in _run_checks
django_1 | issues.extend(super()._run_checks(**kwargs))
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
django_1 | return checks.run_checks(**kwargs)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
django_1 | new_errors = check(app_configs=app_configs)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
django_1 | return check_resolver(resolver)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
django_1 | return check_method()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 399, in check
django_1 | for pattern in self.url_patterns:
django_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
django_1 | res = instance.__dict__[self.name] = self.func(instance)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 584, in url_patterns
django_1 | patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
django_1 | res = instance.__dict__[self.name] = self.func(instance)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 577, in urlconf_module
django_1 | return import_module(self.urlconf_name)
django_1 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
django_1 | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
django_1 | File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
django_1 | File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
django_1 | File "<frozen importlib._bootstrap_external>", line 728, in exec_module
django_1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
django_1 | File "/app/config/urls.py", line 18, in <module>
django_1 | path("", include("innovacion_innsai.innovation.urls", namespace="innovation")),
django_1 | File "/usr/local/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
django_1 | urlconf_module = import_module(urlconf_module)
django_1 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
django_1 | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
django_1 | File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
django_1 | File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
django_1 | File "<frozen importlib._bootstrap_external>", line 728, in exec_module
django_1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
django_1 | File "/app/innovacion_innsai/innovation/urls.py", line 2, in <module>
django_1 | from innovacion_innsai.innovation import views
django_1 | File "/app/innovacion_innsai/innovation/views.py", line 9, in <module>
django_1 | from .analytics import alimentacion_cases, agro_cases, turismo_cases, movilidad_cases
django_1 | File "/app/innovacion_innsai/innovation/analytics.py", line 17, in <module>
django_1 | for case in Case.objects.filter(sector__sector=sectors[0]):
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 308, in __getitem__
django_1 | qs._fetch_all()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1242, in _fetch_all
django_1 | self._result_cache = list(self._iterable_class(self))
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 55, in __iter__
django_1 | results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1133, in execute_sql
django_1 | cursor.execute(sql, params)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 99, in execute
django_1 | return super().execute(sql, params)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
django_1 | return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
django_1 | return executor(sql, params, many, context)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
django_1 | return self.cursor.execute(sql, params)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
django_1 | raise dj_exc_value.with_traceback(traceback) from exc_value
django_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
django_1 | return self.cursor.execute(sql, params)
django_1 | django.db.utils.ProgrammingError: relation "innovation_sector" does not exist
django_1 | LINE 1: ...n_sector"."id", "innovation_sector"."sector" FROM "innovatio...
django_1 | ^
django_1 |
innovacion_innsai_django_1 exited with code 1
node_1 |
node_1 | > innovacion_innsai#1.1.0 dev /app
node_1 | > gulp
node_1 |
node_1 | [09:14:48] Using gulpfile /app/gulpfile.js
node_1 | [09:14:48] Starting 'default'...
node_1 | [09:14:48] Starting 'styles'...
node_1 | [09:14:48] Starting 'scripts'...
node_1 | [09:14:48] Starting 'imgCompression'...
node_1 | [09:14:48] gulp-imagemin: Minified 0 images
node_1 | [09:14:48] Finished 'imgCompression' after 34 ms
node_1 | [09:14:48] Finished 'scripts' after 128 ms
node_1 | [09:14:49] Finished 'styles' after 1.09 s
node_1 | [09:14:49] Starting 'initBrowserSync'...
node_1 | [09:14:49] Starting 'watchPaths'...
node_1 | [Browsersync] Proxying: http://django:8000
node_1 | [Browsersync] Access URLs:
node_1 | -----------------------------------
node_1 | Local: http://localhost:3000
node_1 | External: http://172.20.0.4:3000
node_1 | -----------------------------------
node_1 | UI: http://localhost:3001
node_1 | UI External: http://localhost:3001
node_1 | -----------------------------------
In case it might be relevant, if I visit the docker-machine's IP adreess and port (http://192.168.99.101:2376) before launching docker-compose build o up, the page displays "Client sent an HTTP request to an HTTPS server."
Here is my 'local.yml':
version: '3'
volumes:
local_postgres_data: {}
local_postgres_data_backups: {}
services:
django:
build:
context: .
dockerfile: ./compose/local/django/Dockerfile
image: innovacion_innsai_local_django
depends_on:
- postgres
volumes:
- .:/app
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- "8000:8000"
command: /start
postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: innovacion_innsai_production_postgres
volumes:
- local_postgres_data:/var/lib/postgresql/data
- local_postgres_data_backups:/backups
env_file:
- ./.envs/.local/.postgres
node:
build:
context: .
dockerfile: ./compose/local/node/Dockerfile
image: innovacion_innsai_local_node
depends_on:
- django
volumes:
- .:/app
# http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html
- /app/node_modules
command: npm run dev
ports:
- "3000:3000"
# Expose browsersync UI: https://www.browsersync.io/docs/options/#option-ui
- "3001:3001"
the result of running docker-machine ls:
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
dev - virtualbox Running tcp://192.168.99.101:2376 v19.03.5
My .postgresql in the .envs/.local folder is:
# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=innovacion_innsai
POSTGRES_USER=debug
POSTGRES_PASSWORD=debug
and my Docker file for local:
FROM python:3.7-slim-buster
ENV PYTHONUNBUFFERED 1
RUN apt-get update \
# dependencies for building Python packages
&& apt-get install -y build-essential \
# psycopg2 dependencies
&& apt-get install -y libpq-dev \
# Translations dependencies
&& apt-get install -y gettext \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install -r /requirements/local.txt
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/local/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
WORKDIR /app
ENTRYPOINT ["/entrypoint"]
Please, I am quite new with Django and Docker so excuse me if I did not explain myself properly. Also, please let me know if you would need any other script or information in order to take a proper look at the problem!
I dont know if you already figured this out and I don't know if I'm right but give this a try:
Instead of:
docker-compose -f local.yml up
Try:
docker-compose -f production.yml up
When you're deploying to production you should build and bring up the site with the production file not the local file.
When upgrading the old packages in the file requirements.txt of my application, of which the deprecated cms-plugins to the newer djangocms-plugins, I got the following error:
<code>
(tonhausPZ) root#manelmr-Lenovo-G560:/home/manel-mr/PhilippZ# python manage.py migrate djangocms-picture
python: can't open file 'manage.py': [Errno 2] No such file or directory
(tonhausPZ) root#manelmr-Lenovo-G560:/home/manel-mr/PhilippZ# python src/manage.py migrate djangocms-picture
Traceback (most recent call last):
File "src/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/djangocms_picture/models.py", line 15, in <module>
from cms.models import CMSPlugin
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/cms/models/__init__.py", line 3, in <module>
from .pagemodel import * # nopyflakes
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/cms/models/pagemodel.py", line 24, in <module>
from cms.models.managers import PageManager, PageNodeManager
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/cms/models/managers.py", line 15, in <module>
from cms.utils.i18n import get_fallback_languages
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/cms/utils/__init__.py", line 7, in <module>
from cms.utils.conf import get_site_id # nopyflakes
File "/home/manel-mr/PhilippZ/src/tonhaus/tonhausPZ/lib/python3.5/site-packages/cms/utils/conf.py", line 11, in <module>
from cms import __version__
ImportError: cannot import name '__version__'
(tonhausPZ) root#manelmr-Lenovo-G560:/home/manel-mr/PhilippZ#
</code>
I couldn't find a solution to this error.
The updated requirements.txt file is:
<code>
certifi==2019.11.28
chardet==3.0.4
cmsplugin-filer==1.1.3
Django==2.2.8
django-appconf==1.0.3
django-classy-tags==0.9.0
django-cms==3.7.1
django-compressor==2.3
django-filer==1.6.0
django-formtools==2.2
django-js-asset==1.2.2
django-libsass==0.7
django-mptt==0.10.0
django-polymorphic==2.0.3
django-rosetta==0.9.3
django-sekizai==1.0.0
django-select2==7.1.2
django-social-share==1.3.2
django-treebeard==4.3
django-uuidfield==0.5.0
djangocms-admin-style==1.4.0
djangocms-attributes-field==1.1.0
djangocms-link==2.5.0
djangocms-rosetta==0.0
djangocms-text-ckeditor==3.8.0
easy-thumbnails==2.6
gevent==1.4.0
greenlet==0.4.15
gunicorn==20.0.4
html5lib==1.0.1
idna==2.8
libsass==0.19.4
microsofttranslator==0.8
olefile==0.46
Pillow==6.2.1
polib==1.1.0
pytz==2019.3
rcssmin==1.0.6
requests==2.22.0
rjsmin==1.1.0
six==1.13.0
sqlparse==0.3.0
Unidecode==1.0.23
urllib3==1.25.7
webencodings==0.5.1
</code>
The file settings.py includes the following code:
<code>
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)
SITE_ID = 1
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': (
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.media',
'django.template.context_processors.csrf',
'django.template.context_processors.tz',
'sekizai.context_processors.sekizai',
'django.template.context_processors.static',
'cms.context_processors.cms_settings',
'cms_tonhaus.context_processors.product_ordering',
'cms_tonhaus.context_processors.wishlist_count',
),
'loaders': (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
)
}
},
]
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware'
)
INSTALLED_APPS = (
'djangocms_admin_style',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'djangocms_picture',
'djangocms_text_ckeditor',
'filer',
'cms',
'django_select2',
'djangocms_file',
'djangocms_audio',
'djangocms_video',
'djangocms_googlemap',
'compressor',
'django_social_share',
'easy_thumbnails',
'djangocms_style',
'djangocms_snippet',
'menus',
'sekizai',
'treebeard',
'djangocms_link',
'djangocms_rosetta',
'rosetta',
'cms_tonhaus',
'tonhaus'
)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
LANGUAGES = (
## Customize this
('de', gettext('de')),
('it', gettext('it')),
)
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'),)
</code>
The database tables are :
<code>
mysql> use www_tonhaus
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-------------------------------------+
| Tables_in_www_tonhaus |
+-------------------------------------+
| auth_group |
| auth_group_permissions |
| auth_permission |
| auth_user |
| auth_user_groups |
| auth_user_user_permissions |
| cms_aliaspluginmodel |
| cms_cmsplugin |
| cms_globalpagepermission |
| cms_globalpagepermission_sites |
| cms_page |
| cms_page_placeholders |
| cms_pagepermission |
| cms_pageuser |
| cms_pageusergroup |
| cms_placeholder |
| cms_placeholderreference |
| cms_staticplaceholder |
| cms_title |
| cms_tonhaus_artistmodel |
| cms_tonhaus_categorymodel |
| cms_tonhaus_productmodel |
| cms_tonhaus_simplefilerimagemodel |
| cms_tonhaus_wishlistmodel |
| cms_tonhaus_wishlistmodel_products |
| cms_treenode |
| cms_urlconfrevision |
| cms_usersettings |
| cmsplugin_filer_image_filerimage |
| django_admin_log |
| django_content_type |
| django_migrations |
| django_session |
| django_site |
| djangocms_audio_audiofile |
| djangocms_audio_audiofolder |
| djangocms_audio_audioplayer |
| djangocms_audio_audiotrack |
| djangocms_file_file |
| djangocms_file_folder |
| djangocms_googlemap_googlemap |
| djangocms_googlemap_googlemapmarker |
| djangocms_googlemap_googlemaproute |
| djangocms_link_link |
| djangocms_picture_picture |
| djangocms_snippet_snippet |
| djangocms_snippet_snippetptr |
| djangocms_style_style |
| djangocms_text_ckeditor_text |
| djangocms_video_videoplayer |
| djangocms_video_videosource |
| djangocms_video_videotrack |
| easy_thumbnails_source |
| easy_thumbnails_thumbnail |
| easy_thumbnails_thumbnaildimensions |
| filer_clipboard |
| filer_clipboarditem |
| filer_file |
| filer_folder |
| filer_folderpermission |
| filer_image |
| filer_thumbnailoption |
| menus_cachekey |
| reversion_revision |
| reversion_version |
+-------------------------------------+
</code
I am using python 3.5 and the newest versions of packages of which django 2.x , knowing that the old version of the application uses python 2.7, django 1.x and cmsplugins.
I am developing my first django website (based on tango with django tutorial), and faced problem with serving static files when Debug = False.
(When I had Debug = True everything worked well)
my folders structure is as following:
|___401.shtml
|___500.shtml
|___requirements.txt
|___400.shtml
|___populate_rango.py
|___manage.py
|___templates
| |___rango
| | |___index.html
| | |___category.html
| | |___cats.html
| | |___category_list.html
| | |___add_category.html
| | |___base.html
| | |___register.html
| | |___restricted.html
| | |___about.html
| | |___login.html
| | |___add_page.html
| |___registration
| | |___logout.html
| | |___registration_complete.html
| | |___registration_form.html
| | |___login.html
|___media
| |___photo.png
| |___.htaccess
| |___profile_images
| | |___Screenshot_from_2016-07-18_145936.png
| | |___Screenshot_from_2016-07-21_112910.png
|___cgi-bin
| |___.htaccess
|___rango
| |___admin.py
| |___migrations
| | |___0003_category_slug.py
| | |_____init__.pyc
| | |___0003_category_slug.pyc
| | |___0001_initial.pyc
| | |___0001_initial.py
| | |___0004_userprofile.pyc
| | |___0002_auto_20160804_1857.py
| | |___0002_auto_20160804_1857.pyc
| | |___0004_userprofile.py
| | |_____init__.py
| |___models.py
| |___tests.py
| |_____init__.pyc
| |___models.pyc
| |___templatetags
| | |_____init__.pyc
| | |___rango_extras.pyc
| | |___rango_extras.py
| | |_____init__.py
| |___forms.py
| |___views.pyc
| |___urls.py
| |___admin.pyc
| |___views.py
| |___urls.pyc
| |___forms.pyc
| |_____init__.py
|___tango_with_django_project
| |___settings.pyc
| |___wsgi.pyc
| |_____init__.pyc
| |___urls.py
| |___settings.py
| |___urls.pyc
| |___wsgi.py
| |_____init__.py
|___static
| |___images
| | |___photo.png
| | |___rango.png
| |___.htaccess
| |___js
| | |___rango-jquery.js
| | |___jquery.js
| | |___rango-ajax.js
|___db.sqlite3
|___test.py
|___404.shtml
|___403.shtml
i added STATIC_ROOT in settings.py path as follows:
import os
import uwsgi
from uwsgidecorators import timer
from django.utils import autoreload
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
(...)
ROOT_URLCONF = 'tango_with_django_project.urls'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
STATIC_ROOT,
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static')
and now i want to run from ssh terminal
python manage.py collectstatic
however i am facing an error
Traceback (most recent call last):
File "manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/home/mrklap/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/mrklap/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/home/mrklap/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in __getattr__
self._setup(name)
File "/home/mrklap/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/home/mrklap/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 98, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'tango_with_django_project.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named uwsgi
i read post and schwärzl answer here:
ImportError: Could not import settings
and modified wsgi.py file to:
import os
import sys
sys.path.append('home/mrklap/domains/tredo.net/public_html/tango_with_django_project')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tango_with_django_project.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
but still when i am in (or out) virtualenv in ssh and run:
>>> import sys
>>> for path in sys.path: print path
...
i am not getting added path
/home/mrklap/venv/lib/python2.7
/home/mrklap/venv/lib/python2.7/plat-x86_64-linux-gnu
/home/mrklap/venv/lib/python2.7/lib-tk
/home/mrklap/venv/lib/python2.7/lib-old
/home/mrklap/venv/lib/python2.7/lib-dynload
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/home/mrklap/venv/local/lib/python2.7/site-packages
/home/mrklap/venv/lib/python2.7/site-packages
>>>
why i can't see that path in listing below?
try sudo pip install uwsgi
as you have imported this in settings file
I tried to group serveral apps into a "app" folder for better management. however i got the below error when i did the first migration.
./manage.py makemigrations
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 132, in handle
migration_name=self.migration_name,
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 45, in changes
changes = self._detect_changes(convert_apps, graph)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 128, in _detect_changes
self.old_apps = self.from_state.concrete_apps
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/migrations/state.py", line 166, in concrete_apps
self.apps = StateApps(self.real_apps, self.models, ignore_swappable=True)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/migrations/state.py", line 228, in __init__
self.render_multiple(list(models.values()) + self.real_models)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/migrations/state.py", line 296, in render_multiple
model.render(self)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/migrations/state.py", line 585, in render
body,
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/models/base.py", line 158, in __new__
new_class.add_to_class(obj_name, obj)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/models/base.py", line 299, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/models/fields/related.py", line 702, in contribute_to_class
super(ForeignObject, self).contribute_to_class(cls, name, virtual_only=virtual_only)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/models/fields/related.py", line 308, in contribute_to_class
lazy_related_operation(resolve_related_class, cls, self.remote_field.model, field=self)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/models/fields/related.py", line 85, in lazy_related_operation
return apps.lazy_model_operation(partial(function, **kwargs), *model_keys)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/models/fields/related.py", line 83, in <genexpr>
model_keys = (make_model_tuple(m) for m in models)
File "/Users/reonard/.virtualenvs/django-ito/lib/python2.7/site-packages/django/db/models/utils.py", line 14, in make_model_tuple
app_label, model_name = model.split(".")
ValueError: too many values to unpack
I added a print statement for the model splitted and the output was:
auth.User
auth.Group_permissions
auth.User_groups
auth.User_user_permissions
app.ticketmgr.BasePriority
It appears that the "app.ticketmgr.BasePriority" has an extra "dot". Actually the app name is "ticketmgr" but put in an "app" folder for better managerment. May i know what should i do to make the migrations work? is there any extra settings should be done to support putting serveral apps in a "app" folder ?
Below is my app folder, there are 2 apps (comm, ticketmgr) in it.
|____app
| |______init__.py
| |____comm
| | |______init__.py
| | |____admin.py
| | |____apps.py
| | |____migrations
| | | |______init__.py
| | |____models.py
| | |____role_required.py
| | |____tests.py
| | |____views.py
| |____ticketmgr
| | |______init__.py
| | |____admin.py
| | |____apps.py
| | |____forms.py
| | |____migrations
| | | |____0001_initial.py
| | | |______init__.py
| | |____models.py
| | |____tests.py
| | |____views.py
Nothing more is needed. Just add "app.ticketmgr", "app.comm" to INSTALLED_APPS.
BasePriority does not appear in your project directories. Maybe it's a model?
The installed app line should be:
app.ticketmgr
Since BasePriority does not exists, django gets 3 arguments instead of the 2 required for app_label,model_name. The "BasePriority" is the third argument, which excepts.