Monday, August 11, 2014

MAC OSX 10.9 / Django + Python MYSQL SERVER ERROS/RESOLVIDOS

ERROS: 

Error loading MySQLdb module: No module named MySQLdb
EnvironmentError: mysql_config not found
error: command 'cc' failed with exit status 1
Library not loaded: libmysqlclient.18.dylib
django.db.utils.OperationalError: (1049, "Unknown database 'cursodjango'")
CommandError: No database fixture specified. Please provide the path of at least one fixture in the command line.

 raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

1˚ Tentei instalar o adaptador para MySQL-Python ...

(django-1.4)macbookdeandre:venvs alds$ pip install MySQL-Python
Downloading/unpacking MySQL-Python
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
  Running setup.py (path:/Volumes/STORAGE/Projects_Web/venvs/django-1.4/build/MySQL-Python/setup.py) egg_info for package MySQL-Python
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/build/MySQL-Python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/build/MySQL-Python/setup.py", line 17, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 25, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Volumes/STORAGE/Projects_Web/venvs/django-1.4/build/MySQL-Python


Storing debug log for failure in /Users/alds/.pip/pip.log

2˚ Instalei o MySQL Server no MAC OXS  + Adicionei os binarios  MySQL no PATH 

macbookdeandre:cursodjango alds$ ls /usr/local/mysql/bin/
innochecksum               mysql                      mysql_find_rows            mysql_waitpid              mysqlcheck                 mysqlhotcopy               replace
msql2mysql                 mysql_client_test          mysql_fix_extensions       mysql_zap                  mysqld                     mysqlimport                resolve_stack_dump
my_print_defaults          mysql_client_test_embedded mysql_plugin               mysqlaccess                mysqld-debug               mysqlshow                  resolveip
myisam_ftdump              mysql_config               mysql_secure_installation  mysqlaccess.conf           mysqld_multi               mysqlslap
myisamchk                  mysql_config_editor        mysql_setpermission        mysqladmin                 mysqld_safe                mysqltest
myisamlog                  mysql_convert_table_format mysql_tzinfo_to_sql        mysqlbinlog                mysqldump                  mysqltest_embedded
myisampack                 mysql_embedded             mysql_upgrade              mysqlbug                   mysqldumpslow              perror
macbookdeandre:cursodjango alds$ cd 
macbookdeandre:~ alds$ vim .bash_profile 
PATH=$PATH:/usr/local/mysql/bin


3˚ Tentei instalar o adaptador já MySQL Server estava instalado, porem tive erro porque o XCODE não estava instalado.

macbookdeandre:Projects_Web alds$ ls
sites venvs
macbookdeandre:Projects_Web alds$ source venvs/django-1.4/bin/activate
(django-1.4)macbookdeandre:Projects_Web alds$  pip install MySQL-Python
Downloading/unpacking MySQL-Python
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
....
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64

xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

error: command 'cc' failed with exit status 1

4˚ Depois de instalar o XCODE , alguns binários o vem no conjunto com o CC, necessário para compilação de alguns pacotes.

macbookdeandre:Projects_Web alds$ c
Display all 117 possibilities? (y or n)
c++                 cancel              chflags             cmp                 complete            cpan2dist           cpp                 csplit              cupsreject          cvfsdb
c++filt             cap_mkdb            chfn                cmpdylib            compress            cpan2dist5.12       cpu_profiler.d      csreq               cupstestdsc         cvfsid
c2ph                captoinfo           chgrp               codesign            config_data         cpan2dist5.16       cpuwalk.d           ctags               cupstestppd         cvgather
c2ph5.12            case                chmod               codesign_allocate   config_data5.12     cpan5.12            crc32               ctf_insert          curl                cvlabel
c2ph5.16            cat                 chown               col                 config_data5.16     cpan5.16            crc325.12           cu                  curl-config         cvmkdir
c89                 cc                  chpass              colcrt              continue            cpanp               crc325.16           cups-config         cut                 cvmkfile
c99                 cd                  chroot              colldef             coreaudiod          cpanp-run-perl      creatbyproc.d       cupsaccept          cvadmin             cvmkfs
c_rehash            certtool            chsh                colrm               corelist            cpanp-run-perl5.12  createhomedir       cupsaddsmb          cvaffinity          cvupdatefs
caffeinate          cfprefsd            cksum               column              corelist5.12        cpanp-run-perl5.16  crlrefresh          cupsctl             cvcp                cvversions
cal                 chat                clang               comm                corelist5.16        cpanp5.12           cron                cupsdisable         cvdb                
calendar            checkgid            clang++             command             cp                  cpanp5.16           crontab             cupsenable          cvdbset             
caller              checknr             clear               compgen             cpan                cpio                csh                 cupsfilter          cvfsck         

5˚ Instalacão do Pacote MySQL-Python realizada com sucesso. 

macbookdeandre:Projects_Web alds$ ls
sites venvs
macbookdeandre:Projects_Web alds$ source venvs/django-1.4/bin/activate
(django-1.4)macbookdeandre:Projects_Web alds$ pip install MySQL-Python
Downloading/unpacking MySQL-Python
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
  Running setup.py (path:/Volumes/STORAGE/Projects_Web/venvs/django-1.4/build/MySQL-Python/setup.py) egg_info for package MySQL-Python
    
