Re: need help - following django tutorial to create polls database - missing "on delete cascade" - using django 2.2.1 with mysql 8.0

2019-07-05 Thread sachin thakur
I am also facing the same problem i am using PostgreSQL data  base . please
do share this issue bug

*Thanks and Kind Regards*


*Sachin Thakur*
about.me/sachin.thakur

 *PG Student*
Dept. of Computer Applications,
*Christ ( Deemed to Be university) Main Campus Bangalore, India*
*UG (DSCASC under Bangalore University )* Bangalore, India.
Mob: *+91 8792560572*
*E-mail : sachin.thakur9...@gmail.com *
*E-mail : sachin.tha...@mca.christuniversity.in
*




On Sat, Jun 29, 2019 at 3:38 AM Joe Reitman  wrote:

> The notes say:
>
>- The exact output will vary depending on the database you are using.
>The example above is generated for* PostgreSQL.*
>
> Are you using the default SQLite?
>
> You could try running migrate and then checking the tables to see if the
> constraint was added using a DB admin viewer.
>
> For SQLite I use - https://sqlitebrowser.org/
> For Postgres  - https://www.pgadmin.org/
>
>
>
> On Tuesday, May 28, 2019 at 7:44:44 PM UTC-5, K Tan wrote:
>>
>> Hi, everyone,
>>
>> This is my first time using Django and I think I'm missing something or
>> there is a bug. I am following the instructions on (
>> https://docs.djangoproject.com/en/2.2/intro/tutorial02/) and I've just
>> added the following chunk of code to "polls/models.py". (I copied/pasted so
>> I know it's correct.)
>>
>> 
>> from django.db import models
>>
>>
>> class Question(models.Model):
>> question_text = models.CharField(max_length=200)
>> pub_date = models.DateTimeField('date published')
>>
>>
>> class Choice(models.Model):
>> question = models.ForeignKey(Question, on_delete=models.CASCADE)
>> choice_text = models.CharField(max_length=200)
>> votes = models.IntegerField(default=0)
>> 
>>
>>
>> Then I ran the following command:
>>
>> 
>> LITTLEBLACK:www samktan$ python3 manage.py makemigrations polls
>> Migrations for 'polls':
>>   polls/migrations/0001_initial.py
>> - Create model Question
>> - Create model Choice
>> 
>>
>> Which is missing one line compared to the tutorial:
>>
>> - Add field question to choice
>>
>>
>>
>> Now when I run this command:
>>
>> 
>> LITTLEBLACK:www samktan$ python3 manage.py sqlmigrate polls 0001
>> BEGIN;
>> --
>> -- Create model Question
>> --
>> CREATE TABLE `polls_question` (`id` integer AUTO_INCREMENT NOT NULL
>> PRIMARY KEY, `question_text` varchar(200) NOT NULL, `pub_date` datetime(6)
>> NOT NULL);
>> --
>> -- Create model Choice
>> --
>> CREATE TABLE `polls_choice` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY
>> KEY, `choice_text` varchar(200) NOT NULL, `votes` integer NOT NULL,
>> `question_id` integer NOT NULL);
>> ALTER TABLE `polls_choice` ADD CONSTRAINT
>> `polls_choice_question_id_c5b4b260_fk_polls_question_id` FOREIGN KEY
>> (`question_id`) REFERENCES `polls_question` (`id`);
>> COMMIT;
>> 
>>
>> It is missing the "on delete cascade" clause, which I suspect it caused
>> by the missing line above.
>>
>> I have confirmed in MySQL that the "on delete cascade" clause is
>> definitely missing.
>>
>> 
>> mysql> show create table `polls_choice`;
>>
>> +--+-+
>> | Table| Create Table
>>
>>
>>
>>
>>
>>|
>>
>> +--+-+
>> | polls_choice | CREATE TABLE `polls_choice` (
>>   `id` int(11) NOT NULL AUTO_INCREMENT,
>>   `choice_text` varchar(200) COLLATE utf8mb4_general_ci NOT NULL,
>>   `votes` int(11) NOT NULL,
>>   `question_id` int(11) NOT NULL,
>>   PRIMARY KEY (`id`),
>>   KEY `polls_choice_question_id_c5b4b260_fk_polls_question_id`
>> (`question_id`),
>>   CONSTRAINT `polls_choice_question_id_c5b4b260_fk_polls_question_id`
>> FOREIGN KEY (`question_id`) REFERENCES `polls_question` (`id`)
>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 

Re: need help - following django tutorial to create polls database - missing "on delete cascade" - using django 2.2.1 with mysql 8.0

2019-06-28 Thread Joe Reitman
The notes say:

   - The exact output will vary depending on the database you are using. 
   The example above is generated for* PostgreSQL.*

Are you using the default SQLite?

You could try running migrate and then checking the tables to see if the 
constraint was added using a DB admin viewer.

For SQLite I use - https://sqlitebrowser.org/
For Postgres  - https://www.pgadmin.org/



On Tuesday, May 28, 2019 at 7:44:44 PM UTC-5, K Tan wrote:
>
> Hi, everyone,
>
> This is my first time using Django and I think I'm missing something or 
> there is a bug. I am following the instructions on (
> https://docs.djangoproject.com/en/2.2/intro/tutorial02/) and I've just 
> added the following chunk of code to "polls/models.py". (I copied/pasted so 
> I know it's correct.)
>
> 
> from django.db import models
>
>
> class Question(models.Model):
> question_text = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
>
> class Choice(models.Model):
> question = models.ForeignKey(Question, on_delete=models.CASCADE)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
> 
>
>
> Then I ran the following command:
>
> 
> LITTLEBLACK:www samktan$ python3 manage.py makemigrations polls
> Migrations for 'polls':
>   polls/migrations/0001_initial.py
> - Create model Question
> - Create model Choice
> 
>
> Which is missing one line compared to the tutorial:
>
> - Add field question to choice
>
>
>
> Now when I run this command:
>
> 
> LITTLEBLACK:www samktan$ python3 manage.py sqlmigrate polls 0001
> BEGIN;
> --
> -- Create model Question
> --
> CREATE TABLE `polls_question` (`id` integer AUTO_INCREMENT NOT NULL 
> PRIMARY KEY, `question_text` varchar(200) NOT NULL, `pub_date` datetime(6) 
> NOT NULL);
> --
> -- Create model Choice
> --
> CREATE TABLE `polls_choice` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY 
> KEY, `choice_text` varchar(200) NOT NULL, `votes` integer NOT NULL, 
> `question_id` integer NOT NULL);
> ALTER TABLE `polls_choice` ADD CONSTRAINT 
> `polls_choice_question_id_c5b4b260_fk_polls_question_id` FOREIGN KEY 
> (`question_id`) REFERENCES `polls_question` (`id`);
> COMMIT;
> 
>
> It is missing the "on delete cascade" clause, which I suspect it caused by 
> the missing line above.
>
> I have confirmed in MySQL that the "on delete cascade" clause is 
> definitely missing.
>
> 
> mysql> show create table `polls_choice`;
>
> +--+-+
> | Table| Create Table 
> 
> 
> 
> 
> 
>|
>
> +--+-+
> | polls_choice | CREATE TABLE `polls_choice` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `choice_text` varchar(200) COLLATE utf8mb4_general_ci NOT NULL,
>   `votes` int(11) NOT NULL,
>   `question_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`),
>   KEY `polls_choice_question_id_c5b4b260_fk_polls_question_id` 
> (`question_id`),
>   CONSTRAINT `polls_choice_question_id_c5b4b260_fk_polls_question_id` 
> FOREIGN KEY (`question_id`) REFERENCES `polls_question` (`id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
>
> 

Re: need help - following django tutorial to create polls database - missing "on delete cascade" - using django 2.2.1 with mysql 8.0

2019-06-28 Thread Jasmine Smith
Looking into, will get back to you soon. Thanks.

On Thu, Jun 27, 2019 at 8:15 PM Rudy Quiroga Gamboa 
wrote:

> Hi, I have the same problem, did you find the problem or the solution ?
>
>
> El martes, 28 de mayo de 2019, 20:44:44 (UTC-4), K Tan escribió:
>>
>> Hi, everyone,
>>
>> This is my first time using Django and I think I'm missing something or
>> there is a bug. I am following the instructions on (
>> https://docs.djangoproject.com/en/2.2/intro/tutorial02/) and I've just
>> added the following chunk of code to "polls/models.py". (I copied/pasted so
>> I know it's correct.)
>>
>> 
>> from django.db import models
>>
>>
>> class Question(models.Model):
>> question_text = models.CharField(max_length=200)
>> pub_date = models.DateTimeField('date published')
>>
>>
>> class Choice(models.Model):
>> question = models.ForeignKey(Question, on_delete=models.CASCADE)
>> choice_text = models.CharField(max_length=200)
>> votes = models.IntegerField(default=0)
>> 
>>
>>
>> Then I ran the following command:
>>
>> 
>> LITTLEBLACK:www samktan$ python3 manage.py makemigrations polls
>> Migrations for 'polls':
>>   polls/migrations/0001_initial.py
>> - Create model Question
>> - Create model Choice
>> 
>>
>> Which is missing one line compared to the tutorial:
>>
>> - Add field question to choice
>>
>>
>>
>> Now when I run this command:
>>
>> 
>> LITTLEBLACK:www samktan$ python3 manage.py sqlmigrate polls 0001
>> BEGIN;
>> --
>> -- Create model Question
>> --
>> CREATE TABLE `polls_question` (`id` integer AUTO_INCREMENT NOT NULL
>> PRIMARY KEY, `question_text` varchar(200) NOT NULL, `pub_date` datetime(6)
>> NOT NULL);
>> --
>> -- Create model Choice
>> --
>> CREATE TABLE `polls_choice` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY
>> KEY, `choice_text` varchar(200) NOT NULL, `votes` integer NOT NULL,
>> `question_id` integer NOT NULL);
>> ALTER TABLE `polls_choice` ADD CONSTRAINT
>> `polls_choice_question_id_c5b4b260_fk_polls_question_id` FOREIGN KEY
>> (`question_id`) REFERENCES `polls_question` (`id`);
>> COMMIT;
>> 
>>
>> It is missing the "on delete cascade" clause, which I suspect it caused
>> by the missing line above.
>>
>> I have confirmed in MySQL that the "on delete cascade" clause is
>> definitely missing.
>>
>> 
>> mysql> show create table `polls_choice`;
>>
>> +--+-+
>> | Table| Create Table
>>
>>
>>
>>
>>
>>|
>>
>> +--+-+
>> | polls_choice | CREATE TABLE `polls_choice` (
>>   `id` int(11) NOT NULL AUTO_INCREMENT,
>>   `choice_text` varchar(200) COLLATE utf8mb4_general_ci NOT NULL,
>>   `votes` int(11) NOT NULL,
>>   `question_id` int(11) NOT NULL,
>>   PRIMARY KEY (`id`),
>>   KEY `polls_choice_question_id_c5b4b260_fk_polls_question_id`
>> (`question_id`),
>>   CONSTRAINT `polls_choice_question_id_c5b4b260_fk_polls_question_id`
>> FOREIGN KEY (`question_id`) REFERENCES `polls_question` (`id`)
>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
>>
>> +--+-+
>> 1 row in set (0.00 sec)
>> 
>>
>> Can someone tell me what I'm doing wrong?
>>
>>
>> --
>>
>> / per ardua ad astra /
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to 

Re: need help - following django tutorial to create polls database - missing "on delete cascade" - using django 2.2.1 with mysql 8.0

2019-06-27 Thread Rudy Quiroga Gamboa
Hi, I have the same problem, did you find the problem or the solution ?


El martes, 28 de mayo de 2019, 20:44:44 (UTC-4), K Tan escribió:
>
> Hi, everyone,
>
> This is my first time using Django and I think I'm missing something or 
> there is a bug. I am following the instructions on (
> https://docs.djangoproject.com/en/2.2/intro/tutorial02/) and I've just 
> added the following chunk of code to "polls/models.py". (I copied/pasted so 
> I know it's correct.)
>
> 
> from django.db import models
>
>
> class Question(models.Model):
> question_text = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
>
> class Choice(models.Model):
> question = models.ForeignKey(Question, on_delete=models.CASCADE)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
> 
>
>
> Then I ran the following command:
>
> 
> LITTLEBLACK:www samktan$ python3 manage.py makemigrations polls
> Migrations for 'polls':
>   polls/migrations/0001_initial.py
> - Create model Question
> - Create model Choice
> 
>
> Which is missing one line compared to the tutorial:
>
> - Add field question to choice
>
>
>
> Now when I run this command:
>
> 
> LITTLEBLACK:www samktan$ python3 manage.py sqlmigrate polls 0001
> BEGIN;
> --
> -- Create model Question
> --
> CREATE TABLE `polls_question` (`id` integer AUTO_INCREMENT NOT NULL 
> PRIMARY KEY, `question_text` varchar(200) NOT NULL, `pub_date` datetime(6) 
> NOT NULL);
> --
> -- Create model Choice
> --
> CREATE TABLE `polls_choice` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY 
> KEY, `choice_text` varchar(200) NOT NULL, `votes` integer NOT NULL, 
> `question_id` integer NOT NULL);
> ALTER TABLE `polls_choice` ADD CONSTRAINT 
> `polls_choice_question_id_c5b4b260_fk_polls_question_id` FOREIGN KEY 
> (`question_id`) REFERENCES `polls_question` (`id`);
> COMMIT;
> 
>
> It is missing the "on delete cascade" clause, which I suspect it caused by 
> the missing line above.
>
> I have confirmed in MySQL that the "on delete cascade" clause is 
> definitely missing.
>
> 
> mysql> show create table `polls_choice`;
>
> +--+-+
> | Table| Create Table 
> 
> 
> 
> 
> 
>|
>
> +--+-+
> | polls_choice | CREATE TABLE `polls_choice` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `choice_text` varchar(200) COLLATE utf8mb4_general_ci NOT NULL,
>   `votes` int(11) NOT NULL,
>   `question_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`),
>   KEY `polls_choice_question_id_c5b4b260_fk_polls_question_id` 
> (`question_id`),
>   CONSTRAINT `polls_choice_question_id_c5b4b260_fk_polls_question_id` 
> FOREIGN KEY (`question_id`) REFERENCES `polls_question` (`id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
>
> +--+-+
> 1 row in set (0.00 sec)
> 
>
> Can someone tell me what I'm doing wrong?
>
>
> -- 
>
> / per ardua ad astra /
>
>

-- 
You received this message because you are subscribed to the Google Groups