Re: Custum save on Foreignkey in Admin

2013-02-05 Thread Pankaj Singh
Hey Avnesh, First of all, your question is not related to current conversation. You should have started a new thread this. You are getting this error because foo.views.index does not exist, i.e., there is no `index` function in views.py file of your `foo` app. P.S. - Please use regular font

Re: Custum save on Foreignkey in Admin

2013-02-05 Thread Avnesh Shakya
plz tell me why this error is coming here... after setting urls.py. plz help me.. ViewDoesNotExist at /admin/ Could not import foo.views.index. View does not exist in module foo.views. Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version: 1.4.3Exception

Re: Custum save on Foreignkey in Admin

2013-02-04 Thread Rob van Dam | Camping het Wieskamp
Hi Pankaj, I tested the code at it works perfectly. Thanks again! I have one question out of curiosity (I don't need this for this project). When a ticketitem is deleted, def save_formset is called, but no instance is made, hence an error message "instance referenced before assignment"

Re: Custum save on Foreignkey in Admin

2013-02-04 Thread Pankaj Singh
Yes, save_formset() has only those instances whose fields were changed. Sincerely, Pankaj Singh http://about.me/psjinx On Mon, Feb 4, 2013 at 10:46 PM, Rob van Dam wrote: > Hi Pankaj, > > Thank you so much You have saved my day :-) I will be able to test it > tomorrow,

Re: Custum save on Foreignkey in Admin

2013-02-04 Thread Rob van Dam
Hi Pankaj, Thank you so much You have saved my day :-) I will be able to test it tomorrow, and I will let you know if it worked. I tested all my previous attempts saving an existing item in Admin. But when nothing is changed in the admin form, def save_formset is not called..

Re: Custum save on Foreignkey in Admin

2013-02-04 Thread Pankaj Singh
Hey Rob, I tested following code and it works. models.py from django.db import models # Create your models here. class Ticket(models.Model): ticketnumber = models.IntegerField() total_amount = models.DecimalField(max_digits=7, decimal_places=2, blank=True) def

Re: Custum save on Foreignkey in Admin

