IBM Developer is your one-stop location for getting hands-on training and learning in-demand skills on relevant technologies such as generative AI, data science, AI, and open source.
汎用ビューでdirect_to_templateを使う場合に、extra_contextを使うとする。 from django.conf import settings from django.conf.urls.defaults import * from django.views.generic.simple import direct_to_template from projects.models import Project from presentation.models import Presentation from documents.models import Document info_dict = {'template': 'index.html', 'extra_context': {'project_list': Project.objects.filter(p
前回で、TODOタスクの追加と一覧までは実現できたので、今回からは編集と削除処理を作っていきます。 削除処理については、汎用ビューのdjango.views.generic.create_update.delete_objectを使います。利用手順としては、まず、views.pyに削除処理用のメソッドを追加します。 /todo/views.py from django.views.generic.create_update import delete_object def delete_task(request): if not request.user.is_authenticated(): return render_to_response(request, "login.html") # ログインユーザのタスクかどうかチェック task = Task.get(request.POST
dispatcher.connectを今まで使っていたけれど、これがdeprecatedになってる。 新たにSignalクラスが増えていて、これがシグナルのベースクラスになるようだ。 from django.db.models.signals import pre_save from django.dispatch import dispatcher def update(signal, sender, instance, **kwds): instance.update_time = datetime.datetime.now() dispatcher.connect(update, pre_save, MyModel) としていたのが、 from django.db.models.signals import pre_save def update(signal, sender, in
Djangoで携帯向けサイトを構築するためのプラグイン。まだ、構想段階なので、以下はメモ。名前はプロジェクト名をdjango-mobilejpにして、モジュール名をmobilejpにしようかな。 インストール $ easy_install django-mobilejp でインストールできるようにする。Django 0.97以上を必須とする予定。 モジュール構成(予定)mobilejp.templatetagsDjangoテンプレートで絵文字や携帯向けHTMLを出力するのを支援するテンプレートタグmobilejp.mail各キャリアごとのメール送信処理mobilejp.forms絵文字入りのフォームデータを扱うためのnewformsラッパーライブラリmobilejp.emoji絵文字をエンコード・デコードするためのライブラリmobilejp.middlewareDjangoミドルウェア。ユ
こんにちは、chihiroです。今回はPythonでモバイルサイトを開発する場合に便利なライブラリ、WSGIUserAgentMobileを紹介します。これはUserAgentからキャリアや端末情報を取得するためのライブラリです。 Google Code WSGIUserAgentMobile http://code.google.com/p/wsgiuseragentmobile/ これは基本的にはPHPのPEAR::Net_UserAgent_Mobile、さらに元を辿ればPerlのHTTP-MobileAgentを、僕がPythonに移植したものですが、いくつか独自のメソッドやプロパティを追加しています。インストールから、基本的な使い方、Djangoで使用する場合の例をご紹介します。 インストール 諸般の事情によりまだPython Package Indexに登録していないので、開
Welcome to Djangosnippets.org, a site for users of the Django web framework to come together and share useful "snippets" of reusable code. If you're just here to browse, you can look through snippets organized by author, by language or by tag. You can also have a look at the top-rated snippets and the most-bookmarked snippets. If you'd like to contribute, sign up for a free account and you'll be a
はじめに 近年、Webアプリケーション開発で用いるプログラミング言語として、Lightweight Language(以降LL)と呼ばれるスクリプト言語が人気を博しています。本稿では、そのスクリプト言語の中からPythonとWebアプリケーションフレームワークのDjango(ジャンゴと読む)を紹介します。 Pythonの大きな特徴として、「言語仕様が小さくシンプルであり、簡潔で読みやすいアプリケーションを作れる」という点が挙げられます。DjangoはPythonの簡潔さをうまく活かし、シンプルかつ本格的な開発ができるWebアプリケーションフレームワークです。本稿ではこのDjangoによるアプリケーション開発の基本をチュートリアル形式で説明します。 対象読者 PythonによるWebアプリケーション開発に興味がある方 日頃、Perl、Ruby、PHP、Java、C#などPython以外のプロ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く