[Fixed]-What is a good Django workflow?

20👍

Follow the Agile approach. Finish one small case, from the start to the end. From the models to the tests to user experience. Then build on it. Iterate.

Thats the right way to software development.

To do it efficiently, you need: (don’t bother right away, you will need it.)

Automated schema migration, automated build system, auto updating and deployment. – None of these, django has got anything to do with. Use pip, fabric, hudson, twill and south appropriately.

Take care not to over burden yourself with all these right away, particularly since you say, you are beginning.

👤lprsd

8👍

the required steps for a Django application?

There are two required steps.

Write the settings. Write the urls.py

The rest of the steps are optional.

This also serves as a checklist of things to do.

Bad policy. You don’t need a checklist of Django features. You need a collection of use cases or user stories which you must implement.

For some reason, you’ve omitted the two most important and valuable features of Django. Configure the default admin interface and write unit tests. The default admin interface is very high value. Unit testing is absolutely central.

You do it like this.

  1. Gather use cases.

  2. Prioritize the use cases.

  3. Define the actors. The classes of actors becomes groups in the security model.

  4. Define enough “applications” to satisfy the first release of use cases. Define the url structure. Cool URL’s don’t change.

  5. Build the first use case: models (including security), admin, urls, tests, forms, views and templates. Note that these are the file names (models.py, admin.py, …) except for templates. Also note that forms and admin should be defined in separate modules even though this isn’t required. Also note that templates will be split between a generic templates directory for top-level stuff and application-specific templates.

  6. Build the second use case: models (including security), admin, urls, tests, forms, views and templates.

n. Package for release. Tweak up the settings. Configure database and mod-wsgi

👤S.Lott

2👍

I personally can’t make a template without writing the views (unless it’s a photoshop draft) but in general that’s the way I go after I have a plan.

What’s extremely important for me is that I don’t dive head-first into the code, and that I spend time mocking up the model structure based on the “screens” or “pages” that the user will see.

Once I have a user experience defined, I make sure the backend is robust enough to handle that experience. If I don’t visualize the user experience, details get left out that are certainly accomplishable in the shell but not ideal for the website, default django admin, etc.

There are always tradeoffs between agile development and a huge spec: I think there’s an important balance. Agile is good: there’s no point planning every detail before writing your first line of code, as your needs will change by the time you get to the end. You don’t know how your users will really use the site.

On the other hand, without a plan, you can end up with a messy foundation that affects all future code.

An educated guess is a good start. Don’t think or assume too much, but definitely have a clear idea how your users will interact with your site for stage 1.

0👍

Always try to remember about a DRY rule. For example, why to write RequestContext every new view is defined, where you can simply write a function once, which will add it for you. Good description is here in another topic.

Try to keep a code written one way. Each time you upgrade a schema of your view, edit it in all already written views. That will help keep your code clear and save a lot time for you in future.

Generally good rule, and how do I write my applications is the rule of small steps. Start with writing a settings and urls, then add one model and one view. When it works, modify – add another models or another views. You won’t even notice, when your project becomes bigger and bigger.

And the last useful rule for clarity of all the source. Keep files in folders. If you have two subsites based one one (for example “accounts” and “blogs”) create two directories names the same. Remeber to put init.py file in each directory. It’s really easy to forget. With this practice it’s easy to write models and views dedicated to each category. By the way it’s a good practice to keep urls like in a tree structure. Main urls.py should contain only links like this one:

(r'^accounts/', include('your_main_name.accounts.urls')),

and of course all media, static, css and so on. In accounts directory urls keep:

urlpatterns = patterns('your_main_name.accounts.views',
    url(r'^$', 'index', name='index'),
)

with all views subdirectories.

Last one – keep code clear with actuall django version. Remeber, that the 3.0 release is comming soon.

Hope this will help.

👤Gandi

0👍

I find that my process varies depending on a lot of variables, mainly whether I know something will work or if I’m experimenting and also whether I’m developing on my production server or in a development environment.

For example, I often do my development directly on the deployment server (most of my work is for intranet projects so there isn’t any security risk, etc). But when I do this I really need to make sure the settings and urls are setup first and that gunicorn and nginx are configured.

If I know something should work, or am setting up a generic base set of code, sometimes I’ll do all that coding for views and models before I even get enough setup to even run the development server. But when experimenting with new code I find it’s good to be able to test every step of the way, so in that case you need your servers running.

In general I do settings, models, syncdb, views, urls, templates, collectstatic, graphics/aesthetics

In general I leave my base.html very plain until the everything else is working, then I add css/js etc.

I guess my point here is that there isn’t really a wrong answer for how you do it, and there isn’t even only one best practice (as far as I’m concerned). When you do more work, you’ll find what you are comfortable with and it’ll even vary from project to project.

Good luck, hopefully you learn to love django!

👤j_syk

0👍

here is something I do in general,

  • configure basic settings
  • configure root url.py
  • configure settings, url.py for static (media) files
  • create model
  • sync db
  • write views (use simple template, if needed)

once you are done with back end implementation

  • think about UI
  • prepare styles, scripts
  • start working on template implementation

Leave a comment