Re: Getting hold of an instance of a model from inside RelatedManager

2011-01-25 Thread kmpm
It's ok by me to return something generic or even raise an exception if I'm calling directly using RelatedStuff.objects.my_method(). Is it possible for my_method to access MainStuff instance or at least find out which way it is accessed? Imagine I got a instance of MainStuff like this... main =

Getting hold of an instance of a model from inside RelatedManager

2011-01-25 Thread kmpm
I have some issues with getting hold of the instance of a Model to which a RelatedManager got contributed to. Is that at all possible and if so, how? >From *my_method* below I can get hold of the model *RelatedStuff* by calling self.model but that really doesn't get me there. class MainStuff(mo

Re: 'unique' field upon inserting

2011-01-25 Thread kmpm
I don't know if this will make you happy but when I researched this some months ago I found no good solution. During my search I came upon the following pages that sort of relate to this... - http://github.com/dcramer/django-idmapper - http://appengine-cookbook.appspot.com/recipe/hi

Re: Generate a daily serial/batch/lot number

2010-09-06 Thread kmpm
On Sep 6, 8:40 pm, raj wrote: > Hi all, > Why can't we use the aggregate function 'max' from within save()? I > found it working to find the lot_max from among the objects filtered > by prod_date and then if lot_max is None, lot_no must be 0, else it's > just lot_max + 1. I don't know if I've mi

Re: Launching Background Processes from a View

2010-09-06 Thread kmpm
://ericholscher.com/blog/2010/jun/23/large-problems-django-mostly-solved-delayed-execut/ /kmpm On Sep 6, 7:20 pm, Heath wrote: > Thanks! yes, > > os.system() will launch the process and return control, but then I'd > have to write a utility to get the PID and other data about the >

Re: Generate a daily serial/batch/lot number

2010-09-06 Thread kmpm
On Sep 6, 6:52 pm, Preston Holmes wrote: > > what about a simple function that does something as low tech as > checking a lock file.  If you had multiple front end servers, this > could be a running process on a server using semaphore lock. > > -Preston Sort of thought about that as well. Meanw

Re: Generate a daily serial/batch/lot number

2010-09-06 Thread kmpm
For anyone listening in... the ticket http://code.djangoproject.com/ticket/2705 might also be worth looking at On Sep 6, 11:39 am, kmpm wrote: > > UUIDs are your best bet. Even if you generated 100 billion UUIDs a > > second for the next 100 years, the chance of one collision would

Re: Generate a daily serial/batch/lot number

2010-09-06 Thread kmpm
> > UUIDs are your best bet. Even if you generated 100 billion UUIDs a > second for the next 100 years, the chance of one collision would only > be 50% [1]. > > class ProducedEntity(models.Model): >     >     uuid = models.CharField(max_length=36, unique=True) > > def _hook_add_uuid(instance,

Re: Generate a daily serial/batch/lot number

2010-09-06 Thread kmpm
On Sep 6, 9:02 am, Mike Dewhirst wrote: > On 6/09/2010 4:19pm, kmpm wrote: > > > I have a project running in a manufacturing industry that is actually > > built upon django. > > In this I need to generate a unique serial, batch or lot number > > (depending on what y

Generate a daily serial/batch/lot number

2010-09-05 Thread kmpm
I have a project running in a manufacturing industry that is actually built upon django. In this I need to generate a unique serial, batch or lot number (depending on what you would like to call it) that is a running number from 0 to whathever for each and every day. There is a high risk of concurr

Re: Multiple databases - syncdb

2010-02-03 Thread kmpm
@klemens you are most definitely not alone. I made a router that would allow me to have one database per app and I get exactly the same type of error on both postgres and sqlite. Doing syncdb on the default db work as it should but when I in this case do a ./manage.py syncdb --database=ads I get th

Re: Inventory model design

2009-12-16 Thread kmpm
Hi, I will try to give my shot at this. I would create one 'Item' model which have common fields like description, product category etc. For quantities I would create a system of units and unit conversion tables for each item using one model called 'Unit' and one called 'ItemUnit' or similar. Unit