Installing collected packages: MySQL-Python
  Running setup.py install for MySQL-Python
    building '_mysql' extension
    cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64
    In file included from _mysql.c:44:
    /usr/local/mysql/include/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined
      #define SIZEOF_SIZE_T  SIZEOF_LONG
              ^
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:43:17: note: previous definition is here
    #        define SIZEOF_SIZE_T           8
                    ^
    In file included from _mysql.c:44:
    /usr/local/mysql/include/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined
    #define HAVE_WCSCOLL
            ^
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:906:9: note: previous definition is here
    #define HAVE_WCSCOLL 1
            ^
    _mysql.c:287:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
                    cmd_argc = PySequence_Size(cmd_args);
                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:317:12: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
                    groupc = PySequence_Size(groups);
                           ~ ^~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:470:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
                            int j, n2=PySequence_Size(fun);
                                   ~~ ^~~~~~~~~~~~~~~~~~~~
    _mysql.c:1127:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_real_escape_string(&(self->connection), out, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1129:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_escape_string(out, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1168:9: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
            size = PyString_GET_SIZE(s);
                 ~ ^~~~~~~~~~~~~~~~~~~~
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/stringobject.h:92:32: note: expanded from macro 'PyString_GET_SIZE'
    #define PyString_GET_SIZE(op)  Py_SIZE(op)
                                   ^~~~~~~~~~~
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/object.h:116:56: note: expanded from macro 'Py_SIZE'
    #define Py_SIZE(ob)             (((PyVarObject*)(ob))->ob_size)
                                     ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    _mysql.c:1178:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_real_escape_string(&(self->connection), out+1, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1180:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                    len = mysql_escape_string(out+1, in, size);
                        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    _mysql.c:1274:11: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
            if ((n = PyObject_Length(o)) == -1) goto error;
                   ~ ^~~~~~~~~~~~~~~~~~
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:434:25: note: expanded from macro 'PyObject_Length'
    #define PyObject_Length PyObject_Size
                            ^
    _mysql.c:1466:10: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                            len = strlen(buf);
                                ~ ^~~~~~~~~~~
    _mysql.c:1468:10: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                            len = strlen(buf);
                                ~ ^~~~~~~~~~~
    _mysql.c:1504:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                                    len = strlen(buf);
                                        ~ ^~~~~~~~~~~
    _mysql.c:1506:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                                    len = strlen(buf);
                                        ~ ^~~~~~~~~~~
    _mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
            if (how < 0 || how >= sizeof(row_converters)) {
                ~~~ ^ ~
    16 warnings generated.
    cc -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.9-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -o build/lib.macosx-10.9-intel-2.7/_mysql.so -arch x86_64
    
Successfully installed MySQL-Python
Cleaning up...
(django-1.4)macbookdeandre:Projects_Web alds$ 


6˚ Problema com : Library not loaded: libmysqlclient.18.dylib

(django-1.4)macbookdeandre:cursodjango alds$ ./manage.py validate
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/base.py", line 280, in execute
    translation.activate('en-us')
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 130, in activate
    return _trans.activate(language)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 188, in activate
    _active.value = translation(language)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 6, in <module>
    from django.contrib.admin.sites import AdminSite, site
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 4, in <module>
    from django.contrib.admin.forms import AdminAuthenticationForm
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/contrib/admin/forms.py", line 6, in <module>
    from django.contrib.auth.forms import AuthenticationForm
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 17, in <module>
    from django.contrib.auth.models import User
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/contrib/auth/models.py", line 48, in <module>
    class Permission(models.Model):
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/models/base.py", line 96, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/models/base.py", line 264, in add_to_class
    value.contribute_to_class(cls, name)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/models/options.py", line 124, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/utils.py", line 198, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/utils.py", line 113, in load_backend
    return import_module('%s.base' % backend_name)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/_mysql.so
  Reason: image not found
(django-1.4)macbookdeandre:cursodjango alds$ ll /usr/local/mysql/lib/libmysqlclient.18.dylib
-rwxr-xr-x  1 root  wheel   4,1M 18 Jul 13:10 /usr/local/mysql/lib/libmysqlclient.18.dylib
(django-1.4)macbookdeandre:cursodjango alds$  ll /usr/lib/libmysqlclient.18.dylib
ls: /usr/lib/libmysqlclient.18.dylib: No such file or directory
(django-1.4)macbookdeandre:cursodjango alds$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Password:
(django-1.4)macbookdeandre:cursodjango alds$ ./manage.py validate
0 errors found
(django-1.4)macbookdeandre:cursodjango alds$ 

7˚ Novo problema com o banco : django.db.utils.OperationalError: (1049, "Unknown database 'cursodjango'")


(django-1.4)macbookdeandre:cursodjango alds$ ./manage.py testserver
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/core/management/commands/testserver.py", line 29, in handle
    db_name = connection.creation.create_test_db(verbosity=verbosity, autoclobber=not interactive)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/creation.py", line 326, in create_test_db
    self._create_test_db(verbosity, autoclobber)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/creation.py", line 387, in _create_test_db
    cursor = self.connection.cursor()
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/__init__.py", line 160, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/__init__.py", line 132, in _cursor
    self.ensure_connection()
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
    self.connect()
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
    self.connect()
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/__init__.py", line 115, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 435, in get_new_connection
    conn = Database.connect(**conn_params)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/Volumes/STORAGE/Projects_Web/venvs/django-1.4/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1049, "Unknown database 'cursodjango'")

8˚ Criar database para ver se resolver o problema 

macbookdeandre:cursodjango alds$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2577
Server version: 5.6.20 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0,00 sec)

mysql> create database cursodjango
    -> ;
Query OK, 1 row affected (0,00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cursodjango        |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0,00 sec)

mysql> 

9˚ Novo teste SERVER

(django-1.4)macbookdeandre:cursodjango alds$ ./manage.py testserver
Creating test database for alias 'default'...
CommandError: No database fixture specified. Please provide the path of at least one fixture in the command line.
(django-1.4)macbookdeandre:cursodjango alds$
(django-1.4)macbookdeandre:cursodjango alds$ ./manage.py syncdb
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table aula5_contato

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'alds'): yes
Email address: andre.luiz.silva.als@gmail.com
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
(django-1.4)macbookdeandre:cursodjango alds$ 

(django-1.4)macbookdeandre:cursodjango alds$ ./manage.py sqlall aula5
BEGIN;
CREATE TABLE `aula5_contato` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `nome` varchar(100) NOT NULL,
    `email` varchar(75) NOT NULL,
    `site` varchar(200) NOT NULL,
    `data_nascimento` date NOT NULL
)
;

