Error while doing migrations for a new table

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error while doing migrations for a new table

Mohamed Ghariani
Hello,
I tried to apply migrations for a new model. The model was used in a form used in the admin so the migrations failed.

He is a sample code i wrote which gave me the same errors.


models.py
from django.db import models

class App(models.Model):
    name = models.CharField(max_length=50)

forms.py
from django import forms

from app.models import App


class AppForm(forms.ModelForm):
    name = ((elem.id, elem.name ) for elem in App.objects.all())

admin.py
from django.contrib import admin

from app.forms import AppForm
from app.models import App


class AppAdmin(admin.ModelAdmin):
    search_fields = ('id', 'name')
    form = AppForm
    list_display = ('id', 'name')

admin.site.register(App, AppAdmin)


After running  ./manage.py makemigrations i got this error

django.db.utils.OperationalError: no such table: app_app

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/1e16f8da-3875-434c-b669-64d3febfd02e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Error while doing migrations for a new table

Mohamed Ghariani
I created a bug on code.djangoproject.com

On Tuesday, 18 April 2017 13:12:05 UTC+1, Mohamed Ghariani wrote:
Hello,
I tried to apply migrations for a new model. The model was used in a form used in the admin so the migrations failed.

He is a sample code i wrote which gave me the same errors.


models.py
from django.db import models

class App(models.Model):
    name = models.CharField(max_length=50)

forms.py
from django import forms

from app.models import App


class AppForm(forms.ModelForm):
    name = ((<a href="http://elem.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Felem.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHFMOIZSj_UPy25ts9PTxlenvNSuQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Felem.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHFMOIZSj_UPy25ts9PTxlenvNSuQ&#39;;return true;">elem.id, <a href="http://elem.name" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Felem.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH-Qntu5hHcHUtk93vfgw6Rwms2Aw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Felem.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH-Qntu5hHcHUtk93vfgw6Rwms2Aw&#39;;return true;">elem.name ) for elem in App.objects.all())

admin.py
from django.contrib import admin

from app.forms import AppForm
from app.models import App


class AppAdmin(admin.ModelAdmin):
    search_fields = ('id', 'name')
    form = AppForm
    list_display = ('id', 'name')

admin.site.register(App, AppAdmin)


After running  ./manage.py makemigrations i got this error

django.db.utils.OperationalError: no such table: app_app

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/8ad0a967-40c2-443a-852b-1f199dd04192%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Error while doing migrations for a new table

Ramiro Morales-2
In reply to this post by Mohamed Ghariani
On Tue, Apr 18, 2017 at 6:52 AM, Mohamed Ghariani <[hidden email]> wrote:
Hello,
I tried to apply migrations for a new model. The model was used in a form used in the admin so the migrations failed.

Please don't post questions like this (about using Django) to this list (its topic is about developing Django). Use the django-users or the #django IRC channel list for that. 


Regards,

--
Ramiro Morales
@ramiromorales

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAO7PdF-jOx9yzbmvrXYEPYDQ2cujTM0s9JaYms1JSadq1z1aeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.