Django

Code

Ticket #5776 (closed: fixed)

Opened 1 year ago

Last modified 10 months ago

Conflict between tutorial and 'Get your database running' section of the 'How to install Django' page

Reported by: Jeff@Bridge2Web.com Assigned to: nobody
Milestone: Component: Documentation
Version: SVN Keywords: mysql
Cc: Triage Stage: Someday/Maybe
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

This snippet from the 'Get your database running' section of the 'How to install Django' page specifies a limited set of permissions needed for the database user:

If you plan to use Django’s manage.py syncdb command to automatically create database tables for your models, you’ll need to ensure that Django has permission to create tables in the database you’re using; if you plan to manually create the tables, you can simply grant Django SELECT, INSERT, UPDATE and DELETE permissions. Django does not issue ALTER TABLE statements, and so will not require permission to do so. If you will be using Django’s testing framework with data fixtures, Django will need permission to create a temporary test database.


However running through the tutorial caused these errors that were corrected by adding ALTER and INDEX permissions:

prompt:~/development/tutsite XXX$ python2.4 manage.py syncdb

Creating table auth_message Creating table auth_group Creating table auth_user Traceback (most recent call last):

File "manage.py", line 11, in ?

execute_manager(settings)

File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 1672, in execute_manager

execute_from_command_line(action_mapping, argv)

File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 1571, in execute_from_command_line

action_mapping[action](int(options.verbosity), options.interactive)

File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 534, in syncdb

cursor.execute(statement)

File "/opt/local/lib/python2.4/site-packages/django/db/backends/util.py", line 12, in execute

return self.cursor.execute(sql, params)

File "/opt/local/lib/python2.4/site-packages/MySQLdb/cursors.py", line 163, in execute

self.errorhandler(self, exc, value)

File "/opt/local/lib/python2.4/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler

raise errorclass, errorvalue

_mysql_exceptions.OperationalError?: (1142, "ALTER command denied to user 'django'@'localhost' for table 'auth_message'")

------------------------

prompt:~/development/tutsite XXX$ python2.4 manage.py syncdb Creating table auth_permission Creating table django_content_type Creating table django_session Creating table django_site Installing index for auth.Permission model Failed to install index for auth.Permission model: (1142, "INDEX command denied to user 'django'@'localhost' for table 'auth_permission'")Loading 'initial_data' fixtures... No fixtures found.

Attachments

5776.diff (0.9 kB) - added by arien <regexbot@gmail.com> on 11/08/07 16:02:28.
5776-alternative.diff (0.9 kB) - added by arien <regexbot@gmail.com> on 11/08/07 16:07:02.
5776-another-possibility.txt (361 bytes) - added by Jeff@Bridge2Web.com on 11/08/07 18:19:20.
Another possible edit …
5776.mysql_index.diff (1.0 kB) - added by Lou Quillio <public@quillio.com> on 12/15/07 18:56:20.

Change History

10/18/07 15:26:50 changed by SmileyChris

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

The documentation says there "if you plan to manually create the tables". Using syncdb isn't manually creating them.

I guess the following sentence which mentions no need for ALTER TABLE isn't clearly linked to the previous sentence. If you think you car write it clearer, give it a go and attach the patch!

11/08/07 16:02:28 changed by arien <regexbot@gmail.com>

  • attachment 5776.diff added.

11/08/07 16:07:02 changed by arien <regexbot@gmail.com>

  • attachment 5776-alternative.diff added.

11/08/07 16:10:48 changed by arien <regexbot@gmail.com>

  • has_patch set to 1.

Either of these two patches will do, I think.

(The first patch changes the wording, while the second only changes punctuation.)

11/08/07 17:24:54 changed by Jeff@Bridge2Web.com

I'm just getting back to this, and it looks like I'm late.

I'm also new to Django and this ticket system so I don't know how to attach the a diff file for this.

I think a better solution might be to split it into two paraagraphs. One for automatically created table permission requirements, and the other for manually created database tables.

I still find the sentence about 'no ALTER permission' is needed by Django. It still looks like it is required by Django, but only if you're using syncdb to manage tables. Its not required if you manually manage the tables. Am I missing soemthing here ?

11/08/07 18:19:20 changed by Jeff@Bridge2Web.com

  • attachment 5776-another-possibility.txt added.

Another possible edit ...

12/01/07 11:45:00 changed by ubernostrum

  • status changed from new to closed.
  • resolution set to fixed.

(In [6794]) Fixed #5776: Added an explanation of when and why Django might need ALTER TABLE privileges to docs/install.txt

12/15/07 18:55:34 changed by Lou Quillio <public@quillio.com>

  • keywords set to mysql.
  • version changed from 0.96 to SVN.
  • stage changed from Accepted to Someday/Maybe.

When using syncdb with models.ForeignKey() against MySQL 5.0, I found that the MySQL user also needs INDEX. Not sure how ambitious install.txt means to be with edge cases, but there's a patch attached just the same.

LQ

12/15/07 18:56:20 changed by Lou Quillio <public@quillio.com>

  • attachment 5776.mysql_index.diff added.

Add/Change #5776 (Conflict between tutorial and 'Get your database running' section of the 'How to install Django' page)




Change Properties
Action