Permalink
Browse files

Fixed #627 -- BACKWARDS-INCOMPATIBLE CHANGE. Admin is now an app, not…

… a middleware. See BackwardsIncompatibleChanges for a full list of changes and information on how to update your code.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@948 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent fd3d579 commit f07e5d4f5df5ca9ca3366d7ecc4b01c490c13198 @adrianholovaty adrianholovaty committed Oct 19, 2005
Showing with 142 additions and 377 deletions.
  1. +8 −2 django/conf/project_template/{settings/main.py → settings.py}
  2. 0 django/conf/project_template/settings/__init__.py
  3. +0 −18 django/conf/project_template/settings/admin.py
  4. 0 django/conf/project_template/settings/urls/__init__.py
  5. +0 −6 django/conf/project_template/settings/urls/admin.py
  6. +3 −0 django/conf/project_template/{settings/urls/main.py → urls.py}
  7. 0 django/{conf/admin_media → contrib/admin/media}/css/base.css
  8. 0 django/{conf/admin_media → contrib/admin/media}/css/changelists.css
  9. 0 django/{conf/admin_media → contrib/admin/media}/css/global.css
  10. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/arrow-down.gif
  11. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/arrow-up.gif
  12. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/changelist-bg.gif
  13. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/chooser-bg.gif
  14. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/chooser_stacked-bg.gif
  15. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/default-bg-reverse.gif
  16. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/default-bg.gif
  17. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon-no.gif
  18. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon-yes.gif
  19. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_addlink.gif
  20. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_alert.gif
  21. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_calendar.gif
  22. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_changelink.gif
  23. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_clock.gif
  24. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_deletelink.gif
  25. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_error.gif
  26. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_searchbox.png
  27. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/icon_success.gif
  28. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/nav-bg-grabber.gif
  29. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/nav-bg-reverse.gif
  30. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/nav-bg.gif
  31. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/selector-add.gif
  32. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/selector-addall.gif
  33. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/selector-remove.gif
  34. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/selector-removeall.gif
  35. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/selector-search.gif
  36. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/selector_stacked-add.gif
  37. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/selector_stacked-remove.gif
  38. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tool-left.gif
  39. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tool-left_over.gif
  40. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tool-right.gif
  41. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tool-right_over.gif
  42. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tooltag-add.gif
  43. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tooltag-add_over.gif
  44. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tooltag-arrowright.gif
  45. BIN django/{conf/admin_media → contrib/admin/media}/img/admin/tooltag-arrowright_over.gif
  46. 0 django/{conf/admin_media → contrib/admin/media}/js/SelectBox.js
  47. 0 django/{conf/admin_media → contrib/admin/media}/js/SelectFilter.js
  48. 0 django/{conf/admin_media → contrib/admin/media}/js/SelectFilter2.js
  49. 0 django/{conf/admin_media → contrib/admin/media}/js/admin/CollapsedFieldsets.js
  50. 0 django/{conf/admin_media → contrib/admin/media}/js/admin/DateTimeShortcuts.js
  51. 0 django/{conf/admin_media → contrib/admin/media}/js/admin/RelatedObjectLookups.js
  52. 0 django/{conf/admin_media → contrib/admin/media}/js/admin/ordering.js
  53. 0 django/{conf/admin_media → contrib/admin/media}/js/calendar.js
  54. 0 django/{conf/admin_media → contrib/admin/media}/js/core.js
  55. 0 django/{conf/admin_media → contrib/admin/media}/js/dateparse.js
  56. 0 django/{conf/admin_media → contrib/admin/media}/js/getElementsBySelector.js
  57. 0 django/{conf/admin_media → contrib/admin/media}/js/timeparse.js
  58. 0 django/{conf/admin_media → contrib/admin/media}/js/urlify.js
  59. +1 −1 django/{conf/admin_templates → contrib/admin/templates/admin}/404.html
  60. +1 −1 django/{conf/admin_templates → contrib/admin/templates/admin}/500.html
  61. 0 django/{conf/admin_templates → contrib/admin/templates/admin}/base.html
  62. +1 −1 django/{conf/admin_templates → contrib/admin/templates/admin}/base_site.html
  63. +1 −1 ...plates/delete_confirmation_generic.html → contrib/admin/templates/admin/delete_confirmation.html}
  64. +1 −1 django/{conf/admin_templates → contrib/admin/templates/admin}/index.html
  65. +1 −1 django/{conf/admin_templates → contrib/admin/templates/admin}/login.html
  66. +1 −1 ...nf/admin_templates/admin_object_history.html → contrib/admin/templates/admin/object_history.html}
  67. +1 −1 django/{conf/admin_templates → contrib/admin/templates/admin}/template_validator.html
  68. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/bookmarklets.html
  69. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/index.html
  70. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/missing_docutils.html
  71. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/model_detail.html
  72. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/model_index.html
  73. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/template_detail.html
  74. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/template_filter_index.html
  75. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/template_tag_index.html
  76. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/view_detail.html
  77. +1 −1 django/{conf/admin_templates/doc → contrib/admin/templates/admin_doc}/view_index.html
  78. +1 −1 django/{conf/admin_templates → contrib/admin/templates}/registration/logged_out.html
  79. +1 −1 django/{conf/admin_templates → contrib/admin/templates}/registration/password_change_done.html
  80. +1 −1 django/{conf/admin_templates → contrib/admin/templates}/registration/password_change_form.html
  81. +1 −1 django/{conf/admin_templates → contrib/admin/templates}/registration/password_reset_done.html
  82. 0 django/{conf/admin_templates → contrib/admin/templates}/registration/password_reset_email.html
  83. +1 −1 django/{conf/admin_templates → contrib/admin/templates}/registration/password_reset_form.html
  84. 0 django/{ → contrib/admin}/templatetags/adminapplist.py
  85. 0 django/{ → contrib/admin}/templatetags/adminmedia.py
  86. +1 −1 django/{ → contrib/admin}/templatetags/log.py
  87. 0 django/{conf → contrib/admin}/urls/admin.py
  88. +6 −6 django/contrib/admin/views/main.py
  89. +1 −1 django/contrib/admin/views/template.py
  90. +2 −11 django/core/management.py
  91. +1 −1 django/core/servers/basehttp.py
  92. +0 −126 django/middleware/admin.py
  93. +0 −46 django/models/auth.py
  94. +2 −2 docs/django-admin.txt
  95. +1 −2 docs/faq.txt
  96. +3 −18 docs/middleware.txt
  97. +10 −22 docs/modpython.txt
  98. +5 −5 docs/settings.txt
  99. +8 −19 docs/tutorial01.txt
  100. +51 −42 docs/tutorial02.txt
  101. +17 −26 docs/tutorial03.txt
