Re: Configure multi-field multi-select form in Django Admin

2009-11-25 Thread rc
Tim,

Thanks for the response. That is what I was looking for. I got it
working now, just needed a little hint. Found the User Admin stuff (in
contrib) and was able to follow that.
As far as the "id" columns.I adapted Django to an existing system
so that is why the models don't necessarily match the Django norm.

Reed

On Nov 24, 7:41 pm, Tim Valenta  wrote:
> > The javascript will be found somewhere under django/contrib/admin/media/js.
>
> To be clear, rc, although the javascript is of course available for
> viewing, you should only need to put that attribute
> "filter_horizontal" on your ModelAdmin.  There shouldn't be any need
> for inserting any custom javascript commands anywhere.  That one
> attribute does it all.
>
> And... this might pose a problem, but I don't see any ManyToManyFields
> in your models.  It won't work unless you're using those, instead of
> ForeignKeys.
>
> For the extra mile, you shouldn't need those various "_id =
> models.AutoField(primary_key=True)" parts.  Django does that
> automatically, but names each one just "id", instead of "[modelname]
> _id".  Unless you specifically want them to be named differently than
> "id", you don't have to specify it, which helps it be more readable.
> But it's of course your own project :)  Do it however you wish!
>
> Tim
>
> On Nov 24, 6:01 pm, Karen Tracey  wrote:
>
> > On Tue, Nov 24, 2009 at 12:32 PM, rc  wrote:
> > > As I mentioned, the Django admin has exactly what I want with the user
> > > permission form (auth_user, auth_permissions and
> > > auth_user_user_permission). Does anyone know where that code is
> > > located in the Django environment?
>
> > That's done with javascript, activated by listing the fields in:
>
> >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
>
> > The javascript will be found somewhere under django/contrib/admin/media/js.
>
> > Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Configure multi-field multi-select form in Django Admin

2009-11-24 Thread Tim Valenta
> The javascript will be found somewhere under django/contrib/admin/media/js.

To be clear, rc, although the javascript is of course available for
viewing, you should only need to put that attribute
"filter_horizontal" on your ModelAdmin.  There shouldn't be any need
for inserting any custom javascript commands anywhere.  That one
attribute does it all.

And... this might pose a problem, but I don't see any ManyToManyFields
in your models.  It won't work unless you're using those, instead of
ForeignKeys.

For the extra mile, you shouldn't need those various "_id =
models.AutoField(primary_key=True)" parts.  Django does that
automatically, but names each one just "id", instead of "[modelname]
_id".  Unless you specifically want them to be named differently than
"id", you don't have to specify it, which helps it be more readable.
But it's of course your own project :)  Do it however you wish!

Tim

On Nov 24, 6:01 pm, Karen Tracey  wrote:
> On Tue, Nov 24, 2009 at 12:32 PM, rc  wrote:
> > As I mentioned, the Django admin has exactly what I want with the user
> > permission form (auth_user, auth_permissions and
> > auth_user_user_permission). Does anyone know where that code is
> > located in the Django environment?
>
> That's done with javascript, activated by listing the fields in:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
>
> The javascript will be found somewhere under django/contrib/admin/media/js.
>
> Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Configure multi-field multi-select form in Django Admin

2009-11-24 Thread Karen Tracey
On Tue, Nov 24, 2009 at 12:32 PM, rc  wrote:

> As I mentioned, the Django admin has exactly what I want with the user
> permission form (auth_user, auth_permissions and
> auth_user_user_permission). Does anyone know where that code is
> located in the Django environment?
>
>
That's done with javascript, activated by listing the fields in:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_horizontal

The javascript will be found somewhere under django/contrib/admin/media/js.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Configure multi-field multi-select form in Django Admin

2009-11-24 Thread rc
As I mentioned, the Django admin has exactly what I want with the user
permission form (auth_user, auth_permissions and
auth_user_user_permission). Does anyone know where that code is
located in the Django environment?

