I'm trying to create a new Django/Python project in the JetBrains PyCharm IDE.
However, while typing my software name it informs me that
"You cannot call your app the same as your project".
Trying to fully understand the distinction between projects and applications in Django, I'd love someone to demonstrate the difference between an application and a project for some known compounded websites like Facebook, Gmail and YouTube.
My try with Facebook:
facebook
users
messages
notifications
posts
...
Basically the gist is that an app represents a specific part of your whole project. Moreover, the app can be "pluggable" into a similar project. In order to be maintainable an app should have it's own objectives that differ from the objectives of other apps.
In the excellent "Two Scoops of Django" book, the authors quote James Bennett:
The art of creating and maintaining a good Django app is that it
should follow the truncated Unix philosophy according to Douglas
McIlroy: "Write programs that do one thing and do it well".
Again the authors state:
In essence, each app should be tightly focused on its task. If an app
can’t be explained in a single sentence of moderate length, or you
need to say ‘and’ more than once, it probably means the app is too big
and should be broken up.
Update 19/12/2014:
With Django 1.7 this description of "Projects and applications" is definitely worth reading.
Update 21/12/2017:
Django 1.10 link here.
from the tutorial in the docs:
Projects vs. apps
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 Web site. A project can contain multiple apps. An app can be in multiple projects.
https://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-models
If you compared it to youtube the whole youtube site could be one big project, with functionality divided in apps such as the video search, messaging, profile/channel creation...if the structure is simpler you can keep different parts in one place, that's up to you. I prefer to only start splitting stuff up down the road.
In the official Django documentation:
1) An application is a web application that does something, for example, a blog system
2) A project is a collection of configuration and applications for a particular web site
3) A project can contain multiple applications. An application can be in multiple projects.
An application can be anything that can do some specific task in website. Ex:Banking domain -> Loan application, credit/debit card application etc.
A project is a collection of applications for a particular web site. Ex: Banking software, Gmail, Facebook etc.
Refer : https://consideratecode.com/2017/12/29/django-app-project-site/
Related
first of all apologies for the vague question, I thought I would clarify it in the body.
So basically, I am looking to design a website for my society, as a person with a fair amount of software development know how(or at-least I would like to think so), how can I go about designing a web application that can be edited, from the front end(I know this breaks alot of MVC principles), I want to make it so, that an administrator can login to the administrator account on the web app, and upload/delete a new blog and make aesthetic changes to the application. Is there any way to build/design a web applications this way.
So basically the program flow would look something like this
Administrators decides to update the blog
Administrator logins into the admin account
Edits the blog on the website
Saves the blog, the edited blog now appears on the front end, visible to all visitors.
Secondly, if the first option is not recommended, what frameworks can I use(preferably python) so that I can ensure the website is as maintainable as possible(after I finish university, I will not be maintaining it ).
Would a common framework such as Django, Flask suffice?
This must all be completed within 4-5 weeks, in a three developer team.
I would go with Flask, you can do almost anything you want with it.
When you say "edit blog" you mean "edit posts of the blog" like postbody-text, photos, etc?
These tasks can be done easily with Flask.
You can do the same with Django too, but Django is more heavy and is more suitable for big websites
In practice, you will create some routes in the Flask app with the functionality you want (edit posts, replace photos, etc) that will be accessed by the admin account only
After reading through How do you divide your project into applications in Django? and Django documentation about applications I am still not sure whether I should make or not a new application for certain stuff.
Let's imagine I have a Website with the following sections: <Home> <Login> <Register> <My account>.
Should all them be different applications? or should they be just one?
Also, imagine I include a section <Wiki> but it is not very linked with the page (I mean, not the design but the content makes relation to it).
Would this be a new project or application?
The individual sets of functionality (such as the ones you listed) should be applications.
When you group several applications together, you form a project.
However, the individual applications are usually self-contained enough that they could be picked up and dropped into another application. In this manner, you can re-use your 'login' application in several projects.
If it's part of the same site or webapp you're building, than don't make another project, one project shares the same settings.py, for example, so you can imagine that everything that relates to it belongs to the same project.
About the apps, you can create an entire project with just one app, but that's not advisable, you can separate your models in apps in a way that you fell confortable with it, for your own organization.
About login/register, take a look on User authentication documentation, that can clarify a little how one part of the site, in this case, authentication, can work with it's own app.
You should also do the Tutorial which could help you to understant how django basically works.
I'm slightly confused on what is meant by a "web application". I.e. Django positions itself as "a web framework" for the development of "web apps", quite similar to the description of Pyramid. What I'm looking for is a framework for an application that has a browser interface but is very database driven. In short: It's a system that should handle transaction and subscriptions. These transactions are registered through a web interface. The backend consists of XML/JSON feeds of these subscriptions/transactions and an administrative interface to generate statistics and reports. Quite similar to a ticketing/box office system.
Now: Is it a good decision to start out with something like Django/Pyramid even though they seem more focussed on the creation of "websites" rather than (scalable) input/output "applications". Is there any python framework that I'm better of using or are they perfectly suited for the kind of software that I'm describing?
Any help would be greatly appreciated!
I don't know Pyramid at the time of writing so I'll answer the Django part, though I can imagine the answer to apply to Pyramid as well as the distinction between websites and web application is quite vague.
Django is suitable for both websites and web applications: you can create an informative website for your local library as well as an all-in web application with lots of interactive features. Django simply facilitates the creation of the backend of a web system. Both websites and web applications use databases, have caching and can have interactive parts with forms.
It's just that websites are usually just for informing the user (most sites out there) or interacting with others (such as forums). A web application is best described with some examples, such as webmail, administrative interfaces, Google Docs, etc; it serves as a replacement of a desktop application.
From a technical perspective, there's no clear cut thing that separates the world of websites from web applications, it's just a matter of what you create with your web framework.
To answer your question, Django is quite suitable for creating a database-driven web application as it supports multiple databases, caching, autmatic creation and handling of forms, etc. I can imagine Pyramid to be suitable as well but I can't answer that. It's good to explore your options.
I believe that at this point you might want to think more about the overall architecture of your application rather than frameworks. For Example
Single Tier - Just a simple webapp, using simple file or object storage
Two Tier - Webapp + Relational Database. The webapp contains the presentation logic + business logic using MVC principles
Three Tier - Webapp + Middle Tier + Relation Database. In this setting, the Middle Tier will basically contain all the business & processing logic. The Webapp is then just a presentation layer
Once you decide the architecture, you can then start thinking about which framework to use for each of the component of the architecture.
I believe progressing this way will be less confusing and will give clarity of thought.
I need to create web application, which can be reached by user as regular web site and as XML-RPC web service. Also web site should have mobile version. I'm planning to use next technologies:
Django (for web frontends (regular and mobile)).
Pyramid (for web service).
SQLAlchemy, Memcached (for persistence level)
Later other projects can reach this data and providing logic, so I think it is better to make two tiers. I see it in next way:
Tier 1. Main logic service level. This level will provide API for frontend applications (Django powered web site, for example).
Tier 2. Different mostly end client applications (web site, API for remote client devices).
For communication between this tiers I'm planning to use XML-RPC protocol.
In this case it will be easy to scale it and add new front end application or connect another projects to this (I believe it).
I have main question, -- what can I use to make it easy build first tier? Maybe there is some framework good for that?
And what do you think about this whole architecture. Because I'm filling that I'm thinking in Java terms developing in Python. Maybe there is some another idioms in Python world for such situations.
Thanks for you time and help.
P. S.
Some links for reading are welcome.
This architecture really makes no sense. You're using Django, a full-stack web framework, for the front end, but not using it for the database. And you're using Pyramid, another full-stack web framework, for the web service side, thus ensuring that you duplicate all the business logic.
Much as I am an advocate of Django, I would say it has no place in your architecture. It looks like the only thing you're really using it for is URL routing and templates, both of which Pyramid does itself fine - you can even use Jinja2, which is based on Django's template language, as the template language in Pyramid if you like.
Doing it this way means that you can share the business logic between the front-end and web service code, since you'll almost certainly find that a lot of it will be the same.
I must say also that I don't understand the division into tiers, which you have described as separate from the front-end/web service division. To me, the web service is the second tier. It makes no sense to have a further division.
You should checkout the Turbogears framework as it is composed of several popular components: ORM with sqlalchemy, pylons for logic and support for WSGI, permits support for several templating engines for the frontend... endless.
I use it for several web-services behind AJAX-enabled front-ends (like Flex-based apps, among others). You can front end the TG2-based webapp with apache or your favorite WSGI-enabled web server too.
Checkout their website since they have a tutorial to setup a wiki in 20 minutes.
Cheers!
I need to build a web site with the following features:
1) user forum where we expect light daily traffic
2) database backend for users to create profiles, where they can log in
and upload media (pictures)
3) users can uses their profile to buy content from an online inventory
4) create web pages, shopping carts etc for online inventory
5) secure online credit card processing
I am very familiar with python but not with python web frameworks. I do know
some SQL. How do I get started developing something like this? Is Django
a good alternative?
Not programming related per se: Where do you recommend I get web hosting with a domain
name for an application like this?
Django was made for this kind of thing. Check it out.
As far as hosting, djangofriendly.com is a great resource. I have used WebFaction before and I am absolutely in love with how easy it is to get Django going with them and with their excellent customer service. Very top notch for reasonable prices if you are going the shared hosting route.
If you are looking to speed up some of the tasks described, you should check out Pinax and Django Pluggables. Thanks to the way Django applications are setup it is trivially easy to plug an application into your project.
You can try Pylons lightweight web framework.
Your requirements make pinax sound like a library you might want to look into if you go the django route.
Google App Engine will provide hosting for free as well as Django and a db..