@@ -27,22 +27,28 @@
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
# Make this unique, and don't share it with anybody.
SECRET_KEY = ''
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
-# 'django.core.template.loaders.app_directories.load_template_source',
'django.core.template.loaders.filesystem.load_template_source',
+ 'django.core.template.loaders.app_directories.load_template_source',
# 'django.core.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
"django.middleware.common.CommonMiddleware",
+ "django.middleware.sessions.SessionMiddleware",
"django.middleware.doc.XViewMiddleware",
)
-ROOT_URLCONF = '{{ project_name }}.settings.urls.main'
+ROOT_URLCONF = '{{ project_name }}.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates".
@@ -1,18 +0,0 @@
-# Django settings for {{ project_name }} project admin site.
-
-from main import *
-
-TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates".
-)
-ROOT_URLCONF = '{{ project_name }}.settings.urls.admin'
-MIDDLEWARE_CLASSES = (
- 'django.middleware.sessions.SessionMiddleware',
- 'django.middleware.admin.AdminUserRequired',
- 'django.middleware.common.CommonMiddleware',
-)
-
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/media/'
@@ -1,6 +0,0 @@
-from django.conf.urls.defaults import *
-
-urlpatterns = patterns('',
- (r'^admin/', include('django.conf.urls.admin')),
- (r'^r/', include('django.conf.urls.shortcut')),
-)
@@ -3,4 +3,7 @@
urlpatterns = patterns('',
# Example:
# (r'^{{ project_name }}/', include('{{ project_name }}.apps.foo.urls.foo')),
+
+ # Uncomment this for admin:
+# (r'^admin/', include('django.contrib.admin.urls.admin')),
)
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block title %}Page not found{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; Server error</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base" %}
+{% extends "admin/base" %}
{% block title %}{{ title }} | Django site admin{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block content %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block coltype %}colMS{% endblock %}
{% block bodyclass %}dashboard{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}
<div class="breadcrumbs"><a href="../../../../">Home</a> &rsaquo; <a href="../../">{{ module_name }}</a> &rsaquo; <a href="../">{{ object|truncatewords:"18" }}</a> &rsaquo; History</div>
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block content %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Bookmarklets</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Documentation</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Documentation</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block extrahead %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block coltype %}colSM{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; Templates &rsaquo; {{ name }}</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block coltype %}colSM{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block coltype %}colSM{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; <a href="../">Views</a> &rsaquo; {{ name }}</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block coltype %}colSM{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a></div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Password change</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Password change</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Password reset</div>{% endblock %}
@@ -1,4 +1,4 @@
-{% extends "base_site" %}
+{% extends "admin/base_site" %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Password reset</div>{% endblock %}
@@ -1,4 +1,4 @@
-from django.models.auth import log
+from django.models.admin import log
from django.core import template
class AdminLogNode(template.Node):
File renamed without changes.
@@ -6,7 +6,7 @@
from django.core.exceptions import Http404, ObjectDoesNotExist, PermissionDenied
from django.core.extensions import DjangoContext as Context
from django.core.extensions import get_object_or_404, render_to_response
-from django.models.auth import log
+from django.models.admin import log
from django.utils.html import strip_tags
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.utils.text import capfirst, get_text_list
@@ -49,7 +49,7 @@ def get_query_string(original_params, new_params={}, remove=[]):
return '?' + '&amp;'.join(['%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20')
def index(request):
- return render_to_response('index', {'title': 'Site administration'}, context_instance=Context(request))
+ return render_to_response('admin/index', {'title': 'Site administration'}, context_instance=Context(request))
index = staff_member_required(index)
def change_list(request, app_label, module_name):
@@ -266,7 +266,7 @@ def change_list(request, app_label, module_name):
else:
pass # Invalid argument to "list_filter"
- raw_template = ['{% extends "base_site" %}\n']
+ raw_template = ['{% extends "admin/base_site" %}\n']
raw_template.append('{% block bodyclass %}change-list{% endblock %}\n')
if not is_popup:
raw_template.append('{%% block breadcrumbs %%}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; %s</div>{%% endblock %%}\n' % capfirst(opts.verbose_name_plural))
@@ -538,7 +538,7 @@ def _get_template(opts, app_label, add=False, change=False, show_delete=False, f
admin_field_objs = opts.admin.get_field_objs(opts)
ordered_objects = opts.get_ordered_objects()[:]
auto_populated_fields = [f for f in opts.fields if f.prepopulate_from]
- t = ['{% extends "base_site" %}\n']
+ t = ['{% extends "admin/base_site" %}\n']
t.append('{% block extrahead %}')
# Put in any necessary JavaScript imports.
@@ -1087,7 +1087,7 @@ def delete_stage(request, app_label, module_name, object_id):
log.log_action(request.user.id, opts.get_content_type_id(), object_id, obj_repr, log.DELETION)
request.user.add_message('The %s "%s" was deleted successfully.' % (opts.verbose_name, obj_repr))
return HttpResponseRedirect("../../")
- return render_to_response('delete_confirmation_generic', {
+ return render_to_response('admin/delete_confirmation', {
"title": "Are you sure?",
"object_name": opts.verbose_name,
"object": obj,
@@ -1102,7 +1102,7 @@ def history(request, app_label, module_name, object_id):
order_by=("action_time",), select_related=True)
# If no history was found, see whether this object even exists.
obj = get_object_or_404(mod, pk=object_id)
- return render_to_response('admin_object_history', {
+ return render_to_response('admin/object_history', {
'title': 'Change history: %r' % obj,
'action_list': action_list,
'module_name': capfirst(opts.verbose_name_plural),
@@ -23,7 +23,7 @@ def template_validator(request):
errors = manipulator.get_validation_errors(new_data)
if not errors:
request.user.add_message('The template is valid.')
- return render_to_response('template_validator', {
+ return render_to_response('admin/template_validator', {
'title': 'Template validator',
'form': formfields.FormWrapper(manipulator, new_data, errors),
}, context_instance=DjangoContext(request))
@@ -17,7 +17,6 @@
# Use django.__path__[0] because we don't know which directory django into
# which has been installed.
PROJECT_TEMPLATE_DIR = os.path.join(django.__path__[0], 'conf', '%s_template')
-ADMIN_TEMPLATE_DIR = os.path.join(django.__path__[0], 'conf', 'admin_templates')
def _get_packages_insert(app_label):
return "INSERT INTO packages (label, name) VALUES ('%s', '%s');" % (app_label, app_label)
@@ -142,7 +141,7 @@ def get_sql_delete(mod):
if cursor is not None:
cursor.execute("SELECT id FROM content_types WHERE package = %s", [app_label])
for row in cursor.fetchall():
- output.append("DELETE FROM auth_admin_log WHERE content_type_id = %s;" % row[0])
+ output.append("DELETE FROM django_admin_log WHERE content_type_id = %s;" % row[0])
# Close database connection explicitly, in case this output is being piped
# directly into a database client, to avoid locking issues.
@@ -378,16 +377,8 @@ def startproject(project_name, directory):
"Creates a Django project for the given project_name in the given directory."
from random import choice
_start_helper('project', project_name, directory)
- # Populate TEMPLATE_DIRS for the admin templates, based on where Django is
- # installed.
- admin_settings_file = os.path.join(directory, project_name, 'settings', 'admin.py')
- settings_contents = open(admin_settings_file, 'r').read()
- fp = open(admin_settings_file, 'w')
- settings_contents = re.sub(r'(?s)\b(TEMPLATE_DIRS\s*=\s*\()(.*?)\)', "\\1\n r%r,\\2)" % ADMIN_TEMPLATE_DIR, settings_contents)
- fp.write(settings_contents)
- fp.close()
# Create a random SECRET_KEY hash, and put it in the main settings.
- main_settings_file = os.path.join(directory, project_name, 'settings', 'main.py')
+ main_settings_file = os.path.join(directory, project_name, 'settings.py')
settings_contents = open(main_settings_file, 'r').read()
fp = open(main_settings_file, 'w')
secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
@@ -602,7 +602,7 @@ def __init__(self, application):
from django.conf import settings
import django
self.application = application
- self.media_dir = django.__path__[0] + '/conf/admin_media'
+ self.media_dir = django.__path__[0] + '/contrib/admin/media'
self.media_url = settings.ADMIN_MEDIA_PREFIX
def __call__(self, environ, start_response):
Oops, something went wrong.

0 comments on commit f07e5d4

Please sign in to comment.