On Nov 24, 10:13 am, rc  wrote:
> What I want to do is have a form with one field that allows you to
> select a profile. Once this profile is selected there will be two
> windows below that show available tests and selected tests. The Django
> admin interface for the user permissions uses this format. Not sure
> what it is called in Django.
>
> My current models are listed below. I have a joining table called
> Testsuite that joins tests to profiles. It works now, but the admin is
> not very easy to add or remove tests to a testsuite since you have to
> add one at a time. If someone can point me in the right direction I
> would appreciate it.
>
> Anyway I have the following models:
> ---
> Models
> --
>
> class Profile(models.Model):
>     profile_id = models.AutoField(primary_key=True)
>     profile_name = models.CharField(max_length=75)
>     description = models.CharField(max_length=1500, blank=True)
>     def __unicode__(self):
>                         return self.profile_name
>     class Meta:
>         db_table = u'profile'
>
> class Testcase(models.Model):
>     test_id = models.AutoField(primary_key=True)
>     test_name = models.CharField(max_length=300)
>     src = models.ForeignKey(Source, null=True, blank=True)
>     bitrate = models.IntegerField(null=True, blank=True)
>     test_type = models.CharField(max_length=300)
>     output_resolution = models.CharField(max_length=15, blank=True)
>     description = models.CharField(max_length=3000, blank=True)
>     ref_file = models.CharField(max_length=765, blank=True)
>     ref_encode_filesize = models.IntegerField(null=True, blank=True)
>     ref_y_psnr = models.DecimalField(null=True, max_digits=7,
> decimal_places=2, blank=True)
>     ref_u_psnr = models.DecimalField(null=True, max_digits=7,
> decimal_places=2, blank=True)
>     ref_v_psnr = models.DecimalField(null=True, max_digits=7,
> decimal_places=2, blank=True)
>     ref_yuv_psnr = models.DecimalField(null=True, max_digits=7,
> decimal_places=2, blank=True)
>     highmark_version = models.CharField(max_length=60, blank=True)
>     def __unicode__(self):
>                 return self.test_name
>     class Meta:
>         db_table = u'testcase'
>
> class Testsuite(models.Model):
>     testsuite_id = models.AutoField(primary_key=True)
>     profile = models.ForeignKey(Profile, related_name='profile')
>     test = models.ForeignKey(Testcase, related_name='test')
>     #def __unicode__(self):
>                         #                       return
> self.testsuite_id
>     def __unicode__(self):
>                return '%s,%s' % (self.profile, self.test)
>     class Meta:
>         db_table = u'testsuite'

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Configure multi-field multi-select form in Django Admin

2009-11-24 Thread rc
What I want to do is have a form with one field that allows you to
select a profile. Once this profile is selected there will be two
windows below that show available tests and selected tests. The Django
admin interface for the user permissions uses this format. Not sure
what it is called in Django.

My current models are listed below. I have a joining table called
Testsuite that joins tests to profiles. It works now, but the admin is
not very easy to add or remove tests to a testsuite since you have to
add one at a time. If someone can point me in the right direction I
would appreciate it.


Anyway I have the following models:
---
Models
--

class Profile(models.Model):
profile_id = models.AutoField(primary_key=True)
profile_name = models.CharField(max_length=75)
description = models.CharField(max_length=1500, blank=True)
def __unicode__(self):
return self.profile_name
class Meta:
db_table = u'profile'

class Testcase(models.Model):
test_id = models.AutoField(primary_key=True)
test_name = models.CharField(max_length=300)
src = models.ForeignKey(Source, null=True, blank=True)
bitrate = models.IntegerField(null=True, blank=True)
test_type = models.CharField(max_length=300)
output_resolution = models.CharField(max_length=15, blank=True)
description = models.CharField(max_length=3000, blank=True)
ref_file = models.CharField(max_length=765, blank=True)
ref_encode_filesize = models.IntegerField(null=True, blank=True)
ref_y_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
ref_u_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
ref_v_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
ref_yuv_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
highmark_version = models.CharField(max_length=60, blank=True)
def __unicode__(self):
return self.test_name
class Meta:
db_table = u'testcase'

class Testsuite(models.Model):
testsuite_id = models.AutoField(primary_key=True)
profile = models.ForeignKey(Profile, related_name='profile')
test = models.ForeignKey(Testcase, related_name='test')
#def __unicode__(self):
#   return
self.testsuite_id
def __unicode__(self):
   return '%s,%s' % (self.profile, self.test)
class Meta:
db_table = u'testsuite'

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.