Reputation: 229
I have following problem. I've created table 'users' using postgres database, then I've created model:
from django.db import models
class Users(models.Model):
name= models.CharField(max_length=30)
surmane=models.CharField(max_length=50)
city=models.CharField(max_length=60)
country=models.CharField(max_length=30)
street=models.CharField(max_length=60)
code=models.CharField(max_length=30)
email=models.CharField(max_length=30)
def __str__(self):
return self.name
After I made syncdb, the model-table occurs in the database but it is not populated in data from the table 'users'. Why is that? No error occured during synchronization. Everything gone well exept that thing. Thanks!
Upvotes: 1
Views: 510
Reputation: 62
Django provides a table auth_users for storing user data in the database. If you want to make your own User model, you can do so either by extending the class User in django.contrib , or make a separate model for User Profile having a foreign key as User .
Secondly , if you want to create table with data before syncdb, you have to make the table as the same name as the _users , so that after the syncdb , django won't create a new table in the database , instead use your table. Hope it solves your doubt.
Upvotes: 2