December 28, 2014

Speedy Django Development

guitar Speedy Django DevelopmentAs I’ve mentioned before, I am building my own web store using Django. The coding is going extremely quickly, thanks to the excellence of the framework.

I find myself marvelling at how quickly and simply various elements come together, especially when I contrast this to my previous experience doing the same thing with Java for an employer.

For example, the Login/User framework. With Django, I simply include the auth middleware, and create a couple templates to “skin” the login, profile, password change, and password reset pages. In return, I get a full-featured, working login system with sessions, cookies, and all that tedious plumbing done for me. Total time from decision to use the built-in framework to implementation? Two hours, including learning the system. Unbelievable.

Contrast that with my use of Acegi/Spring to handle authentication in a Java app. I was shockingly fast implementing this, taking just two full working days. The documentation directly states that you should plan on at the very least one full week. The system was huge, slow, and baroque. Modifying the system was clumsy and frequently required I relearn things from the reams of documentation. Yes, overall it offered more functionality. No, there was no stripped-path to just get the most needed set of features for a website. The craziest thing is that the config files for Acegi
alone were larger than all the code and templates I wrote for django login
.

Another example is my need to generate thumbnails for some graphics. I want to generate them “on the fly”, when needed. Total lines of code to do this in Python with PIL, integrated with Django? 7. Total time? 15 minutes, including all the logic needed to make sure that I only create the thumbnail once.

Contrast this with the nightmare that is the Java image API. I seriously spent days making a caching thumbnailing system in Java for an Auction site I worked on. Even after that, it was much slower than my Python solution.

Now that I am actually developing a serious app for Django, I find myself feeling the love more and more. Thanks Django team!
[tags]django,python,spring,acegi,pil[/tags]

Share and Enjoy:
  • services sprite Speedy Django Development
  • services sprite Speedy Django Development
  • services sprite Speedy Django Development
  • services sprite Speedy Django Development
  • services sprite Speedy Django Development
  • services sprite Speedy Django Development
  • services sprite Speedy Django Development
  • services sprite Speedy Django Development

Related posts:

  1. Another win for Django One nice thing about Django is that unlike many frameworks,...
  2. Top ten reasons to use Django for your web framework Django is pulling ahead of every other web framework I’ve...
  3. Django encourages Flow Django is one good web framework....
  4. Django Magic Removal, this time for real Despite my earlier initial successes using the Django Magic-Removal Branch,...
  5. Django on Rimuhosting This is just a quick post to confirm that Django...

About Bruce Kroeze

Comments

  1. It’s great to see you’re working on a Django based store. We have a project called Satchmo that is attempting to build a Django-based framework for use in online stores.

    Come check us out here – http://satchmo.python-hosting.com/wiki

    We’re in the very early stages and would welcome any help. However, it is amazing how quick and powerful Django is. for instance, I’ve incorporated Nesh’s thumbnails into the store and it is really easy to create thumbnails and automatically cache them. Or, maybe you can use some of the models/code we’ve put together to help make your transition even easier!

    Thanks,
    Chris

  2. Can you out your 7 lines of code to use thumbnails? I have to do the same thing, and it would very useful for me.

    If an image is removed, is the thumbnail removed too?

  3. Bruce says:

    Alright. I have added a few lines since I wrote the blog entry. Here’s the somewhat more developed private method from the class which does that. If you strip the logs and comments, it is 13 lines.


    def _create_thumb(self, force):
    log.debug("Thumbnailing (%i x %i) %s", self.x, self.y, self.parent.filename)
    do_create = True

    if files.is_file(self.filename):
    if force:
    log.debug("Forcing removal of existing thumbnail: %s" % self.filename)
    os.remove(self.filename)

    elif files.newest_filename(self.parent.filename, self.filename) == self.parent.filename:
    log.debug("Found existing (older than parent image) thumbnail, removing: %s", self.filename)
    os.remove(self.filename)

    else:
    log.debug("Found existing thumbnail, skipping create: %s", self.filename)
    do_create = False

    if do_create:
    im = Image.open(self.parent.filename)
    im.thumbnail((self.x, self.y), Image.ANTIALIAS)
    im.save(self.filename, "JPEG")
    log.debug("Created thumbnail: %s", self.filename)

Speak Your Mind

*