Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Validating a Django model field based on another field's value?
I have a Django app with models accessible by both Django REST Framework and a regular form interface. The form interface has some validation checks before saving changes to the model, but not using any special Django framework, just a simple local change in the view. I'd like to apply the same validation to forms and REST calls, so I want to move my validation into the model. I can see how to do that for simple cases using the validators field of the Field, but in one case I have a name/type/value model where the acceptable values for 'value' change depending on which type is selected. The validator doesn't get sent any information about the model that the field is in, so it doesn't have access to other fields. How can I perform this validation, without having essentially the same code in a serializer for DRF and my POST view for the form? -
Docker-compose tutorial not working "python: can't open file 'manage.py"
I am running simple Docker-compose example shown here Here is Dockerfile: FROM python:2.7 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ Here is docker-compose.yml: version: '2' services: db: image: postgres web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" depends_on: - db When I am trying to launch the example with docker-compose it gives me following: alex@universe:~/projects/testcompose$ docker-compose up testcompose_db_1 is up-to-date Recreating testcompose_web_1 Attaching to testcompose_db_1, testcompose_web_1 web_1 | python: can't open file 'manage.py': [Errno 2] No such file or directory db_1 | The files belonging to this da... Probably tutorial is not up to date so if you know answer please write it here. -
How to fix error saying plugin_env` should be an ``Environment`` instance that contains pkg_resources.DistributionNotFound: Django==1.8
when I run the command from the shell: $ django-admin.py startproject myproject . i get the below error: Traceback (most recent call last): File "/usr/local/bin/django-admin.py", line 4, in <module> __import__('pkg_resources').run_script('Django==1.8', 'django-admin.py') File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 2716, in <module> File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 685, in require def __getstate__(self): File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 588, in resolve The `plugin_env` should be an ``Environment`` instance that contains pkg_resources.DistributionNotFound: Django==1.8 even though django is installed. >>> import django >>> django <module 'django' from '/Library/Python/2.7/site-packages/Django-1.8-py2.7.egg/django/__init__.pyc'> -
Django on IIS 7.5 - Opening Local Files
I am running django 1.9 on python 2.7.9 on IIS 7.5. This is a simple website that organizes all excel and PDF files, and allows the user to select a link and open the PDF files. The content is showing. However, my biggest problem is that I can't get any of the links to open. I understand 3 things from other stack overflow questions: I must use the file:/// previx Firefox and Chrome (and other modern browsers) disabled the ability to open local files. This is from 3-4 years ago. I can create a new virtual file directory in IIS, but this isn't working. What am I missing? Thanks -
Issue adding request headers for Django Tests
I need to add a header to a request in a Django test. I have browsed a few pages on both Stack Overflow and elsewhere, following various suggestions. I can add the headers to PUTs and GETs successfully, but having an issue with POSTs. Any advice would be greatly appreciated. For PUT and GET I have used the following [passing successfully]: resp = self.client.put(resource_url, res_params, **{'HTTP_SSL_CLIENT_CERT': self.client_cert}) For POST, I tried the same thing but am receiving the error: "'str' object has no attribute 'items'" I have tried the following: resp = self.client.post(resource_url, res_params, **{'HTTP_SSL_CLIENT_CERT': self.client_cert}) resp = self.client.post(resource_url, res_params, HTTP_SSL_CLIENT_CERT=self.client_cert) resp = self.client.post(resource_url, res_params, HTTP_SSL_CLIENT_CERT='1234567890') -
django : 'posts' is not a registered namespace
I don't know why am I getting this weird error. I haven't used posts URL but I am still getting this error while I am opening inbox and rest of the things are working fine. Main urls.py from classroom.views import classroom_full, classroom_create urlpatterns = [ url(r'^messages/', include('postman.urls', namespace='postman', app_name='postman')), url(r'^admin/', admin.site.urls), url(r'^student/', include("student.urls", namespace='student')), url(r'^(?P<username>\w+)/(?P<slug>[\w-]+)/$', classroom_full, name='classroom_full'), url(r'^(?P<username>\w+)/$', classroom_create, name='classroom_create'), ] student.urls.py from django.conf.urls import url from django.contrib import admin from .views import ( login_view, loggedin, logout, ) urlpatterns = [ url(r"^$", login_view , name="login"), #url(r"^accounts/loggedin/$", loggedin , name="loggedin"), url(r"^accounts/logout/$", logout, name="logout"), url(r'^(?P<username>\w+)/$', loggedin, name='loggedin'), ] Traceback: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/messages/inbox/ Django Version: 1.10.2 Python Version: 3.4.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'pagination', 'postman', 'pinax.notifications', 'mailer', 'student', 'teacher', 'classroom', 'bootstrapform', 'pagedown', 'posts'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'pagination.middleware.PaginationMiddleware'] Template error: In template C:\Users\rohit\Desktop\GBPEC\portal\lib\site-packages\postman\templates\postman\inbox.html, error at line 0 'posts' is not a registered namespace 1 : {% extends "postman/base_folder.html" %} 2 : {% load i18n %} 3 : {% block pm_folder_title %}{% trans "Received Messages" %}{% endblock %} 4 : {% block pm_undelete_button %}{% endblock %} 5 : {% block pm_recipient_header %}{% endblock %} 6 : {% block pm_date … -
Django ImportError: No module named... but module is visible in Project Interpreter settings
I am developing a Django app and I am experiencing a strange problem. I've installed a few modules using pip and I can see them in "project interpreter settings": However, when I try to import any of these modules I get errors like this: File "/Users/Franek/Documents/testy/testy/testysearch/views.py", line 4, in <module> from sumy.summarizers.text_rank import TextRankSummarizer ImportError: No module named sumy.summarizers.text_rank I am using virtualenv, but I don't think this can be an issue, because when I try to run some of these modules from console (bypassing Django) they work properly. What am I doing wrong? -
Using Docker for uWSGI + Django + nginx
So I am kinda new to docker (even newer to uwsgi and nginx). I am trying to create a docker container for a django app which uses uwsgi and nginx. The docker-compose.yml builds normally and even runs without giving any errors, the problem is that I get : the container for the app exited with code 1 and nothing seems to happen. In the dockerfile of the app I have some standart installations and CMD ["/usr/local/bin/uwsgi", "--ini", "/code/uwsgi.ini"]. My nginx Dockerfile looks like this: FROM ubuntu:16.04 # Install Nginx. RUN apt-get update && \ apt-get install -y nginx && \ rm -rf /var/lib/apt/lists/* && \ echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \ chown -R www-data:www-data /var/lib/nginx # Define mountable directories. VOLUME ["/etc/nginx/sites-available", "/etc/nginx/certs", "/etc/nginx/conf.d"] ADD configfile /etc/nginx/sites-available/ ADD certif.key /etc/nginx/certs/ ADD certif.crt /etc/nginx/certs/ RUN rm /etc/nginx/sites-enabled/default && rm /etc/nginx/sites-available/default RUN ln -s /etc/nginx/sites-available/ctrd /etc/nginx/sites-enabled/ctrd # Define default command. CMD ["nginx"] # Expose ports. EXPOSE 3306 And the configfile I have barely touched except changing it to listen to port 3306 as I am using MySQL and it is set to that port. The docker-compose.yml is also standard using a ready image for MySQL, just building the Dockerfile for the app … -
Django rest framework pagination
I am trying to add pagination into my project, couldn't find any clear documentation or tutorial. I have a list of offices models Office.py class Office(Model): name = CharField(_("name"), default=None, max_length=255, null=True) email = EmailField(_("email"), default=None, max_length=255, null=True) description = TextField(_("description"), default=None, null=True) Serializer class OfficeSerializer(ModelSerializer): id = IntegerField(read_only=True) name = CharField(read_only=True) email = URLField(read_only=True) description = CharField(read_only=True) class Meta: model = Office fields = ("id", "name", "email", "description") views.py @api_view(["GET"]) @permission_classes((AllowAny,)) def offices(request): instance = Office.objects.filter()[:10] serializer = OfficeSerializer(instance, many=True) return Response(serializer.data) Any help with returning Office list with pagination ? -
How to register a user with Twitter django-AllAuth
My goal is to create users with Django-AllAuth. I would like my users to see a button they click that says sign up with Twitter. That is how they can sign up to use my application. I don't need email verification or anything else. settings.py contains: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.twitter', 'myApp', ] # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # This is where I'm setting up AllAuth AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', # `allauth` specific authentication methods, such as login by e-mail 'allauth.account.auth_backends.AuthenticationBackend', ) ACCOUNT_EMAIL_REQUIRED=False SOCIALACCOUNT_AUTO_SIGNUP=True LOGIN_REDIRECT_URL = '/' ACCOUNT_LOGOUT_REDIRECT_URL = '/' I also have a url from accounts set in my urls.py url(r'^accounts/', include('allauth.urls')), I have followed the steps for activating my application with Twitter. I don't understand how to create a user based on these instructions. I have created a template with a button that shows my sign up button. {% if user.is_authenticated %} <a id="logout" href="/accounts/logout" class="btn btn-success">Logout</a> {% else %} <a id="twitter_login" href="/accounts/twitter/login" class="btn btn-success">Sign in with Twitter</a> {% endif %} Is my next step to create a view … -
Django KeyError kwargs.pop('pk')
I'm using CBV in Django 1.9 and in CreateView when I try to pass an additional parameter ('pk') to my form using self.kwargs.pop('pk') i got "Key Error" but if I get the parameter by index it works, here is my code: def get_form(self, form_class=None, **kwargs): self.project_version_pk = self.kwargs.pop('pk') form = super(HarmonyRelationCreateView, self).get_form(form_class) form.fields['project_version'].queryset = form.fields['project_version'].queryset.filter(pk=self.project_version_pk) form.fields['project_version'].initial = self.project_version_pk return form def get(self, request, *args, **kwargs): self.object = None form_class = self.get_form_class() form = self.get_form(form_class, pk=self.kwargs['pk']) return self.render_to_response( self.get_context_data(form=form) And I get this error: builtins.KeyError KeyError: 'pk' File "RelationView.py", line 65, in get_form self.project_version_pk = self.kwargs.pop('pk') KeyError: 'pk' But if i read the key this way it works: def get_form(self, form_class=None, **kwargs): self.project_version_pk = self.kwargs['pk'] form = super(HarmonyRelationCreateView, self).get_form(form_class) form.fields['project_version'].queryset = form.fields['project_version'].queryset.filter(pk=self.project_version_pk) form.fields['project_version'].initial = self.project_version_pk return form I don't really understand why the parameter is missing on pop() or which is the best practice for this. -
MailChimp bad request JSONParseError with Python
I am trying to hook up to MailChimp's api, in my Django application, to add an email to one of my lists. Seems pretty simple enough. I add my api key to the header of the request, with the email address and other variable in the body of the request. every time I try and connect though, I get a response status code of 400. The message says there is a JSON parsing error, and that my JSON is either formatted incorrectly, or there is missing data required for the request. I am making this same api call however with Postman, and am getting a good response back. view function import requests def join_newsletter(request, email): # hash the user's email for mailchimp's API # m = hashlib.md5() # c_email = email # m.update(c_email.encode('utf-8')) # email_hash = m.hexdigest() api_key = 'apikey ' + settings.MAILCHIMP_API api_endpoint = api_endpoint data = { "email_address": email, "status": "subscribed" } header = { 'Authorization': api_key } r = requests.post(api_endpoint, data=data, headers=header) message = r.content return message -
How to Convert URLField in a Image on Django
I have kept the url of an image on a URLField, such that as well as I can display the image on the model of my home page and not the string of the URL, I can not convert that direction, "www.google.es/images/car "in an image of a car? models.py Photo class (models.Model): name = models.CharField (max_length = 150) url = models.URLField () __unicode def __ (self): # 0 parameters return self.name views.py def home (request): photos = Photo.objects.all () html = '<ul>' for photo in photos: html + = '<li>' + photo.url + '</ li>' html + = '</ ul>' return HttpResponse (html) How could i convert in a imagen photo.url into a Image. -
Django 1.9.2 "reverse" error during password reset attempt
My app sits on Django 1.9.2 and Django REST Framework 3.3.2, with a single page app on the front-end. I must admit I'm new to Django but the docs are unmatched. I'm trying to implement a custom PasswordResetForm view. My strategy is as follow: User uses on a front-end form that POSTs data (email string) to an API endpoint (api/v1/password/reset) when she wants to reset her password. If email is found in DB, send an email and return a successful response. For part 1, here's the relevant code: # urls.py url(r'^api/v1/password/reset/?$', PasswordResetView.as_view(), name='password-reset-link') - # views.py class PasswordResetView(GenericAPIView): serializer_class = PasswordResetSerializer permission_classes = (AllowAny,) def post(self, request, *args, **kwargs): # Use DRF serializer to validate data. serializer = self.get_serializer(data=request.data) # Ensure data is valid before proceeding. if serializer.is_valid() == False: return Response('error': serializer.errors, 'message': 'Error while attempting to reset password'}, status.HTTP_400_BAD_REQUEST) else: # Ensure the user exists. existing_user = get_user_model().objects.filter( email=serializer.validated_data.get('email') ) if not existing_user: return Response({'error': {'code': 'email_not_in_db'}}, status.HTTP_404_NOT_FOUND) # Validated data fed to a child class of PasswordResetForm. form = UserForgotPasswordForm(serializer.validated_data) if form.is_valid(): path = os.path.join(os.path.dirname(os.path.abspath(__file__ + '../../')), 'templates/registration/password_reset_email.html') try: # Save form, effectively attempting to trigger mail sending. # Unfortunately an exception gets thrown! form.save(from_email='no-reply@abc.xyz', email_template_name=path, request=request) … -
I am facing to start runserver django?
While running server i got the following error.I am using Django===1.10.2 and default sqlite3 database as backend.But i got the following exceptions. python manage.py runserver Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread started by <function wrapper at 0x7f56983c3140> Traceback (most recent call last): File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run self.check_migrations() File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/core/management/base.py", line 437, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__ self.loader = MigrationLoader(self.connection) File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__ self.build_graph() File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 203, in build_graph self.applied_migrations = recorder.applied_migrations() File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations self.ensure_schema() File "/home/nidhinjames/popo/popo/mysite/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in ensure_schema raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc) UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 6: ordinal not in range(128) Any solutions can be appreciated???? -
Django cursor query to fetch total time
I have a mysql query to fetch total time of sessions. The query is SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(end_time,start_time)))) as total FROM session where helper_mode = 1 When i am running this query in my mysql GUI i am getting the correct result as total 35:34:27 But when i am running the same query using django cursor i am getting an exception like hour must be in 0..23 My cusror query is, cursor = connection.cursor() cursor.execute("SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(end_time,start_time)))) as total FROM session where helper_mode = 1") Its happening when the total time exceeding 24 hours. Why i am getting this Exception? Any help would be greatly appreciated. -
Checking input of URLfield for broken links
I'm using modelform_factory to generate forms in my administration panel. Now, I'd like to check if there's a URLfield in the model / form in question and if so, validate it to see if it's broken. Here is a part of my view.py generating and treating the form and post request. model_name = apps.get_model("product", model) EditForm = modelform_factory(model_name, fields=("__all__")) if request.method == "POST": formset = EditForm(request.POST, request.FILES, instance=model_name.objects.get(id=object_id)) if formset.is_valid(): formset.save() #Success - redirect to all objects from model else: formset = EditForm(instance=model_name.objects.get(id=object_id)) return render(request, 'product/admin/edit.html', {'model': model, 'object_id': object_id, 'formset': formset}) else: formset = EditForm(instance=model_name.objects.get(id=object_id)) return render(request, 'product/admin/edit.html', {'model': model, 'object_id': object_id, 'formset': formset}) -
Django queryset with isnull=True in get_object_or_404
I have 2 records in the posts table, one of the row in table has rating as NULL and the other has rating as 2, both have same user_id say 5 I implement this first post = get_object_or_404(Post.objects.filter(user_id=user_id,rating__isnull=True)) So the first record with rating null should return 404 page but it is not and the second record display properly Now I tried, post = get_object_or_404(Post.objects.filter(user_id=user_id,rating=2)) Now both are throwing 404 page Can any one help me to fix it? -
Django Session authentication not working in aws ec2 and working in local workstation
i'm unable process forward, code is working on local system after deployment session authentication is not working. read forums stated to add WSGIPassAuthorization On, added in sites-enabled/000-defualt.conf file but its not working Thanks in Advance -
VirtualBox command works correct in bash, but does not work in nginx
We have a project on nginx/Django, using VirtualBox. When we try to run command ("VBoxManage list runningvms") in nginx, we have the next error: "Failed to initialize COM because the global settings directory '/.config/VirtualBox' is not accessible!\" If we run this command in console, it works fine. What can we do to make it working good in nginx? Other details: nginx is runned by user "www-data", console - by the other user (Administrator). -
Django AppsNotLoaded
I'm trying to make a python script to put some things in my database; from django.conf import settings settings.configure() import django.db from models import Hero #Does not work..? heroes = [name for name in open('hero_names.txt').readlines()] names_in_db = [hero.hero_name for hero in Hero.objects.all()] #ALready existing heroes for heroname in heroes: if heroname not in names_in_db: h = Hero(hero_name=heroname, portraid_link='/static/heroes/'+heroname) h.save() The import throws the following Traceback (most recent call last): File "heroes_to_db.py", line 4, in <module> from models import Hero File "C:\Users\toft_\Desktop\d2-patchnotes-master\dota2notes\patch\models.py", line 5, in <module> class Hero(models.Model): File "C:\Python27\lib\site-packages\django\db\models\base.py", line 105, in __new__ app_config = apps.get_containing_app_config(module) File "C:\Python27\lib\site-packages\django\apps\registry.py", line 237, in get_containing_app_config self.check_apps_ready() File "C:\Python27\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. I know I can do python manage.py --shell and write the code for hand but to be honest, I dont want to. What am I missing ? -
how to log all request in tastypie django
I have used tastypie in django to handle REST api request. When ever I do GET/POST request it comes to dehydrate method by default. But for DELETE/PUT request it doesn't have any method tastypie handles it, so there is no way to log request information. class ProjectResource(ModelResource): allowed_methods = ['get', 'put', 'post', 'delete'] resource_name = 'project' queryset = Project.objects.all() validation = FormValidation(form_class=ProjectForm) always_return_data = True filtering = { 'id': ALL, 'slug': ALL, } def dehydrate(self, bundle): import pdb;pdb.set_trace() #--> get/post request hit this function logger.log('app.main','debug', 'Project info', bundle) bundle.data['name'] = cgi.escape(bundle.obj.name) return bundle Is there any function to override ModelResource in tastypie.resource module? so that for all request i get the bundle data first and then i will pass that to logger before it is processed. -
Django creating wrong type for fields in intermediate table (manytomany)
I have a model in Django which the pk is not an integer and it has a field which is a manytomany. This manytomany references the model itself. When I ran makemigration I didn't realize, but it did not create the fields in the intermediate table as char(N). In fact, it create as an integer. # models.py class Inventory(models.Model): sample_id = models.CharField(max_length=50, primary_key=True) parent_id = models.ManyToManyField("self") This throws errors whenever I try to add objects to my parent model >>> p = Inventory.objects.get(sample_id='sample01') >>> child = Inventory.objects.get(sample_id='sample02') >>> p.parent_id.add(child) I get the error psycopg2.DataError: invalid input syntax for integer: "sample02" LINE 1: ...HERE ("inventory_parent_id"."to_inventory_id" IN ('sample... I saw the fields in the intermediate table, inventory_parent_id, created by Django and their types are not correct. Columns (3) |--id (integer) |--from_inventory_id (integer) |--to_inventory_id (integer) My questions are: Is it bad if I change the types manually? Will it break the migrations? Or did I have to do something so Django can catch this misleading type? -
I want to make a variable in my views.py which changes depending the name of the urlpattern used
Here's my code. whatever urlpattern is chosen: I want the name of it to be stored as url in views.py. Which is then used in queryset filter(). urls.py url(r'^news/', BoxesView.as_view(), name='news'), url(r'^sport/', BoxesView.as_view(), name='sport'), url(r'^cars/', BoxesView.as_view(), name='cars'), views.py class BoxesView(ListView): url = #urlname to go here def get_queryset(self): queryset_list = Post.objects.all().filter(category=url) models.py category = models.CharField(choices=CATEGORY_CHOICES) choices.py CATEGORY_CHOICES = ( ('1', 'news'), ('2', 'sport'), ('3', 'cars'), ) Any idea? -
Error 'cannot import name post_revision_commit'
Hi everyone I move my project, to a server I now I try to load the database python manage.py loaddata resource/ddbb/20160817_db.json or even run the server but I obtain this error. File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/mxp1217/django1101/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/home/mxp1217/django1101/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute django.setup() File "/home/mxp1217/django1101/lib/python2.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/home/mxp1217/django1101/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/home/mxp1217/django1101/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/mxp1217/django1101/lib/python2.7/site-packages/cms/models/__init__.py", line 3, in <module> from .pagemodel import * # nopyflakes File "/home/mxp1217/django1101/lib/python2.7/site-packages/cms/models/pagemodel.py", line 1453, in <module> _reversion() File "/home/mxp1217/django1101/lib/python2.7/site-packages/cms/models/pagemodel.py", line 1449, in _reversion exclude_fields=exclude_fields File "/home/mxp1217/django1101/lib/python2.7/site-packages/cms/utils/helpers.py", line 135, in reversion_register from cms.utils import reversion_hacks File "/home/mxp1217/django1101/lib/python2.7/site-packages/cms/utils/reversion_hacks.py", line 18, in <module> from reversion.models import Revision, Version, post_revision_commit # NOQA # nopyflakes ImportError: cannot import name post_revision_commit This is my installation in my environment on the server cmsplugin-filer==1.1.3 dj-database-url==0.4.1 Django==1.8.15 django-appconf==1.0.2 django-classy-tags==0.8.0 django-cms==3.4.1 django-filer==1.2.5 django-formtools==1.0 django-mptt==0.8.6 django-polymorphic==0.8.1 django-reversion==2.0.6 django-sekizai==0.10.0 Django-Select2==4.3.2 django-treebeard==4.0.1 djangocms-admin-style==1.2.5 djangocms-attributes-field==0.1.1 djangocms-column==1.7.0 djangocms-googlemap==0.5.2 djangocms-inherit==0.2.2 djangocms-installer==0.9.1 djangocms-link==2.0.1 djangocms-snippet==1.9.1 djangocms-style==1.7.0 djangocms-text-ckeditor==3.3.0 djangocms-video==2.0.2 djangorestframework==3.4.7 easy-thumbnails==2.3 feedparser==5.2.1 html5lib==0.9999999 MySQL-python==1.2.5 Pillow==3.4.1 pytz==2016.7 six==1.10.0 tzlocal==1.3 Unidecode==0.4.19 Any idea How I can solvent this problem.