Re: help with foreign keys in admin

2011-02-02 Thread Karl Bowden
On 3 February 2011 16:14, Bobby Roberts  wrote:

> considering this model:
>
> class Inventory (models.Model):
>id = models.AutoField (primary_key=True)
>Barcode = models.BigIntegerField(blank=False)
>Location = models.CharField (max_length=25,blank=False,
> db_index=True)
>Sku = models.CharField (max_length=25,blank=False,
> db_index=True)
>Quantity = models.DecimalField (blank=False, max_digits=7,
> default=0,decimal_places=2,help_text='Quanity on barcode')
>LastAction = models.ForeignKey('AppSettings.InventoryOption',
> verbose_name=_('Last Action'), related_name='LastAction',blank=False,
> null=False)
>LastTouchedBy = models.ForeignKey(User, unique=False,
> db_index=True, blank=False)
>LastUpdated = models.DateTimeField
> (auto_now_add=True,blank=False, db_index=True,help_text='Auto Filled')
>
> class InventoryAdmin(admin.ModelAdmin):
>list_display =
> ('Barcode','Sku','Location','LastAction','LastUpdated','User.first_name',)
>search_fields = ['Barcode','Location','Sku','LastTouchedBy']
>readonly_fields =
>
> ['BarCode','Location','Sku','Quantity','LastAction','LastTouchedBy','LastUpdated']
> admin.site.register(Inventory,InventoryAdmin)
>
>
>
> two questions.
>
> 1) LastTouchedBy is the userid - what do i need to do to print out the
> firstname+lastname of the user in the list_display. (ie instead of
> printing out userid 123, I want to print out the user's full name,
> "john doe"
>

2) LastAction - I'm importing AppSettings model further up the page,
> how can I print out the text value of
> (AppSettings.InventoryOption.name) in place of the numerical value
> stored in LastAction
>
>
Hi Bobby,
You might be able to do this with python property decorators for both these
questions.

Ie:
class Inventory(models.Model):
@property
def touched_by_name(self):
return self.LastTouchedBy.get_full_name()

@property
def inventory_option_name(self):
return self.AppSettings.InventoryOption.name

class InventoryAdmin(admin.ModelAdmin):
list_display
= 
('Barcode','Sku','Location','LastAction','inventory_option_name','LastUpdated','touched_by_name',)

- Karl




>
> rapid help greatly appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-cms-2.0 problem

2009-08-10 Thread Karl Bowden

On Mon, Aug 10, 2009 at 9:22 PM, Rob B (uk) wrote:
>
> Trying to get a default install of :
> http://github.com/digi604/django-cms-2.0/
> up and running on my dev but I'm getting this error when trying to log
> into admin
> http://dpaste.com/77696/
>
> Any ideas?

Good morning Rob,

I just got an instance of django-cms-2.0 from git running yesterday.
And I must say I'm quite impressed.

I did run into a few hiccups on the way, but never say the error you
are receiving.

I am using Django-1.1 and started with the example project
django-cms-2.0/example/. I needed to disable 'south' and 'reversion'
to be able to run syncdb to a sqlite db and add pages respectively.

Any more details about your dev platform?

- Karl

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---