deprecated urls as strings: problem adding second + urls to main urls.py file

23 views
Skip to first unread message

Andrew Emory

unread,
Aug 6, 2016, 12:42:29 PM8/6/16
to Django users
I am having trouble with how I would intuitively get my url patterns to work, by listing the actual path to the view function.

So it needs to be a callable, ok.  But I don't like having 15+ from appname import views as appname_view.

I can add a url.py file in each app and use include().   But then in the app, I would do a relative view import and import all the functions to that module...

Is there a better way to do this?  Am I missing something?

I am watching a tutorial on django 1.9...ha, that is my problem, I assumed I was working on 1.9.  The latest, which is what I have installed, is 1.10.

My question still stands, would someone please share convention with me on the best way to do this?

Thank You.

Tim Graham

unread,
Aug 6, 2016, 3:05:25 PM8/6/16
to Django users
You're not missing something. You should imports. Sorry you don't like the look of it, but that's Python.

Andrew Emory

unread,
Aug 6, 2016, 11:16:04 PM8/6/16
to Django users
Is there convention on import view as vs a separate URL file in every app?  

Is there separate URL in each app only used if you need to use include() ??

Tim Graham

unread,
Aug 8, 2016, 1:18:35 PM8/8/16
to Django users
I'm not sure exactly what you're asking. Maybe you could give a concrete example. For a complex example, you could take a look at the urls.py for djangoproject.com: https://github.com/django/djangoproject.com/blob/249c3482982fc43afc6b6fa575fe79f938ebe472/djangoproject/urls/www.py. There are many ways to structure things though.
Reply all
Reply to author
Forward
0 new messages