well, you can always write the raw SQL querie...
-- https://docs.djangoproject.com/en/1.4/topics/db/sql/
On Sunday, September 29, 2013 10:16:47 PM UTC-5, Lachlan Musicman wrote:
On Sunday, September 29, 2013 10:16:47 PM UTC-5, Lachlan Musicman wrote:
Hola,
I have a inventory system with Parts and Part types. Part Types are
Archetypes, parts are instances of Part Types with details (unit cost,
serial number, date of purchase, etc).
A big issue is that not all Parts have serial numbers (box of 1000
screws for instance). But when we get a large quantity of parts that I
would like to apply serial numbers to, data entry staff don't want to
enter the otherwise identical data again and again.
Since most serialised products we are storing come with numbers that
are "in serial", I want to replace the creation process with a form
that also asks for "first serial number" and "number of parts" -
giving a nice list of easily incremented serial numbers. Then we can
create the requisite objects at the same time, and save them with just
the diff serial.
What is the best way to do this?
I've seen three solutions so far:
1. bulk_create https://docs.djangoproject.com/en/1.4/ref/models/ querysets/#bulk-create
problem: doesn't call model save method (in my case, where the slug is
populated from the id).
2. transaction.commit_manually
https://docs.djangoproject.com/en/dev/topics/db/ transactions/#django.db. transaction.commit_manually
3. Signals https://docs.djangoproject.com/en/dev/ref/signals/# django.db.models.signals.post_ save
(and now that I think about it, probably transaction.commit_manually
coupled with it).
What does the list recommend as a method?
Also, as I discovered in the IRC the other day, there really is a time
when CBVs aren't appropriate. Should this process be a CBV - it seems
a lot more suited to a FBV.
Cheers
L.
--
Maya Otos (@maya_otos) tweeted at 9:27 PM on Tue, Jul 30, 2013:
When you used to be punk, and now you are still punk but not as punk,
are you post-punk or decaying punk or ex-punk or just not punk anymore
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 it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f166ff7b-f449-47b1-add8-05d07759f9b5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment