Entrades

S'estan mostrant les entrades amb l'etiqueta django

Django Integrity Error amb loaddata

Si fent una importació de dades amb Django mitjançant la comanda:   ./manage.py loaddata i us apareix el següent error: IntegrityError : duplicate key value violates unique constraint "django_content_type_app_label_key" The problem is simply that you're getting the content types defined twice - once when you do syncdb , and once from the exported data you're trying to import. Since you may well have other items in your database that depend on the original content type definitions, I would recommend keeping those. So, after running syncdb , do manage.py dbshell and in your database do TRUNCATE django_content_type; to remove all the newly-defined content types. Then you shouldn't get any conflicts - on that part of the process, in any case. Resposta Original (Stackoverflow)

Django + Postgres: duplicate key value violates unique constraint

Aquesta entrada tracta d'un problema que et pot aparèixer quan importes una taula amb valors ja creats. Aleshores et trobes que la clau que assigna els nous identificadors(AUTOINCREMENT o SERIAL) no es reactualitza i, per tant, apareix l'error esmentat. Per tal de solucionar-ho has de seguir aquests tres passos: //Consultem el valor més alt de la taula SELECT MAX ( id ) FROM la_teva_taula ; //mirem quin és el següent valor que pendria una nova entrada SELECT nextval ( 'la_teva_taula_id_seq' ); //assignem el nou valor amb el màxim vist més una unitat per tal d'evitar col·lisió amb l'últim element afegit SELECT setval ( ' la_teva_taula _id_seq' , ( SELECT MAX ( id ) FROM la_teva_taula )+ 1 );

Django + MySql

Per tots aquells que volgueu treballar en el mòn del desenvolupament web teniu aquesta opció: Django , un framework en python: enllaç a la pàgina oficial MySQL , la Base de Dades on treballar: enllaç amb les comandes bàsiques