django-1.7

Django 1.7 makemigrations freezing/hanging

北战南征 提交于 2019-12-22 03:51:45
问题 I'm finally upgrading from Django 1.6 to 1.7, and removing South in the process. I followed the official Django instructions and removed all my old numbered migrations. Now I'm trying to run python manage.py makemigrations to get the new migrations to continue moving forward with 1.7's migrations module, but it completely hangs and the only output I get is the following: bash -cl "/Users/me/.virtualenvs/mysite-Dj17/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py

Add non-null and unique field with already populated model

不问归期 提交于 2019-12-20 17:26:58
问题 I have one model in my app running in a server with a few entries. I need to add a SlugField , unique and not-null for this model. The SlugField will be populated based on trading_name . I've changed my model in order to add this new field and modified save method: class Supplier(StatusModel): SLUG_MAX_LENGTH = 210 slug = models.SlugField(unique=True, max_length=SLUG_MAX_LENGTH) trading_name = models.CharField(max_length=200, verbose_name=_('trading name')) ... def save(self, *args, **kwargs)

AttributeError while using Django Rest Framework with serializers

百般思念 提交于 2019-12-20 11:03:14
问题 I am following a tutorial located here that uses Django Rest Framework, and I keep getting a weird error about a field. I have the following model in my models.py from django.db import models class Task(models.Model): completed = models.BooleanField(default=False) title = models.CharField(max_length=100) description = models.TextField() Then my serializer in serializers.py from rest_framework import serializers from task.models import Task class TaskSerializer(serializers.ModelSerializer):

django.db.utils.IntegrityError: (1062, “Duplicate entry '' for key 'slug'”)

霸气de小男生 提交于 2019-12-18 07:12:22
问题 I'm trying to follow the tangowithdjango book and must add a slug to update the category table. However I'm getting an error after trying to migrate the databases. http://www.tangowithdjango.com/book17/chapters/models_templates.html#creating-a-details-page I didn't provide a default value for the slug, so Django asked me to provide one and as the book instructed I type in ''. It's worth noticing that instead of using sqlite as in the original book I'm using mysql. models.py from django.db

django.db.utils.IntegrityError: (1062, “Duplicate entry '' for key 'slug'”)

北战南征 提交于 2019-12-18 07:12:18
问题 I'm trying to follow the tangowithdjango book and must add a slug to update the category table. However I'm getting an error after trying to migrate the databases. http://www.tangowithdjango.com/book17/chapters/models_templates.html#creating-a-details-page I didn't provide a default value for the slug, so Django asked me to provide one and as the book instructed I type in ''. It's worth noticing that instead of using sqlite as in the original book I'm using mysql. models.py from django.db

How to migrate back from initial migration in Django 1.7?

China☆狼群 提交于 2019-12-17 17:53:00
问题 I created a new app with some models and now I noticed that some of the models are poorly thought out. As I haven't committed the code the sensible thing would be to migrate the database to last good state and redo the migration with better models. In this case the last good state is database where the new app doesn't exist. How can I migrate back from initial migration in Django 1.7? In South one could do: python manage.py migrate <app> zero Which would clear <app> from migration history and

django 1.7 migrate gets error “table already exists”

十年热恋 提交于 2019-12-17 10:19:03
问题 I am trying to apply a migration but am getting the error: django.db.utils.OperationalError: (1050, "Table 'customers_customer' already exists") I get this by issuing the following command: python manage.py migrate My customer table already exists, so what do I do to let the migration know this, not error out, and run my modification to my model? I ran this on my local environment with local database with no problem. It is when I pointed my database to production and ran migrate above that I

How to simplify migrations in Django 1.7?

╄→гoц情女王★ 提交于 2019-12-17 08:10:11
问题 There are already similar questions for South, but I have started my project with Django 1.7 and am not using South. During development a lot of migrations have been created, however the software is not yet delievered and there exists no database that must be migrated. Therefore I would like to reset the migrations as if my current model was the original one and recreate all databases. What is the recommended way to do that? EDIT: As of Django 1.8 there is a new command named squashmigrations

Django 1.7 - makemigrations not detecting changes

倾然丶 夕夏残阳落幕 提交于 2019-12-17 04:47:15
问题 As the title says, I can't seem to get migrations working. The app was originally under 1.6, so I understand that migrations won't be there initially, and indeed if I run python manage.py migrate I get: Operations to perform: Synchronize unmigrated apps: myapp Apply all migrations: admin, contenttypes, auth, sessions Synchronizing apps without migrations: Creating tables... Installing custom SQL... Installing indexes... Running migrations: No migrations to apply. If I make a change to any

Django 1.7 - makemigrations not detecting changes

折月煮酒 提交于 2019-12-17 04:47:15
问题 As the title says, I can't seem to get migrations working. The app was originally under 1.6, so I understand that migrations won't be there initially, and indeed if I run python manage.py migrate I get: Operations to perform: Synchronize unmigrated apps: myapp Apply all migrations: admin, contenttypes, auth, sessions Synchronizing apps without migrations: Creating tables... Installing custom SQL... Installing indexes... Running migrations: No migrations to apply. If I make a change to any