<?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>Les notes de Golgotha &#187; Framework</title>
	<atom:link href="https://blog.developpez.com/cs-blog/pcategory/framework/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/cs-blog</link>
	<description>Quelques articles sur le développement.</description>
	<lastBuildDate>Thu, 16 May 2013 04:53:41 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Django &#8211; Afficher les données d&#8217;une table</title>
		<link>https://blog.developpez.com/cs-blog/p11976/framework/django-afficher-les-donnees-dune-table</link>
		<comments>https://blog.developpez.com/cs-blog/p11976/framework/django-afficher-les-donnees-dune-table#comments</comments>
		<pubDate>Thu, 16 May 2013 04:53:41 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=160</guid>
		<description><![CDATA[Dans l&#8217;article précédent, nous avons créée deux notes, voyons comment les afficher sur notre page web. Pour ce faire, nous allons utiliser une boucle for dans le template. Avant tout, il faut sélectionner les notes dans la contrôleur et les &#8230; <a href="https://blog.developpez.com/cs-blog/p11976/framework/django-afficher-les-donnees-dune-table">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p style="text-align: justify">Dans l&rsquo;article précédent, nous avons créée deux notes, voyons comment les afficher sur notre page web. Pour ce faire, nous allons utiliser une boucle for dans le template.</p>
<p>Avant tout, il faut sélectionner les notes dans la contrôleur et les envoyer au template :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">shortcuts</span> <span style="color: #ff7700;font-weight:bold;">import</span> render_to_response <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> myapp.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> Note <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> home<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notes <span style="color: #66cc66;">=</span> Note.<span style="color: black;">objects</span>.<span style="color: #008000;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> render_to_response<span style="color: black;">&#40;</span><span style="color: #483d8b;">'home.html'</span><span style="color: #66cc66;">,</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">'notes'</span>: notes<span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></div></div>
<p>Les deux éléments importants à retenir :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">notes <span style="color: #66cc66;">=</span> Note.<span style="color: black;">objects</span>.<span style="color: #008000;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
<p>Je récupère tout les enregistrements <strong>Note</strong> (équivalent à select * from myapp_note)</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: black;">&#123;</span><span style="color: #483d8b;">'notes'</span>: notes<span style="color: black;">&#125;</span></div></div>
<p>la variable notes est transmit sous le nom &lsquo;notes&rsquo; à mon template (la page HTML).</p>
<p>Comme vous le voyez, nous n&rsquo;utilisons pas de SQL pour récupérer les enregistrements en base de données. Ici tout est objet.<br />
</br><br />
Voyons maintenant comment afficher les notes dans mon fichier html :</p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% extends &quot;base.html&quot; %} <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% block content %} <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Todo :<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span>&gt;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% for n in notes %} <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>{{ n.libelle }}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% endfor %} <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% endblock %}</div></div>
<p><strong>Django</strong> nous permet d’itérer sur l&rsquo;objet notes avec une boucle <strong>{% for n in notes %}</strong>. l&rsquo;affichage de l&rsquo;attribut se fait avec <strong>{{ objet.attribut }}</strong>.</p>
<p>Et voici le résultat :</p>
<p><img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-9.png" alt="affichage de notes" /></p>
<p>Dans le prochain article, nous verrons comment ajouter, supprimer et modifier un objet avec <strong>Django</strong>.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Django &#8211; le site d&#8217;administration</title>
		<link>https://blog.developpez.com/cs-blog/p11974/framework/django-le-site-dadministration</link>
		<comments>https://blog.developpez.com/cs-blog/p11974/framework/django-le-site-dadministration#comments</comments>
		<pubDate>Wed, 15 May 2013 18:48:53 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=153</guid>
		<description><![CDATA[Cinquième article consacré à Django. Django est livré avec un site d&#8217;administration de données, un peux comme phpMyAdmin. Il permet d&#8217;ajouter/créer et supprimer des objets en base de données. Cela est très utile quand vous débuter avec votre site web, &#8230; <a href="https://blog.developpez.com/cs-blog/p11974/framework/django-le-site-dadministration">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Cinquième article consacré à <strong>Django</strong>.</p>
<p style="text-align: justify">
<strong>Django</strong> est livré avec un site d&rsquo;administration de données, un peux comme <strong>phpMyAdmin</strong>. Il permet d&rsquo;ajouter/créer et supprimer des objets en base de données. Cela est très utile quand vous débuter avec votre site web, et que tout n&rsquo;est pas encore terminé. Voyons comment il fonctionne.</p>
<p style="text-align: justify">
Pour commencer, il faut déclarer l&rsquo;objet <strong>Note</strong> (créée dans l&rsquo;article précédent) dans l&rsquo;administration, sinon il n&rsquo;apparaitra pas. Pour cela, créer un nouveau fichier <strong>admin.py</strong> dans le répertoire <strong>/mysite/myapp</strong>
</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> myapp.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> Note <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span> <span style="color: #ff7700;font-weight:bold;">import</span> admin <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; admin.<span style="color: #dc143c;">site</span>.<span style="color: black;">register</span><span style="color: black;">&#40;</span>Note<span style="color: black;">&#41;</span></div></div>
<p>Ensuite, il faut paramétrer différent fichier pour que l&rsquo;administration soit en place :<br />
Dans <strong>settings.py</strong>, dé-commentez les lignes relatives à l&rsquo;administration :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INSTALLED_APPS <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.auth'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.contenttypes'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.sessions'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.sites'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.messages'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.staticfiles'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'myapp'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Uncomment the next line to enable the admin: </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #483d8b;">'django.contrib.admin'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Uncomment the next line to enable admin documentation: </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #483d8b;">'django.contrib.admindocs'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span></div></div>
<p>Ainsi que dans le fichier des urls :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">conf</span>.<span style="color: black;">urls</span>.<span style="color: black;">defaults</span> <span style="color: #ff7700;font-weight:bold;">import</span> patterns<span style="color: #66cc66;">,</span> include<span style="color: #66cc66;">,</span> url <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span> <span style="color: #ff7700;font-weight:bold;">import</span> admin <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; admin.<span style="color: black;">autodiscover</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; urlpatterns <span style="color: #66cc66;">=</span> patterns<span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url<span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^$'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'mysite.myapp.views.home'</span><span style="color: #66cc66;">,</span> name<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'home'</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url<span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^admin/'</span><span style="color: #66cc66;">,</span> include<span style="color: black;">&#40;</span>admin.<span style="color: #dc143c;">site</span>.<span style="color: black;">urls</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span></div></div>
<p>Resynchronisez la base de données avec la commande <strong>syncdb</strong>.</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; manage.py syncdb <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating tables ... <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table django_admin_log <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Installing custom SQL ... <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Installing indexes ... <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; No fixtures found.</div></div>
<p>Redémarrer votre serveur, puis rendez-vous à la page <strong>http://127.0.0.1:8000/admin/</strong>.<br />
</br><br />
Connecter vous avec le compte que vous avez crée précédemment en ligne de commande. (avec <strong>syncdb</strong>) Si tout ce passe bien vous arriverez à cette page :</p>
<p><img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-6.png" alt="admin django" /></p>
<p>Nous pouvons directement créer des Notes ici :<br />
<img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-7.png" alt="add notes" /><br />
<em>Cliquez sur Notes, puis Add Note.</em></p>
<p>Créer deux notes.</p>
<p><img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-8.png" alt="creation notes" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django &#8211; le modèle de données</title>
		<link>https://blog.developpez.com/cs-blog/p11964/framework/django-le-modele-de-donnees</link>
		<comments>https://blog.developpez.com/cs-blog/p11964/framework/django-le-modele-de-donnees#comments</comments>
		<pubDate>Sat, 11 May 2013 05:33:10 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=148</guid>
		<description><![CDATA[Bienvenu dans le quatrième article consacré à Django. Nous allons voir une des forces de Django : l&#8217;abstraction de la base de données. Django utilise un fichier modele.py, qui défini clairement les objets du projet. Tout comme le Python, Django &#8230; <a href="https://blog.developpez.com/cs-blog/p11964/framework/django-le-modele-de-donnees">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Bienvenu dans le quatrième article consacré à <strong>Django</strong>.</p>
<p style="text-align: justify">
Nous allons voir une des forces de <strong>Django</strong> : l&rsquo;abstraction de la base de données. <strong>Django</strong> utilise un fichier <strong>modele.py</strong>, qui défini clairement les objets du projet. Tout comme le Python, <strong>Django</strong> est très orienté objet. Ici nous ne verrons pas de requêtes sql, de connexion à la base de données, ou de <em>commit</em> Cela pourrait paraître comme une limitation mais <strong>Django</strong> à été pensé et construit pour cela, vous avez donc une multitude d&rsquo;outils pour aller aussi loin que vous le voulez.
</p>
<p>Pour illustrer cela, nous allons créer une liste de note puis l&rsquo;afficher.<br />
<em>Je considère que vous avez une base de donnée MySQL installée sur votre machine.</em></p>
<p>Premièrement, il faut définir la base de données dans le fichier <strong>settings.py</strong> :</p>
<p><span id="more-148"></span></p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DATABASES <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'default'</span>: <span style="color: black;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'ENGINE'</span>: &nbsp; <span style="color: #483d8b;">'mysql'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'NAME'</span>: &nbsp; &nbsp; <span style="color: #483d8b;">'django_db'</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'USER'</span>: &nbsp; &nbsp; <span style="color: #483d8b;">'root'</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'PASSWORD'</span>: <span style="color: #483d8b;">'root'</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'HOST'</span>: <span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'PORT'</span>: <span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span></div></div>
<p style="text-align: justify">
Donc ici j&rsquo;ai créer un schéma qui se nomme <strong>django_db</strong> sur ma base de donnée MySQL.<br />
Ces données sont utilisé pour que <strong>Django</strong> dialogue avec votre base de données, comme vous pouvez le voir, votre projet pourra aussi bien tournée sur MySQL que sqlite3 ou encore oracle sans changer une seule ligne de code !
</p>
<p>Maintenant que le paramétrage est fait, ouvrer le fichier <strong>models.py</strong> et copier le code suivant :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">db</span> <span style="color: #ff7700;font-weight:bold;">import</span> models <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">class</span> Note<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; libelle <span style="color: #66cc66;">=</span> models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length<span style="color: #66cc66;">=</span><span style="color: #ff4500;">200</span><span style="color: black;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; status <span style="color: #66cc66;">=</span> &nbsp;models.<span style="color: black;">IntegerField</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__unicode__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">libelle</span></div></div>
<p>Il faut déclarer notre application dans le fichier de configuration :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INSTALLED_APPS <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.auth'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.contenttypes'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.sessions'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.sites'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.messages'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'django.contrib.staticfiles'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'myapp'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Uncomment the next line to enable the admin: </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># 'django.contrib.admin', </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Uncomment the next line to enable admin documentation: </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># 'django.contrib.admindocs', </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span></div></div>
<p style="text-align: justify">
Je déclare donc une nouvelle class Note avec deux attributs : <strong>libelle</strong> qui sera le texte de la note et le status pour savoir si c&rsquo;est fait ou pas. la fonction __unicode__ nous servira pour plus tard, c&rsquo;est le texte qui sera renvoyé pour l&rsquo;objet.</p>
<p>Nous arrivons à une phase typique de <strong>Django</strong> : le liens avec la base de données à été défini ainsi que notre modèle, <strong>Django</strong> est donc capable de créer la base de données.<br />
<br />
Taper la commande suivante :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; manage.py syncdb</div></div>
<p><em>Penser à installer le support de mysql pour python. (http://www.codegood.com/archives/129)</em></p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d:\DEV\mysite&amp;gt<span style="color: #66cc66;">;</span>manage.<span style="color: black;">py</span> syncdb<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating tables ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">Creating</span> table auth_permission<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table auth_group_permissions<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table auth_group<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table auth_user_user_permissions<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table auth_user_groups<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table auth_user<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table auth_message<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table django_content_type<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table django_session<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table django_site<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Creating table myapp_note<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; You just installed Django<span style="color: #483d8b;">'s auth system, which means you don'</span>t have <span style="color: #008000;">any</span> superuse<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs defined.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">Would</span> you like to create one now? <span style="color: black;">&#40;</span>yes/no<span style="color: black;">&#41;</span>: yes<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Username <span style="color: black;">&#40;</span>Leave blank to use <span style="color: #483d8b;">'administrateur'</span><span style="color: black;">&#41;</span>: root<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; E-mail address: cedric.<span style="color: black;">salaun</span><span style="color: #66cc66;">@</span>gmail.<span style="color: black;">com</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Password:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Password <span style="color: black;">&#40;</span>again<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Superuser created successfully.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">Installing</span> custom SQL ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">Installing</span> indexes ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">No</span> fixtures found.</div></div>
<p style="text-align: justify">
Comme vous pouvez le constater, <strong>Django</strong> met en place plusieurs tables que nous n&rsquo;avons pas défini, ce sont des tables &laquo;&nbsp;système&nbsp;&raquo; qui sont là pour nous facilité la vie, par exemple pour la gestion des utilisateurs, la gestions des droits etc&#8230; La seule ligne qui nous intéresse vraiment ici c&rsquo;est <strong>Creating table myapp_note</strong> Pour la création de notre table Note.</p>
<p style="text-align: justify">
Nous avons vu dans cette article, comment mettre en place une base de données avec <strong>Django</strong>, nous verrons dans le prochaine article comment manipuler les tables et ajouter des données avec l&rsquo;administration de Django.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django &#8211; Introduction aux templates</title>
		<link>https://blog.developpez.com/cs-blog/p11961/framework/django-introduction-aux-templates</link>
		<comments>https://blog.developpez.com/cs-blog/p11961/framework/django-introduction-aux-templates#comments</comments>
		<pubDate>Fri, 10 May 2013 05:47:01 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=109</guid>
		<description><![CDATA[Bienvenu dans ce troisième article consacré à Django. Nous allons maintenant voir comment Django intègre les pages HTML. Pour cela nous allons modifier le fichier settings.py pour lui donner le répertoire ou serons placés les fichiers HTML, ce que Django &#8230; <a href="https://blog.developpez.com/cs-blog/p11961/framework/django-introduction-aux-templates">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>Bienvenu dans ce troisième article consacré à <strong>Django</strong>.</h2>
<p>Nous allons maintenant voir comment <strong>Django</strong> intègre les pages HTML.</p>
<p style="text-align: justify">
Pour cela nous allons modifier le fichier <strong>settings.py</strong> pour lui donner le répertoire ou serons placés les fichiers HTML, ce que <strong>Django</strong> nomme les templates. Commencer par ajouter le répertoire templates dans <strong>mysite/</strong> puis modifier le fichier <strong>settings.py</strong> :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TEMPLATE_DIRS <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;C:/mysite/templates&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span></div></div>
<p><em>Le chemin vers le dossier templates doit être absolut.</em></p>
<p><span id="more-109"></span></p>
<p>Dans le nouveau répertoire templates, créer votre premier template : <strong>home.html</strong></p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hello Template !</div></div>
<p>Ensuite, il faut indiquer dans notre fichier <strong>view.py</strong>, que nous allons passer par un template :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">shortcuts</span> <span style="color: #ff7700;font-weight:bold;">import</span> render_to_response <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> home<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> render_to_response<span style="color: black;">&#40;</span><span style="color: #483d8b;">'home.html'</span><span style="color: black;">&#41;</span></div></div>
<p style="text-align: justify">
Notez le changement ici on utilise <strong>render_to_response</strong>, et non plus <strong>HttpResponse</strong>, puisque nous passons maintenant par un template (home.html) alors qu&rsquo;avec <strong>HttpResponse</strong>, c&rsquo;est directement du HTTP qui était renvoyé. <strong>render_to_response</strong> nous permet d&rsquo;injecter un certain nombre d&rsquo;objet dans une page HTML pour être ensuite rendue au client dans ça forme définitive.</p>
<p>Relancer votre serveur puis recharger la page web :</p>
<p><img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-3.png" alt="django" /></p>
<h2>Template et héritage</h2>
<p style="text-align: justify">
Maintenant que vous savez utiliser un template, regardons ce que <strong>Django</strong> nous propose pour nous faciliter la vie. Il y a bien longtemps, dans une galaxie lointaine, très lointaine.. Nous utilisions <a href="http://cyberzoide.developpez.com/html/frame.php3" title="frames et framset">les frames et frameset</a> pour ne pas avoir de redondance de code entre les pages web, puisque souvent le menu, le header et le footer sont les mêmes sur toutes les pages. <strong>Django</strong> nous propose un système d&rsquo;héritage au niveau des pages web, voyons ça de plus près ensemble.</p>
<p>Créez une page web dans le dossier de template, que nous appellerons <strong>base.html</strong> :</p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>mon site web<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Mon premier site web<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% block content %} {% endblock %}</div></div>
<p>Ici nous voyons pour la première fois le langage de template propre à <strong>Django</strong>.<br />
<strong>{% block content %}{% endblock %}</strong> est une déclaration de block, qui nous permettra de venir insérer à cette endroit du contenu.</p>
<p>Il faut maintenant modifier notre page <strong>home.html</strong> pour se servir de ce fichier :</p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% extends &quot;base.html&quot; %} <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% block content %} <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Première page du site <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% endblock %}</div></div>
<p>Pour dire à <strong>Django</strong> que cette page va hériter de la page <strong>base.html</strong>, nous lui indiquons : <strong>{% extends &laquo;&nbsp;base.html&nbsp;&raquo; %}</strong></p>
<p style="text-align: justify">
Ensuite, il suffit de reprendre le ou les blocks déclaré dans la page mère, ici <strong>{% block content %}</strong>. Quand <strong>Django</strong> va rendre cette page, il va aller chercher <strong>base.html</strong>, puis y inclure les différents block. L’exemple n&rsquo;est pas très parlant mais il faut imaginer que le fichier <strong>base.html</strong> est le squelette complet de notre site, cela permet de ne pas dupliquer le code, et aussi d&rsquo;avoir un seule endroit à modifier pour changer l&rsquo;aspect générale du site web.</p>
<p>Le résultat de notre page web :</p>
<p><img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-4.png" alt="site web django" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django &#8211; Premiers pas</title>
		<link>https://blog.developpez.com/cs-blog/p11960/framework/django-premier-pas</link>
		<comments>https://blog.developpez.com/cs-blog/p11960/framework/django-premier-pas#comments</comments>
		<pubDate>Thu, 09 May 2013 08:55:18 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=91</guid>
		<description><![CDATA[Deuxième article sur Django, Hello world ! Nous allons commencer par écrire un premier projet qui affichera &#171;&#160;Hello world&#160;&#187; pour nous assurer que Django est prêt. Commencer par ouvrir une invite de commande, puis taper la commande suivante : django-admin.py &#8230; <a href="https://blog.developpez.com/cs-blog/p11960/framework/django-premier-pas">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h1>Deuxième article sur Django, Hello world !</h1>
<p style="text-align: justify">
Nous allons commencer par écrire un premier projet qui affichera &laquo;&nbsp;Hello world&nbsp;&raquo; pour nous assurer que Django est prêt. Commencer par ouvrir une invite de commande, puis taper la commande suivante :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">django-admin.py startproject mysite</div></div>
<p>placer vous dans le répertoire nouvellement crée : <strong>mysite</strong>.<br />
Vous devriez retrouver les éléments suivant :</p>
<ul>
<li>manage.py
<li>settings.py
<li>urls.py
<li>__init__.py
</ul>
<p><span id="more-91"></span></p>
<ul>
<li>Le dossier /<strong>mysite</strong> contient tout les éléments de votre projet.
<li><strong>manage.py</strong> est l&rsquo;utilitaire vous permetra d&rsquo;interagire avec Django.
<li><strong>settings.py</strong> est le fichier de configuration de votre projet.
<li><strong>urls.py</strong> est la table des url de votre projet.</ul>
<p style="text-align: justify">
A ce stade, nous avons créé un projet Django, maintenant nous allons créer une application. Il est possible de décomposer sont site web en plusieurs applications, ceci permet de faire des choses réutilisables par la suite dans d&rsquo;autre projet.</p>
<p>Taper la commande suivante :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python manage.py startapp myapp</div></div>
<p>Django va créer pour nous le squelette de l&rsquo;application dans le répertoire /myapp.</p>
<ul>
<li>models.py
<li>tests.py
<li>views.py
<li>__init__.py
</ul>
<p>Le fichier <strong>models.py</strong> contiendra le modèle de donnée de notra application<br />
le fichier <strong>views.py</strong> est un fichier particulier qui servira à écrire notre code métier.</p>
<p>Nous allons maintenant démarrer le serveur d&rsquo;application fournis avec Django, taper la commande :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python manage.py runserver</div></div>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Validating models...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 errors found<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Django version 1.3.1, using settings 'mysite.settings'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Development server is running at http://127.0.0.1:8000/<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Quit the server with CTRL-BREAK.</div></div>
<p>Vous pouvez ouvrir un navigateur et aller à l&rsquo;url indiqué : http://127.0.0.1:8000/</p>
<p><img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-1.png" alt="premier lancement de Django" /></p>
<p>Maintenant que tout est en place, nous allons faire notre première page.<br />
Commencer par editer le fichier <strong>mysite/urls.py</strong> :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">urlpatterns <span style="color: #66cc66;">=</span> patterns<span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^$'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'mysite.myapp.views.home'</span><span style="color: #66cc66;">,</span> name<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'home'</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span></div></div>
<p>Ici nous voulons que l&rsquo;index du site [http://127.0.0.1:8000/] appèle l&rsquo;action <strong>home</strong> du fichier <strong>view.py</strong><br />
Éditez ensuite le fichier <strong>mysite/myapp/views.py</strong> pour ajouter cette action :</p>
<div class="codecolorer-container python railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">http</span> <span style="color: #ff7700;font-weight:bold;">import</span> HttpResponse<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> home<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> HttpResponse<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hello, world.&quot;</span><span style="color: black;">&#41;</span></div></div>
<p>Maintenant, relancer la page web :</p>
<p><img src="http://salaun-cedric.developpez.com/tutoriels/web/introduction-django/images/Django-2.png" alt="Django" /></p>
<p>Si vous avez cette page, vous pouvez passer à la suite <img src="https://blog.developpez.com/cs-blog/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django &#8211; installation</title>
		<link>https://blog.developpez.com/cs-blog/p11958/framework/django-installation</link>
		<comments>https://blog.developpez.com/cs-blog/p11958/framework/django-installation#comments</comments>
		<pubDate>Wed, 08 May 2013 19:26:59 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=81</guid>
		<description><![CDATA[Je débute une petite série d&#8217;article traitant de Django que j’espère vous sera utile. Partie I &#8211; l&#8217;installation Sous windows Au préalable, il faut installer python 2.7 que vous trouverez ici. Vous aurez besoin de modifier votre variable PATH, en &#8230; <a href="https://blog.developpez.com/cs-blog/p11958/framework/django-installation">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Je débute une petite série d&rsquo;article traitant de <strong>Django</strong> que j’espère vous sera utile.</p>
<p style="text-align: center">
<img align="center" src="https://djangoproject.com/s/img/logos/django-logo-negative.png" alt="django logo" width="50%">
</p>
<h1>Partie I &#8211; l&rsquo;installation</h1>
<h2>Sous windows</h2>
<p>Au préalable, il faut installer <strong>python 2.7</strong> que <a href="http://www.python.org" title="ici" target="_blank">vous trouverez ici</a>.</p>
<p>Vous aurez besoin de modifier votre <strong>variable PATH</strong>, en y ajoutant : </p>
<blockquote><p>C:\Python27\;C:\Python27\Scripts; </p></blockquote>
<p>(si vous avez installé python dans C:\Python27)</p>
<p><span id="more-81"></span></p>
<p>Pour modifier la variable PATH de windowss :</p>
<ul>
<li>Clique droits sur &laquo;&nbsp;Ordinateur&nbsp;&raquo; (sur le bureau ou dans le menu directement)
<li>Dans le menu cliquez sur &laquo;&nbsp;Proprietés&nbsp;&raquo;
<li>Allez dans &laquo;&nbsp;paramètre système avancé&nbsp;&raquo;
<li>Cliquez sur le bouton &laquo;&nbsp;varaible d&rsquo;environnement&nbsp;&raquo;
<li>Dans la liste variable système, cliquez sur la variable &laquo;&nbsp;path&nbsp;&raquo;
<li>Cliquez sur modifier
<li>Ajouter le chemin que vous voulez à la suite de la liste
<li>Fermer toutes les fenètre avec le bouton &laquo;&nbsp;ok&nbsp;&raquo;
</ul>
<p style="text-align: justify">
Une fois que python est bien installé allez sur la page de téléchargement de Django puis télécharger Django ( à l&rsquo;heure ou j&rsquo;écris, le fichier se nomme Django-1.4.1.tar.gz ). Pour décompresser ce fichier je vous conseil d&rsquo;utiliser 7zip, En effet le format tar.gz est propre à unix, 7zip est tout à fait capable de décompresser correctement ce genre d&rsquo;archive. La premier décompression vous donnera un fichier .tar, refaite une décompression de ce fichier pour avoir le dossier décompressé de Django.
</p>
<p style="text-align: justify">
Si vous vous retrouvez comme moi avec un chemin long vers le dossier de Django (Django-1.4.1.tar\dist\Django-1.4.1\Django-1.4.1) n&rsquo;hésiter pas à copier le dernier dossier et à le placer dans C:\ directement. Normalement vous devriez vous retrouver avec C:\Django-1.4.1\django.
</p>
<p>Lancer la commande suivante :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python setup.py install</div></div>
<p>Il ne reste plus qu&rsquo;a modifier la variable PATH, comme vous l&rsquo;avez fait pour python en ajoutant : C:\Django-1.4.1\django\bin.</p>
<p>Pour vérifier que Django est opérationel, taper la commande :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">django-admin.py --version<br />
1.4.1</div></div>
<p>Il faut relancer la console à chaque fois que vous modifier la variable PATH</p>
<h2>Sous Ubuntu</h2>
<p>Sur ubuntu l&rsquo;installation se fait en une ligne :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sudo apt-get install python-django</div></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Un tableau dynamique avec jQuery en quelques lignes</title>
		<link>https://blog.developpez.com/cs-blog/p11889/framework/un-tableau-dynamique-avec-jquery-en-quelques-lignes</link>
		<comments>https://blog.developpez.com/cs-blog/p11889/framework/un-tableau-dynamique-avec-jquery-en-quelques-lignes#comments</comments>
		<pubDate>Thu, 04 Apr 2013 13:26:43 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Framework]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=58</guid>
		<description><![CDATA[Bonjour, Voici un small exemple d&#8217;un tableau dynamique avec id incrémental et jQuery powered &#160; &#160; &#60;button id=&#34;add_line&#34;&#62;Ajouter une ligne&#60;/button&#62; &#160; &#160; &#60;table id=&#34;matable&#34; border=&#34;1&#34;&#62; &#160; &#160; &#160; &#160; &#60;tr id=&#34;row_1&#34;&#62; &#160; &#160; &#160; &#160; &#160; &#160; &#60;td&#62;Une cellule&#60;/td&#62; &#160; &#8230; <a href="https://blog.developpez.com/cs-blog/p11889/framework/un-tableau-dynamique-avec-jquery-en-quelques-lignes">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Bonjour,</p>
<p>Voici un small exemple d&rsquo;un <strong>tableau dynamique</strong> avec id incrémental et <strong><font color="red">jQuery</font></strong> powered <img src="https://blog.developpez.com/cs-blog/wp-includes/images/smilies/icon_razz.gif" alt=":P" class="wp-smiley" /></p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;add_line&quot;</span>&gt;</span>Ajouter une ligne<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;matable&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;row_1&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>Une cellule<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>Une cellule<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>Une cellule<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span></div></div>
<div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#add_line&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> last_row <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#matable tr:last'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> new_id <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>last_row<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>last_row<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">clone</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#matable tr:last'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'row_'</span> <span style="color: #339933;">+</span> new_id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>interface vs Code</title>
		<link>https://blog.developpez.com/cs-blog/p11716/framework/interface-vs-code</link>
		<comments>https://blog.developpez.com/cs-blog/p11716/framework/interface-vs-code#comments</comments>
		<pubDate>Tue, 15 Jan 2013 16:41:53 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Framework]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/cs-blog/?p=49</guid>
		<description><![CDATA[Aviez vous déjà remarqué ? Plus on simplifie la tache coté utilisateur, plus le code deviens complexe ! &#8211; Avez vous déjà fait ce constat ?]]></description>
				<content:encoded><![CDATA[<p>Aviez vous déjà remarqué ?</p>
<p><a href="http://blog.developpez.com/cs-blog/p11716/framework/interface-vs-code/attachment/ihmvscode" rel="attachment wp-att-50"><img src="http://blog.developpez.com/cs-blog/files/2013/01/ihmvscode-300x225.gif" alt="ihmvscode" width="300" height="225" class="aligncenter size-medium wp-image-50" /></a></p>
<p>Plus on simplifie la tache coté utilisateur, plus le code deviens complexe !</p>
<p>&#8211; Avez vous déjà fait ce constat ?</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django &amp; Python 2.6 avec MySQL 5.1</title>
		<link>https://blog.developpez.com/cs-blog/p8392/framework/django_aamp_python_2_6_avec_mysql</link>
		<comments>https://blog.developpez.com/cs-blog/p8392/framework/django_aamp_python_2_6_avec_mysql#comments</comments>
		<pubDate>Mon, 23 Nov 2009 08:55:15 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Framework]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Bonjour, Voici un petit tutoriel pour mettre en place Django dans un environnement Windows avec Python 2.6 et MySQL 5.1 comme base de donnée. Django est un des nombreux frameworks web, réalisés pour la création de site web. Le langage &#8230; <a href="https://blog.developpez.com/cs-blog/p8392/framework/django_aamp_python_2_6_avec_mysql">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Bonjour,</p>
<p>Voici un petit tutoriel pour mettre en place <a href="http://www.django-fr.org/">Django</a> dans un environnement Windows avec <a href="http://www.python.org/download/releases/2.6.4/">Python <strong>2.6</strong></a> et <a href="http://dev.mysql.com/downloads/mysql/5.1.html">MySQL <strong>5.1</strong></a> comme base de donnée.</p>
<p>Django est un des nombreux frameworks web, réalisés pour la création de site web. Le langage utilisé est le langage python, un langage de script qui est très orienté objet. Django est en concurrence avec d&rsquo;autres frameworks du même type, comme <a href="http://rubyonrails.org/">RubyOnRails</a> qui utilise le langage Ruby, ou <a href="http://www.zend.com/fr/">Zend</a> qui utilise le langage PHP. La plupart de ces frameworks se doivent d&rsquo;être simple d&rsquo;utilisation, pour faciliter le développement de site web. Un site web réalisé avec Django peut être hébergé sur les serveurs de google avec <a href="http://code.google.com/intl/fr-FR/appengine/">Google App Engine</a> (GAE). </p>
<p><strong>1. Téléchargement des programmes nécessaire :</strong></p>
<ul>
<li><a href="http://www.django-fr.org/">Django</a></li>
<li><a href="http://www.python.org/download/releases/2.6.4/">Python <strong>2.6</strong></a></li>
<li><a href="http://dev.mysql.com/downloads/mysql/5.1.html">MySQL <strong>5.1</strong></a></li>
</ul>
<p><span id="more-1"></span></p>
<p><strong>2. Installation des programmes :</strong></p>
<p><center><img src="http://www-03.ibm.com/systems/ca/fr/resources/systems_i_graphics_mysql_50x50.jpg" alt="MySQL" title="MySQL" /></center><br />
Installer tout d&rsquo;abord MySQL 5.1, avec les paramètres par défaut:<br />
&#8211; cocher la case qui permet d&rsquo;inscrire directement le /bin MySQL dans la variable PATH de votre ordinateur.<br />
Je vous invite aussi à télécharger <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html">GUI tools </a> qui comprends 3 programmes très pratique pour administrer votre base de données MySQL.<br />
Quand votre base de données est démarrée, vous pouvez déjà créer une nouvelle base de données qui servira pour Django.<br />
(Pour ma part je vais l&rsquo;appeler <strong>Django</strong>.)</p>
<p><center><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Python.svg/48px-Python.svg.png" alt="Python" title="Python" /></center><br />
Installer ensuite Python 2.6, il n&rsquo;y a pas de procédure particulière, récupérer simplement l&rsquo;exe sur le site officiel de python puis lancer l&rsquo;exécution;<br />
Si vous avez déjà python 3.X d&rsquo;installé, il est conseillé de le désinstaller sous peine de problèmes de compatibilité.</p>
<p><center><img src="http://www.peterbe.com/plog/categoryimages/django.gif" alt="Django" title="Django" /></center><br />
Pour finir, installer Django, pour cela télécharger la dernière version de l&rsquo;archive sur leur site officiel, puis déziper le tout dans le répertoire de votre choix. par exemple dans <strong>D:\DEV\</strong> , ensuite ouvrer une nouvelle console (WINDOWS+R puis taper CMD et faite entrée).</p>
<p>(Pour ceux qui savent manipuler un repository,<br />
la meilleur solution pour prendre Django est de faire un checkout sur le repos de Django : http://code.djangoproject.com/svn/django/trunk/ )</p>
<p>Dans la console, aller dans le répertoire où vous avez placé Django puis taper la commande suivante :</p>
<blockquote><p><code class="codecolorer text default"><span class="text">setup.py install</span></code></p></blockquote>
<p>Normalement, Windows devrait reconnaitre le format <strong>.py</strong> et lancer l&rsquo;installation, toutefois, si ce n&rsquo;est pas le cas, vous pouvez aussi utiliser la commande suivante :</p>
<blockquote><p><code class="codecolorer text default"><span class="text">python setup.py install</span></code></p></blockquote>
<p>Si Windows ne reconnait toujours pas python, ajouter le chemin du répertoire ou se trouve python dans votre variable PATH.</p>
<p>Voilà, l&rsquo;installation basique est finie.. et c&rsquo;est là que les ennuis commence !</p>
<p>Vous pouvez donc commencer un nouveau projet Django sans trop de problème.. jusque la commande <strong>syncdb</strong> qui va nous en poser quelques-uns.</p>
<p>N&rsquo;oubliez pas de renseigner le fichier settings.py de votre projet, avec les paramètres de votre base de données :</p>
<blockquote><p>DATABASE_ENGINE = &lsquo;mysql&rsquo;<br />
DATABASE_NAME = &lsquo;django&rsquo; (ou votre nom de base de données)<br />
DATABASE_USER = &lsquo;root&rsquo;<br />
DATABASE_PASSWORD = &lsquo;root&rsquo;<br />
DATABASE_HOST = &nbsp;&raquo;<br />
DATABASE_PORT = &nbsp;&raquo;</p></blockquote>
<p><strong>3. Réparer l&rsquo;accès à la base de données :</strong></p>
<p>Pour que la base de données MySQL soit opérationnelle voici la procédure à suivre :</p>
<p>La commande <strong>syncdb</strong> nous donne l&rsquo;erreur suivante :</p>
<blockquote><p>Error loading MySQLdb module: No module named MySQLdb</p></blockquote>
<p>La solution consiste à télécharger le module, <strong>pour python 2.6</strong> :</p>
<p><a href="http://sourceforge.net/projects/mysql-python/forums/forum/70460/topic/2316047">MySQL-python-1.2.2.win32-py2.6.exe</a></p>
<p>Une fois le module correctement installé, vous pouvez relancer la commande syncdb, une nouvelle erreur apparait.. </p>
<blockquote><p>Error loading MySQLdb module: DLL load failed: Le module spécifié est introuvable.</p></blockquote>
<p>Il manque 2 DLL dans le dossier de Windows, <em>system32</em> :</p>
<p><a href="http://www.fichier-dll.fr/libguide40.dll,11261">libguide40.dll</a><br />
<a href="http://www.dll-files.com/dllindex/dll-files.shtml?libmmd">libmmd.dll</a></p>
<p>Une fois insérés (ou copiés) dans le dossier, relancer la commande, ça marche enfin !</p>
<p>Vous pouvez donc coder votre site web paisiblement avec Django <img src="https://blog.developpez.com/cs-blog/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /></p>
<p>Pour aller plus loin :</p>
<p>Un très bon tutoriel pour commencer avec google app engine et Django :</p>
<p>http://tutorials.shire-biz.com/home/djangowithappenginepatch</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Play! un Django like à la sauce java</title>
		<link>https://blog.developpez.com/cs-blog/p7663/framework/play/play_un_django_like_a_la_sauce_java</link>
		<comments>https://blog.developpez.com/cs-blog/p7663/framework/play/play_un_django_like_a_la_sauce_java#comments</comments>
		<pubDate>Thu, 28 May 2009 22:59:56 +0000</pubDate>
		<dc:creator><![CDATA[Golgotha]]></dc:creator>
				<category><![CDATA[Play!]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Bonjour, Mon première article porte sur un framework java qui semble jeune mais qui fera sûrement parler de lui à l&#8217;avenir ! Play! est un framework web développé par la société zenexity. Après une installation et quelques manipulation, les personnes &#8230; <a href="https://blog.developpez.com/cs-blog/p7663/framework/play/play_un_django_like_a_la_sauce_java">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Bonjour,</p>
<p>Mon première article porte sur un framework java qui semble jeune mais qui fera sûrement parler de lui à l&rsquo;avenir !<br />
<a href="http://www.playframework.org/">Play!</a> est un framework web développé par la société <a href="http://www.zenexity.fr/frameworks/anatomie-dun-framework-de-developpement-web/">zenexity</a>. </p>
<p>Après une installation et quelques manipulation, les personnes familière de ce genre d&rsquo;outil retrouverons avec facilité<br />
leurs marque, nous retrouverons les commandes basic des frameworks web tel que Django ou Ruby on Rails :</p>
<p>Pour démarrer un nouveau projet :</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Play start myapp</div></div>
<p>Vous trouverez alors une nouvelle arborescence, prête à démarrer.<br />
Le modèle est semblable à Django, avec le traditionnelle MVC (Modèle, Vue, Contrôleur).</p>
<p>Une différence a noté tout de même quand à l&rsquo;utilisation première, vous ne trouverez pas de commande de synchronisation comme <strong>syncdb</strong> pour Django ou le <strong>rake: db migrate</strong> de Ruby On rails. </p>
<p>En effet la façon de travailler en java est un peut différente, et le framework Play! s&rsquo;appuie sur une couche JPA et des annotation comme @entity pour cela. Les entité son donc automatiquement créées en base de donnée si elle ne le sont pas déjà, c&rsquo;est tout à fait transparent et automatique.</p>
<p><a href="http://twitter.com/home?status=Lecture%20actuelle:%20http://blog.developpez.com/cs-blog/p7663/framework/play/play-un-django-like-a-la-sauce-java/"><strong>Twitter me</strong></a></p>
<p><strong>A venir -> installation du framework sur MAC OSX et Windows</strong></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
