Rainy

Thanks for the feedback and I'm sure you are right that the line is incorrect. However I need a bit of instruction. I have read extensively over the last year but I think I must be missing a fundamental thing. This is the first programming I've ever done so you may need to spell it out in the most simplest terms.

My aim is to take the decimal value of the percentage field on the Fringe table and use it to multiply against the currency_total value on the Detail table of the record and then store that on the Detail table. There may be more than one fringe for a row and so the percentages need to be summed before they are sent to the save. I was hoping I had written that with the _get_fringe_value routine -but maybe not!

What I think I've not understood is how these processes are called and whether I have put this coding in the right place. As I am trying to save values at the same time I put the def _get_fringe_values under the Detail class. Should I be in fact creating a model.Manager to run this process and then call that on save. On my readings I thought model managers were used at table level rather than row level and I think what I'm trying to do is effect a row not a table.

I've been looking through Definitive guide to Django, Practical Django projects and Pro Django but they are more concerned with getting the relationship of the models understood (which is no bad thing) rather than the actual syntax when writng code. I have worked through some Python tutorials online but still struggle to test my code via the shell! All this leads me to going around in ever decreasing circles - I hope you can help me out of the fog.

-TS


Rainy wrote:
On Jan 20, 2:04 pm, Trevor Stanley <h...@balancingact.me.uk> wrote:
Kenneth

That is what I originally though but if I write that this is the error I
get:

in _get_fringe_value
    ft = Fringe.objects.select_related().filter(id=self.id).values()
AttributeError: 'str' object has no attribute 'id'

I'm in London and I do this in my spare time so have just arrived home
from work.  Many thanks for looking at this for me.



This line isn't right:

fringe_value = _get_fringe_value('aqft')

Not sure what you're trying to do, if first arg
to that function is self, you should use it
as an instance method, e.g.

detail = Detail(...)
detail._get_fringe_value()

If you want to pass it a second arg, change
def line to accept a 2nd arg and call with:

detail._get_fringe_value('aqft')

-ak


--
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.

Reply via email to