2013-02-04 Thread Rob van Dam | Camping het Wieskamp
Hi Pankaj, I have tried many things today, but unfortunately I cannot get anything working :-( Can you give me a bit more information on this issue? Any hint would be highly appreciated! I cannot get anything saved in the database. For testing I made this setup (added ordernumber to the

Re: Custum save on Foreignkey in Admin

2013-02-02 Thread Rob
Thank you for the reply! I was working on a custom save in models.py, never thought about working on the formset in admin.py Rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from

Re: Custum save on Foreignkey in Admin

2013-02-02 Thread Pankaj Singh
http://stackoverflow.com/questions/8294889/override-save-on-django-inlinemodeladmin Sincerely, Pankaj Singh http://about.me/psjinx On Sun, Feb 3, 2013 at 1:34 AM, Pankaj Singh wrote: > Hey Rob, > > You can override save_formset() method of ModelAdmin for this. Create > a

Re: Custum save on Foreignkey in Admin

2013-02-02 Thread Pankaj Singh
Hey Rob, You can override save_formset() method of ModelAdmin for this. Create a method update_total_amount(self) in your Ticket Model. class TicketAdmin(admin.ModelAdmin): def save_formset(self, request, form, formset, change): instances = formset.save(commit=False) for

Custum save on Foreignkey in Admin

2013-02-02 Thread Rob
I have two models: class Tickets(models.Model): ticketnumber = models.IntegerField() total_amount = models.DecimalField() class TicketItems(models.Model): name = models.Charfield(max_length=30) ticket = models.ForeignKey(Tickets) price = models.DecimalField() amount =

Show mail instead user name in ForeignKey at admin

2010-07-30 Thread Alexandre González
Hi! When I'm using user as ForeignField in some of my models I get a box with the username, can I override this with the mail instead the username? I've tested making a Proxy class, but I think that the proxy classes isn't for this. I heard about MonkeyPatch but I don't know how to use it, or

Re: ForeignKey / ManyToManyField / admin interface

2010-03-06 Thread Matthew Warren
Ok, thanks for the reply. I had wondered along those lines myself, and changed the code to; class elements(models.Model): name=models.CharField(max_length=21) elementgroup=models.ForeignKey(grouping) class grouping(models.Model): name=models.CharField(max_length=48) Though now when

Re: ForeignKey / ManyToManyField / admin interface

2010-03-06 Thread Christophe Pettus
On Mar 6, 2010, at 10:37 AM, Matthew Warren wrote: Hi, I have a model like the following; class elements(models.Model): name=models.CharField(max_length=21) class grouping(models.Model): name=models.CharField(max_length=48) elementgroup=models.ForeignKey(elements) I'm

ForeignKey / ManyToManyField / admin interface

2010-03-06 Thread Matthew Warren
Hi, I have a model like the following; class elements(models.Model): name=models.CharField(max_length=21) class grouping(models.Model): name=models.CharField(max_length=48) elementgroup=models.ForeignKey(elements) I'm assuming this means that a grouping may relate to multiple

Re: trouble with foreignkey and admin interface

2008-11-25 Thread delfick755
> The error message is telling you exactly what the problem is here. It > wants Position to have a ForeignKey to Member. When you read that and > look at your models and see that you have Member having a ForeignKey to > Position, you have to then think that perhaps that means you've got the >

Re: trouble with foreignkey and admin interface

2008-11-24 Thread Malcolm Tredinnick
On Tue, 2008-11-25 at 13:39 +0900, Stephen Moore wrote: > Hello, > > I'm trying to create a model here for essentially recording the > positions held by members in the committee of a university club I'm > creating a website for. > > However, I'm new to django and am having some issues. > > So

trouble with foreignkey and admin interface

2008-11-24 Thread Stephen Moore
Hello, I'm trying to create a model here for essentially recording the positions held by members in the committee of a university club I'm creating a website for. However, I'm new to django and am having some issues. So far, I have : A Committee model containing a year and a set of members

Multiple selects for ForeignKey in admin

2008-10-24 Thread Nick Sandford
Just wondering how easy it would be to implement something like this: class Foo(models.Model): name = models.CharField(max_length=200) bar = models.ForeignKey(Bar) class Bar(models.Model): name = models.CharField(max_length=200) category = models.CharField(max_length=200)

Restrict values for ForeignKey field (admin site)

2008-09-29 Thread janedenone
Hi, I intend to create a simple inventory app. There are two major tables/ models: software and hardware. Software can be installed on certain types of hardware (i.e. PCs and servers), but not on others (displays etc). How can I restrict the ForeignKey field displayed within the edit form for

Re: ForeignKey reverse admin

2007-06-15 Thread Malcolm Tredinnick
On Fri, 2007-06-15 at 02:37 -0700, endi wrote: > I have a little problem with ForeignKey's. It's easy to explain. > My database model involves a many-to-one relationship which i would > like to admin reversely. > > ie. Articles and Authors, one Articles can have one Author, one > Authors can

ForeignKey reverse admin

2007-06-15 Thread endi
I have a little problem with ForeignKey's. It's easy to explain. My database model involves a many-to-one relationship which i would like to admin reversely. ie. Articles and Authors, one Articles can have one Author, one Authors can have many Articles. I would like to admin the thing from the

Re: ForeignKey and Admin

2006-07-06 Thread arthur debert
What you are looking for is the edit_inline option for the event field: class EventDate(models.Model): ... event = models.ForeignKey(Event, edit_inline=True) more info here: http://www.djangoproject.com/documentation/tutorial2/#adding-related-objects [] arthur

ForeignKey and Admin

2006-07-06 Thread X-Phuture
Hello, I'm currently creating a website in Django and I have a problem to create my models. I have 2 classes : - Event : which hold the information about an event (where it take place, the number of places available, etc...) - EventDate which is used to know when an event takes place (since an