Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.

2008-04-24 Thread joasch


Being new in the Python/Django camp (2 weeks) but doing php for
several years, I find this a very interesting topic and I would like
to extend the question a bit, like "when is an app becoming too big?"
The use case here is when you develop a rather complicated "app" which
need to have quite some functionality and all bits need to be there
for i to work. Mutual dependencies so to speak. I think one such good
example is the Satchmo ecommerce app. It's kind of built up as a
project of apps, which makes it (unnecessarily?) difficult to
implement in an existing site, imho, unless you make it a "sub-site"
like shop.domain.com to integrate with a www.domain.com.

Having studying Python/Django intensively these weeks, trying to merge
it with my general developing knowledge, I kinda tend to look at this
(optimaly) being 1 app, and things like discount, giftcertificate,
etc. isn't really apps but modules making up a bigger app or is this
"wrong" thinking? Remember, I am very new to Python but not to
programming in general and what I realy try to arrive at is to "think
Python/Django" - which of course will take its time;-)

To sum up, if you write such a "big" app, how is the best and
"correct" Django way to organize such code as some files could get
really lengthy of code? Surely splitting it up in smaller files is the
way to go, but are there any "rules" there?

And by the way, yet another one moving from php to python - I just
can't understand why I haven't done this long time ago, although
better late then never as it's said.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.

2008-04-24 Thread Norman Harman

Erik Vorhes wrote:
> There's nothing wrong with parceling out models across different apps.
> And unless you're planning on distributing each app separately, don't
> worry about cross-app dependencies.
> 
> In this case, I'd encourage you to--since you'll probably want to do
> more than just book-related stuff with your people. (The same could be
> said about the books.)
> 
> Another reason to have 2 apps for these models is overall growth of
> models.py. The more code that's there, the harder it becomes to edit.
> (I'm in the process of parceling out a bunch of models myself. Don't
> give yourself that headache!)

If you are distributing apps separately you can use conttenttypes and 
generic relations.

http://www.djangoproject.com/documentation/models/generic_relations/

django-tagging django-voting are some apps that use that.  Find them on 
google code.

-- 
Norman J. Harman Jr.
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.

2008-04-23 Thread Michael Elsdörfer

On Apr 23, 10:29 pm, Jay <[EMAIL PROTECTED]> wrote:
> In the django docs I see that you can easily make a foreign key by
> referencing the model:
>
>   manufacturer = models.ForeignKey('production.Manufacturer')
>
> ...but it feels like maybe stepping outside the "django way."

You can also just import the model itself from the other app and use
it directly. This works just fine as long as you don't need cross
references, i.e. app A importing app B importing app A.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.

2008-04-23 Thread Jay

I was thinking along the same lines-- it's more of a single, big app
than a bunch of portables.  And I was worried about models.py becoming
too unwieldy.  Thanks a lot!

On Apr 23, 4:38 pm, "Erik Vorhes" <[EMAIL PROTECTED]> wrote:
> There's nothing wrong with parceling out models across different apps.
> And unless you're planning on distributing each app separately, don't
> worry about cross-app dependencies.
>
> In this case, I'd encourage you to--since you'll probably want to do
> more than just book-related stuff with your people. (The same could be
> said about the books.)
>
> Another reason to have 2 apps for these models is overall growth of
> models.py. The more code that's there, the harder it becomes to edit.
> (I'm in the process of parceling out a bunch of models myself. Don't
> give yourself that headache!)
>
> E
>
>
>
> On Wed, Apr 23, 2008 at 3:29 PM, Jay <[EMAIL PROTECTED]> wrote:
>
> >  I'm working on a project which for the purposes of this conversation
> >  we could say is about authors writing and sharing books.
>
> >  My tendency is to want to make an app called "people" and an app
> >  called "books," as these are two different models in my mind.  A
> >  person has certain attributes which would be defined in the "person"
> >  model, and the book has certain attributes which would be defined in
> >  the "book" model.
>
> >  For some reason it's weirding me out to put these in the same app.  I
> >  think because seeing tables like people_book or books_person doesn't
> >  feel right.  I imagine something more like:
>
> >  books_book
> >  books_genre
> >  people_person
> >  people_group
> >  people_person_contacts
>
> >  But I need to make the link between the author (person) and the book.
> >  In the django docs I see that you can easily make a foreign key by
> >  referencing the model:
>
> >   manufacturer = models.ForeignKey('production.Manufacturer')
>
> >  ...but it feels like maybe stepping outside the "django way."
>
> >  I know there's no definitive answer, but at what point do you
> >  typically decide that something belongs in it's own app?  Is it
> >  typical to dump everything into a single app?
>
> --
> portfolio:http://textivism.com/
> blog:http://erikanderica.org/erik/
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.

2008-04-23 Thread Erik Vorhes

There's nothing wrong with parceling out models across different apps.
And unless you're planning on distributing each app separately, don't
worry about cross-app dependencies.

In this case, I'd encourage you to--since you'll probably want to do
more than just book-related stuff with your people. (The same could be
said about the books.)

Another reason to have 2 apps for these models is overall growth of
models.py. The more code that's there, the harder it becomes to edit.
(I'm in the process of parceling out a bunch of models myself. Don't
give yourself that headache!)

E

On Wed, Apr 23, 2008 at 3:29 PM, Jay <[EMAIL PROTECTED]> wrote:
>
>  I'm working on a project which for the purposes of this conversation
>  we could say is about authors writing and sharing books.
>
>  My tendency is to want to make an app called "people" and an app
>  called "books," as these are two different models in my mind.  A
>  person has certain attributes which would be defined in the "person"
>  model, and the book has certain attributes which would be defined in
>  the "book" model.
>
>  For some reason it's weirding me out to put these in the same app.  I
>  think because seeing tables like people_book or books_person doesn't
>  feel right.  I imagine something more like:
>
>  books_book
>  books_genre
>  people_person
>  people_group
>  people_person_contacts
>
>  But I need to make the link between the author (person) and the book.
>  In the django docs I see that you can easily make a foreign key by
>  referencing the model:
>
>   manufacturer = models.ForeignKey('production.Manufacturer')
>
>  ...but it feels like maybe stepping outside the "django way."
>
>  I know there's no definitive answer, but at what point do you
>  typically decide that something belongs in it's own app?  Is it
>  typical to dump everything into a single app?
>  >
>



-- 
portfolio: http://textivism.com/
blog: http://erikanderica.org/erik/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---