On Sun, 2007-05-20 at 11:34 -0700, Greg wrote: > Malcolm, > Ok, I've modified my models.py with the following code > > class sdetails(models.Model): > color = models.ForeignKey(color) > size = models.ForeignKey(size) > price = models.ForeignKey(price) > > class style(models.Model): > name = models.CharField(maxlength=100) > styleslug = models.SlugField(prepopulate_from=["name"]) > image = models.ImageField(upload_to='site_media/') > collection_id = models.ForeignKey(collection) > styledetails = models.ManyToManyField(sdetails, > edit_inline=models.TABULAR, num_in_admin=3) > > > However, I now get an error becuase I guess I can't use edit_inline in > a ManyToManyField. Any suggestions?
Ohm yeah.. that's true. Sorry, I wasn't concentrating when I wrote my initial reply. You have two (well three, but two right now) choices here that I can think of immediately: (1) Don't use edit inline (since you can't), but use the "+" link that appears next to a standard many-to-many selection box to add new items. (2) Manually construct the many-to-many relation by creating a model with two ForeignKey fields that link to "style" and "sdetails" (dude! Use capitals for your class names like the rest of the world so that they stand out in text!) and edit that intermediate model in the Admin. You can then put edit_inline on the two fields. I made that work for a client that needed that type of editing and it was acceptable as a quick way to get something working. The mysterious third option is find some hack that works today and look forward eagerly to the newforms-admin branch, because there are a lot more customisability hooks in that code, so things like this should be possible (although you will have to read Python code to work out all the little details). Alternatively, don't get hung up on using the admin app for entering this particular set of data. Knock up a custom form to do it. Regards, Malcolm > > On May 20, 12:36 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > On Sun, 2007-05-20 at 10:03 -0700, Greg wrote: > > > Hello, > > > I am trying to create a Django website where I sell area rugs. I'm > > > starting the process of creating the structure of my site, but am > > > having problems creating my admin correctly. Each area rug that I > > > sell has a list of sizes (with a price associated with each size). I > > > can't seem to figure out how I'm going to setup my admin page that > > > add's an area rug. This page is going to need to be able to add > > > multiple sizes and associated each size with a price. > > > > > Here is a snaphot of my admin page when i add a style > > >http://www.plushrugs.com/image.jpg. As you can see I don't have it > > > setup to where I can associate a size with a price. All I can do is > > > select multiple sizes and multiple prices. > > > > > You can also take a look at my models file at the following url - > > >http://www.plushrugs.com/model.txt > > > > The problem isn't in the admin interface setup, so much as in your model > > design. As you noticed in the admin interface, there is no > > correspondence between a prices, colors and sizes, but this difficulty > > extends to the model level. A "style" contains a bunch of those items, > > without tying them together into triplets. > > > > I would suggest that you make a new model which holds a particular > > combination of price, color and size and then the "style" class has a > > many-to-many field pointing to this other model. Then you can use > > edit_inline to create new price/color/size combinations when you are > > creating a style. > > > > Regards, > > Malcolm- Hide quoted text - > > > > - Show quoted text - > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

