Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Anyone could recommend a good guide/tutorial/article with tips/guidelines in how to organize and partition a large Django project?
I'm looking for advices in what to do when you need to start factorizing the initial unique files (models.py, urls.py, views.py) and working with more than a few dozens of entities.
Each "application" should be small -- a single reusable entity plus a few associated tables. We have about 5 plus/minus 2 tables per application model. Most of our half-dozen applications are smaller than 5 tables. One has zero tables in the model.
Each application should be designed to be one reusable concept. In our case, each application is a piece of the overall site; the applications could be removed and replaced separately.
Indeed, that's our strategy. As our requirements expand and mature, we can remove and replace applications independently from each other.
It's okay to have applications depend on each other. However, the dependency has to be limited to the obvious things like "models" and "forms". Also, applications can depend on the names in each other's URL's. Consequently, your named URL's must have a form like "application-view" so the reverse function or the {% url %} tag can find them properly.
Each application should contain it's own batch commands (usually via a formal Command that can be found by the django-admin script.
Finally, anything that's more complex than a simple model or form that's shared probably doesn't belong to either application, but needs to be a separate shared library. For example, we use XLRD, but wrap parts of it in our own class so it's more like the built-in csv module. This wrapper for XLRD isn't a proper part of any one application, to it's a separate module, outside the Django applications.
I've found it to be helpful to take a look at large open-source Django projects and take note of how that project does it. Django's site has a good list of open-source projects:
http://code.djangoproject.com/wiki/DjangoResources#Open-SourceDjangoprojects
As does Google (although most of these are smaller add-in template tags and Middleware:
http://code.google.com/hosting/search?q=label:django
Of course, just because one project does it one way does not mean that that way is The Right Way (or The Wrong Way). Some of those projects are more successful than others.
In the end, the only way to really learn what works and doesn't work is to try it out yourself. All the tips and hints in the world wont help unless you try it out yourself, but they may help you get started in the right direction.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 months ago.
Improve this question
I have dabbled with Django and Created one project successfully.
What I don't understand is how exactly the whole Django Framework Works e.g. internal structure, which line of code gets executed first and why, what would be workflow between a request and response cycle, etc. ? I maybe asking the wrong questions.
What would be the best way to understand the Django framework?
I suggest you to start with a Django in depth video by James Bennett. He's member of the Django core team and was involved with it since the 2005. Video descriptions says:
This is a tutorial that goes beyond most tutorials; it's meant for
developers who already know a bit about Django and want to really
understand the inner guts of the framework. This tutorial will not
involve writing code or apps; rather, it'll be a deep tour of the
workings and APIs of Django itself, across all the bundled components
and at all levels of the stack.
I personally love this video to death, it's the starting point for my understanding of Django.
If you want to build some more advanced Django projects while being a tyro take a look at these -
http://shop.oreilly.com/product/0636920032502.do
http://shop.oreilly.com/product/9781785886775.do
If you want to read more about Django design patterns and best practices try these
https://www.twoscoopspress.com/products/two-scoops-of-django-1-8
https://highperformancedjango.com/
I assume you're wandering into Django framework territory from the neighbourhood of PHP based server-side scripts.
I too(like any newcomer...) was initially intrigued with the seemingly unnecessary abstractions around webpages, databases and business logic of the websites/web apps.
Firstly, understand that the concept of server-side web development using Django is directed by the MVC paradigm. It takes a while getting used to, but is very simple and intuitive once you get a hang of it.
Next, learn to visualize the app directory and project directory structures and the dependencies between them. For example, you should be able to understand the reason for having a separate <your_app_name> folder within every templates folder...
Finally, learning by experience and practice is a good way to learn Django basics. Jump into the simple sample implementations of Polls app to get the workflow. Finish all 7 parts of the Polls app tutorial.
Don't worry if you don't get concepts at once. Re-read them and don't forget to code as you learn.
Here's the starting point:
Django Polls app tutorial Part 1
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Let's say you have a universal college application. The user inputs their information and the universal application submits the correct subset of information to each school.
What is a good approach to organizing the data validation?
For example, when a user decides to apply to school A you must validate that the user has input into the universal application all of the information required for school A.
This process is repeated for school B, school C, etc. Most of the information that must be validated is probably the same for each application, with some small differences.
Is there a library or architecture that would be optimal for setting this up? I've looked into solutions like Cerberus or Py-Good which help with the validation part, but not really the high-level approach.
In Rails, I have seen a solution called validation contexts. I am trying to implement this in Python (Django).
If you are working with Django, it has everything you will need to validate incoming data. The standard way to validate data with Django is through forms (and more specifically, form validation.)
From the docs:
Django’s role in forms
Handling forms is a complex business. Consider Django’s admin, where
numerous items of data of several different types may need to be
prepared for display in a form, rendered as HTML, edited using a
convenient interface, returned to the server, validated and cleaned
up, and then saved or passed on for further processing.
Django’s form functionality can simplify and automate vast portions of
this work, and can also do it more securely than most programmers
would be able to do in code they wrote themselves.
You will find some helpful examples in the links that I've posted. I would recommend looking at the clean method.
If the logic is mostly the same for each scenario, but with slight differences, you will likely be able to create a single form that can process the data appropriately based on what the user has selected.
Hope this helps.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Just a stupid question. I've been struggling in these last days, as a Django beginner, with the email registration (instead of the default User registration), and I've been thinking: is it better (in a process of learning) to keep on with the struggle and succeed, in the end, in the realization of the "project", or is it good too to use Django packages (like django-registration-redux)?
I mean, is it going to help me all the struggle of doing things without packages (i.e. Suppose I want to work as a Django developer), or is it useless effort?
Thank you.
Although I agree with The Laughing Man that this is opinion based, I will give my opinion hoping it will help. I have worked with Django for quite a while now, and I have learned that the answer to your question is based on a few things; Does the package have all of the functionalities you need, and a little more in case you need it? Can you and will you want to extend the functionality of the package yourself eventually? And most importantly - is the package well maintained? I found that answering yes to those three questions usually meant it was a good bet to go with the package.
In your case - it looks like the package is very well maintained - so I would go with that assuming it meets the other 2 criteria (or django-allauth, which is also excellent). No point in reinventing the wheel, especially if someone has done it better.
I agree with The Laughing Man and Hybrid for their respective view points. I have not worked with Django, but have worked with a large number of other frameworks.
I would like to add to what Hybrid has said - remember that Django is a framework and a framework usually consists of a set of packages most of which work in tandem with each other(for example a method in one package P1 may expect an argument that is actually obtained using facilities from another package P2).
Hence, if your code uses the packages available within Django then it will seamlessly work with other packages within the Django framework. If you are to (re)invent the wheel, then you may end up with some highly sophisticated and specialized functionality which would have the following characteristics:
Buggy - because you may not have handled all the use-cases and flows needed within that package.
Does not promote seamless integration with other core framework libraries. In which case you would need to write more code so that your specialized class works with the framework classes.
Re-inventing the wheel most often is a waste of time unless you are truly sure that you can solve the same problem in a real mind-blowing new way.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I heard a lot of people talking about Django on various forums. But I am having a very basic question : What is meant by Framework and why Django is used.
After listening a lot about Django, I ran few chapters for Django (from Djangobook.com). After running these chapters, I am wondering how Django can be used to create a very simple website. (Website should have few pages like Home, Favorites, About, Contact linked to each other and will be providing static content).
Can Django be used for creation of such website? I searched a lot on internet but couldn't find any relevant examples, I only encountered with the examples for creation of blog, forum sites etc. If Django can be used for creation of this website, what should be the approach.
Can someone please explain this basic term "Framework" and its significance?
No. It's not for making websites. Your sample just sounds like you want plain old HTML.
Django is for creating web applications. That is, software, normally backed by a database, that includes some kind of interactivity, that operates through a browser. A Framework provides a structure and common methods for making this kind of software.
I think what you're looking for is a very simple CMS (Content Management System), there are many of those available in all kinds of languages/frameworks. Django has django-cms and mezzanine (among others).
What django is really awesome at is building dynamic websites really fast, you don't need to worry about most things, you just define your data model and off you go (almost). If you want to have a better insight into what's possible, have a look at the django tutorial (under "First Steps"), it gives you a good introduction to django and how to build websites using it.
Django can be used to create dynamic high-security web applications. For creating a static website like the one you asked, HTML is enough.
Tutorial for creating a django application can be found here.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'd like to use Python to build a website with more than 100,000 PV each day. Now what I concern is to choose which web framework. I know lots of people use Django, and some people use web.py. Django seems powerful, and I also like the simplicity of web.py. Which framework should I use? (Please introduce the performance and the maintenance complexity, thanks!) Can web.py build complicated applications? Are there other frameworks better than these two?
In case you haven't started yet, Give both frameworks a try. I started off with Django and moved to web.py.
Web.py is not that hard as one might think. In fact, I find it easier to work with than with Django!
Just my 2 cents.
EDIT: Also, this might help: http://www.aaronsw.com/weblog/rewritingreddit
Django makes building complicated sites really simple. Before Django, I was messing around with PHP, and I was doing a really terrible job putting it together. Django leads you in the right direction with some good practices which makes your site really easy to maintain and update. I really like the ORM and how you can easily work with data from the database without having to write a single line of SQL. It makes development less of a slog.
I don't have any experience with web.py, and I can't compare the performance of the two. But you can't go wrong with Django at least.
Django is actually quite fast. Using caches and multiple DB backends is a doodle - you actually can utilize Django's predefined caching framework for one-line view caching or even template fragment caching. And of course - low-level cache API. And - it's fun!
In my experience - deployed under nginx and uWSGI, watched over by Supervisord, with the recently hot Celery task queueing package – Django is blazingly fast, easy to scale and configure and very reliable.
forget all those, if you want a beautiful framework look for weppy, i have used django , web2py, bottle,flask and most major php frameworks, just use weppy its full stack and exquisitely elegant, for php i simply created my own microframework that looks abit like weppy but its not fullstack, i love the granular control that weppy gives me and its quite easy to learn and its such a joy to use, eer did i already say that its beautiful? yes it surely is hahaha. you can find it here : http://www.weppy.org thank me later