| | 1 | {{{ |
| | 2 | #!rst |
| | 3 | |
| | 4 | .. |
| | 5 | ========== |
| | 6 | Django FAQ |
| | 7 | ========== |
| | 8 | |
| | 9 | .. sidebar:: Domande frequenti su Django |
| | 10 | :subtitle: traduzione in lingua italiana. |
| | 11 | |
| | 12 | Documento originale: `Django FAQ`_ |
| | 13 | |
| | 14 | Traduzione: paolo `<paolo@php3.it>` |
| | 15 | |
| | 16 | Aggiornato alla revisione: 3137 |
| | 17 | |
| | 18 | .. _Django FAQ: http://www.djangoproject.com/documentation/faq/ |
| | 19 | |
| | 20 | .. contents:: **Contenuti del capitolo** |
| | 21 | |
| | 22 | =========================== |
| | 23 | Domande frequenti su Django |
| | 24 | =========================== |
| | 25 | |
| | 26 | .. |
| | 27 | General questions |
| | 28 | ================= |
| | 29 | |
| | 30 | Domande generali |
| | 31 | ================ |
| | 32 | |
| | 33 | .. |
| | 34 | Why does this project exist? |
| | 35 | ---------------------------- |
| | 36 | |
| | 37 | Perché esiste questo progetto? |
| | 38 | |
| | 39 | .. |
| | 40 | Django grew from a very practical need: World Online, a newspaper Web |
| | 41 | operation, is responsible for building intensive Web applications on journalism |
| | 42 | deadlines. In the fast-paced newsroom, World Online often has only a matter of |
| | 43 | hours to take a complicated Web application from concept to public launch. |
| | 44 | |
| | 45 | Django è cresciuto grazie ad un'esigenza pratica: il ruolo di World Online, un'agenzia |
| | 46 | giornalistica su Web, consiste nel realizzare applicazioni Web |
| | 47 | per la pubblicazione di articoli e notizie. Nel vorticoso mondo |
| | 48 | dell'informazione, Word Online spesso deve trasformare applicazioni Web |
| | 49 | concettuali in materiale pronto per il lancio al pubblico, in poche ore. |
| | 50 | |
| | 51 | .. |
| | 52 | At the same time, the World Online Web developers have consistently been |
| | 53 | perfectionists when it comes to following best practices of Web development. |
| | 54 | |
| | 55 | Contestualmente, gli sviluppatori Web di World Online sono stati |
| | 56 | puntigliosi quando si è trattato di seguire meticolosamente le best practices |
| | 57 | (ndt, le migliori pratiche, intendendo le esperienze più significative o dai |
| | 58 | migliori risultati adottati in diversi contesti) dello sviluppo Web. |
| | 59 | |
| | 60 | .. |
| | 61 | Thus, Django was designed not only to allow fast Web development, but |
| | 62 | *best-practice* Web development. |
| | 63 | |
| | 64 | Quindi Django è stato progettato non soltanto per consentire un veloce sviluppo |
| | 65 | Web, ma anche uno sviluppo che seguisse le migliori modalità per |
| | 66 | ottenere ottimi risultati. |
| | 67 | |
| | 68 | .. |
| | 69 | Django would not be possible without a whole host of open-source projects -- |
| | 70 | `Apache`_, `Python`_, and `PostgreSQL`_ to name a few -- and we're thrilled to |
| | 71 | be able to give something back to the open-source community. |
| | 72 | |
| | 73 | .. _Apache: http://httpd.apache.org/ |
| | 74 | .. _Python: http://www.python.org/ |
| | 75 | .. _PostgreSQL: http://www.postgresql.org/ |
| | 76 | |
| | 77 | Django non sarebbe mai stato possibile senza alcuni altri progetti open-source -- |
| | 78 | `Apache`_, `Python`_ e `PostgreSQL`_, per citarne qualcuno -- e noi ci siamo |
| | 79 | sentiti elettrizzati nel poter restituire qualcosa alla comunità open-source. |
| | 80 | |
| | 81 | .. _Apache: http://httpd.apache.org/ |
| | 82 | .. _Python: http://www.python.org/ |
| | 83 | .. _PostgreSQL: http://www.postgresql.org/ |
| | 84 | |
| | 85 | .. |
| | 86 | What does "Django" mean, and how do you pronounce it? |
| | 87 | ----------------------------------------------------- |
| | 88 | |
| | 89 | Che cosa significa "Django", e come lo si pronuncia |
| | 90 | --------------------------------------------------- |
| | 91 | |
| | 92 | .. |
| | 93 | Django is named after `Django Reinhardt`_, a gypsy jazz guitarist from the 1930s |
| | 94 | to early 1950s. To this day, he's considered one of the best guitarists of all time. |
| | 95 | |
| | 96 | Il nome Django deriva da `Django Reinhardt`_, un chitarrista jazz gitano del |
| | 97 | periodo dagli anni '30 ai primi anni '50. Ai giorni nostri è considerato uno |
| | 98 | dei migliori chitarristi di tutti i tempi. |
| | 99 | |
| | 100 | .. Listen to his music. You'll like it. |
| | 101 | |
| | 102 | Ascolta la sua musica. Ti piacerà. |
| | 103 | |
| | 104 | .. Django is pronounced **JANG**-oh. Rhymes with FANG-oh. |
| | 105 | |
| | 106 | Django è pronunciato **JANG**-oh. La rima è con FANG-oh. |
| | 107 | |
| | 108 | .. |
| | 109 | .. _Django Reinhardt: http://en.wikipedia.org/wiki/Django_Reinhardt |
| | 110 | |
| | 111 | .. _Django Reinhardt: http://en.wikipedia.org/wiki/Django_Reinhardt |
| | 112 | |
| | 113 | .. |
| | 114 | Is Django stable? |
| | 115 | ----------------- |
| | 116 | |
| | 117 | Django è stabile? |
| | 118 | ----------------- |
| | 119 | |
| | 120 | .. |
| | 121 | Yes. World Online has been using Django for more than two years. Sites built on |
| | 122 | Django have weathered traffic spikes of over one million hits an hour and at |
| | 123 | least one Slashdotting. Yes, it's quite stable. |
| | 124 | |
| | 125 | Sì. World Online ha utilizzato Django per più di due anni. Siti costruiti con |
| | 126 | Django sono stati esposti a picchi di traffico di più di un milione di |
| | 127 | richieste all'ora, ed ad almeno un effetto Slashdot. Sì, è piuttosto |
| | 128 | stabile. |
| | 129 | |
| | 130 | .. |
| | 131 | Does Django scale? |
| | 132 | ------------------ |
| | 133 | |
| | 134 | Le applicazioni realizzate con Django possono scalare? |
| | 135 | ------------------------------------------------------ |
| | 136 | |
| | 137 | .. |
| | 138 | Yes. Compared to development time, hardware is cheap, and so Django is |
| | 139 | designed to take advantage of as much hardware as you can throw at it. |
| | 140 | |
| | 141 | Sì. Confrontando il costo legato ai tempi di sviluppo ed il costo ben più modesto |
| | 142 | dell'hardware, abbiamo pensato di progettare Django affinché sia in grado di sfruttare |
| | 143 | al meglio tutta la potenza di calcolo che gli viene messa a disposizione. |
| | 144 | |
| | 145 | .. |
| | 146 | Django uses a "shared-nothing" architecture, which means you can add hardware |
| | 147 | at any level -- database servers, caching servers or Web/application servers. |
| | 148 | |
| | 149 | Django adotta una architettura "shared-nothing", cioè puoi decidere di |
| | 150 | potenziare l'hardware ad ogni livello -- sui server database, sui server di |
| | 151 | cache o sui Web server. |
| | 152 | |
| | 153 | .. |
| | 154 | The framework cleanly separates components such as its database layer and |
| | 155 | application layer. And it ships with a simple-yet-powerful `cache framework`_. |
| | 156 | |
| | 157 | Il framework separa in modo netto i componenti, come ad esempio il livello del |
| | 158 | database dal livello dell'applicazione. Inoltre è a corredo un simplice ma |
| | 159 | potente `cache framework`_. |
| | 160 | |
| | 161 | .. |
| | 162 | .. _`cache framework`: http://www.djangoproject.com/documentation/cache/ |
| | 163 | |
| | 164 | .. _`cache framework`: http://www.djangoproject.com/documentation/cache/ |
| | 165 | |
| | 166 | .. |
| | 167 | Who's behind this? |
| | 168 | ------------------ |
| | 169 | |
| | 170 | Chi c'è dietro al progetto? |
| | 171 | --------------------------- |
| | 172 | |
| | 173 | .. |
| | 174 | Django was developed at `World Online`_, the Web department of a newspaper in |
| | 175 | Lawrence, Kansas, USA. |
| | 176 | |
| | 177 | Django è stato sviluppato in `World Online`_, il dipartimento Web di un |
| | 178 | giornale in Lawrence, Kansas, USA. |
| | 179 | |
| | 180 | .. |
| | 181 | `Adrian Holovaty`_ |
| | 182 | Adrian is a Web developer with a background in journalism. He was lead |
| | 183 | developer at World Online for 2.5 years, during which time Django was |
| | 184 | developed and implemented on World Online's sites. Now he works for |
| | 185 | washingtonpost.com building rich, database-backed information sites, and |
| | 186 | continues to oversee Django development. He likes playing guitar (Django |
| | 187 | Reinhardt style) and hacking on side projects such as `chicagocrime.org`_. |
| | 188 | He lives in Chicago. |
| | 189 | |
| | 190 | On IRC, Adrian goes by ``adrian_h``. |
| | 191 | |
| | 192 | `Adrian Holovaty`_ |
| | 193 | Adrian è uno sviluppatore Web con competenze in campo giornalistico. E' |
| | 194 | stato il programmatore principale a World Online per due anni e mezzo, durante |
| | 195 | i quali Django ha vissuto il suo sviluppo e ha potenziato molti siti per World |
| | 196 | Online. Attualmente lavora per washingtonpost.com, dove realizza importanti |
| | 197 | siti di informazione basati su database, mentre continua a sopraintendere lo |
| | 198 | sviluppo di Django. Gli piace suonare la chitarre (nello stile di Django |
| | 199 | Reinhardt) e lavorare su progetti secondari, come `chicagocrime.org`_. |
| | 200 | Vive a Chicago. |
| | 201 | |
| | 202 | Su IRC, Adrian è noto come ``adrian_h``. |
| | 203 | |
| | 204 | .. |
| | 205 | `Jacob Kaplan-Moss`_ |
| | 206 | Jacob is a whipper-snapper from California who spends equal time coding and |
| | 207 | cooking. He's lead developer at World Online and actively hacks on various |
| | 208 | cool side projects. He's contributed to the Python-ObjC bindings and was |
| | 209 | the first guy to figure out how to write Tivo apps in Python. Lately he's |
| | 210 | been messing with Python on the PSP. He lives in Lawrence, Kansas. |
| | 211 | |
| | 212 | On IRC, Jacob goes by ``jacobkm``. |
| | 213 | |
| | 214 | `Jacob Kaplan-Moss`_ |
| | 215 | Jacob è un ragazzo californiano che trascorre il suo tempo scrivendo codice |
| | 216 | e cucinando. E' lo sviluppatore principale a World Online e lavora attivamente |
| | 217 | su progetti collaterali di considerevole interesse. Ha contribuito ai binding |
| | 218 | Python-ObjC ed è stata la prima persona a scrivere applicazioni per Tivo in Python. |
| | 219 | Di recente ha cominciato a interessarsi a Python su PSP. |
| | 220 | Vive in Lawrence, Kansas. |
| | 221 | |
| | 222 | Su IRC, Jacob è noto come ``jacobkm``. |
| | 223 | |
| | 224 | .. |
| | 225 | `Simon Willison`_ |
| | 226 | Simon is a well-respected Web developer from England. He had a one-year |
| | 227 | internship at World Online, during which time he and Adrian developed |
| | 228 | Django from scratch. The most enthusiastic Brit you'll ever meet, he's |
| | 229 | passionate about best practices in Web development and has maintained a |
| | 230 | well-read Web-development blog for years at http://simon.incutio.com. |
| | 231 | He works for Yahoo UK, where he managed to score the title "Hacker Liason." |
| | 232 | He lives in London. |
| | 233 | |
| | 234 | On IRC, Simon goes by ``SimonW``. |
| | 235 | |
| | 236 | `Simon Willison`_ |
| | 237 | Simon è uno sviluppatore Web molto apprezzato proveniente dall'Inghilterra. |
| | 238 | Ha lavorato internamente a World Online per un anno, durante il quale assieme |
| | 239 | ad Adrian ha sviluppato Django da zero. E' l'inglese più entusiastico che si |
| | 240 | possa incontrare, è appassionato di best practices in ambito Web ed ha |
| | 241 | mantenuto per anni un blog di successo sullo sviluppo Web, che puoi leggere |
| | 242 | all'indirizzo http://simon.incutio.com. Lavora per Yahoo UK, dove ha ottenuto |
| | 243 | il titolo di "Hacker Liaison". |
| | 244 | Vive a Londra. |
| | 245 | |
| | 246 | Su IRC, Simon è noto come ``SimonW``. |
| | 247 | |
| | 248 | .. |
| | 249 | `Wilson Miner`_ |
| | 250 | Wilson's design-fu makes us all look like rock stars. When not sneaking |
| | 251 | into apartment complex swimming pools, he's the Commercial Development |
| | 252 | Director for World Online, which means he makes the money that pays all our |
| | 253 | paychecks. He lives in Lawrence, Kansas. |
| | 254 | |
| | 255 | On IRC, Wilson goes by ``wilsonian``. |
| | 256 | |
| | 257 | `Wilson Miner`_ |
| | 258 | Le doti artistiche di Wilson ci fanno apparire come star del rock. Quando |
| | 259 | non si trova a progettare piscine serpeggianti in qualche appartamento, ricopre |
| | 260 | il ruolo di "Direttore dello Sviluppo Commerciale" per World Online, cioè |
| | 261 | produce il denaro dei nostri salari. Vive in Lawrence, Kansas. |
| | 262 | |
| | 263 | Su IRC, Wilson è noto come ``wilsonian``. |
| | 264 | |
| | 265 | .. _`World Online`: http://code.djangoproject.com/wiki/WorldOnline |
| | 266 | .. _`Adrian Holovaty`: http://www.holovaty.com/ |
| | 267 | .. _`washingtonpost.com`: http://www.washingtonpost.com/ |
| | 268 | .. _`chicagocrime.org`: http://www.chicagocrime.org/ |
| | 269 | .. _`Simon Willison`: http://simon.incutio.com/ |
| | 270 | .. _`simon.incutio.com`: http://simon.incutio.com/ |
| | 271 | .. _`Jacob Kaplan-Moss`: http://www.jacobian.org/ |
| | 272 | .. _`Wilson Miner`: http://www.wilsonminer.com/ |
| | 273 | |
| | 274 | .. |
| | 275 | Which sites use Django? |
| | 276 | ----------------------- |
| | 277 | |
| | 278 | The Django wiki features a consistently growing `list of Django-powered sites`_. |
| | 279 | Feel free to add your Django-powered site to the list. |
| | 280 | |
| | 281 | .. _list of Django-powered sites: http://code.djangoproject.com/wiki/DjangoPoweredSites |
| | 282 | |
| | 283 | Quali siti usano Django? |
| | 284 | ------------------------ |
| | 285 | |
| | 286 | Il wiki di Django esibisce una lista in costante crescita di `siti |
| | 287 | realizzati con Django`_. Aggiungi liberamente anche il tuo sito a questa lista. |
| | 288 | |
| | 289 | .. _siti realizzati con Django: http://code.djangoproject.com/wiki/DjangoPoweredSites |
| | 290 | |
| | 291 | .. |
| | 292 | Django appears to be a MVC framework, but you call the Controller the "view", and the View the "template". How come you don't use the standard names? |
| | 293 | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| | 294 | |
| | 295 | Sembra che Django sia un framework MVC, ma ciò che voi chiamate "view" è il Controller, e la View il "template". Come mai non usate i nomi standard? |
| | 296 | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| | 297 | |
| | 298 | .. |
| | 299 | Well, the standard names are debatable. |
| | 300 | |
| | 301 | Bene, la nomenclatura standard è opinabile. |
| | 302 | |
| | 303 | .. |
| | 304 | In our interpretation of MVC, the "view" describes the data that gets presented |
| | 305 | to the user. It's not necessarily *how* the data *looks*, but *which* data is |
| | 306 | presented. The view describes *which data you see*, not *how you see it.* It's |
| | 307 | a subtle distinction. |
| | 308 | |
| | 309 | Per come noi interpretiamo il paradigma MVC, la "view" descrive i dati che |
| | 310 | vengono presentati all'utente. Non necessariamente *come* si *presentano*, ma |
| | 311 | *quali* dati sono presentati. La view descrive *quali dati sono esposti*, non |
| | 312 | *come vengono esposti*. E' una distinzione sottile. |
| | 313 | |
| | 314 | .. |
| | 315 | So, in our case, a "view" is the Python callback function for a particular URL, |
| | 316 | because that callback function describes which data is presented. |
| | 317 | |
| | 318 | Perciò, nel nostro caso, una "view" è una funzione Python che viene invocata |
| | 319 | per un particolare URL, poiché questa funzione descrive quali dati sono |
| | 320 | presentati. |
| | 321 | |
| | 322 | .. |
| | 323 | Furthermore, it's sensible to separate content from presentation -- which is |
| | 324 | where templates come in. In Django, a "view" describes which data is presented, |
| | 325 | but a view normally delegates to a template, which describes *how* the data is |
| | 326 | presented. |
| | 327 | |
| | 328 | Inoltre, serve per separare i contenuti dalla presentazione -- fase in cui |
| | 329 | subentrano i template. In Django, una "view" descrive quali dati sono |
| | 330 | presentati, e normalmente delega la presentazione ad un template, il cui |
| | 331 | compito è descrivere *come* i dati sono presentati. |
| | 332 | |
| | 333 | .. |
| | 334 | Where does the "controller" fit in, then? In Django's case, it's probably the |
| | 335 | framework itself: the machinery that sends a request to the appropriate view, |
| | 336 | according to the Django URL configuration. |
| | 337 | |
| | 338 | Quindi il "controller" dove rientra? Nel caso di Django, probabilmente è il |
| | 339 | framework stesso, inteso come serie di meccanismi che inviano le richieste alla view |
| | 340 | appropriata in base alla configurazione degli URL. |
| | 341 | |
| | 342 | .. |
| | 343 | If you're hungry for acronyms, you might say that Django is a "MTV" framework |
| | 344 | -- that is, "model", "template", and "view." That breakdown makes much more |
| | 345 | sense. |
| | 346 | |
| | 347 | Se sei affamato di acronimi, potresti dire che Django è un framework "MTV" -- |
| | 348 | ovvero, "model", "template" e "view". Questa suddivisione può avere un senso. |
| | 349 | |
| | 350 | .. |
| | 351 | At the end of the day, of course, it comes down to getting stuff done. And, |
| | 352 | regardless of how things are named, Django gets stuff done in a way that's most |
| | 353 | logical to us. |
| | 354 | |
| | 355 | A fine giornata, ovviamente, l'importante è aver terminato il proprio lavoro. |
| | 356 | E, indipendentemente da come vengano chiamate le varie parti del framework, Django |
| | 357 | consente di compiere gli incarichi lavorativi nel modo che secondo noi è più |
| | 358 | logico. |
| | 359 | |
| | 360 | .. |
| | 361 | <Framework X> does <feature Y> -- why doesn't Django? |
| | 362 | ----------------------------------------------------- |
| | 363 | |
| | 364 | <Il framework X> offre la <funzionalità Y> -- Perché Django no? |
| | 365 | --------------------------------------------------------------- |
| | 366 | |
| | 367 | .. |
| | 368 | We're well aware that there are other awesome Web frameworks out there, and |
| | 369 | we're not adverse to borrowing ideas where appropriate. However, Django was |
| | 370 | developed precisely because we were unhappy with the status quo, so please be |
| | 371 | aware that "because <Framework X>" does it is not going to be sufficient reason |
| | 372 | to add a given feature to Django. |
| | 373 | |
| | 374 | Siamo ben consapevoli che esistono altri framework Web grandiosi, e non siamo |
| | 375 | contrari a prendere alcune idee in prestito. Tuttavia Django è stato sviluppato |
| | 376 | precisamente perché eravamo scontenti della situazione che esisteva prima della |
| | 377 | sua progettazione, quindi "che il <framework X>" metta a disposizione qualcosa |
| | 378 | in più non è una ragione sufficiente per aggiungere quella funzionalità a |
| | 379 | Django. |
| | 380 | |
| | 381 | .. |
| | 382 | Why did you write all of Django from scratch, instead of using other Python libraries? |
| | 383 | -------------------------------------------------------------------------------------- |
| | 384 | |
| | 385 | Perché avete scritto Django interamente da zero, invece di usare librerie Python a disposizione? |
| | 386 | ------------------------------------------------------------------------------------------------ |
| | 387 | |
| | 388 | .. |
| | 389 | When Django was originally written a couple of years ago, Adrian and Simon |
| | 390 | spent quite a bit of time exploring the various Python Web frameworks |
| | 391 | available. |
| | 392 | |
| | 393 | Quando un paio di anni fa Django fu scritto, Adrian e Simon dedicarono parte |
| | 394 | del loro tempo all'esplorazione dei vari framework Web scritti in Python. |
| | 395 | |
| | 396 | .. In our opinion, none of them were completely up to snuff. |
| | 397 | |
| | 398 | Secondo noi, nessuno di essi era completamente adeguato. |
| | 399 | |
| | 400 | .. We're picky. You might even call us perfectionists. (With deadlines.) |
| | 401 | |
| | 402 | Siamo esigenti. Potresti anche chiamarci perfezionisti (con scadenze). |
| | 403 | |
| | 404 | .. |
| | 405 | Over time, we stumbled across open-source libraries that did things we'd |
| | 406 | already implemented. It was reassuring to see other people solving similar |
| | 407 | problems in similar ways, but it was too late to integrate outside code: We'd |
| | 408 | already written, tested and implemented our own framework bits in several |
| | 409 | production settings -- and our own code met our needs delightfully. |
| | 410 | |
| | 411 | Con il trascorrere del tempo siamo incappati in librerie open-source che |
| | 412 | offrivano funzionalità da noi già sviluppate. Era rassicurante vedere che |
| | 413 | altre persone risolvevano problemi simili ai nostri in modi simili, ma era |
| | 414 | troppo tardi per integrare codice esterno: considerando il tempo che sarebbe |
| | 415 | servito avremmo invece scritto, testato ed implementato i bit del nostro |
| | 416 | framework in ambiente di produzione -- ed il nostro codice ha incontrato le |
| | 417 | nostre esigenze deliziosamente. |
| | 418 | |
| | 419 | .. |
| | 420 | In most cases, however, we found that existing frameworks/tools inevitably had |
| | 421 | some sort of fundamental, fatal flaw that made us squeamish. No tool fit our |
| | 422 | philosophies 100%. |
| | 423 | |
| | 424 | Nella maggior parte dei casi, tuttavia, abbiamo riscontrato che i framework e gli |
| | 425 | strumenti esistenti avavano qualche genere di fondamentale, fatale pecca che ci |
| | 426 | avrebbe nauseati. Nessun tool incontra la nostra filosofia al 100%. |
| | 427 | |
| | 428 | .. Like we said: We're picky. |
| | 429 | |
| | 430 | Come abbiamo detto: siamo perfezionisti. |
| | 431 | |
| | 432 | .. We've documented our philosophies on the `design philosophies page`_. |
| | 433 | |
| | 434 | Abbiamo documentato la nostra filosofia nella `pagina delle filosofie di |
| | 435 | progettazione`_. |
| | 436 | |
| | 437 | .. |
| | 438 | .. _design philosophies page: http://www.djangoproject.com/documentation/design_philosophies/ |
| | 439 | |
| | 440 | .. _pagina delle filosofie di progettazione: http://www.djangoproject.com/documentation/design_philosophies/ |
| | 441 | |
| | 442 | .. |
| | 443 | Do you have any of those nifty "screencast" things? |
| | 444 | --------------------------------------------------- |
| | 445 | |
| | 446 | Avete qualcuno di quegli screencast così attraenti? |
| | 447 | --------------------------------------------------- |
| | 448 | |
| | 449 | .. |
| | 450 | You can bet your bottom they're on the way. But, since we're still hammering |
| | 451 | out a few points, we want to make sure they reflect the final state of things |
| | 452 | at Django 1.0, not some intermediary step. In other words, we don't want to |
| | 453 | spend a lot of energy creating screencasts yet, because Django APIs will shift. |
| | 454 | |
| | 455 | Puoi scommettere che arriveranno. Ma, poiché stiamo ancora lavorando su alcuni |
| | 456 | aspetti, vogliamo essere sicuri che essi riflettano lo stato conclusivo delle |
| | 457 | cose al momento del rilascio di Django 1.0, evitando ritratti intermedi. In |
| | 458 | altre parole, non intendiamo ancora impiegare molte energie per gli screencast, |
| | 459 | perché le API di Django muteranno. |
| | 460 | |
| | 461 | .. In the meantime, though, check out this `unofficial Django screencast`_. |
| | 462 | |
| | 463 | Nel frattempo, puoi guardare questi `screencast non ufficiali`_. |
| | 464 | |
| | 465 | .. |
| | 466 | .. _unofficial Django screencast: http://www.throwingbeans.org/django_screencasts.html |
| | 467 | |
| | 468 | .. _screencast non ufficiali: http://www.throwingbeans.org/django_screencasts.html |
| | 469 | |
| | 470 | .. |
| | 471 | Is Django a content-management-system (CMS)? |
| | 472 | -------------------------------------------- |
| | 473 | |
| | 474 | Django è un sistema per la gestione dei contenuti (CMS)? |
| | 475 | -------------------------------------------------------- |
| | 476 | |
| | 477 | .. |
| | 478 | No, Django is not a CMS, or any sort of "turnkey product" in and of itself. |
| | 479 | It's a Web framework; it's a programming tool that lets you build Web sites. |
| | 480 | |
| | 481 | No, Django non è un CMS, né una sorta di "prodotto chiavi in mano" di suo. E' |
| | 482 | un framework Web, uno strumento di programmazione che consente di realizzare |
| | 483 | siti Web. |
| | 484 | |
| | 485 | .. |
| | 486 | For example, it doesn't make much sense to compare Django to something like |
| | 487 | Drupal_, because Django is something you use to *create* things like Drupal. |
| | 488 | |
| | 489 | Ad esempio, non ha molto senso confrontare Django con un sistema come Drupal_, |
| | 490 | in quanto usando Django puoi *creare* qualcosa simile a Drupal. |
| | 491 | |
| | 492 | .. |
| | 493 | Of course, Django's automatic admin site is fantastic and timesaving -- but |
| | 494 | the admin site is one module of Django the framework. Furthermore, although |
| | 495 | Django has special conveniences for building "CMS-y" apps, that doesn't mean |
| | 496 | it's not just as appropriate for building "non-CMS-y" apps (whatever that |
| | 497 | means!). |
| | 498 | |
| | 499 | Certamente l'interfaccia di amministrazione di Django è fantastica e ti |
| | 500 | consente di risparmiare moltissimo tempo -- ma il sito di amministrazione è un |
| | 501 | modulo del framework Django. Inoltre, sebbene Django si presti particolarmente |
| | 502 | per creare applicazioni "CMS-y", non significa che non sia appropriato per |
| | 503 | realizzare applicazioni "non-CMS-y" (qualsiasi cosa si voglia intendere!). |
| | 504 | |
| | 505 | .. _Drupal: http://drupal.org/ |
| | 506 | |
| | 507 | .. |
| | 508 | When will you release Django 1.0? |
| | 509 | --------------------------------- |
| | 510 | |
| | 511 | Quando rilascerete Django 1.0? |
| | 512 | ------------------------------ |
| | 513 | |
| | 514 | .. |
| | 515 | Short answer: When we're comfortable with Django's APIs, have added all |
| | 516 | features that we feel are necessary to earn a "1.0" status, and are ready to |
| | 517 | begin maintaining backwards compatibility. This should happen in a couple of |
| | 518 | months or so, although it's entirely possible that it could happen earlier. |
| | 519 | That translates into summer 2006. |
| | 520 | |
| | 521 | Risposta breve: quando saremo convinti delle API di Django, quando avremo |
| | 522 | aggiunto tutte le funzionalità che riteniamo essere necessarie per guadagnare |
| | 523 | lo stato "1.0", e infine quando saremo pronti per cominciare a mantenere la |
| | 524 | compatibilità relativamente alle versioni precedenti. Tutto questo dovrebbe |
| | 525 | accadere con buona approssimazione nell'arco di un paio di mesi, benché sia |
| | 526 | possibile che si verifichi in seguito. |
| | 527 | Un periodo di rilascio verosimile è l'estate 2006. |
| | 528 | |
| | 529 | .. |
| | 530 | The merging of Django's `magic-removal branch`_ went a long way toward Django |
| | 531 | 1.0. |
| | 532 | |
| | 533 | L'integrazione del codice `magic-removal` nei sorgenti della linea di sviluppo |
| | 534 | principale di Django ha considerevole influenza sul rilascio della versione |
| | 535 | 1.0. |
| | 536 | |
| | 537 | .. |
| | 538 | Of course, you should note that `quite a few production sites`_ use Django in |
| | 539 | its current status. Don't let the lack of a 1.0 turn you off. |
| | 540 | |
| | 541 | Naturalmente, dovresti non trascurare il fatto che esistono `vari siti in |
| | 542 | produzione`_ che usano Django nello stato attuale. Non farti inibire dalla non |
| | 543 | ufficialità della versione corrente. |
| | 544 | |
| | 545 | .. |
| | 546 | .. _magic-removal branch: http://code.djangoproject.com/wiki/RemovingTheMagic |
| | 547 | .. _quite a few production sites: http://code.djangoproject.com/wiki/DjangoPoweredSites |
| | 548 | |
| | 549 | .. _magic-removal: http://code.djangoproject.com/wiki/RemovingTheMagic |
| | 550 | .. _vari siti in produzione: http://code.djangoproject.com/wiki/DjangoPoweredSites |
| | 551 | |
| | 552 | .. |
| | 553 | How can I download the Django documentation to read it offline? |
| | 554 | --------------------------------------------------------------- |
| | 555 | |
| | 556 | Come posso scaricare la documentazione di Django e leggerla offline? |
| | 557 | -------------------------------------------------------------------- |
| | 558 | |
| | 559 | .. |
| | 560 | The Django docs are available in the ``docs`` directory of each Django tarball |
| | 561 | release. These docs are in ReST (ReStructured Text) format, and each text file |
| | 562 | corresponds to a Web page on the official Django site. |
| | 563 | |
| | 564 | La documentazione su Django è disponibile nella directory ``docs`` di ogni |
| | 565 | archivio contenente un rilascio ufficiale. Questi documenti sono in formato |
| | 566 | ReST (ReStructured Text), ed ogni file di testo corrisponde ad una pagina Web |
| | 567 | del sito. |
| | 568 | |
| | 569 | .. |
| | 570 | Because the documentation is `stored in revision control`_, you can browse |
| | 571 | documentation changes just like you can browse code changes. |
| | 572 | |
| | 573 | Poiché la documentazione risiede in un sistema per il `controllo delle |
| | 574 | revisioni`_, puoi consultare le modifiche apportate adottando le stesse |
| | 575 | modalità usate per il codice sorgente. |
| | 576 | |
| | 577 | .. |
| | 578 | Technically, the docs on Django's site are generated from the latest development |
| | 579 | versions of those ReST documents, so the docs on the Django site may offer more |
| | 580 | information than the docs that come with the latest Django release. |
| | 581 | |
| | 582 | Tecnicamente, i documenti sul sito di Django sono generati usando le ultime |
| | 583 | versioni di sviluppo dei documenti ReST, e per questo la documentazione sul |
| | 584 | sito può offrire informazioni più aggiornate rispetto a quelle che trovi a |
| | 585 | corredo dell'ultimo rilascio di Django. |
| | 586 | |
| | 587 | .. |
| | 588 | .. _stored in revision control: http://code.djangoproject.com/browser/django/trunk/docs |
| | 589 | |
| | 590 | .. _controllo delle revisioni: http://code.djangoproject.com/browser/django/trunk/docs |
| | 591 | |
| | 592 | .. |
| | 593 | Installation questions |
| | 594 | ====================== |
| | 595 | |
| | 596 | Domande sull'installazione |
| | 597 | ========================== |
| | 598 | |
| | 599 | .. |
| | 600 | How do I get started? |
| | 601 | --------------------- |
| | 602 | |
| | 603 | #. `Download the code`_. |
| | 604 | #. Install Django (read the `installation guide`_). |
| | 605 | #. Walk through the tutorial_. |
| | 606 | #. Check out the rest of the documentation_, and `ask questions`_ if you |
| | 607 | run into trouble. |
| | 608 | |
| | 609 | Da dove comincio? |
| | 610 | ----------------- |
| | 611 | |
| | 612 | #. `Scarica il codice`_. |
| | 613 | #. Installa Django (leggi la `guida di installazione`_). |
| | 614 | #. Segui il tutorial_. |
| | 615 | #. Leggi il resto della documentazione_, e `fai domande`_ se incontri qualche problema. |
| | 616 | |
| | 617 | .. _`Scarica il codice`: http://www.djangoproject.com/download/ |
| | 618 | .. _`guida di installazione`: http://www.djangoproject.com/documentation/install/ |
| | 619 | .. _tutorial: http://www.djangoproject.com/documentation/tutorial1/ |
| | 620 | .. _documentazione: http://www.djangoproject.com/documentation/ |
| | 621 | .. _`fai domande`: http://www.djangoproject.com/community/ |
| | 622 | |
| | 623 | .. |
| | 624 | How do I fix the "install a later version of setuptools" error? |
| | 625 | --------------------------------------------------------------- |
| | 626 | |
| | 627 | Come risolvo l'errore "install a later version of setuptools"? |
| | 628 | -------------------------------------------------------------- |
| | 629 | |
| | 630 | .. Just run the ``ez_setup.py`` script in the Django distribution. |
| | 631 | |
| | 632 | Semplicemente esegui lo script ``ez_setup.py`` nella distribuzione di Django. |
| | 633 | |
| | 634 | .. |
| | 635 | What are Django's prerequisites? |
| | 636 | -------------------------------- |
| | 637 | |
| | 638 | Quali sono i prerequisiti richiesti da Django? |
| | 639 | ---------------------------------------------- |
| | 640 | |
| | 641 | .. Django requires Python_ 2.3 or later. No other Python libraries are required. |
| | 642 | |
| | 643 | Django richiede la versione 2.3 di Python_ o successiva. Non serve nessun'altra |
| | 644 | libreria. |
| | 645 | |
| | 646 | .. |
| | 647 | For a development environment -- if you just want to experiment with Django -- |
| | 648 | you don't need to have a separate Web server installed; Django comes with its |
| | 649 | own lightweight development server. For a production environment, we recommend |
| | 650 | `Apache 2`_ and mod_python_, although Django follows the WSGI_ spec, which |
| | 651 | means it can run on a variety of server platforms. |
| | 652 | |
| | 653 | In ambiente di sviluppo -- se vuoi soltanto fare esperimenti -- non hai |
| | 654 | l'esigenza di dover usare un server Web separato; Django viene fornito con un |
| | 655 | server Web adatto ad essere usato in ambienti di sviluppo. In ambiente di |
| | 656 | produzione, raccomandiamo `Apache 2`_ e mod_python_, sebbene Django segua la |
| | 657 | specifica WSGI_ e quindi possa essere usato su un vasto numero di piattaforme |
| | 658 | server. |
| | 659 | |
| | 660 | .. |
| | 661 | You'll also need a database engine. PostgreSQL_ is recommended, and MySQL_ |
| | 662 | and `SQLite 3`_ are supported. |
| | 663 | |
| | 664 | Ti servirà anche un motore di database. PostgreSQL_ è raccomandato, MySQL_ e |
| | 665 | `SQLite 3`_ sono supportati. |
| | 666 | |
| | 667 | .. _Python: http://www.python.org/ |
| | 668 | .. _Apache 2: http://httpd.apache.org/ |
| | 669 | .. _mod_python: http://www.modpython.org/ |
| | 670 | .. _WSGI: http://www.python.org/peps/pep-0333.html |
| | 671 | .. _PostgreSQL: http://www.postgresql.org/ |
| | 672 | .. _MySQL: http://www.mysql.com/ |
| | 673 | .. _`SQLite 3`: http://www.sqlite.org/ |
| | 674 | |
| | 675 | .. |
| | 676 | Do I have to use mod_python? |
| | 677 | ---------------------------- |
| | 678 | |
| | 679 | Devo usare mod_python? |
| | 680 | ---------------------- |
| | 681 | |
| | 682 | .. |
| | 683 | Not if you just want to play around and develop things on your local computer. |
| | 684 | Django comes with its own Web server, and things should Just Work. |
| | 685 | |
| | 686 | Non se intendi sviluppare applicazioni di prova o applicazioni che nascono per |
| | 687 | essere usate sul computer locale. Django integra un server Web, e il sistema |
| | 688 | dovrebbe semplicemente funzionare ed essere pronto per l'uso. |
| | 689 | |
| | 690 | .. |
| | 691 | For production use, though, we recommend mod_python. The Django developers have |
| | 692 | been running it on mod_python for more than two years, and it's quite stable. |
| | 693 | |
| | 694 | Per ambienti di produzione, tuttavia, raccomandiamo mod_python. Gli |
| | 695 | sviluppatori di Django stanno usando mod_python da più di due anni, e come |
| | 696 | soluzione è risultata ampiamente stabile. |
| | 697 | |
| | 698 | .. |
| | 699 | However, if you don't want to use mod_python, you can use a different server, |
| | 700 | as long as that server has WSGI_ hooks. See the `server arrangements wiki page`_. |
| | 701 | |
| | 702 | Se però non vuoi usare mod_python, puoi usare un server differente, purché |
| | 703 | offra gli hook WSGI_. Consulta la `pagina del wiki sulle configurazioni dei |
| | 704 | server`_. |
| | 705 | |
| | 706 | .. _WSGI: http://www.python.org/peps/pep-0333.html |
| | 707 | .. _pagina del wiki sulle configurazioni dei server: http://code.djangoproject.com/wiki/ServerArrangements |
| | 708 | |
| | 709 | .. |
| | 710 | How do I install mod_python on Windows? |
| | 711 | --------------------------------------- |
| | 712 | |
| | 713 | * For Python 2.4, check out this `guide to mod_python & Python 2.3`_. |
| | 714 | * For Python 2.3, grab mod_python from http://www.modpython.org/ and read |
| | 715 | `Running mod_python on Apache on Windows2000`_. |
| | 716 | * Also, try this (not Windows-specific) `guide to getting mod_python |
| | 717 | working`_. |
| | 718 | |
| | 719 | Come installo mod_python su Windows? |
| | 720 | ------------------------------------ |
| | 721 | |
| | 722 | * Per Python 2.4, consulta questa `guida a mod_python & Python 2.3`_. |
| | 723 | * Per Python 2.3, scarica mod_python da http://www.modpython.org/ e leggi |
| | 724 | `Far funzionare mod_python per Apache su Windows2000`_. |
| | 725 | * Inoltre, puoi provare questa `guida per far funzionare mod_python`_ (non |
| | 726 | è specifica per Windows). |
| | 727 | |
| | 728 | .. _`guida a mod_python & Python 2.3`: http://www.lehuen.com/nicolas/index.php/2005/02/21/39-win32-build-of-mod_python-314-for-python-24 |
| | 729 | .. _`Far funzionare mod_python per Apache su Windows2000`: http://groups-beta.google.com/group/comp.lang.python/msg/139af8c83a5a9d4f |
| | 730 | .. _`guida per far funzionare mod_python`: http://www.dscpl.com.au/articles/modpython-001.html |
| | 731 | |
| | 732 | .. |
| | 733 | Will Django run under shared hosting (like TextDrive or Dreamhost)? |
| | 734 | ------------------------------------------------------------------- |
| | 735 | |
| | 736 | Django funzionerà se ospitato su hosting condivisi (come TextDrive o Dreamhost)? |
| | 737 | -------------------------------------------------------------------------------- |
| | 738 | |
| | 739 | .. See our `Django-friendly Web hosts`_ page. |
| | 740 | |
| | 741 | Consulta la pagina `Web hosts che supportano Django`_. |
| | 742 | |
| | 743 | .. _`Web hosts che supportano Django`: http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts |
| | 744 | |
| | 745 | .. |
| | 746 | Should I use the official version or development version? |
| | 747 | --------------------------------------------------------- |
| | 748 | |
| | 749 | Dovrei usare la versione ufficiale o quella di sviluppo? |
| | 750 | -------------------------------------------------------- |
| | 751 | |
| | 752 | .. |
| | 753 | The Django developers improve Django every day and are pretty good about not |
| | 754 | checking in broken code. We use the development code (from the Subversion |
| | 755 | repository) directly on our servers, so we consider it stable. With that in |
| | 756 | mind, we recommend that you use the latest development code, because it |
| | 757 | generally contains more features and fewer bugs than the "official" releases. |
| | 758 | |
| | 759 | Gli sviluppatori migliorano Django ogni giorno e sono molto abili a non |
| | 760 | inserire codice mal funzionante. Noi usiamo il codice di sviluppo (proveniente |
| | 761 | dal repository Subversion) direttamente sui nostri server, perciò lo |
| | 762 | consideriamo stabile. Con questo in mente ti raccomandiamo di usare la versione |
| | 763 | più recente del codice in sviluppo, poiché generalmente contiene un maggior |
| | 764 | numero di funzionalità e meno bachi rispetto alla versione "ufficiale". |
| | 765 | |
| | 766 | .. |
| | 767 | Using Django |
| | 768 | ============ |
| | 769 | |
| | 770 | Usare Django |
| | 771 | ============ |
| | 772 | |
| | 773 | .. |
| | 774 | Why do I get an error about importing DJANGO_SETTINGS_MODULE? |
| | 775 | ------------------------------------------------------------- |
| | 776 | |
| | 777 | Perché ottengo un errore sull'importazione di DJANGO_SETTINGS_MODULE? |
| | 778 | --------------------------------------------------------------------- |
| | 779 | |
| | 780 | .. Make sure that: |
| | 781 | |
| | 782 | Assicurati che: |
| | 783 | |
| | 784 | .. |
| | 785 | * The environment variable DJANGO_SETTINGS_MODULE is set to a fully-qualified |
| | 786 | Python module (i.e. "mysite.settings.main"). |
| | 787 | |
| | 788 | * Said module is on ``sys.path`` (``import mysite.settings.main`` should work). |
| | 789 | |
| | 790 | * The module doesn't contain syntax errors (of course). |
| | 791 | |
| | 792 | * If you're using mod_python but *not* using Django's request handler, |
| | 793 | you'll need to work around a mod_python bug related to the use of |
| | 794 | ``SetEnv``; before you import anything from Django you'll need to do |
| | 795 | the following:: |
| | 796 | |
| | 797 | os.environ.update(req.subprocess_env) |
| | 798 | |
| | 799 | (where ``req`` is the mod_python request object). |
| | 800 | |
| | 801 | * La variabile d'ambiente DJANGO_SETTINGS_MODULE sia impostata su un modulo |
| | 802 | Python completamente specificato (fully-qualified) (ad esempio, |
| | 803 | "mysite.settings.main"). |
| | 804 | * Detto modulo sia elencato in ``sys.path`` (in questa evenienza, ``import |
| | 805 | mysite.settings.main`` non dovrebbe segnalare errori). |
| | 806 | * Il modulo non contenga errori di sintassi (ovviamente). |
| | 807 | * Se stai usando mod_python ma *non* il request handler di Django, devi |
| | 808 | operare per aggirare un baco di mod_python relativo all'uso di ``SetEnv``; prima |
| | 809 | di importare qualsiasi cosa da Django devi eseguire:: |
| | 810 | |
| | 811 | os.environ.update(req.subprocess_env) |
| | 812 | |
| | 813 | (dove ``req`` è l'oggetto request di mod_python) |
| | 814 | |
| | 815 | .. |
| | 816 | I can't stand your template language. Do I have to use it? |
| | 817 | ---------------------------------------------------------- |
| | 818 | |
| | 819 | Non posso adottare il vostro linguaggio di template. Devo usarlo per forza? |
| | 820 | --------------------------------------------------------------------------- |
| | 821 | |
| | 822 | .. |
| | 823 | We happen to think our template engine is the best thing since chunky bacon, |
| | 824 | but we recognize that choosing a template language runs close to religion. |
| | 825 | There's nothing about Django that requires using the template language, so |
| | 826 | if you're attached to ZPT, Cheetah, or whatever, feel free to use those. |
| | 827 | |
| | 828 | Ci capita di pensare che il nostro motore di template sia la miglior trovata dopo il |
| | 829 | chunky bacon, ma riconosciamo che scegliere un linguaggio di template è qualcosa di |
| | 830 | religioso. Non c'è nessun motivo per cui Django ti imponga di usare il nostro linguaggio |
| | 831 | di template, perciò se hai buona confidenza con ZPT, Cheetah o altro, sei libero di |
| | 832 | poterli usare. |
| | 833 | |
| | 834 | .. |
| | 835 | Do I have to use your model/database layer? |
| | 836 | ------------------------------------------- |
| | 837 | |
| | 838 | Devo usare i vostri strumenti per creare i modelli e gestire l'interfacciamento ai database? |
| | 839 | -------------------------------------------------------------------------------------------- |
| | 840 | |
| | 841 | .. |
| | 842 | Nope. Just like the template system, the model/database layer is decoupled from |
| | 843 | the rest of the framework. The one exception is: If you use a different |
| | 844 | database library, you won't get to use Django's automatically-generated admin |
| | 845 | site. That app is coupled to the Django database layer. |
| | 846 | |
| | 847 | No. Proprio come per il sistema di template, il sistema di gestione dei modelli |
| | 848 | e dei database è disaccoppiato dal resto del framework. L'unica eccezione è che |
| | 849 | usando una differente libreria di interfacciamento ai database non ti potrai |
| | 850 | avvalere del sito di amministrazione generato automaticamente. Infatti l'applicazione |
| | 851 | dedicata a ciò utilizza il nostro database layer. |
| | 852 | |
| | 853 | .. |
| | 854 | How do I use image and file fields? |
| | 855 | ----------------------------------- |
| | 856 | |
| | 857 | Come si usano i campi immagine e file? |
| | 858 | -------------------------------------- |
| | 859 | |
| | 860 | .. |
| | 861 | Using a ``FileField`` or an ``ImageField`` in a model takes a few steps: |
| | 862 | |
| | 863 | #. In your settings file, define ``MEDIA_ROOT`` as the full path to |
| | 864 | a directory where you'd like Django to store uploaded files. (For |
| | 865 | performance, these files are not stored in the database.) Define |
| | 866 | ``MEDIA_URL`` as the base public URL of that directory. Make sure that |
| | 867 | this directory is writable by the Web server's user account. |
| | 868 | |
| | 869 | #. Add the ``FileField`` or ``ImageField`` to your model, making sure |
| | 870 | to define the ``upload_to`` option to tell Django to which subdirectory |
| | 871 | of ``MEDIA_ROOT`` it should upload files. |
| | 872 | |
| | 873 | #. All that will be stored in your database is a path to the file |
| | 874 | (relative to ``MEDIA_ROOT``). You'll must likely want to use the |
| | 875 | convenience ``get_<fieldname>_url`` function provided by Django. For |
| | 876 | example, if your ``ImageField`` is called ``mug_shot``, you can get the |
| | 877 | absolute URL to your image in a template with |
| | 878 | ``{{ object.get_mug_shot_url }}``. |
| | 879 | |
| | 880 | Usare un campo ``FileField`` o ``ImageField`` in un modello consiste in alcuni |
| | 881 | passi: |
| | 882 | |
| | 883 | #. Nel file di configurazione, definisci come valore di ``MEDIA_ROOT`` il |
| | 884 | percorso completo alla directory dove vuoi che Django memorizzi i file |
| | 885 | caricati (per motivi legati alle prestazioni, questi file non vengono |
| | 886 | mantenuti nel database). Definisci come valore di ``MEDIA_URL`` l'URL |
| | 887 | pubblico base per quella directory, ed assicurati che l'utente che esegue |
| | 888 | il server Web abbia i diritti per scrivervi. |
| | 889 | |
| | 890 | #. Aggiungi il campo ``FileField`` o ``ImageField`` al modello, ed |
| | 891 | assicurati di definire per l'opzione ``upload_to`` la sottodirectory di |
| | 892 | ``MEDIA_ROOT`` dove desideri che i file vengano mantenuti. |
| | 893 | |
| | 894 | #. Tutto quello che verrà mantenuto all'interno del database sarà il |
| | 895 | percorso del file (relativo a ``MEDIA_ROOT``). Probabilmente ti troverai |
| | 896 | spesso ad usare la comoda funzione ``get_<fieldname>_url`` fornita da |
| | 897 | Django. Ad esempio, se il nome del campo immagine è ``mug_shot``, potrai |
| | 898 | accedere all'URL assoluto dell'immagine in un template con |
| | 899 | ``{{ object.get_mug_shot_url }}``. |
| | 900 | |
| | 901 | .. |
| | 902 | If I make changes to a model, how do I update the database? |
| | 903 | ----------------------------------------------------------- |
| | 904 | |
| | 905 | Se modifico il modello, come aggiorno il database? |
| | 906 | -------------------------------------------------- |
| | 907 | |
| | 908 | .. |
| | 909 | If you don't mind clearing data, your project's ``manage.py`` utility has an |
| | 910 | option to reset the SQL for a particular application:: |
| | 911 | |
| | 912 | manage.py reset appname |
| | 913 | |
| | 914 | Se non ti interessa mantenere eventuali dati preesistenti, l'utility |
| | 915 | ``manage.py`` offre un'opzione per resettare i dati di una particolare |
| | 916 | applicazione:: |
| | 917 | |
| | 918 | manage.py reset appname |
| | 919 | |
| | 920 | .. |
| | 921 | This drops any tables associated with ``appname`` and recreates them. |
| | 922 | |
| | 923 | Questo comando elimina le tabelle associate a ``appname`` e le ricrea. |
| | 924 | |
| | 925 | .. |
| | 926 | If you do care about deleting data, you'll have to execute the ``ALTER TABLE`` |
| | 927 | statements manually in your database. That's the way we've always done it, |
| | 928 | because dealing with data is a very sensitive operation that we've wanted to |
| | 929 | avoid automating. That said, there's some work being done to add partially |
| | 930 | automated database-upgrade functionality. |
| | 931 | |
| | 932 | Se invece vuoi mantenere dati preesistenti, dovrai eseguire i costrutti ``ALTER |
| | 933 | TABLE`` manualmente. Noi abbiamo sempre scelto questa strada perché avere a |
| | 934 | che fare con i dati è un'operazione delicata e perciò abbiamo preferito evitare |
| | 935 | automatismi. Detto questo, è in corso una parziare implementazione della |
| | 936 | funzionalità di aggiornamento automatico dei dati. |
| | 937 | |
| | 938 | .. |
| | 939 | Do Django models support multiple-column primary keys? |
| | 940 | ------------------------------------------------------ |
| | 941 | |
| | 942 | I modelli di Django supportano chiavi primarie a colonna multipla? |
| | 943 | ------------------------------------------------------------------ |
| | 944 | |
| | 945 | .. No. Only single-column primary keys are supported. |
| | 946 | |
| | 947 | No. Sono supportante soltanto chiavi primarie costituite da una singola |
| | 948 | colonna. |
| | 949 | |
| | 950 | .. |
| | 951 | But this isn't an issue in practice, because there's nothing stopping you from |
| | 952 | adding other constraints (using the ``unique_together`` model option or |
| | 953 | creating the constraint directly in your database), and enforcing the |
| | 954 | uniqueness at that level. Single-column primary keys are needed for things such |
| | 955 | as the admin interface to work; e.g., you need a simple way of being able to |
| | 956 | specify an object to edit or delete. |
| | 957 | |
| | 958 | Ma nella pratica questo non rappresenta un problema, poiché non c'è nessun |
| | 959 | impedimento nell'aggiungere altri vincoli (usando l'opzione ``unique_together`` |
| | 960 | nel modello o agendo direttamente sul database), e richiedendo l'unicità a |
| | 961 | questo livello. Le chiavi primarie a colonna singola sono necessarie per far |
| | 962 | funzionare ad esempio l'interfaccia di amministrazione; (questo perché |
| | 963 | offrono un modo semplice per poter modificare o eliminare un oggetto). |
| | 964 | |
| | 965 | .. |
| | 966 | The database API |
| | 967 | ================ |
| | 968 | |
| | 969 | Le API del database |
| | 970 | =================== |
| | 971 | |
| | 972 | .. |
| | 973 | How can I see the raw SQL queries Django is running? |
| | 974 | ---------------------------------------------------- |
| | 975 | |
| | 976 | Come posso vedere l'SQL nativo delle query eseguite da Django? |
| | 977 | -------------------------------------------------------------- |
| | 978 | |
| | 979 | .. |
| | 980 | Make sure your Django ``DEBUG`` setting is set to ``True``. Then, just do |
| | 981 | this:: |
| | 982 | |
| | 983 | >>> from django.db import connection |
| | 984 | >>> connection.queries |
| | 985 | [{'sql': 'SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date FROM polls_polls', |
| | 986 | 'time': '0.002'}] |
| | 987 | |
| | 988 | Assicurati che l'impostazione ``DEBUG`` sia ``True``. Poi, semplicemente |
| | 989 | scrivi:: |
| | 990 | |
| | 991 | >>> from django.db import connection |
| | 992 | >>> connection.queries |
| | 993 | [{'sql': 'SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date FROM polls_polls', |
| | 994 | 'time': '0.002'}] |
| | 995 | |
| | 996 | .. |
| | 997 | ``connection.queries`` is only available if ``DEBUG`` is ``True``. It's a list |
| | 998 | of dictionaries in order of query execution. Each dictionary has the following:: |
| | 999 | |
| | 1000 | ``sql`` -- The raw SQL statement |
| | 1001 | ``time`` -- How long the statement took to execute, in seconds. |
| | 1002 | |
| | 1003 | ``connection.queries`` è disponibile solo se ``DEBUG`` è ``True``. Si tratta di |
| | 1004 | una lista in cui i dizionari che contengono le informazioni appaiono in ordine di |
| | 1005 | esecuzione. Ogni dizionario è composto da:: |
| | 1006 | |
| | 1007 | ``sql`` -- Il codice SQL nativo |
| | 1008 | ``time`` -- Il tempo richiesto per l'esecuzione della query, in secondi. |
| | 1009 | |
| | 1010 | .. |
| | 1011 | ``connection.queries`` includes all SQL statements -- INSERTs, UPDATES, |
| | 1012 | SELECTs, etc. Each time your app hits the database, the query will be recorded. |
| | 1013 | |
| | 1014 | ``connection.queries`` include tutti i costrutti SQL -- INSERT, UPDATES, |
| | 1015 | SELECT, ecc. Ogni volta che l'applicazione fa uso del database, la query verrà |
| | 1016 | memorizzata. |
| | 1017 | |
| | 1018 | .. |
| | 1019 | Can I use Django with a pre-existing database? |
| | 1020 | ---------------------------------------------- |
| | 1021 | |
| | 1022 | Posso usare Django con database che già esistono? |
| | 1023 | ------------------------------------------------- |
| | 1024 | |
| | 1025 | .. Yes. See `Integrating with a legacy database`_. |
| | 1026 | |
| | 1027 | Si. Vedi `Integrazione con database esistenti`_. |
| | 1028 | |
| | 1029 | .. |
| | 1030 | .. _`Integrating with a legacy database`: http://www.djangoproject.com/documentation/legacy_databases/ |
| | 1031 | |
| | 1032 | .. _`Integrazione con database esistenti`: http://www.djangoproject.com/documentation/legacy_databases/ |
| | 1033 | |
| | 1034 | .. |
| | 1035 | The admin site |
| | 1036 | ============== |
| | 1037 | |
| | 1038 | Il sito di amministrazione |
| | 1039 | ========================== |
| | 1040 | |
| | 1041 | .. |
| | 1042 | I can't log in. When I enter a valid username and password, it just brings up the login page again, with no error messages. |
| | 1043 | --------------------------------------------------------------------------------------------------------------------------- |
| | 1044 | |
| | 1045 | Non riesco a entrare. Quando inserisco un nome utente e una password validi vengo riportato alla pagina di login senza messaggi di errore. |
| | 1046 | ------------------------------------------------------------------------------------------------------------------------------------------ |
| | 1047 | |
| | 1048 | .. |
| | 1049 | The login cookie isn't being set correctly, because the domain of the cookie |
| | 1050 | sent out by Django doesn't match the domain in your browser. Try these two |
| | 1051 | things: |
| | 1052 | |
| | 1053 | * Set the ``SESSION_COOKIE_DOMAIN`` setting in your admin config file |
| | 1054 | to match your domain. For example, if you're going to |
| | 1055 | "http://www.mysite.com/admin/" in your browser, in |
| | 1056 | "myproject.settings" you should set ``SESSION_COOKIE_DOMAIN = 'www.mysite.com'``. |
| | 1057 | |
| | 1058 | * Some browsers (Firefox?) don't like to accept cookies from domains that |
| | 1059 | don't have dots in them. If you're running the admin site on "localhost" |
| | 1060 | or another domain that doesn't have a dot in it, try going to |
| | 1061 | "localhost.localdomain" or "127.0.0.1". And set |
| | 1062 | ``SESSION_COOKIE_DOMAIN`` accordingly. |
| | 1063 | |
| | 1064 | Il cookie di login non è stato impostato correttamente, perché il dominio del |
| | 1065 | cookie mandato da Django non coincide con il dominio nel tuo browser. Puoi |
| | 1066 | provare a: |
| | 1067 | |
| | 1068 | * Impostare il parametro ``SESSION_COOKIE_DOMAIN`` nel file di |
| | 1069 | configurazione sul nome del tuo dominio di provenienza. Ad esempio se nel |
| | 1070 | browser compare "http://www.mysite.com/admin/", in "myproject.settings" |
| | 1071 | dovresti scrivere ``SESSION_COOKIE_DOMAIN = 'www.mysite.com'``. |
| | 1072 | |
| | 1073 | * Alcuni browser (Firefox?) non gradiscono di accettare cookie da domini |
| | 1074 | che non contengano punti all'interno del loro nome. Se stai facendo |
| | 1075 | girare il sito di amministrazione sul "localhost" o su un altro nome che |
| | 1076 | senza punti, prova ad usare "localhost.localdomain" o "127.0.0.1". |
| | 1077 | Inoltre configura ``SESSION_COOKIE_DOMAIN`` di conseguenza. |
| | 1078 | |
| | 1079 | .. |
| | 1080 | I can't log in. When I enter a valid username and password, it brings up the login page again, with a "Please enter a correct username and password" error. |
| | 1081 | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | 1082 | |
| | 1083 | Non riesco a entrare. Quando inserisco un nome utente e una password validi vengo riportato alla pagina di login con l'errore "Inserire un nome utente e una password validi". |
| | 1084 | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| | 1085 | |
| | 1086 | .. |
| | 1087 | If you're sure your username and password are correct, make sure your user |
| | 1088 | account has ``is_active`` and ``is_staff`` set to True. The admin site only |
| | 1089 | allows access to users with those two fields both set to True. |
| | 1090 | |
| | 1091 | Se sei sicuro che il nome utente e la password sono corretti, assicurati che i |
| | 1092 | flag ``is_active`` e ``is_staff`` relativi all'utente siano True. |
| | 1093 | Il sito di amministrazione permette l'accesso ai soli utenti in cui questi |
| | 1094 | due campi risultano attivi. |
| | 1095 | |
| | 1096 | .. |
| | 1097 | How do I automatically set a field's value to the user who last edited the object in the admin? |
| | 1098 | ----------------------------------------------------------------------------------------------- |
| | 1099 | |
| | 1100 | Come posso far si che venga memorizzato automaticamente in un campo l'utente che per ultimo ha modificato un oggetto? |
| | 1101 | --------------------------------------------------------------------------------------------------------------------- |
| | 1102 | |
| | 1103 | .. |
| | 1104 | At this point, you can't do this. But it's an oft-requested feature, so we're |
| | 1105 | discussing how it can be implemented. The problem is we don't want to couple |
| | 1106 | the model layer with the admin layer with the request layer (to get the current |
| | 1107 | user). It's a tricky problem. |
| | 1108 | |
| | 1109 | Attualmente non è possibile. Considerando però che le richieste per questa |
| | 1110 | funzionalità sono piuttosto frequenti, stiamo discutendo una possibile |
| | 1111 | implementazione. Il problema è che non vogliamo creare dipendenze tra il layer |
| | 1112 | del modello, il layer di amministrazione e il layer di gestione delle richieste |
| | 1113 | (per ottenere l'utente). E' un problema ingarbugliato. |
| | 1114 | |
| | 1115 | .. |
| | 1116 | How do I limit admin access so that objects can only be edited by the users who created them? |
| | 1117 | --------------------------------------------------------------------------------------------- |
| | 1118 | |
| | 1119 | Come si limita l'accesso agli oggetti in modo che soltanto chi li ha creati possa amministrarli? |
| | 1120 | ------------------------------------------------------------------------------------------------ |
| | 1121 | |
| | 1122 | .. See the answer to the previous question. |
| | 1123 | |
| | 1124 | Vedi la risposta alla precedente domanda. |
| | 1125 | |
| | 1126 | .. |
| | 1127 | My admin-site CSS and images showed up fine using the development server, but they're not displaying when using mod_python. |
| | 1128 | --------------------------------------------------------------------------------------------------------------------------- |
| | 1129 | |
| | 1130 | Il CSS e le immagini del sito di amministrazione vengono mostrati usando il server di sviluppo, ma non compaiono usando mod_python. |
| | 1131 | ----------------------------------------------------------------------------------------------------------------------------------- |
| | 1132 | |
| | 1133 | .. |
| | 1134 | See `serving the admin files`_ in the "How to use Django with mod_python" |
| | 1135 | documentation. |
| | 1136 | |
| | 1137 | Vedi `erogare i file di amministrazione`_ nel documento "Come usare Django con |
| | 1138 | mod_python". |
| | 1139 | |
| | 1140 | .. |
| | 1141 | .. _serving the admin files: http://www.djangoproject.com/documentation/modpython/#serving-the-admin-files |
| | 1142 | |
| | 1143 | .. _erogare i file di amministrazione: http://www.djangoproject.com/documentation/modpython/#serving-the-admin-files |
| | 1144 | |
| | 1145 | .. |
| | 1146 | My "list_filter" contains a ManyToManyField, but the filter doesn't display. |
| | 1147 | ---------------------------------------------------------------------------- |
| | 1148 | |
| | 1149 | "list_filter" contiene un campo ManyToManyField, ma il filtro non lo mostra. |
| | 1150 | ---------------------------------------------------------------------------- |
| | 1151 | |
| | 1152 | .. |
| | 1153 | Django won't bother displaying the filter for a ``ManyToManyField`` if there |
| | 1154 | are fewer than two related objects. |
| | 1155 | |
| | 1156 | Django non si prende la briga di mostrare il filtro per un campo |
| | 1157 | ``ManyToManyField`` se ci sono meno di due oggetti associati. |
| | 1158 | |
| | 1159 | .. |
| | 1160 | For example, if your ``list_filter`` includes ``sites``, and there's only one |
| | 1161 | site in your database, it won't display a "Site" filter. In that case, |
| | 1162 | filtering by site would be meaningless. |
| | 1163 | |
| | 1164 | Ad esempio, se ``list_filter`` include ``sites``, ma c'è un solo sito nel |
| | 1165 | database, non sarà mostrato un filtro "Siti". In questo caso, filtrare per sito |
| | 1166 | non avrebbe senso. |
| | 1167 | |
| | 1168 | .. |
| | 1169 | How can I customize the functionality of the admin interface? |
| | 1170 | ------------------------------------------------------------- |
| | 1171 | |
| | 1172 | Come posso personalizzare le funzionalità dell'interfaccia di amministrazione? |
| | 1173 | ------------------------------------------------------------------------------ |
| | 1174 | |
| | 1175 | .. |
| | 1176 | You've got several options. If you want to piggyback on top of an add/change |
| | 1177 | form that Django automatically generates, you can attach arbitrary JavaScript |
| | 1178 | modules to the page via the model's ``class Admin`` ``js`` parameter. That |
| | 1179 | parameter is a list of URLs, as strings, pointing to JavaScript modules that |
| | 1180 | will be included within the admin form via a ``<script>`` tag. |
| | 1181 | |
| | 1182 | Disponi di parecchie opzioni. Se vuoi aggiungere qualche funzionalità alla form |
| | 1183 | di aggiunta e modifica che Django crea automaticamente, puoi usare il parametro |
| | 1184 | ``js`` nella classe ``class Admin`` del modello che intendi modificare, |
| | 1185 | inserendo codice JavaScript. Questo parametro è una lista di URL, specificati |
| | 1186 | come stringhe, che puntano ai moduli JavaScript che verranno caricati dal tag |
| | 1187 | ``<script>``. |
| | 1188 | |
| | 1189 | .. |
| | 1190 | If you want more flexibility than simply tweaking the auto-generated forms, |
| | 1191 | feel free to write custom views for the admin. The admin is powered by Django |
| | 1192 | itself, and you can write custom views that hook into the authentication |
| | 1193 | system, check permissions and do whatever else they need to do. |
| | 1194 | |
| | 1195 | Se ti serve maggiore flessibilità per apportare cambiamenti più sostanziali, |
| | 1196 | puoi scrivere view personalizzate per il sito di amministrazione. Questo sito è |
| | 1197 | realizzato con Django stesso, e tu puoi scrivere view personalizzate che si |
| | 1198 | interfacciano al sistema di autenticazione, che controllano permessi e che in |
| | 1199 | genere svolgano qualsiasi funzione che possa tornarti utile. |
| | 1200 | |
| | 1201 | .. |
| | 1202 | If you want to customize the look-and-feel of the admin interface, read the |
| | 1203 | next question. |
| | 1204 | |
| | 1205 | Se vuoi personalizzare l'aspetto dell'interfaccia di amministrazione, prosegui |
| | 1206 | con la lettura della prossima domanda. |
| | 1207 | |
| | 1208 | .. |
| | 1209 | The dynamically-generated admin site is ugly! How can I change it? |
| | 1210 | ------------------------------------------------------------------ |
| | 1211 | |
| | 1212 | Il sito di amministrazione generato dinamicamente è brutto. Come posso modificarlo? |
| | 1213 | ----------------------------------------------------------------------------------- |
| | 1214 | |
| | 1215 | .. |
| | 1216 | We like it, but if you don't agree, you can modify the admin site's |
| | 1217 | presentation by editing the CSS stylesheet and/or associated image files. The |
| | 1218 | site is built using semantic HTML and plenty of CSS hooks, so any changes you'd |
| | 1219 | like to make should be possible by editing the stylesheet. We've got a |
| | 1220 | `guide to the CSS used in the admin`_ to get you started. |
| | 1221 | |
| | 1222 | A noi piace, ma se non sei dello stesso parere puoi modificare l'aspetto agendo sui fogli |
| | 1223 | di stile CSS e/o sulle immagini. Il sito è costruito usando HTML semantico, e |
| | 1224 | gli hook ai fogli di stile abbondano, quindi agendo sui fogli di stile dovresti |
| | 1225 | essere in grado di apportare qualsiasi cambiamento tu desideri. Per aiutarti |
| | 1226 | abbiamo messo a disposizione una `guida ai CSS usati nell'amministrazione`_. |
| | 1227 | |
| | 1228 | .. |
| | 1229 | .. _`guide to the CSS used in the admin`: http://www.djangoproject.com/documentation/admin_css/ |
| | 1230 | |
| | 1231 | .. _`guida ai CSS usati nell'amministrazione`: http://www.djangoproject.com/documentation/admin_css/ |
| | 1232 | |
| | 1233 | .. |
| | 1234 | How do I create users without having to edit password hashes? |
| | 1235 | ------------------------------------------------------------- |
| | 1236 | |
| | 1237 | Come creo utenti senza dover fare gli hash delle password? |
| | 1238 | ---------------------------------------------------------- |
| | 1239 | |
| | 1240 | .. |
| | 1241 | We don't recommend you create users via the admin interface, because at the |
| | 1242 | moment it requires you to edit password hashes manually. (Passwords are hashed |
| | 1243 | using one-way hash algorithms for security; there's currently no Web interface |
| | 1244 | for changing passwords by entering the actual password rather than the hash.) |
| | 1245 | |
| | 1246 | Noi sconsigliamo di creare gli utenti usando l'interfaccia di amministrazione, |
| | 1247 | poiché ciò richiede la modifica manuale dell'hash delle password (viene |
| | 1248 | effettuato l'hash della password usando un algoritmo di hash one-way, per |
| | 1249 | motivi di sicurezza; attualmente non esiste un'interfaccia Web di |
| | 1250 | amministrazione per cambiare la password immettendo la password stessa invece |
| | 1251 | dell'hash). |
| | 1252 | |
| | 1253 | .. |
| | 1254 | To create a user, you'll have to use the Python API. See `creating users`_ for |
| | 1255 | full info. |
| | 1256 | |
| | 1257 | Per creare un utente, dovrai usare le API Python. Vedi `creare utenti`_ per |
| | 1258 | tutte le informazioni necessarie. |
| | 1259 | |
| | 1260 | .. |
| | 1261 | .. _creating users: http://www.djangoproject.com/documentation/authentication/#creating-users |
| | 1262 | |
| | 1263 | .. _creare utenti: http://www.djangoproject.com/documentation/authentication/#creating-users |
| | 1264 | |
| | 1265 | }}} |