COMMIT;

Saturday, August 9, 2014

Django para iniciantes - Comandos 1 / OSX 10.9

Instalando :
pip é um sistema de gerenciamento de pacotes usado para instalar e gerenciar pacotes de software escritos nalinguagem de programação Python. Muitos pacotes podem ser encontrados no Python Package Index (PyPI).
Virtualenv é uma ferramenta que permite que criemos, ambientes virtuais isolados para projetos Python. 


sh-3.2# easy_install pip virtualenv

MacBook-de-Andre:Projects_Web alds$ mkdir Projects_Web
MacBook-de-Andre:Projects_Web alds$ cd Projects_Web/
MacBook-de-Andre:Projects_Web alds$ mkdir venvs

Criar os ambientes virtuais para projetos Python
MacBook-de-Andre:Projects_Web alds$ virtualenv --system-site-packages venvs/django-1.4
New python executable in venvs/django-1.4/bin/python
Installing setuptools, pip...done.
MacBook-de-Andre:Projects_Web alds$

Ativando projeto
MacBook-de-Andre:Projects_Web alds$ source venvs/django-1.4/bin/activate
(django-1.4)MacBook-de-Andre:Projects_Web alds$

Instalando pacote dentro do projeto
(django-1.4)MacBook-de-Andre:Projects_Web alds$ pip install django
Downloading/unpacking django
  Downloading Django-1.6.5-py2.py3-none-any.whl (6.7MB): 6.7MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...

Verificando versão do 
Python
(django-1.4)MacBook-de-Andre:Projects_Web alds$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 6, 5, 'final', 0)
>>>

ROTEIRO

django-admin.py
django-admin.py startproject cursodjango
python manage.py runserver

Iniciando Projeto Web

(django-1.4)MacBook-de-Andre:Projects_Web alds$ mkdir sites
(django-1.4)MacBook-de-Andre:Projects_Web alds$ cd sites/
(django-1.4)MacBook-de-Andre:sites alds$ pwd
/Volumes/STORAGE/Projects_Web/sites
(django-1.4)MacBook-de-Andre:sites alds$ django-admin.py startproject cursodjango
(django-1.4)MacBook-de-Andre:sites alds$


(django-1.4)MacBook-de-Andre:sites alds$ pwd
/Volumes/STORAGE/Projects_Web/sites
(django-1.4)MacBook-de-Andre:sites alds$ ls
cursodjango
(django-1.4)MacBook-de-Andre:sites alds$ cd cursodjango/
(django-1.4)MacBook-de-Andre:cursodjango alds$ ll
total 8
drwxr-xr-x  6 alds  admin   204B  9 Ago 12:27 cursodjango
-rwxr-xr-x  1 alds  admin   254B  9 Ago 12:27 manage.py
(django-1.4)MacBook-de-Andre:cursodjango alds$

Iniciando Server Web
(django-1.4)MacBook-de-Andre:cursodjango alds$ python manage.py runserver
Validating models...

0 errors found
August 09, 2014 - 15:54:56
Django version 1.6.5, using settings 'cursodjango.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.


Fonte : 
http://allissonazevedo.com
https://www.youtube.com/watch?v=ZJKNbgq_lhg&list=PLfkVgm8720kzm6fmTekjtKyFcppyD4Ubd