Re: New-by Model traps and other questions...

2010-09-08 Thread Lance F. Squire
On the many to many field, Great info, I'll look into those. On combining the fields, 'Thumbs' is really Thumbnail images of 'Images'. However, not all 'Images' have 'Thumbs' Thinking that 3 possibly blank fields in 'Images' is more efficient than 9 fields in a different table for each actual

New-by Model traps and other questions...

2010-09-07 Thread Lance F. Squire
Ok, I'm just getting back to a project I had to put on hold for a while. I recently read an article on problems new Django users fall into, and I think I hit one. The bottom of my 'Systems' model looks like this: keyboard = models.CharField(max_length=80) cart = models.CharField(

Conceptual Problems/ Sanity(mine) Checking...

2009-05-26 Thread Lance F. Squire
return self.name def get_thumb(self): return self.imagesmall.filter(primary=True)[0] Should I continue this way or should (how could ) I re-work the System, Image and Thumb models to do the job? I'm thinking I need another descriptor on the Image model. Oh, 'primary

Re: Converting .96 to 1.0 How to admin models?

2008-09-26 Thread Lance F. Squire
On Sep 26, 1:53 pm, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > > # relative import is simpler and safer > import models > > # using introspection > from django.db.models import Model > for name in dir(models): > obj = getattr(models, name) > if obj is not Model and issubclass(obj,

Converting .96 to 1.0 How to admin models?

2008-09-26 Thread Lance F. Squire
Converting a .96 site I was working on to the 1.0 set-up. Is there a quick way to list all my models in the admin? Or do I have to : from HCVGM.systems.models import System admin.site.register(System) for every one? b.t.w. I presume the class Admin: pass in the Models.py is

Re: Getting specific data from a many to many field.

2008-09-16 Thread Lance F. Squire
On Sep 16, 2:30 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > > Sorry, my mistake. filter() always gives you a queryset - because > there might be more than one instance of the related model that fits > the criteria - so you can't jut reference the location/width directly. > The best way is to

Re: Getting specific data from a many to many field.

2008-09-15 Thread Lance F. Squire
On Sep 15, 5:21 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > Probably the easiest solution, if you know you're > always going to be requesting a certain lookup, is to define a custom > method on the model: > > class System(models.Model): > ... field declarations ... > > def get_heade

Re: Getting specific data from a many to many field.

2008-09-15 Thread Lance F. Squire
On Sep 15, 4:13 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > So, putting that all together: > > {% for pic in info.system_pictures.all %} > {% ifequal pic.image_category.name 'Header_Pic' %} > > {% endifequal %} > {% endfor %} > Sweet! That works. Thanks! I'll try to rememb

Getting specific data from a many to many field.

2008-09-15 Thread Lance F. Squire
Using Fedora 8, Django version 0.96.3 I'm currently trying to pull two specific images from a list of images associated with a model. Currently the Models are like this: class ImageCat(models.Model): name = models.CharField(maxlength=80) class Image(models.Model): name = models.Ch

Re: Displaying a list of lists?

2008-09-12 Thread Lance F. Squire
On Sep 12, 8:32 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > You need the ifchanged tag: > > > {% for items in list %} > {% if changed items.0 %}{{ items.0 }}{% endifchanged %} td>{{ items.1 }} > {% endfor %} > Thats what I went with! Looks like it would use less processor cycles to do t

Re: Displaying a list of lists?

2008-09-11 Thread Lance F. Squire
Is there a way to see if a filed changes between iterations? That is, I pass the Systems list to the template sorted by Manufacturer and name. The template then only displays the new Manufacturer name when it changes? I thought I saw something like that somewhere, but can't find it now Lanc

Displaying a list of lists?

2008-09-11 Thread Lance F. Squire
Currently using Django version 0.96.3, on a Fedora 8 system. I've currently set-up models for 'Manufacturer' and 'System'. System has a Foreignkey to Manufacturer. I'd like to display a list like so: Manu A System a System b System c Manu B System a System b System c Etc...

Re: Forms from Database Tables with choice selects.

2008-05-22 Thread Lance F. Squire
charfield just to get it to render at all. Lance On May 21, 7:41 pm, "Adam Gomaa" <[EMAIL PROTECTED]> wrote: > Lance, it's also not clear to me what exactly you need. Are you using > ModelForm? If not, what do you mean by the 'auto generated' form? I > think

Re: Forms from Database Tables with choice selects.

2008-05-22 Thread Lance F. Squire
k three people. It could > have one m2m or 3 fks to Person depending on the strictness of the > requirement for 3 and the business logic it supports. If you went this > route, you could present a user with a form for ThreeRelatedPeople and they > could choose three existing or create

Forms from Database Tables with choice selects.

2008-05-21 Thread Lance F. Squire
I'm trying to make a Form where 3 people need to be inputed. All three need to have a Title.(EG. Mr. Mrs. etc.) I tried making the Title fields in the database be a key to a table of title selections. The sql generation had no trouble with that, but the Form generator doesn't like it at all... I