Hello everybody,
I'm new to django, and writing my first app, I have a question before deploying it.
I need to have a function that would create or modify, according to a few rules and a precise instance of a model (Song), many instances of another model (Words) at once.
Writing that function is easy, my problem is, where should I put it, so it's easy to use when the application will be in production?
Should it be in the model layer? Or in a separate module? Will I call it with the shell? Is it possible to access it via the admin site? Or any other way?
I would strongly suggest you use signals.
--
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...@googlegroups.com.
To post to this group, send email to django...@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/1f785d0b-304d-49e5-94c0-57a49cae4e79%40googlegroups.com.
Thanks, Tom,
I'm not sure I need to use signals altogether, as I know when a Song is added. If I make a method in the Song model, I suppose I can import the model and run it in the shell? Or is there a way I could run it directly from the admin site?
Hélène
On 21/05/2014 17:15, Tom Lockhart wrote:
On 2014-05-20, at 12:26 PM, "C. Kirby" <mis...@gmail.com> wrote:
I would strongly suggest you use signals.
This nicely enables an automatic path of execution. But if you also want to execute this code, say, from the admin interface or separately for testing then you may want to package the fundamental code into a method of the Song model, then run that method in the signal handler.
hth
- Tom
--
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...@googlegroups.com.
To post to this group, send email to django...@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/537CD10A.9070307%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/z416rzZ8Ih8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@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/75348526-0BC0-4153-B1C9-2DCEA95F3282%40gmail.com.