<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bgola &#187; add_view</title>
	<atom:link href="http://blog.brunogola.com.br/tag/add_view/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.brunogola.com.br</link>
	<description>python, free software, hacking, free culture, bicycle commuting, geocaching</description>
	<lastBuildDate>Wed, 08 Dec 2010 12:49:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Modifying Django NewForms-Admin views</title>
		<link>http://blog.brunogola.com.br/2008/09/modifying-django-newforms-admin-views/</link>
		<comments>http://blog.brunogola.com.br/2008/09/modifying-django-newforms-admin-views/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 12:22:31 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[add_view]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[customize]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[newforms]]></category>
		<category><![CDATA[newforms-admin]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=56</guid>
		<description><![CDATA[Playing with the new Django features, specially with the NewForms-Admin, I was looking for a way to change the add view behavior for some models. It&#8217;s really easy and obvious (it&#8217;s always easy and obvious with Python and Django). First, you&#8217;ll need the admin.py file in your app directory. from django.contrib import admin from myproject.myapp.models [...]]]></description>
			<content:encoded><![CDATA[<p>Playing with the new <a href="http://www.djangoproject.com/">Django</a> features, specially with the NewForms-Admin, I was looking for a way to change the <em>add</em> view behavior for some <em>models</em>.</p>
<p>It&#8217;s really easy and obvious (it&#8217;s always easy and obvious with Python and Django).</p>
<p>First, you&#8217;ll need the <em>admin.py</em> file in your app directory.</p>
<p><code><br />
from django.contrib import admin<br />
from myproject.myapp.models import MyModel</p>
<p>class MyModelAdmin(admin.ModelAdmin):<br />
    def add_view(self, request):<br />
        if request.method == 'POST':<br />
            # do whatever you want<br />
            # remember, POSTing means that someone entered data.<br />
        return admin.ModelAdmin.add_view(self, request)</p>
<p>admin.site.register(MyModel, MyModelAdmin)<br />
</code></p>
<p>The <em>add_view</em> method is called when you try to <em>add</em> an entry using the admin. There are other interesting methods you should look too, for customizing the admin behavior (change_view, delete_view, etc).</p>
<p>Another way to customize things is to write your own <em>ModelForm</em>, but it&#8217;s beyond the scope of this post <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/09/modifying-django-newforms-admin-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

