Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How can I allow spaces in a Django username regex?
I am trying to allow spaces to be accepted into the username field of the default django.contrib.auth.models User, other people have asked directly or similar questions before: Here, Here, and Here. I have tried to implement these suggestions however I cannot seem to find a good example of how to get this to work. From what I understand I need to change the regex in the username field validator, to do this I can override the UserCreationForm from contrib.auth.forms to implement a different field for username and provide my own validation. (as suggested in this answer). How specifically do I do this? for reference, this is currently what I am using as a signup form: class SignUpForm(forms.ModelForm): """ This form class is for creating a player """ username = forms.CharField(label='Gamertag', max_length=16, widget=forms.TextInput(attrs={'placeholder': 'Gamertag', 'class': 'form-input'})) email = forms.EmailField(label='email', widget=forms.TextInput(attrs={'placeholder': 'Email', 'class': 'form-input', 'type':'email'})) password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password', 'class': 'form-input'})) class Meta: model = User fields = ['username', 'email', 'password'] widgets = { 'password': forms.PasswordInput(), } def clean_email(self): email = self.cleaned_data.get('email') username = self.cleaned_data.get('username') if email and User.objects.filter(email=email).exclude(username=username).count(): raise forms.ValidationError(u'A user with that email already exists.') return email -
How to set up a celery delayed task from django view using rabbitmq queue
I have to create a task in celery using the rabbitmq in a django project. Basically the project is need to send push notification. There is two option for the admin person to send the push notification 1) Send now: When they click the push notification send instantly 2) Send later: In this case admin set a date and time and i need to send the push notification on that date and time only. My tasks.py is from celery.task import task from celery.task.schedules import crontab from datetime import timedelta from celery.decorators import periodic_task #@task @periodic_task(run_every=(crontab(minute='*/1'))) def multiply(x, y): multiplication = x * y print('print me here') return multiplication celery.py is from __future__ import absolute_import import os from celery import Celery from django.conf import settings # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') app = Celery('mazda') # Using a string here means the worker will not have to # pickle the object when using Windows. app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) #s@app.task(bind=True) def debug_task(self): print('Request: {0!r}'.format(self.request)) and i am caling the task from the view like result = multiply.delay(3,5) When i am running the command celery -A {myappname} worker -l info i can see that the task is created … -
Django: A serious issue or is there a way around?
I am stuck with a problem from a week and found no solution either in documentation or stackoverflow. The issue is annotation over multiple models. If we annotate over multiple models the result is not correct. A ticket raised on this is still open, so we cannot annotate over multiple models. Done. Now i had a different approach to annotate as follow: inventory_purchase=productmodel.objects.filter(company=request.user.company.entity) purchase=inventory_purchase.annotate(purchase=Sum('exproduct__Quantity')) sale = inventory_purchase.annotate(sale=Sum('serviceproduct__Quantity')) purchase_return = inventory_purchase.annotate(purchase_return=Sum('dnproduct__Quantity')) sales_return = inventory_purchase.annotate(sales_return=Sum('cnproduct__Quantity')) What i did is, annotating each model separately. Now i have correct data as required. However this has created an issue in template rendering. My template is: {% for invoices in inventory_movement %} <tr> <td>{{ invoices.product_name }}</td> <td>+{{ invoices.purchase|default:0 }} </td> <td>-{{ invoices.sale|default:0 }}</td> <td>+{{ invoices.sales_return|default:0 }}</td> <td>-{{ invoices.purchase_return|default:0 }}</td> <td>-</td> </tr> {% endfor %} Result in html is: Each product is displayed multiple times. However i want to show product only once and their respective value in column next to them. Is there any solution? -
Django nested Inline formsets outside admin
So I am making a a website for selling cars. And I can't make this work This is my models.py: class Car(models.Model): owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) Titlu = models.CharField(max_length=20) Marca = models.ForeignKey(aBrand, on_delete=models.CASCADE) Model = models.ForeignKey(bModel, on_delete=models.CASCADE) Versiune = models.ForeignKey(cBatch, on_delete=models.CASCADE) Caroserie = models.CharField(max_length=50, choices=alege_caroseria) Combustibil = models.CharField(max_length=50, choices=alege_combustibil) An_fabricatie = models.CharField(max_length=50, choices=((str(x), x) for x in range(1980,2018))) Rulaj = models.PositiveIntegerField() Capacitate_motor = models.PositiveIntegerField() # Optionale Stare = models.CharField(max_length=50, choices=alege_stare, blank=True) Putere = models.PositiveIntegerField(blank=True) Cutie_de_viteze = models.CharField(max_length=50, choices=alege_cutie, blank=True) Transmisie = models.CharField(max_length=50, choices=alege_transmisie, blank=True) Volan = models.CharField(max_length=50, choices=alege_volan, blank=True) Norma_de_poluare = models.CharField(max_length=50, choices=alege_norma, blank=True) Timbru_de_mediu_platit = models.BooleanField() Inmatriculat = models.BooleanField() Fara_accident = models.BooleanField() Avariat = models.BooleanField() Primul_proprietar = models.BooleanField() Detalii = models.TextField(blank=True) def __str__(self): return self.owner.email +" - "+ self.Titlu class CarImage(models.Model): Car = models.ForeignKey(Car, on_delete=models.CASCADE) car_image = models.ImageField( upload_to='C:/Users/Robert/Desktop/ve/carsbook/media/sales/carimages', blank=True ) def __str__(self): return self.Car.owner.email +" - "+ self.Car.Titlu + " - image" This is my forms.py: class CarForm(forms.ModelForm): class Meta: model = Car exclude = ("owner",) CarImagesFormset = modelformset_factory(CarImage, exclude=("Car",), extra=8) and this is my view: def adauga(request): if request.method == "POST": form = CarForm(request.POST) formset = CarImagesFormset(request.POST) if form.is_valid() and formset.is_valid(): nCar = form.save(commit=False) images = formset.save(commit=False) nCar.owner = request.user nCar.save() for image in images: image.Car = … -
What is the proper workflow for major changes in git?
I am currently working on a major overhaul to an email system within a small Django project. As it stands, I will need to make huge modifications to almost every aspect of the system and I think it would be easier instead if I started from scratch while deleting most of the old files. 1) Should I comment out old code or overwrite it? 2) Should I delete old files or should I rename it to something unused? 3) What is common practice when it comes to major overhauls in git? -
Update html page after reading input from a server in Django
I was working on a Django App that has client-server communication.User provides a input to the client and the server displays the response.This response has to be rendered on a html page and the backend should be done in Django.Any ideas/suggestions ? -
Django app rest api exposed
Given the source code of a django app. Are the a library or a way to get a list of all callable api from that application. That's it a list of url someone could requst for a given rosource. -
Django - Can't load custom filter in templates
I want to show delta time as 'x days ago'. I tried Django's timesince filter, but it returns 'x days, x minutes'. I want to show only days. I tried humanize's naturaltime, but I guess its only for DateTimeField. I'm using DateField. I have a custom filter like this (app_filters.py); from django import template from datetime import date register = template.Library() @register.filter(name='days_since') def days_since(value): delta = value - date.today() if delta.days == 0: return 'Today' elif delta.days < 1: return '{} days ago'.format(abs(delta.days)) elif delta.days == 1: return 'Tomorrow' elif delta.days > 1: return 'In {} days'.format(delta.days) This is application folder; app/ models.py views.py ... templatetags/ __init__.py app_filters.py I added the 'app' to INSTALLED_APPS in settings.py I'm trying to use this filter in templates like this; {% extends 'app/base.html' %} {% load app_filters %} {{ entry.date_updated | days_since }} Then I get the error: 'app_filters' is not a registered tag library. Where is my mistake? -
Custom User profile for Django user
Django - Models extension Vs User Profile I want add some custom fields like following 1. ssn 2. is_manager 3. manager I have 2 choices - Extend AbstractUserModel OR Create User profile based on signal and have OnetoOne field. Which one is better, future proof, DB migration friendly and maintainable ? -
Jquery make tab active from another page
So i have a button on another page, and when a user clicks on it, it should redirect to another page and add the active class to the tab that the window.location.hash takes.. but it doesn't work. It just redirects to that page. What am i doing wrong? HTML: <div role="tabpanel" class="tab-pane" id="messages"> <div class="embed-responsive embed-responsive-16by9" style="height: 500px;"> <iframe class="embed-responsive-item" src="{% url 'userena_umessages_list' %}"></iframe> </div> JQUERY: <script> $("#butonmesaj").on('click', function(){ window.location.href = "{% url 'userena_profile_detail' user%}#messages"; var id = window.location.hash; $(id).addClass('active'); }); -
Values list vs Iterating
I have to extract value of id field from each model instance in queryset. What is more efficient - iterating through queryset with use of list comprehension or values list method with flat argument setted to true and then converted to list? -
Django calculation with many TimeFields
I'm working on a webapp, which should calculate with several TimeField objects. No I stuck at one point. How is it possible to add different TimeFields together and subtract a DecimalField from the outcome TimeField. I've tried different ways. For example to convert the TimeFields into a str-object (which doesn't work either...). Does anyone of you got an idea how I can handle that issue? A small hint would be a pleasure for me. Thanks! -
How to combine Django and Node.Js as backend?
I am Python/Django developer, But, there are features in Node.Js which is very important for me to use. Is it possible to be done on a single server? or do i have to use them separately to have no bugs? Note: I have almost no knowledge about Node.Js just need it for a single task which i can understand, is it still required? So for example, there is a Node.Js server which does specific task, It get's the information and sends to Django using to specific port AES 128 encrypted UDP socket, Python server's socket is bound to specific port, and will listen to it, when information is received, It will fill up specific model and continue listening to port. Example in code: Python ( Using socket library ): import socket from multiprocessing import process import sys IPv4 = socket.gethostbyname(socket.gethostname()) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind(8000) class SendAndReceive(): def Listen(self): while True: time.sleep(2) self.data, self.addr = s.recvfrom(1024) if sys.getsizeof(data) > 23: self.model_will_be_filled = True self.Send() def Send(self): if self.model_will_be_filled = True: s.sendto(self.data, ("NodeJs server ip here", 8000)) if __name__ == '__main__': Main = SendAndReceive() Listening = Process(target=Main.Listen()) Listening.start() Is there any way doing it on one server? Or do i need … -
Django Annotation, Django doing a double outer left join
I am in a bit of a problem. I have a model called Customer I also have two other models called Invoice and Payment Now, Invoice is FK to Customer and Payment is FK to Invoice I want a query where I find out how much of balance is due from customer. My Invoice model has, among others the following fields: invoice_id = models.CharField(blank=True, max_length=12) total=models.DecimalField(max_digits=12, decimal_places=2) grand_discount=models.DecimalField(max_digits=10, decimal_places=2) customer=models.ForeignKey(Customer, related_name='salesInvoice_sales_master_customer') My payment model is as follows: invoice_no=models.ForeignKey(salesInvoice, related_name='salesPayment_sales_sales_salesInvoice') amount_paid=models.DecimalField(max_digits=12, decimal_places=2) collected_on=models.DateTimeField(null=True) Now, I am calling the on the annotate on Customer object as follows: customers = Customer.objects.for_tenant(request.user.tenant).annotate(total= Sum('salesInvoice_sales_master_customer__total')\ -Sum('salesInvoice_sales_master_customer__grand_discount')\ -Sum('salesInvoice_sales_master_customer__salesPayment_sales_sales_salesInvoice__amount_paid')) Everything is working file till the last line (I checked by removing the last SUM on sales payment. i.e. the payment model). As this query is put, Django does a "double" LEFT OUTER JOIN on invoice model, as a result total and grand_discount is getting doubled. For example is total is 1000, grand_discount is 100, amount_paid is 500, the query shows total is 2000, grand_discount as 200 and amount_paid as 500 Is there any way this could be solved, other than RAW SQL (my DB is postgresql)? -
angularjs django integration
I can load the page with items if I include the angularjs declaration inside script tag in index.html. Otherwise, not working. app/templates/app/index.html {% load staticfiles %} <html> <head> <link rel="stylesheet" type="text/css" href="{% static "components/bootstrap/dist/css/bootstrap.css" %}"> <script type="text/javascript" src="{% static "javascript/app.js"%}"></script> <script type="text/javascript" src="{% static "components/angular/angular.min.js"%}"></script> <script type="text/javascript" src="{% static "components/angular-route/angular-route.js"%}"></script> </head> <body ng-app="store"> <div ng-controller="ItemController"> {% verbatim %} <div class="panel" ng-repeat="item in items"> <p>{{ item.id }}</p> </div> {% endverbatim %} </div> </body> </html> app/static/javascript/app.js angular.module('store', ['ngRoute']) .controller('ItemController', function($scope, $http) { $http.get('/api/items').success(function(data){ $scope.items = data; }); }); -
How to edit an object of Super Class via an object in the SubClass
basically i have two class (Customer, EmpClass), and i tried many times to find a way in witch one employee (object of EmpClass) can perform the functionalities that are available to the Customer Class's object,ex Deposit,withdraw and so on and off course on behalf of one customer, and later on time of enquiry i can tell which employee have perform what operations for a particular customer and like that . and thanks in advance :) my models : class Customer(object): ''' this class contains all Customer related Information and Functions''' BankName = "SBH" def __init__(self, Cname,CacountNumber, Cbalance): self.Cname = Cname self.CacountNumber = CacountNumber self.Cbalance = Cbalance def Deposit(self, DepositAmount): self.Cbalance = self.Cbalance + DeposetAmount def WithDraw(self, WithDrawAmount): if WithDrawAmount > self.Cbalance: raise InSuffetiantFunds self.Cbalance = self.Cbalance - WithDrawAmount def C_Info(self): print "Bank Name :", Customer.BankName print "Customer Name :", self.Cname print "Customer Acount Number : ", self.CacountNumber print "Customer Balance :", self.Cbalance class EmpClass(Customer): ''' this class contains all Employee related Information and Functions''' BankName = "SBH" def __init__(self, EmpName,EmpId,): self.EmpName = EmpName self.EmpId = EmpId Customer.__init__(self, Cname,CacountNumber, Cbalance) def E_Info(self): print "Bank Name :", EmpClass.BankName print "Employee Name:", self.EmpName print "Employee Id : ", self.EmpId -
Remove label from SIgnUp form
I'm trying to extend the default form and remove the labels for Django-allauth signup form. Most labels are removed successfully, but I'm not able to remove the label for the email field. from django import forms from .models import Profile class SignupForm(forms.ModelForm): gender = forms.CharField(max_length=1, label='Gender') first_name = forms.CharField(max_length=50, label='First Name') last_name = forms.CharField(max_length=50, label='Last Name') birthday = forms.CharField(max_length=50, label='Birthday') location = forms.CharField(max_length=50, label='Location') def __init__(self, *args, **kwargs): super(SignupForm, self).__init__(*args, **kwargs) self.fields['first_name'].widget.attrs.update({'autofocus': 'autofocus'}) #remove labels for fields for field_name in self.fields: field = self.fields.get(field_name) field.widget.attrs['placeholder'] = field.label field.label ='' class Meta: model = Profile fields = ('first_name', 'last_name', 'gender', 'birthday', 'location') def signup(self, request, user): # Save your user user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] user.save() # Save your profile profile = Profile() profile.user = user profile.email = self.cleaned_data['email'] profile.birthday = self.cleaned_data['birthday'] profile.location = self.cleaned_data['location'] profile.gender = self.cleaned_data['gender'] profile.save() Rendered SignUp form -
Python Beginner-- what next?
Hi im new to Python and just finished taking a Python Bootcamp course on Udemy. I did a little PHP coding in the past, however other than that dont really have much experience with coding at all. My goal is to eventually be so good at Python that i'd be able to get a job easily (i have a few friends who are like that). I was wondering if people here could give me advice on what i should learn next If i eventually want to be use python for data science/web development/mobile development/making robots. Here were my ideas: 1) Go through the documentation on the python website and read all the tutorials and memorize/read the builtin libraries. 2) Try to learn a few frameworks such as Django/Flask/Twisted/SQLalchemy 3) Learn linux/bash/shell/git <-- not sure how helpful this would be but from watching videos it seems that this would really help in becoming a python software engineer/fullstack developer? am i correct about this? is it necessary? 4) What about PostgreSQL? is that relevant at all with python? 5) I am going to also enroll in a few more courses on Udemy, if anyone can recommend other great sites for crash courses … -
In Django, how can I process a downloaded file for secondary validation before saving?
I am trying to create a better validation system for my website which accepts .stl (3dprinter) files. It currently works as shown below in my models.py with just validating the file extension. What I need is to run the file path through a script I made called "slicecheck.py" that receives a file path and outputs dimensions and other file variables. My script calls to a local program on my server, and if the object doesn't pass this test I would like it to not allow the form to save. I'm not sure how I could validate after file download. All I need is to specify the file path then save the given additional model forms or flash an error message and reject the save. models.py def user_directory_path(instance, filename): # file will be uploaded to MEDIA_ROOT/user_<id>/<filename> return os.path.join('uploads', str(instance.Title), filename) def validate_file_extension(value): ext = os.path.splitext(value.name)[1] valid_extensions = ['.stl','.STL'] if not ext in valid_extensions: raise ValidationError(u'Please upload a .stl file type only') class UploadedFiles(models.Model): user = models.ForeignKey( settings.AUTH_USER_MODEL, blank=True, null=True) STL = models.FileField(_('STL Upload'), upload_to=user_directory_path, validators=[validate_file_extension]) Photo = models.ImageField(_('Photo'), upload_to=user_directory_path, validators=[validate_img_extension]) I have seen references to TemporaryFileUploadHandlers but I haven't been able to get it to work. I'm not sure if validators … -
Nginx proxy_pass to unix socket takes too long
I have a website where the frontend is written in angular and I'm trying to get it to by, SEO friendly, and make it visible and crawl-able by Facebook and other sites, at the lowest cost possible, so I've edited nginx to detect the user-agent and if it's a crawler, it should hit the unix socket where django is located, and django will serve an html file with needed meta tags, the porblem is that the crawler part is too slow, sometimes it takes more than a minute to respond, I'm not sure why. here's my nginx what my nginx file look like. server { listen 80; server_name bteekh.com; proxy_set_header X-Forwarded-Proto $scheme; server_name_in_redirect off; root /home/camara/shoftda-angular2/dist; location / { proxy_buffering off; proxy_request_buffering off; proxy_redirect off; proxy_connect_timeout 3000s; proxy_read_timeout 8000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; set $memcached_key "$uri?$args"; memcached_pass 127.0.0.1:11211; error_page 404 502 504 = @fallback; if ($http_user_agent ~* "baiduspider|twitterbot|whatsapp|facebookexternalhit|MetaURI API|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|Googlebot|slackbot|vkShare|W3C_Validator") { proxy_pass http://unix:/home/camara/python/shoftda.sock; } if ($http_user_agent ~* "Twitterbot") { proxy_pass http://unix:/home/camara/python/shoftda.sock; } try_files $uri$args $uri$args/ $uri.html /index.html =404; } location @fallback { try_files $uri$args $uri$args/ $uri.html /index.html =404; } location /media/ { alias /home/camara/python/media/; } location /static/ { alias /home/camara/python/assets/; } … -
Integrating Bootstrap notify in Django templates
Am trying to have django messages i.e login successful, you have been signed out. displayed using bootstrap notify. I have followed this answer here How to use notify in Django with Bootstrap? but it did not work out. Any help/assistance will highly appreciated -
Django: Automatically fill a form field with certain field value depending on where form is accessed
As you see on my views.py, the redirect is on the list of decks. I want the app to redirect to the deck that the card belongs to, so I'm trying to change the return redirect('card:deck_list') statement. Each deck has their own page, with their own "Add card" button. That current deck is where I want those cards added to belong to. views.py def card_new(request, deck): if request.method == "POST": form = CardForm(request.POST) if form.is_valid(): card = form.save(commit=False) card.save() return redirect('card:deck_list') else: form = CardForm() return render(request, 'card/card_edit.html', {'form': form}) urls.py url(r'^$', views.IndexView.as_view(), name='deck_list'), url(r'^(?P<deck>[0-9]+)/$', views.DeckView.as_view(), name='detail'), url(r'^deck/new/$', views.deck_new, name='deck_new'), url(r'^deck/(?P<deck>[0-9]+)/edit/$', views.deck_edit, name='deck_edit'), url(r'^deck/(?P<deck>[0-9]+)/delete/$', views.deck_delete, name='deck_delete'), url(r'^deck/(?P<deck>[0-9]+)/new/$', views.card_new, name='card_new'), models.py class Deck(models.Model): name = models.CharField(max_length=100) description = models.CharField(max_length=200, default='N/A') def __str__(self): return self.name def get_absolute_url(self): return reverse('card:deck_list') class Card(models.Model): term = models.CharField(max_length=100) definition = models.CharField(max_length=200) deck = models.ForeignKey(Deck, on_delete=models.CASCADE) def __str__(self): return self.term def get_absolute_url(self): return reverse('card:deck_list') -
Install the libmaxminddb C library on Windows 8 in easy steps
I am trying to use GeoLite city databases from Maxmind. I have installed Geoip2 module in my virtual environment. However, one of the requirement is installing "libmaxminddb C library, so that geoip2 can leverage the C library’s faster speed". I have looked here for instructions on how to install on windows, but i'm not sure how to install the libmaxminddb C library, Can you please give a guidance please? -
Django - Ordering by a foreign key
I have a class that's called Movie: class Movie(models.Model): title = models.CharField(max_length=511) tmdb_id = models.IntegerField(null=True, blank=True, unique=True) release = models.DateField(null=True, blank=True) poster = models.TextField(max_length=500, null=True) backdrop = models.TextField(max_length=500, null=True, blank=True) popularity = models.TextField(null=True, blank=True) and a class named Trailer: class Trailer(models.Model): movie = models.ForeignKey(Movie, on_delete=models.CASCADE) link = models.CharField(max_length=100) date = models.DateTimeField(auto_now_add=True) How can I display all movies ordered by the date of the trailer? I have tried: Movie.objects.order_by('trailer__date') but that causes multiple duplicates depending on how many Trailer objects are associated to the Movie, how can I avoid the duplicates and have one entry per each movies ordered by the date of the Trailer object? -
Django : ProgrammingError: column "id" does not exist
I try to use postgresql database (before I had SQLite) but I have a message when I execute python manage.py migrate : Operations to perform: Apply all migrations: sessions, admin, sites, auth, contenttypes, main_app Running migrations: Rendering model states... DONE Applying main_app.0004_auto_20161002_0034...Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 200, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 92, in migrate self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 198, in apply_migration state = migration.apply(state, schema_editor) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 123, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 482, in alter_field old_db_params, new_db_params, strict) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql/schema.py", line 110, in _alter_field new_db_params, strict, File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 634, in _alter_field params, File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 110, in execute cursor.execute(sql, params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line …