On 17/01/2017 9:44 AM, Thufir Hawat wrote:
Not sure that I follow:
What’s the difference between a project and an app? An app is a Web
application that does something – e.g., a Weblog system, a database of
public records or a simple poll app. A project is a collection of
configuration and apps for a particular website. A project can contain
multiple apps. An app can be in multiple projects.
How can an app be in multiple projects? If someone would make that
sentence more concrete that would be appreciated.
A Django "app" is just part of a project. A simple project must have at
least one app to contain the models, views and templates. More complex
projects would get unwieldy (code-wise) if you couldn't split them into
multiple apps. Think of these as multiple directories containing
separate sets of models, views templates - but which can connect to each
other by using the ordinary Python "import" mechanism.
Those multiple directories have names equal to the app names. So from
app.models import Classname becomes an easy way of simplifying your
project into multiple directories.. er apps.
In the settings, you need to name all the apps (dirs) in the project so
Django knows where to find all the models and so on.
If you know you will use a particular part of one project (an app - say
for inserting note records into a table) in another project you can
copy/paste and adjust the edge bits so it works in that other project.
On the other hand, if you are disciplined and careful you can use object
oriented programming techniques (and the Django docs) to write those
edge bits in a non-specific way so it can slot unchanged into other
projects which are expecting it. That app can be in multiple projects.
If you are really disciplined and part-guru you can make such apps
public for us lesser mortals to install and save us from re-inventing
that particular wheel. But that's another story :)
Cheers
Mike
thanks,
Thufir
--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/d0542aff-2079-3d87-99ba-66f160c7eb91%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.