Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
- },
- 'legacy_db': {
- 'ENGINE': 'django.db.backends.mysql',
- 'NAME': 'name',
- 'USER': 'user',
- 'PASSWORD': 'pass',
- 'HOST': 'host',
- 'PORT': '3306',
- }
- python manage.py inspectdb --database legacy_db > models.py
- from django.db import models
- class User(models.Model):
- username = models.CharField(max_length=16)
- email = models.CharField(max_length=255, blank=True, null=True)
- password = models.CharField(max_length=32)
- create_time = models.DateTimeField(blank=True, null=True)
- id = models.IntegerField(primary_key=True)
- def __str__(self):
- return self.username
- class Meta:
- managed = False
- db_table = 'user'
- all = User.objects.all()
- all: unable to get repr for <class 'django.db.models.query.QuerySet'>
Add Comment
Please, Sign In to add comment