Changeset 2047
- Timestamp:
- 01/18/06 07:16:58 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/db/models/manager.py
r2039 r2047 101 101 # Check if extra tables are allowed. If not, throw an error 102 102 if (tables or joins) and not allow_joins: 103 raise TypeError ("Joins are not allowed in this type of query")103 raise TypeError, "Joins are not allowed in this type of query" 104 104 105 105 # Compose the join dictionary into SQL describing the joins. … … 151 151 152 152 def delete(self, *args, **kwargs): 153 nArguments = len(args) + len(kwargs) 154 155 # remove the DELETE_ALL argument, if it exists 156 delete_all = kwargs.pop('DELETE_ALL', False) 157 153 158 # disable non-supported fields 154 159 kwargs['select_related'] = False … … 158 163 kwargs['limit'] = None 159 164 165 # Check that there at least one query argument 166 if nArguments == 0 and not delete_all: 167 raise TypeError, "SAFTEY MECHANISM: Specify DELETE_ALL=True if you actually want to delete all data" 168 160 169 opts = self.klass._meta 161 170 django/branches/magic-removal/tests/modeltests/basic/models.py
r2029 r2047 211 211 4L 212 212 213 >>> Article.objects.delete() 214 Traceback (most recent call last): 215 ... 216 TypeError: SAFTEY MECHANISM: Specify DELETE_ALL=True if you actually want to delete all data 217 218 >>> Article.objects.delete(DELETE_ALL=True) 219 >>> Article.objects.get_count() 220 0L 221 213 222 """ 214 223
