Daphne with absolute path to ASGI file

301 views
Skip to first unread message

BR

unread,
Oct 22, 2019, 3:56:47 PM10/22/19
to Django users
I've been using Daphne for months without issue, and have reorganized my project structure to make things a bit easier. However, it appears that Daphne needs to be run from the folder containing the Django project module like so:

daphne project.asgi:application

How can I specify the full path to project.asgi:application?

BR

unread,
Oct 22, 2019, 4:23:31 PM10/22/19
to Django users
This is Windows by the way

wd

unread,
Oct 22, 2019, 11:07:17 PM10/22/19
to django...@googlegroups.com
hi,

I checked the source code for Daphne, it uses import_by_path to import application

def import_by_path(path):
"""
Given a dotted/colon path, like project.module:ClassName.callable,
returns the object at the end of the path.
"""
module_path, object_path = path.split(":", 1)
target = importlib.import_module(module_path)
for bit in object_path.split("."):
target = getattr(target, bit)
return target

The importlib.import_module https://docs.python.org/3/library/importlib.html#importlib.import_module seems not support a path as it's args.

In linux, we can use command like 'cd path && daphne project.asgi:application' to run the application in any path, but I don't know if windows support it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4fbd3a46-3939-492a-a893-86d96fbe21f5%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages