Changes between Version 39 and Version 40 of NewbieMistakes
- Timestamp:
- Feb 21, 2011, 12:57:24 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NewbieMistakes
v39 v40 332 332 333 333 Ensure they have different values - e.g. ADMIN_MEDIA_PREFIX = 'admin-media' and MEDIA_URL = '/media' 334 335 336 == Default value and Callables == 337 338 ==== Symptom ==== 339 340 You call a method to set a default value, such as random.randint(), but the value is the same for every new instance of your object. 341 342 ==== Probable cause ==== 343 344 Each new instance doesn't call random.randint() 345 346 ==== Solution ==== 347 348 Prepend "lambda:" like 349 {{{ 350 MyRandNum = models.CharField(max_length=4, default=lambda:random.randint(1000,9999)) 351 }}} 352