Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-26 Thread Abba Haruna
thank you

-- 
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 django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23a22766-8296-416c-8734-a3771eb6beb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread Jason
on_delete is a required parameter now in django 2.0

https://docs.djangoproject.com/en/2.0/releases/2.0/#features-removed-in-2-0


   - The on_delete argument for ForeignKey and OneToOneField is now 
   required in models and migrations. Consider squashing migrations so that 
   you have fewer of them to update.

-- 
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 django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c3ea951d-4426-4973-b1bf-1d645402d1bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread vineeth sagar
For a foreign keys you have to specify an on_delete attribute,

food=models.ForiegnKey(Food,on_delete=models.CASCADE)

If a row in the parent table(food for example) is deleted this will cause
the row/s that refers to that particular food item in your Restraunt model
be deleted.

on_delete can be given other options as SET_NULL,DO_NOTHING. Refer the docs
they are extensive on this topic.

On Nov 23, 2018 1:20 AM, "Abba Haruna"  wrote:

> from django.db import models
>
> class Food(models.Model):
> name = models.CharField(max_length=30)
> picture = models.ImageField(upload_to='images/', null=True)
> def __unicode__(self):
> return self.name
> class Town(models.Model):
> name = models.CharField(max_length=30)
>
> def __unicode__(self):
> return self.name
> class Restaurant(models.Model):
> name = models.CharField(max_length=100)
> desc = models.CharField(max_length=100)
> menu = models.CharField(max_length=100)
> web = models.CharField(max_length=100)
> phone = models.CharField(max_length=40)
> address = models.CharField(max_length=100)
> post_code = models.CharField(max_length=20)
> picture = models.ImageField(upload_to='images/', null=True)
> map = models.ImageField(upload_to='images/', null=True)
> gmap_url = models.CharField(max_length=200, null=True)
> food = models.ForeignKey(Food)
> town = models.ForeignKey(Town)
> STARS = ((1,'one'),
> (2,'two'),
> (3,'three'),
> (4,'four'),)
> votes = models.IntegerField(choices=STARS, default=4)
> def __unicode__(self):
> return self.name
> def __str__(self):
>
> --
> 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 django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/de6ad3df-e330-43e1-875a-58895e245851%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMMZq8OuObyCbPXrwb47uSozX3sk7RXPiHaJnZxV%3Dk6SPjYpuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread Abba Haruna
from django.db import models

class Food(models.Model):
name = models.CharField(max_length=30)
picture = models.ImageField(upload_to='images/', null=True)
def __unicode__(self):
return self.name
class Town(models.Model):
name = models.CharField(max_length=30)

def __unicode__(self):
return self.name
class Restaurant(models.Model):
name = models.CharField(max_length=100)
desc = models.CharField(max_length=100)
menu = models.CharField(max_length=100)
web = models.CharField(max_length=100)
phone = models.CharField(max_length=40)
address = models.CharField(max_length=100)
post_code = models.CharField(max_length=20)
picture = models.ImageField(upload_to='images/', null=True)
map = models.ImageField(upload_to='images/', null=True)
gmap_url = models.CharField(max_length=200, null=True)
food = models.ForeignKey(Food)
town = models.ForeignKey(Town)
STARS = ((1,'one'),
(2,'two'),
(3,'three'),
(4,'four'),)
votes = models.IntegerField(choices=STARS, default=4)
def __unicode__(self):
return self.name
def __str__(self):

-- 
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 django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/de6ad3df-e330-43e1-875a-58895e245851%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.