#416 closed task (wontfix)
Automate site introspection for url pattern modules, view methods, template directories, and applications
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | 0.91 |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | UI/UX: | no |
Description
Read this with your best over-the-top advertising voice:
Are you sick of maintaining module-level URL configuration files? Do you keep forgetting to refer to them in your site-level URL configuration file? Have you recently forgotten to populate TEMPLATE_DIRS or INSTALLED_APPS?
You need AUTOSITE!
AUTOSITE has been brought to you by one programmer's bizarre tendency to spend two hours writing 300+ lines of code to replace around 30 lines of code that were taking him less than two minutes per day to maintain. His
insanity is YOUR gain. If only 100 Django programmers benefit from this module, all his hard work will have been worthwhile.
:)
Attachments (1)
Change History (11)
by , 19 years ago
Attachment: | autosite.py added |
---|
comment:1 by , 19 years ago
Okay, more seriously:
There's still a little that can be done to take manual work out of Django programming. If this were any other framework, I'd hardly bother: why save five minutes when the framework is costing you hours of time just to write a simple application? With Django, that application might only be a half hour job and saving five minutes might be significant.
Automatically figuring out which applications are in a site should be a no-brainer. I'm wading through the directory tree rather than looking through the content_types
and packages
tables, but either way we should be able to save the user the effort. If it's a package under sitename/apps
, it's an application, right?
Similarly, there's no point requiring that the user manually tell us where to find the URL configuration file if it's sitting there in plain sight with an obvious name like sitename/urls.py
. We're also giving them too much work to do if we insist that they create appname/settings/
, appname/settings/urls/
, and two __init__.py
files just so that the URLs and settings can live in packages rather than modules.
Eliminating the application-level URL configuration file entirely is arguably a step too far, but given the rest of the infrastructure it was pretty easy.
# Set the URL pattern as an attribute manually... def index(request): # ... index.urlpattern = r'^/?$' # ... or use a decorator. @urlpattern(r'^/?$') def index(request): # ...
Needless to say, whilst I'm going to find autosite.py
pretty handy for my own sites I really wrote it for all the people I've seen on #django
muttering about the various problems I've solved. Please feel free to use some or all of it for the core framework.
comment:2 by , 19 years ago
Hmm. In my gallery I have two prefixes for URLs - /images/ and /manage/ - that point to two urlpattern configs in the same application (to make use of shortcut notation). So how would I do it with autosite? Will all methods have to have fully qualified urlpatterns - and will the advantage of decoupling app urls from project urls be lost - or will I still have to have a global project-level urlpattern file and all methods of a app will show up under the apps url prefix?
Maybe you should give a full sample on how to use autosite with a project that has two apps with different base urlpatterns, that would make it clearer how autosite is to be used.
comment:3 by , 19 years ago
FYI: As of [415], django-admin.py startapp
doesn't create a /apps/appname/urls/
directory, so that's no longer as complex.
comment:5 by , 19 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
The new manage.py does some stuff that makes this less complex.
comment:7 by , 18 years ago
Component: | Core framework → Admin interface |
---|---|
milestone: | → Version 0.92 |
priority: | normal → low |
Severity: | normal → minor |
Type: | defect → task |
Version: | → 0.91 |
comment:8 by , 18 years ago
Resolution: | wontfix |
---|---|
Severity: | minor → critical |
Status: | closed → reopened |
comment:9 by , 18 years ago
Resolution: | → wontfix |
---|---|
Severity: | critical → normal |
Status: | reopened → closed |
AUTOSITE! Use it TODAY!