Re: How to execute some user defined codes (functions) when Django boot?

2010-08-18 Thread Richard Colley
Why not call your "boot" code from settings.py? On Aug 18, 4:05 pm, Tang Daogang wrote: > hi, Emily, > > Let me introduce Scala/Lift as example. > > Every lift project has a file named 'Boot.scala', this file will only > be executed once when this project boots up. In this file, we can > write so

Re: Is it ok to super/save() twice in model.save()?

2010-05-14 Thread Richard Colley
7;t even get as far as discovering that it could > cause problems with shortcut functions. What turned me off at the > outset was needing to provide fake or default values for every other > field in the model, deleting that one if the "real" save failed, etc. > Seemed like a

Re: Is it ok to super/save() twice in model.save()?

2010-05-13 Thread Richard Colley
Exactly as you had described ... I wanted to upload images to paths with the model instance's id in it. Seemed easier for a human to relate to that way (in case of maintenance outside of django). However, the uuid approach or similar may be the way forward. On May 13, 10:58 pm, zinckiwi wrote:

Is it ok to super/save() twice in model.save()?

2010-05-13 Thread Richard Colley
I have overriden the save method on my model, and want to use the id field (default autoincrementing pk) to set one of the other fields. Is this ok: class MyModel(models.Model): ... def save(self, *args, **kwargs): super(MyModel, self).save(*args, **kwargs) self.some_string_

Re: include behavior

2009-06-21 Thread Richard Colley
For 1., did you import play_django? On Jun 21, 11:17 am, tekion wrote: > All, > I noticed that putting single quote around include argument makes a > different, for example: >  (r'^admin/', include(admin.site.urls)), >  (r'^polls/', include('play_django.polls.urls')), > works.  Where as: >  (r'^

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
, Jun 17, 2009 at 14:42, Richard Colley wrote: > > > > > Thanks TiNo, > > > Are there any caveats with this?  e.g. to make syncdb etc. work > > correctly? > > I don't know, as I never tried, and I am not very experienced with messing > with the inner meta c

Re: How do I get a field value instead of in an admin selectbox?

2009-06-17 Thread Richard Colley
The answer was given to you in the previous post. Whatever __unicode__() returns from your model is what will be displayed. So, on your model, define a __unicode__ method: e.g. class Person(...): def __unicode__(self): return self.name On Jun 18, 12:03 am, DaveB wrote: > > Your

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
lank attribute to false. > > TiNo > > On Wed, Jun 17, 2009 at 13:32, Richard Colley wrote: > > > > > Ok, after looking through the django wiki entries for AuditTrail > > (http://code.djangoproject.com/wiki/AuditTrail) and DynamicModels > > (http://code.dja

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
n the desirability of doing this, and potential alternative solutions. Thanks, Richard On Jun 17, 8:03 pm, Richard Colley wrote: > I have a need to define 2 models, both with a large number of fields > in common, but where in once case these common fields are completely > optional, and in the o

Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
I have a need to define 2 models, both with a large number of fields in common, but where in once case these common fields are completely optional, and in the other case they are mandatory. class XYZTemplate(Model): field_a = TextField( blank=True) field_b = TextField( blank=True)

Re: OT: running custom management command from cron & Unicode output error

2009-06-09 Thread Richard Colley
import sys, codecs, locale sys.stdout = codecs.getwriter(locale.getpreferredencoding()) (sys.stdout) or you can hard-code locale.getpreferredencoding() as 'utf-8' On Jun 7, 2:19 am, "Carlos A. Carnero Delgado" wrote: > Hi there! > > I'm having a problem with a custom management command. Running