python - Django 1.8.3 adding ForeignKey for existing database -


i'm following django tutorial 4 adding permissions api resources. http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/

i have existing database in postgres i'm able read/write values using django api. want add permissions via user.auth needs addition of column in db. following error when browsing api:

programmingerror @ /server/ column server.owner_id not exist 

this server model:

class server(models.model):     discovered = models.booleanfield()     status = models.smallintegerfield()     serialnumber = models.charfield(max_length=100, null=true)     hostname = models.charfield(max_length=250)     description = models.charfield(max_length=250, blank=true, null=true)     created = models.datetimefield(auto_now_add=true)         fk_server_model = models.foreignkey('servermodel', db_column='fk_server_model')     fk_licensing = models.foreignkey(licensing, db_column='fk_licensing', blank=true, null=true)     fk_network_services = models.foreignkey(networkservices, db_column='fk_network_services', blank=true, null=true)     fk_network_interfaces = models.foreignkey(networkinterfaces, db_column='fk_network_interfaces', blank=true, null=true)     fk_server_authentication = models.foreignkey('servercredentials', db_column='fk_server_authentication', blank=true, null=true)     owner = models.foreignkey('auth.user', related_name='servers')      def save(self, *args, **kwargs):         super(server, self).save(*args, **kwargs)      class meta:         managed = false         db_table = 'server' 

as part of tutorial, want django foreign key field owner_id after doing a:

python manage.py syncdb 

my database table server doesn't have add field not foreign key relationship auth_user table. what's right way have django auto generate foreign keys in database? tried:

python manage.py migrate 

with similar results thanks

i ended adding field manually in db. owner_id type int4 table , create fk reference


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -