Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Saving Pillow image into model
I'm trying to save a Pillow Image into my model so that my model can take care of it. Here's how my model looks like: class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) avatar = models.ImageField(storage=OverwriteStorage(), upload_to=create_user_image_path, validators=[validate_avatar], default="default/avatars/avatar.jpg") def save(self, *args, **kwargs): super(Profile, self).save(*args, **kwargs) if self.avatar: image = Image.open(self.avatar) height, width = image.size if height == 200 and width == 200: image.close() return image = image.resize((200, 200), Image.ANTIALIAS) image.save(self.avatar.path) image.close() The model resizes the image and saves it accordingly. I'm using allauth to get the image of the signed up social account through an adapter, like so: avatar_url = sociallogin.account.get_avatar_url() avatar = create_avatar(avatar_url) profile.avatar = avatar profile.save() def create_avatar(avatar_url): response = requests.get(avatar_url) avatar = Image.open(BytesIO(response.content)) return avatar However, I get an error that says: AttributeError: 'JpegImageFile' object has no attribute '_committed' What am I doing wrong and how can I solve this? -
[Django]How to get slugs from different models in the urls i.e path(<slug:slug1>/<slug:slug2>/)?
Im trying to get a ur pattern that looks like this WWW.domain.com/slug1/slug2, where slug1 is the foreignkey to slug to. Think of it like library.com//. The author and book are two different models, both with their own slug. Is there a way where i can import the slug from author to the detailview of the book and then use it in the urls for the book detailview? This is how i imagine the path to look like: path('brands/<slug:brand_slug>/<slug:model_slug>', views.Brand_ModelsDetailView.as_view(), name='model-detail'), These are my models: class Brand(models.Model): brand_name = models.CharField( max_length=50, help_text='Enter the brand name',) slug = AutoSlugField(populate_from='brand_name', default = "slug_error", unique = True, always_update = True,) def get_absolute_url(self): """Returns the url to access a particular brand instance.""" return reverse('brand-detail', kwargs={'slug':self.slug}) def __str__(self): return self.brand_name class Brand_Models(models.Model): name = models.CharField(max_length=100) brand = models.ForeignKey('Brand', on_delete=models.SET_NULL, null=True) slug = AutoSlugField(populate_from='name', default = "slug_error_model", unique = True, always_update = True,) def get_absolute_url(self): """Returns the url to access a particular founder instance.""" return reverse('model-detail', kwargs={'slug':self.slug}) def __str__(self): return self.name My current attempt at the views: class Brand_ModelsDetailView(generic.DetailView): model = Brand_Models def get_queryset(self): qs = super(Brand_ModelsDetailView, self).get_queryset() return qs.filter( brand__slug=self.kwargs['brand_slug'], slug=self.kwargs['model_slug'] ) -
How to normalize the tables inside PostgreSQL database
I am building social network platform where users can register to their profile, fill it up and create events for the others. My problem is that I don't know what is the best approach to create tables. One guy told me I should NORMALIZE TABLES, meaning - he wants me to create separated tables for CITY, COUNTRY, UNIVERSITY, COMPANY and later connect those information with SQL Query which makes sense for me. If I will get 100 of students to sign up from the same University it makes sense for me to call only one University Name from University table instead of having rows and rows with university name filled in - it's data redundancy. However, the other guy told me, it's a bad practice, and I should put all information inside USER TABLE - firstName, lastName, profileIMG, universityName, CompanyName, cityName, CountryName and so on. He says MORE TABLES CREATES MORE PROBLEMS. From my part, I do understand the logic of the first guy but here is my another problem. As I mentioned, users fill up their RESUME in their profile and I want them to be allowed to add up to 3 universities they had been attending - bachelor … -
Does the compile function require any special configuration in Django?
I have a piece of code written out as a string that I would like to execute in Django. It works in the python shell interpreter, but not in Django. I am using python 3.6 and Django 2.1. Here is an example of the code: a = 'def solution():\n\timport random\n\treturn random.randint(1,10)' exec(compile(a, '', 'exec')) print(solution()) The above code in the interpreter will run as expected and print a random number between 1 and 10. In Django I get an error NameError: name 'solution' is not defined Thank you for any help -
'AnonymousUser' object has no attribute '_meta' during log in
I have an application in Django 1.11 and my problem is an error: 'AnonymousUser' object has no attribute '_meta' It appears at the moment of logging in. Previously a user was created using a custom sign up form (I am using email address instead of username). The user is created because I can log in to the admin panel at /admin/. Below is my login form: class LoginForm(AuthenticationForm): email = forms.CharField(label='Email', max_length=50, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Email', 'type': 'text', 'id': 'email'})) password = forms.CharField(label='Password', max_length=50, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Password', 'type': 'password', 'id': 'password'})) field_order = ['email', 'password'] def __init__(self, *args, **kwargs): super(LoginForm, self).__init__(*args, **kwargs) self.fields.pop('username') -
CreateView doesn't create anything in Django
I'm trying to do a CreateView that registers a series of details of a race in Django. views.py: class RegistrarDetalles(CreateView): model = DetallesCarrera second_model = Carrera form_class = RegistrarDetallesForm template_name = "carrera/detallesC.html" success_url = reverse_lazy('detalleC') def get_context_data(self, **kwargs): pk = self.kwargs.get('pk') context = super(RegistrarDetalles, self).get_context_data(**kwargs) context['carrera'] = Carrera.objects.get(id=pk) return context def get_success_url(self): return reverse_lazy('detalleC', kwargs={'pk': self.object.id_carr}) models.py: class DetallesCarrera(models.Model): id = models.CharField(max_length=20, primary_key=True) numero = models.IntegerField(blank=True, null=True) id_carr = models.ForeignKey(Carrera, on_delete=models.CASCADE) id_caba = models.ForeignKey(Caballo, on_delete=models.CASCADE) id_jock = models.ForeignKey(Jockey, on_delete=models.CASCADE) posicion = models.IntegerField(blank=True, null=True) forms.py: class RegistrarDetallesForm(forms.ModelForm): class Meta: model = DetallesCarrera fields = [ 'id', 'id_carr', 'id_caba', 'id_jock', ] widgets = { 'id': forms.TextInput(attrs={'class': 'form-control'}), 'id_carr': forms.Select(attrs={'class': 'form-control','id':'uno'}), 'id_caba': forms.Select(attrs={'class': 'form-control'}), 'id_jock': forms.Select(attrs={'class': 'form-control'}), } urls.py: path('listaCarr/<pk>/detalleC/agregar', login_required(views.RegistrarDetalles.as_view()), name='RegDetallCr'), The form within the html template: <form method="POST"> {% csrf_token %} <div class="input-group form-group"> <div class="input-group-prepend"> <span class="input-group-text"><i class="far fa-id-card"></i></span> </div> <!--<input type="text" class="form-control" placeholder="Id" name="id" onblur="this.value=(document.getElementById('uno').value+'-'+a"> --> {{ form.id }} {{ form.id.errors }} </div> <div class="input-group form-group"> <div class="input-group-prepend"> <span class="input-group-text"><i class="far fa-id-card"></i></span> </div> <input type="text" class="form-control" placeholder="Id Carrera" name="id_carr" value="{{ carrera.id }}" disabled> {{ form.id_carr.errores }} </div> <div class="input-group form-group"> <div class="input-group-prepend"> <span class="input-group-text"><i class="far fa-clock"></i></span> </div> {{ form.id_caba }} {{ form.id_caba.errors }} </div> <div class="input-group form-group"> <div class="input-group-prepend"> … -
Django CreateAPIView not showing creation Form
Working with the Django REST Framework i encountered quite a big problem. Here is what my problem looks like: CreateAPIView not showing Form What I currently have at serializers.py: class TaskCreateSerializer(serializers.ModelSerializer): # Create class Meta: model = Task fields = ('title') At views.py: class TaskCreateAPIView(CreateAPIView): # Create queryset = Task.objects.all() serializer_class = TaskCreateSerializer And at urls.py: path('tasks/create/', TaskCreateAPIView.as_view(), name='create_tasks') So basically i can't create any task objects What I tried: class TaskCreateSerializer(serializers.ModelSerializer): # Create title = serializers.CharField() # New line (does not work) class Meta: model = Task fields = ('title') Thanks in advance! -
Reverse for 'ipads_by_school' with keyword arguments '{'school_id': ''}' not found. 1 pattern(s) tried: ['(?P<school_id>[^/]+)$'] - Django
I'm relatively new to Django/Python and was wondering if you guys can assist me with my problem. I've been trying to figure it out since last night but no luck. Thanks in advance! The line of code from my index.html that generates the NoReverseMatch error in the title is this. <a href="{% url 'ipads_by_school' school_id=LES %}" class="btn btn-outline-primary m-1" >LES</a> This is my urls.py from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), path('<str:school_id>', views.ipads_by_school, name='ipads_by_school') ] This is my views.py from django.shortcuts import render from django.http import HttpResponse from .models import Ipad def index(request): return render(request, 'ipads/index.html') def ipads_by_school(request, school_id): school_ipads = Ipad.objects.filter(school_id__icontains=school_id) context = { 'school_ipads': school_ipads } return render(request, 'ipads/ipads_by_school.html', context) -
Convert function view to class based view
I am trying to write a a Function-based View (FBV) as a Class-based View (CBV), specifically a CreateView. So far I have been able to write the FBV as a generic View but not as a CreateView. How would I go about doing this? FBV def register(request): registered = False if request.method == 'POST': user_form = UserCreationForm(data=request.POST) if user_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() registered = True else: print(user_form.errors) else: user_form = UserCreationForm() return render(request,'accounts/registration.html', {'user_form':user_form, 'registered':registered}) Converted View class RegisterView(View): def get(self, request): registered = False user_form = UserCreationForm() return render(request,'accounts/registration.html', {'user_form':user_form, 'registered':registered}) def post(self, request): registered = False user_form = UserCreationForm(data=request.POST) if user_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() registered = True else: print(user_form.errors) return render(request,'accounts/registration.html', {'user_form':user_form, 'registered':registered}) -
Django get the number of objects in each day of a month
I'm trying to get the number of objects in each day of a month, using the following in view: startIng = datetime.datetime(2019,1,1) endIng = datetime.datetime(2019,2,1) aDayDelta = timedelta(days=1) totalDays = (endIng - startIng).days days = [startIng + k*aDayDelta for k in range(totalDays)] for mydays in days: datem = Daily_movements.objects.filter(mov_date__startswith=(mydays)) ... but I get nothing, trying i e: datem = Daily_movements.objects.filter(mov_date__startswith=datetime.datetime(2019, 2, 9, 0, 0)) I get the perfect result for this given date TIA for any help -
Django Rest Framework Getting serializer from model
I am looking for a way to get a serializer from a model class. This is so that I can easily serialize model data, without having to harcode the serializer name and I figured something like this would do (simplified): import serializers class Model: serializer = serializers.Serializer import models class Serializer: model = models.Model m = Model.objects.get(pk=1) print(m.serializer(m).data) But this raises a AttributeErrordue to import errors. Am I going about this the completely wrong way? Is there an easier way of doing this, or is there a way to make this work somewhat like the above? Thanks in advance. -
Customize a ModelAdmin and TabularInline with dynamic behavior
I'm developping a WebApp with Django for the Design Office of my firm. We're designing and building Actuators. So in a firt time, the "admin" users need to enter data through the CRUD systems of Django. For most of the models, it's enough. But for some table relationship I need to design a custom admin-form with dynamic content. Please consider the following models: # Functional Block class Block(models.Model): block_id = AutoField() name = CharField() # Metric System (g, kg, daN...) class Unit(models.Model): unit_id = AutoField() name = CharField() abbrebiation = CharField() # Block Performance class Performance(models.Model): performance_id = AutoField() name = CharField() code = CharField() type = PositiveSmallInterger() unit = ForeignKey() # Instance of a Block class BlockInstance(models.Model): instance_id = AutoField() block = ForeignKey(to='Block) name = CharField() # Performance Value for a specific BlockInstance and a given Performance class PerformanceValue(models.Model): performance_value_id = AutoField() block_instance = ForeignKey(to='BlockInstance') performance = ForeignKey(to='Performance') doc = CharField() tolerance = FloatField() value = FloatField() That's basically the most important (simplified) classes. The trick is to capture the BlockInstance model. The ideal scenario would be: Capturing the related block of the BlockInstance modekl with a dropdown list (OK). According the block selected, I need a dynamic behavior: … -
How to make django distinguish between "c" and "cpp" that belong to my model field "tag"?
I have a model that looks like the following in my db... Column 1(Project=CharField, see models.py below) Deathstar, BB8, Halo Ring, Spaceship Column 2(Tag=CharField, see models.py below) c, cpp, cpp, lots of stuff I have the following requirements I have to achieve. 1 Must sort 'Tag' column from most occured to least occured. 2 Must remove duplicates ( such as 'cpp' in this example) I can get something going with the following but it's saying there's more 'c' tags than 'cpp tags?!?! NotesAppModel.objects.annotate(Count('tag')) <QuerySet [<NotesAppModel: c>, <NotesAppModel: cpp>, <NotesAppModel: cpp>, <NotesAppModel: lots of stuff>]> I also tried the following but it just lists the same thing. NotesAppModel.objects.annotate(c=Count('tag')).order_by('-c') I also need to remove duplicates. I know that if this was just a simple list of strings I would use a simple function as follows. But this doesn't work with django queries. What's the django way? def remove_dups(somelist): seen = set() return [x for x in somelist if not (x in seen or seen.add(x))] models.py class NotesAppModel(models.Model): project = models.CharField(max_length=100, blank=True) tag = models.CharField(max_length=100, blank=True) def __str__(self): return self.tag -
ValueError while rendering form in template
Ok, this is the 3rd day searching a solution to this error, so I'm just going to ask here. I am aware that there are other questions similar to mine, but apparently all the others have another cause. This is my setup: Django Version: 2.1.5 Python Version: 3.7.1 My error is this: ValueError at /testsel too many values to unpack (expected 2) This is my traceback: Traceback (most recent call last): File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/core/handlers/base.py", line 126, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/core/handlers/base.py", line 124, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/ricardo/Projects/Organizacional/organizacional/home/views.py", line 36, in testsel return render(request,'home/testsel.html',{ 'form':form }) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/shortcuts.py", line 36, in render content = loader.render_to_string(template_name, context, request, using=using) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/loader.py", line 62, in render_to_string return template.render(context, request) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render return self.template.render(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/base.py", line 171, in render return self._render(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/base.py", line 163, in _render return self.nodelist.render(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/base.py", line 937, in render bit = node.render_annotated(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated return self.render(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/base.py", line 163, in _render return self.nodelist.render(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/base.py", line 937, in render bit = node.render_annotated(context) File "/home/ricardo/anaconda3/lib/python3.7/site-packages/django/template/base.py", … -
General API Advice - Apollo or Relay Modern for GraphQL?
At a crossroads in my project where I need to decide which way to venture forward with my front end API. I am using a Django-GraphQL back end and so far a React front end. I chose React because I am new to this style of app development and React appears to be the simplest(read, easiest for a me to understand) to implement of the popular ones I can find. I know would like to use either Apollo or Relay Modern to serve the GraphQl data to the front end app. Relay Modern seems like it would make the most sense with it's fragmenting options and some built in features in graphene-django already supporting it. With my limited time doing this as more of a hobby than anything, I need to invest my time spent learning wisely. Before I dive down the rabbit hole of either side, I'd like some advice/opinions from folks who have used either/or/both. If this is the wrong forum to post this in my apologies. -
My form doesn't show up in the template {{ form }} doesn't do anything
My form which I created in forms.py doesn't show up in the template. I created context in views.py and passed it through {{ u_form }} but it still doesn't work. my forms.py UserCreationModelForm is working fine. But other two are not working. from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth import get_user_model from .models import Profile User = get_user_model() class UserCreationModelForm(UserCreationForm): class Meta: model = User fields = ['username', 'first_name', 'last_name', 'country', 'city', 'email', 'password1', 'password2'] class UserUpdateForm(forms.ModelForm): username = forms.CharField() email = forms.EmailField() class Meta: model = User fields = ['username', 'email'] class ProfileUpdateForm(forms.ModelForm): class Meta: model = Profile fields = ['image'] my views.py from django.shortcuts import render from django.urls import reverse_lazy from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import CreateView, DetailView from .forms import UserCreationModelForm, UserUpdateForm, ProfileUpdateForm from .models import User class UserRegistrationView(CreateView): form_class = UserCreationModelForm success_url = reverse_lazy('login') template_name = 'users/registration.html' class CabinetView(LoginRequiredMixin, DetailView): model = User def get_object(self): return self.request.user def home(request): return render(request, 'registration/home.html') def profile(request): u_form = UserUpdateForm() p_form = ProfileUpdateForm() context = { 'u_form': u_form, 'p_form': p_form } return render(request, 'registration/user_detail.html', context) my main urls.py from django.contrib import admin from django.urls import path, include from django.conf import settings … -
Django Media Directory HTTP 404 for Uploaded Images
My project structure is: - api/ - urls.py ... - avatars/ - 16701016.jpg - 16701019.jpg ... - frontend/ - static/ - frontend/ - templates/ - urls.py ... - website/ - settings.py - urls.py ... Part of the settings.py file: STATIC_URL = '/static/' MEDIA_ROOT = os.path.abspath('../avatars/') MEDIA_URL = '/avatars/' The contents of /website/urls.py : urlpatterns = [ path('admin/', admin.site.urls), path('api/', include('api.urls')), re_path(r'^.*', include('frontend.urls')) ] Now I need to access the /avatars/*.jpg files via URL like http://127.0.0.1:8000/avatars/*.jpg But It is not working (Just 404). What is the problem? -
Django - Weasyprint, Can load Image from media?
I am using Weasyprint for Django 2.1, I can load the static image to PDF like that <img class="facep src="{% static 'images/face.jpg' %}" alt=""> but when I tried to use URL to load from media <img src="{{ user.picresume.url }}" alt=""> it doesn't work. Firstly, I tested in HTML the result that ok. Help plz. -
How to combine several models in one forms in django?
I am having 4 models in Django: Products, Orders,lines_Orders, and Invoice. Based on these models, I would like to create a form that will generate the invoice given an order number. But I don't know how the views could be and how to combine these models into one form. class Product(models.Model): # productId=models.IntegerField(auto_created=True) customerId=models.ForeignKey(Customers, on_delete=models.CASCADE) productNumber=models.CharField(max_length=15, unique=True) productDescription=models.CharField(max_length=25) unitPrice = models.FloatField() storageQuantity=models.FloatField() class Orders(models.Model): orderID=models.AutoField(primary_key=True) customerID = models.ForeignKey(Customers, on_delete=models.CASCADE) oderDate = models.DateTimeField() class Order_lines(models.Model): oderID = models.ForeignKey(Orders, on_delete=models.CASCADE) productNumber=models.ForeignKey(Product, on_delete=models.CASCADE) quantity = models.FloatField(default=0.00) class Invoice(models.Model): dateInvoice=models.DateField() receiveDate=models.DateField() OrderNumber=models.ForeignKey(Orders, on_delete=models.CASCADE) Please assist -
Custom Image Widget in with Django
I'm trying to build a custom Image Widget in the following manner: class ImageWidget(forms.widgets.Widget): template_name = 'widgets/picture.html' def get_context(self, name, value, attrs=None): return {'widget': { 'name': name, 'value': value, }} def render(self, name, value, attrs=None): context = self.get_context(name, value, attrs) template = loader.get_template(self.template_name).render(context) return mark_safe(template) The problem is that value contains the file's relative path without including the MEDIA prefix (as a form field would). I don't know how to append or how to access that field in Django 1.8 Here's the picture.html file contents just in case: Currently: <img src={{ widget.value }}> <br>Change: <input id="id_profile_image" name="profile_image" type="file"> Rendered HTML: <p> <label for="id_profile_image">Profile image:</label> Currently: <img src="profile_images/CSC_00111.jpeg"> <br>Change: <input id="id_profile_image" name="profile_image" type="file"> </p> I need the src attribute value to be /media/profile_images/CSC_00111.jpeg. -
whay do i need web api to link between django and other js framworks
hello everybody ,it's my firts question in this forums :D so my question is whay do i need web api to link between django and other js framworks for example django with angular and is it necessary to built an web api like (rest api) to link between back end and front end and thanx a lot -
Receive Server Error 500 on Heroku with Django for specific pages with images
For the last couple of hours I've been searching through Stack Overflow for a fix, but most posts about the Server Error 500 could not provide a fix for me. Django can't find static images and returns a 500. The images are in static/css/images. for example, I try to get https://monkeyparliament.herokuapp.com/about/. Logs return: 2019-02-10T17:09:33.362724+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'css\images\donate.png' 2019-02-10T17:09:33.363611+00:00 app[web.1]: 10.31.121.50 - - [10/Feb/2019:17:09:33 +0000] "GET /about/ HTTP/1.1" 500 27 "https://monkeyparliament.herokuapp.com/music/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36" But when I https://monkeyparliament.herokuapp.com/music/, it seems it can find css/js/fonts in the static folder. Feel free to inspect the page source. Why are my images not found? Procfile web: gunicorn websitemp.wsgi:application --log-file - Requirements dj-database-url==0.5.0 Django==2.0.10 gunicorn==19.9.0 psycopg2==2.7.7 pytz==2018.9 whitenoise==4.1.2 dj-database-url==0.5.0 Django==2.0.10 django-heroku==0.3.1 gunicorn==19.9.0 pytz==2018.9 whitenoise==4.1.2 Structure website is the app, websitemp is the project -
Is there a way to perform validation on related Orderable in InlinePanel in WagtailCMS?
I am using Wagtail CMS and I need some validation for my Orderable model. Like, ensuring that at most one of the fields is filled. Normally, I would override the clean(self) method for the Django model, but calling super().clean() inside that method returns None. I am still able to access the fields with self.field_name and raising ValidationError still prevents the model from creation, but it doesn't show which fields caused the error for the model in the admin interface. I have tried overriding the clean method, that stops the model from being committed but doesn't show errors on the interface I have tried following this part of the guide, but the clean method there isn't even called for the Orderable. This is the example of my clean method def clean(self): super().clean() has_image = self.image is not None has_video = self.video_url is not None if has_image == has_video: raise ValidationError('Either a video or an image must be set') I expect validation errors to show up in the admin interface. -
Django HTTP requests fail on Heroku but not locally
I have this Django project and there's a function in it that executes a for loop with a HTTP request for every iteration. Locally everything's fine but on Heroku if the iterations are more than 2 or 3 it fails. I'm wondering if Heroku blocks too many outgoing requests and if there's a workaround. Thanks! -
How to correct this error “django.db.migrations.exceptions.MigrationSchemaMissing:”
How to correct this error "django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1"))" I can use it on another computer, and this is caused by creating a database using the ‘python manage.py migrate’ statement.