On Mon, 2009-02-23 at 12:23 -0800, knight wrote:
> Hi,
>
> I have models.py like this:
>
> class Media_biz(models.Model):
> ---
> default = models.BooleanField("Default", blank=True, null=True)
> ---
>
> def get_default_Media_biz():
> if Media_biz.objects.filter(default=True).co
Hi,
I have models.py like this:
class Media_biz(models.Model):
---
default = models.BooleanField("Default", blank=True, null=True)
---
def get_default_Media_biz():
if Media_biz.objects.filter(default=True).count() != 0:
return Media_biz.objects.filter(default=True)[0]
Thanks,
My Media_biz is edited inline in another class. So I have:
class MetadataInline(admin.StackedInline) and
class MetadataAdmin(admin.ModelAdmin)
Can you tell what method I should override and in which class in order
to set the initial value while editing inline?
Regards, Alex Arshavski.
>
> > > I have the following classes in my models.py:
>
> > > class Default(models.Model):
> > > name = models.CharField(max_length=50, choices =
> > > (('rental_period', 'rental_period'), ('currency', 'currency')),
> > > unique=True)
> > > value = models.CharField(max_length=50)
>
> > >
On Feb 5, 3:59 pm, knight wrote:
> Hi,
>
> I have the following classes in my models.py:
>
> class Default(models.Model):
> name = models.CharField(max_length=50, choices =
> (('rental_period', 'rental_period'), ('currency', 'currency')),
> unique=True)
> value = models.CharField(max_leng
Hi,
Thanks for the fast reply.
Each Default instance provide default value for one of the fields:
I want to take the default value of rental_period to rental_period and
default value of currency to currency.
The value of the currency should be the name of Currency object for
foreign key.
Thanks,
On Feb 5, 10:59 am, knight wrote:
> Hi,
>
> I have the following classes in my models.py:
>
> class Default(models.Model):
> name = models.CharField(max_length=50, choices =
> (('rental_period', 'rental_period'), ('currency', 'currency')),
> unique=True)
> value = models.CharField(max_l
Hi,
I have the following classes in my models.py:
class Default(models.Model):
name = models.CharField(max_length=50, choices =
(('rental_period', 'rental_period'), ('currency', 'currency')),
unique=True)
value = models.CharField(max_length=50)
class Media_biz(models.Model):
name =
On Tue, Jan 6, 2009 at 10:08 PM, Chris wrote:
>
> I've created a ModelForm from a model containing a foreign key field
> (called user) linked to my User class. When the form is saved, I want
> this value to be set to the current authenticated user. What's the
> best way to do this?
>
> My form's
I've created a ModelForm from a model containing a foreign key field
(called user) linked to my User class. When the form is saved, I want
this value to be set to the current authenticated user. What's the
best way to do this?
My form's save method takes the current user as an argument. I've
trie
This is what I have done in these situations (I don't know if it is
proper or even good but did seem to work):
Implement _post_save on the Asset something like so ...
def _post_save(self):
# do needed imports
try:
self.get_assetstate()
catch assetstates.AssetStateDoesNotExist
No, sorry, that was an error I introduced when I was composing the email...
here's the real code...
class AssetState(meta.Model):
state=meta.CharField(maxlength=128)
def __repr__(self):
return self.state
class META:
admin=meta.Admin()
ordering = ['id']
class
On 9/21/05, Rachel Willmer <[EMAIL PROTECTED]> wrote:
> class State(meta.Model):
> state=meta.CharField(maxlength=128)
> def __repr__(self):
> return self.state
>
> class Asset(meta.Model):
> definition=meta.ForeignKey(AssetDefinition)
> state=meta.F
I have two classes:
class State(meta.Model):
state=meta.CharField(maxlength=128)
def __repr__(self):
return self.state
class Asset(meta.Model):
definition=meta.ForeignKey(AssetDefinition)
state=meta.ForeignKey(AssetState,null=True,blank=True)
14 matches
Mail list logo