Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

magic-removal: Fixed #1681. OneToOneField now works properly in the a…

…dmin system.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2800 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3b0e5d8d2950803c5503dae3af7565987a36f983 1 parent 1a02e9d
Joseph Kocherhans authored May 01, 2006
8  django/contrib/admin/templates/admin/field_line.html
@@ -9,14 +9,6 @@
9 9
   {% if not bound_field.has_label_first %}
10 10
     {% field_label bound_field %}
11 11
   {% endif %}
12  
-  {% if change %}
13  
-    {% if bound_field.field.primary_key %}
14  
-      {{ bound_field.original_value }}
15  
-    {% endif %}
16  
-    {% if bound_field.raw_id_admin %}
17  
-      {% if bound_field.existing_display %}&nbsp;<strong>{{ bound_field.existing_display|truncatewords:"14" }}</strong>{% endif %}
18  
-    {% endif %}
19  
-  {% endif %}
20 12
   {% if bound_field.field.help_text %}<p class="help">{{ bound_field.field.help_text }}</p>{% endif %}
21 13
 {% endfor %}
22 14
 </div>
8  django/contrib/admin/templates/widget/foreign.html
@@ -10,3 +10,11 @@
10 10
 {% if bound_field.needs_add_label %}
11 11
     <a href="{{ bound_field.related_url }}add/" class="add-another" id="add_{{ bound_field.element_id }}" onclick="return showAddAnotherPopup(this);"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a>
12 12
 {% endif %}{% endif %}
  13
+{% if change %}
  14
+    {% if bound_field.field.primary_key %}
  15
+        {{ bound_field.original_value }}
  16
+    {% endif %}
  17
+    {% if bound_field.raw_id_admin %}
  18
+        {% if bound_field.existing_display %}&nbsp;<strong>{{ bound_field.existing_display|truncatewords:"14" }}</strong>{% endif %}
  19
+    {% endif %}
  20
+{% endif %}
3  django/contrib/admin/templates/widget/one_to_one.html
... ...
@@ -1 +1,2 @@
1  
-{% include "widget/foreign.html" %}
  1
+{% if add %}{% include "widget/foreign.html" %}{% endif %}
  2
+{% if change %}{% if bound_field.existing_display %}&nbsp;<strong>{{ bound_field.existing_display|truncatewords:"14" }}</strong>{% endif %}{% endif %}
34  django/db/models/fields/related.py
@@ -76,6 +76,23 @@ def _get_related_query_name(self, opts):
@@ -451,23 +468,6 @@ def get_attname(self):
12  docs/model-api.txt
@@ -877,16 +877,8 @@ string ``"self"`` instead of the model name; references to as-yet undefined
877 877
 models can be made by using a string containing the model name.
878 878
 
879 879
 This ``OneToOneField`` will actually replace the primary key ``id`` field
880  
-(since one-to-one relations share the same primary key), and has a few
881  
-differences in the admin interface:
882  
-
883  
-    * No ``Place`` selection interface is displayed on ``Restaurant`` pages.
884  
-      There will be one (and only one) ``Restaurant`` for each ``Place``.
885  
-
886  
-    * On the ``Restaurant`` change list, every ``Place`` -- whether it has an
887  
-      associated ``Restaurant`` or not -- will be displayed. Adding a
888  
-      ``Restaurant`` to a ``Place`` just means filling out the required
889  
-      ``Restaurant`` fields.
  880
+(since one-to-one relations share the same primary key), and will be displayed
  881
+as a read-only field when you edit an object in the admin interface:
890 882
 
891 883
 See the `One-to-one relationship model example`_ for a full example.
892 884
 

0 notes on commit 3b0e5d8

Please sign in to comment.
Something went wrong with that request. Please try again.