Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
jquery & django ASGI app(using channels) compatible issue
I try to deploy andrewgodwin's django simple chat app. gitrepo html rendering works well as to http request. jQuery code works well. Also in my development environment(which uses local database : sqlite3, local redis-server : localhost) jQuery works well as to both http and channel request. However in production environment(I use heroku postgresql and heroku redis)only as to channel request, jQuery code is not applied. var webSocketBridge = new channels.WebSocketBridge(); webSocketBridge.connect(ws_path); webSocketBridge.listen(function(data) {...}); webSocketBridge.send({"command": "leave","room": roomId}); When above code executed, jquery code not loaded. Actually I questioned this issue yesterday, but I haven't resolved it yet. It is my yesterday question url. this issue is so troublesome. I'd appreciate your help. -
I am unable to send generated token to Android client as Response in views.py with perform_create(self, serializer) method?
I am unable to send generated token to Android client as Response in views.py with perform_create(self, serializer) method since perform_create(self, serializer) sends a default response on serializer.save() .Am only able to print token. This is my views.py class CreateAccountView(generics.ListCreateAPIView): """This class handles the GET and POSt requests of our rest api.""" queryset = Account.objects.all() serializer_class = AccountSerializer def perform_create(self, serializer): """Save the post data when creating a new bucketlist.""" data = self.request.data print ("="+data['accesstoken'] ) graph=facebook.GraphAPI(data['accesstoken']) args={'fields':'id,name,email'} profile=graph.get_object('me',**args) print ("dict="+profile['name'] ) instance =serializer.save(displayname=profile['name'],fbid=profile['id']) token=Token.objects.get(user=instance) print ("viewtoken="+token.key) I learnt that inorder to send custom response we need to use def create(self, request, *args, **kwargs). How do I get saved instance as in perform_create() like this instance =serializer.save(displayname=profile['name'],fbid=profile['id']) token=Token.objects.get(user=instance) -
How to draw svgs generated by a same function of D3js multiple times in Django templates?
I want to a standalone illustration(generated by d3js) for every textual snippet that server return in the template of django. However, the first text snippet has n pics, the second snippet has n-1 pics and so on. How could I draw an independent illustration for every single snippet? I know that the key to address this question is to correctly select the right element. However, as select(div.question) can only the first div of questions and selectAll(div.question) can not allocate pics for every single questions, I really don't know how can the code selects the right element. The result and codes are listed as follow. Current result: The current result. The first snippet has all the 4 pics. The JavaScript function to draw a image of svg is as follow: <script> function draw(links){ // http://blog.thomsonreuters.com/index.php/mobile-patent-suits-graphic-of-the-day/\ var nodes = {}; // Compute the distinct nodes from the links. links.forEach(function(link) { link.source = nodes[link.source] || (nodes[link.source] = {name: link.source}); link.target = nodes[link.target] || (nodes[link.target] = {name: link.target}); }); var width = 600, height = 400; var force = d3.layout.force() .nodes(d3.values(nodes)) .links(links) .size([width, height]) .linkDistance(60) .charge(-300) .on("tick", tick) .start(); var svg = d3.selectAll('div.question').append("svg") .attr("width", width) .attr("height", height); // Per-type markers, as they don't inherit … -
Django extend global template
I'm new to Django and creating first application in Django 1.11 I have created three application pages, users, search and directory structure is as myapp |- pages |- templates |- pages |- home.html |- urls.py |- views.py |- ... |- search |- templates |- search |- index.html |- myapp |- settings.py |- urls.py |- static |- css |- style.css |- js |- script.js |- templates |- base.html |- manage.py In the myapp/pages/views.py contain from django.views.generic import TemplateView class HomeView(TemplateView): template_name = 'pages/home.html' myapp/pages/templates/pages/home.html contains {% extends 'base.html' %} {% block content %} <h1>Home page</h1> {% endblock %} myapp/templates/base.html contains {% load static %} <html> <head> <link href="{% static 'css/style.css' %}"> ... </head> <body> <header> Welcome to my app </header> <div class="container"> {% block content %} {% endblock %} </div> </body> </html> But when I try to access http://127.0.0.1:8000/pages it gives error as Exception Type: TemplateDoesNotExist Exception Value: base.html Template-loader postmortem Django tried loading these templates, in this order: Using engine django: django.template.loaders.app_directories.Loader: /path_to_app/seotool/pages/templates/base.html (Source does not exist) django.template.loaders.app_directories.Loader: /usr/local/lib/python3.6/site-packages/django/contrib/admin/templates/base.html (Source does not exist) django.template.loaders.app_directories.Loader: /usr/local/lib/python3.6/site-packages/django/contrib/auth/templates/base.html (Source does not exist) How to load base.html in view. Since all three apps will be using common navigation and static files, I don't want … -
Pass extra parameters to Django Model Forms along with request.POST
I have a Rating models with some fields in which ip and url and required fields. I get some of these fields in request.POST but I have to pass ip and url to the modelform from my view. In my views.py : form = RatingModelForm(request.POST, ip=ip, url=url) if form.is_valid(): instance = form.save(commit=False) instance.save() And my in forms.py: class RatingModelForm(forms.ModelForm): class Meta: model = Rating exclude = ('special_object',) def __init__(self, *args, **kwargs): ip = kwargs.pop('ip', None) url = kwargs.pop('url', None) super(RatingModelForm, self).__init__(*args, **kwargs) self.fields['ip'].initial = ip self.fields['url'].initial = url I have tried setting initial values but the form.is_valid() give False and and states that ip and url are required. How do proceed with this ? -
Whats the best way to add authtables to django all auth login
I need the know the best way to implement https://github.com/magoo/AuthTables into https://github.com/pennersr/django-allauth is the best way to do it via adapters? And we alter the flow? -
Dynamic search like stackoverflow for django
Does anyone know what the best plugins to handle the dynamic search like stackoverflow for django? something like this docs: <input type="text" value="how to [django] or [python] duplicate:yes is:answer" style="width: 50%"> I just think about complex queries. query = request.GET.get('q') text_query = # what regex here? tags_query = # is_duplicate = re.search(r'(?P<duplicate>\w+)', query) Questions.objects.filter(...) Or, any suggestion to handle this case? Thanks before.. -
How to enforce character length for asian languages such as chinese, japanese and korean?
Using Django v1.10 and Postgres there's a datafield which may contain a mixture of symbols (such as \|?), numbers, alphabetical letters, as well as Asian language characters. The user says the maximum of this field should be 15 characters. How do I enforce this using Django and Postgres as the database? In postgres, we use utf-8 encoding. I know in PHP, there's a function called mb_strlen. And in python, the equivalent would be to use unicode strings. Within the Django way, what's the best way to enforce max string length? -
How to design step-by-step form in Django?
I have been working on my Django web-app for quite some time now and due to initial poor planning, I have been constantly changing and moving things in my web app so it is a complete mess now. I decided to stop writing codes and reflect on how I want the things to work. One of the questions that came up is the Application form that people would have to fill out. models.py class Contact(models.Model): ContactName = models.CharField(max_length = 250, default='', verbose_name="Contact Name") Country = models.CharField(max_length = 250, default='') City = models.CharField(max_length = 250, default='') etc. I will have over a hundred fields in my form and I don't want them all to be displayed at once but rather make them step by step: Personal Info -> General Info -> Upload supported documents -> etc. I have two questions: 1) Should I keep all 100 fields under one class (Contact) or break them down into a few classes and connect them all using the ForeignKey? What are the best practices? 2) Once the Personal Info fields get filled out, an applicant will press Continue and will be moved to General Info and fill that out and so forth. Should this … -
Why isn't data I wanna connected User model connected to the model?
I wanna parse excel and put it to the model(User) which has same user_id of dictionary. I wrote #coding:utf-8 from django.shortcuts import render import xlrd from .models import User book = xlrd.open_workbook('../data/excel1.xlsx') sheet = book.sheet_by_index(1) def build_employee(employee): if employee == 'leader': return 'l' if employee == 'manager': return 'm' if employee == 'others': return 'o' for row_index in range(sheet.nrows): rows = sheet.row_values(row_index) is_man = rows[4] != "" emp = build_employee(rows[5]) user = User(user_id=rows[1], name_id=rows[2], name=rows[3], age=rows[4],man=is_man,employee=emp) user.save() files = glob.glob('./user/*.xlsx') data_dict_key ={} for x in files: if "$" not in x: book3 = xlrd.open_workbook(x) sheet3 = book3.sheet_by_index(0) cells = [ ('company_id', 0, 4), ('user_id', 0, 5), ('name', 0, 6), ] data_dict = OrderedDict() for key, rowy, colx in cells: try: data_dict[key] = sheet3.cell_value(rowy, colx) except IndexError: data_dict[key] = None if data_dict['user_id'] in data_dict_key: data_dict_key[data_dict['user_id']].update(data_dict) continue data_dict[data_dict_key['user_id']] = data_dict for row_number, row_data in data_dict_key.items(): user1 = User.filter(user_id=row_data['user_id']).exists() if user1: user1.__dict__.update(**data_dict_key) user1.save() db.sqlite3 has data in this part User(user_id=rows[1], name_id=rows[2], name=rows[3], age=rows[4],man=is_man,employee=emp) and in this part user1.__dict__.update(**data_dict_key) separately. I wanna save these part data together in having same user_id in this part User.filter(user_id=row_data['user_id']).exists() so I really cannot understand why I cannot do it.No error happens,so I do not have a clue.What is … -
django user authenticated (not authenticated )
I want to create a simple Django authentication (register/login/logout) but I have problems. if complete login successfully then app go to next page with name mypage because I have define in my settings.py that line : LOGIN_REDIRECT_URL = '/mypage'. but in the new page user is not authenticated user(my user stay authenticated only in the "/login" page ) any idea why I have wrong ? here the code : urls.py url(r'^$', views.home, name='home'), url(r'^mypage/$', views.home2, name='home2'), url(r'^login/$', views.login, {'template_name': 'login.html', 'authentication_form': LoginForm}), url(r'^logout/$', views.logout, {'next_page': '/login/'}), views.py def home(request): return render_to_response('home.html') def mypage(request): return render_to_response('home2.html') settings.py LOGIN_REDIRECT_URL = '/mypage' html 1 : {% if user.is_authenticated %} <li> <a href="/logout">LogOut</a> </li> {% else %} <li> <a href="/login">Login</a> </li> {% endif %} html 2 : {% if user.is_authenticated %} <a href="#" class="lg">Start</a> {% else %} <p>Please Login to start</p> {% endif %} -
Static files not being loaded in production Django
I have the following local file path: project/ migrations/ core/ static/ core/ /images -base.css -index.css -etc... This works on the local server and my css and images are displayed correctly, but on the production server these files are not loaded, what do I have to do to get these loaded in production? -
Use django from InteractiveConsole
# -*- coding: utf-8 -*- from __future__ import unicode_literals import datetime from django.db import models from django.utils import timezone # Create your models here. class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) def __str__(self): return self.choice I am using django(1.11) document to make polls app now i editing (polls/models) as according to document this shows me error. My polls/models is something is wrong with me.plz Help!! Question.objects.all() Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Python36\lib\site-packages\django\db\models\query.py", line 229, in __repr__ return '<%s %r>' % (self.__class__.__name__, data) File "C:\Python36\lib\site-packages\django\db\models\base.py", line 589, in __repr__ u = six.text_type(self) File "C:\Users\hp\mysite\polls\models.py", line 16, in __str__ return self.question AttributeError: 'Question' object has no attribute 'question' -
django filtering a model that contains integer
models.py STORY_CHOICES = ( (0, 'Computer engineering'), (1, 'Mechanical engineering') views.py story_list = MyOBJ.objects.all() query = request.GET.get('q') if query: story_list = story_list.filter( Q(story__icontains=query) ).distinct() story takes data from STORY_CHOICES, when I try to search and write 'Computer engineering' it gives nothing. Also '0' is giving 'Computer engineering'. I want to cover it to text and take it string search. I try to take directly STORY_CHOICES and I met this fail: FieldError at /... Cannot resolve keyword 'STORY_CHOICES' into field. Choices are: .... I didn't find a true way. -
how to use django authentication in "main" template
I've created a main HTML file where I have a template for all apps. And in every other template file I am using : {% extends "main.html" %} To get the content. But there are things I want to add to the main template but only if user is authenticated. I know I can use {% if user.is_authenticated %} but it doesn't work in main.html file. Do you know what am I doing wrong ? What should I do to solve this problem? Thanks in advance, -
Django project not able to run on mac OS X Sierra
I just purchased the new 2017 macbook pro. I want to do two things. the first is run a django project and then run my specific file that I have clones from github. I want to pip install django and I am getting a message that pip is not a command. Every forum is saying that 2017 macbook pro has python 2.X and 3.X I want to set python 3.X as the default. How can i set python 3 as the default? what is the command to get pip because when i try to get it from python 2.x and 3.x, it says the file does not exist. Where and how can I install pip? I tried installing pip but i was getting a message that it does not exist. how can i go about downloading or getting pip on my mac. I have tried a few different ways and nothing is working. Once i get python and pip, I can install Django and run my django application... Where and how can i install django framework onto my mac? Does anyone know how to do this on the OS X sierra for mac. -
Django - passing parameter from view.py to a formset
How to pass a parameter from views.py to a formset in forms.py ? i am using kwargs.pop but its not working! .. any suggestions ? urls.py url(r'^(?i)new-bill/(?P<org_id>\w+)$', BillView.as_view(), name='new-bill'), views.py class BillView(LoginRequiredMixin, generic.CreateView): form_class = BillForm template_name = 'bill/bill_form.html' def get_form_kwargs(self): kwargs = super(BillView, self).get_form_kwargs() kwargs.update({'org_id': self.kwargs.get("org_id")}) return kwargs def get_context_data(self, **kwargs): data = super(BillView, self).get_context_data(**kwargs) if self.request.POST: data['bill_details'] = BillDetailsFormSet(self.request.POST) else: data['bill_details'] = BillDetailsFormSet() return data def form_valid(self, form): context = self.get_context_data() bill_details = context['bill_details'] with transaction.atomic(): organization = Organization.objects.filter(id=self.kwargs.get("org_id")).get() form.instance.org_id = organization form.instance.created_by = self.request.user form.instance.created_date = timezone.datetime.now() self.object = form.save() if bill_details.is_valid(): bill_details.instance = self.object bill_details.save() return super(BillView, self).form_valid(form) def get_success_url(self): return reverse_lazy('organizations:bills', kwargs={'org_id': self.kwargs.get("org_id")}) forms.py class BillForm(forms.ModelForm): class Meta: model = Bill fields = ('bill_no', 'po_number', 'vendor', 'currency', 'bill_date', 'due_date', ) def __init__(self, *args, **kwargs): self.url_org_id = kwargs.pop('org_id') super().__init__(*args, **kwargs) po_numbers = PurchaseOrder.objects.filter(org_id=self.url_org_id).order_by('po_number') vendors = Vendor.objects.filter(org_id=self.url_org_id).order_by('name') org_currencies = OrgCurrencies.objects.filter(Org_id=self.url_org_id).order_by('currency_id') self.fields['po_number'] = forms.ModelChoiceField(queryset=po_numbers, required=False, label='PO. #', widget=widgets.Select(attrs={'size': 1})) self.fields['vendor'] = forms.ModelChoiceField(queryset=vendors, required=True, label='Vendor', widget=widgets.Select(attrs={'size': 1})) self.fields['currency'] = forms.ModelChoiceField(queryset=org_currencies, required=True, label='Currency', widget=widgets.Select(attrs={'size': 1})) self.fields['bill_date'] = forms.DateField(widget=widgets.SelectDateWidget(attrs={'size': 1})) self.fields['due_date'] = forms.DateField(widget=widgets.SelectDateWidget(attrs={'size': 1})) class BillDetailsForm(forms.ModelForm): class Meta: model = BillDetails fields = ('item', 'description', 'qty', 'unit_price', 'amount', 'dr_account', 'cr_account' ) def __init__(self, *args, **kwargs): self.url_org_id = kwargs.pop('org_id') # this is … -
django ModelForm: self: Unable to get repr for <class
I have a django from that is working in my development environment, but not my production environment. If I debug my development environment, I notice this warning appear by the form's __init__ function: self: Unable to get repr for <class 'badges.forms.BadgeAssertionForm'> args <class 'tuple': (None,) kwargs: {'initial': {'badge': <Badge: Test Badge>}} forms.py class BadgeAssertionForm(forms.ModelForm): class Meta: model = BadgeAssertion # fields = '__all__' exclude = ['ordinal', 'issued_by', 'semester'] def __init__(self, *args, **kwds): super(BadgeAssertionForm, self).__init__(*args, **kwds) self.fields['user'].queryset = User.objects.order_by('profile__first_name', 'username') self.fields['user'].label_from_instance = lambda obj: "%s (%s)" % (obj.profile, obj.username) The form is created in views.py: def assertion_create(request, user_id, badge_id): # view can accept a user_id or badge_id, otherwise they will be 0 initial = {} if int(user_id) > 0: user = get_object_or_404(User, pk=user_id) initial['user'] = user if int(badge_id) > 0: badge = get_object_or_404(Badge, pk=badge_id) initial['badge'] = badge form = BadgeAssertionForm(request.POST or None, initial=initial) The other answers I've seen all suggest adding a __str__ function to the class, however, I've never seen a ModelForm requiring a __str__ before? Also, when I add one the error still appears. -
Python/Django Standalone Scirpt - Import by filename is not supported
I have the following script, and it's mean to be a standalone Django script. So I can run "python my_script.py" from the command line. It used to work with Django 1.8, after I upgrade to Django 1.11, I'm getting the following error: Traceback (most recent call last): File "app.py", line 8, in <module> django.setup() File "C:\python27\lib\site-packages\django-1.11.5-py2.7.egg\django\__init__.py", line 22, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "C:\python27\lib\site-packages\django-1.11.5-py2.7.egg\django\conf\__init__.py", line 56, in __getattr__ self._setup(name) File "C:\python27\lib\site-packages\django-1.11.5-py2.7.egg\django\conf\__init__.py", line 41, in _setup self._wrapped = Settings(settings_module) File "C:\python27\lib\site-packages\django-1.11.5-py2.7.egg\django\conf\__init__.py", line 110, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\python27\lib\importlib\__init__.py", line 37, in import_module __import__(name) ImportError: Import by filename is not supported. This is my python script # standalone django setup import os, sys, logging, django prj_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) logging.basicConfig(level=logging.INFO) logging.info("PRJ_DIR: %s" % prj_dir) sys.path.append(prj_dir) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.settings" % prj_dir.split("/")[-1]) django.setup() ... ... -
Facebook login/registration: Error validating verification code
I spend all this day with this error. I am using django-rest-auth which uses django-allauth for social logins. I set login for facebook according the rest-auth documentation. This is a view. Authentication works, but the email for the user was empty. So add callback_url and client_class (like documentation said). from rest_auth.registration.views import SocialLoginView from allauth.socialaccount.providers.oauth2.client import OAuth2Client class FacebookLogin(SocialLoginView): adapter_class = FacebookOAuth2Adapter callback_url = 'http://localhost:8000/rest-auth/facebook/' client_class = OAuth2Client But it is not working. It return this error: "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request" First I think the problem is in the library. So I printed out all parameteres for request and I check all this things. Everything looks fine, so I tried to put the url with GET parameters to facebook graph api. But the error is the same. Here is the all URL which I tried manually, without using the allauth library: https://graph.facebook.com/v2.10/oauth/access_token?redirect_uri=http://localhost:8000/rest-auth/facebook/&client_id=203192345223034931&client_secret=a475bbbscds65437c89bf04d359d98a&code=203192345223034931|l3ujbbbscdhrf0404d3B2de57Dw In the facebook developers interface I set: Valid OAuth redirect URIs: http://localhost:8000/rest-auth/facebook/ App domains: localhost I tried it with the normal domain, but it has not come any change. I will be reallz glad for any clue or help what makes … -
Django - sending emails (SMTPAuthenticationError)
I use: from django.core.mail import send_mail in my app. Yesterday my app normally sent emails without any errors. Today I get "SMTPAuthenticationError". Below is a part of my settings.py: EMAIL_HOST = 'poczta.interia.pl' EMAIL_PORT = 587 EMAIL_HOST_USER = 'username' EMAIL_ADRESS = 'email_adress' EMAIL_HOST_PASSWORD = 'password' This is my email function: def send_activation_email(self): subject = 'SUBJECT' message = 'MESSAGE' from_email = settings.EMAIL_ADRESS to_email = self.email send_mail( subject, message, from_email, [to_email], fail_silently=False, ) I don't have any idea what is going on. Yesterday it was fine, today not. Any ideas? -
Method for sorting an evaluated Queryset (Django)
I have the following function and test: def create_question(days, question_text="Empty"): time = timezone.now() + datetime.timedelta(days=days) return Question.objects.create(question_text = question_text, pub_date=time) def test_two_past_questions(self): """ The questions index page may display multiple questions. """ create_question(question_text="Past question 1.", days=-30) create_question(question_text="Past question 2.", days=-5) response = self.client.get(reverse('polls:index')) self.assertQuerysetEqual( response.context['latest_question_list'].order_by('-pub_date'), ['<Question: Past question 1.>', '<Question: Past question 2.>'], ) This generates the following error: Creating test database for alias 'default'... System check identified no issues (0 silenced). ....F... ====================================================================== FAIL: test_two_past_questions (polls.tests.QuestionIndexViewTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/sahandzarrinkoub/.local/share/virtualenvs/django/mysite/polls/tests.py", line 74, in test_two_past_questions latest_question_list.order_by('-pub_date') File "/Users/sahandzarrinkoub/.local/share/virtualenvs/django/lib/python3.6/site-packages/django/db/models/query.py", line 962, in order_by "Cannot reorder a query once a slice has been taken." AssertionError: Cannot reorder a query once a slice has been taken. To my understanding, it generates an error because the Queryset is already evaluated and order_by is only for reordering in the database. Without the failed sorting attepmpt, my test is failing because the objects are in wrong order: FAIL: test_two_past_questions (polls.tests.QuestionIndexViewTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/sahandzarrinkoub/.local/share/virtualenvs/django/mysite/polls/tests.py", line 77, in test_two_past_questions ['<Question: Past question 1.>', '<Question: Past question 2.>'], File "/Users/sahandzarrinkoub/.local/share/virtualenvs/django/lib/python3.6/site-packages/django/test/testcases.py", line 972, in assertQuerysetEqual return self.assertEqual(list(items), values, msg=msg) AssertionError: Lists differ: ['<Question: Past question 2.>', '<Question: Past question 1.>'] != … -
How to call parse_qs in python3
I'm using Django 1.11.5 and Python 3.5.2 I wanna parse query string in this code but receive No module named parse Error. from urllib.parse import parse_qs qs = 'title=Test&recurring=weekly&description=Test Description' data = parse_qs(qs) How to use parse_qs in python3 ? I have searched in google and I have can't useful result for this problem. -
Models and views in django framework
1.What is verbose_name and verbose_name_plural in models.py ? How do they work here ? 2. why we added if category_slug: in views.py models.py from django.db import models from django.utils import timezone from django.contrib.auth.models import User from django.core.urlresolvers import reverse class Category(models.Model): name = models.CharField(max_length =250) slug = models.SlugField(max_length = 250) class Meta: ordering = ('name',) verbose_name = 'category' verbose_name_plural = 'categories' def get_absolute_url(self): return reverse('blog:list_of_post_by_category', args =[self.slug]) def __str__ (self): return self.name views.py from django.shortcuts import render , get_object_or_404 from .models import Post ,Category def list_of_post_by_category(request,category_slug ): categories = Category.objects.all() post = Post.objects.filter(status = 'published') if category_slug: category = get_object_or_404( Category, slug = category_slug) post = post.filter(category = category) return render(request , 'blog/category/list_of_post_by_category.html', {'categories': categories, 'post': post, 'category': category}) -
Crispy forms works in local site but not in production site
login.html: <div class = "container"> <h2 class = "text-center">Login</h2> <form method = 'post'> {% csrf_token %} {{ form|crispy }} <!--'form' comes from login view imported in urls--> <div class = "text-center"> <br/> <button class="btn btn-primary" type = 'submit'>Login</button> </div> </form> </div> In settings.py I added it to installed apps and specified the crispy template pack: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'crispy_forms', ] CRISPY_TEMPLATE_PACK = 'bootstrap3' and this works well when ran locally, but when I try to run python3.6 manage.py migrate in an ssh connection to my server I get the following error: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/obrien98/webapps/core/lib/python3.6/Django-1.11.5-py3.6.egg/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/home/obrien98/webapps/core/lib/python3.6/Django-1.11.5-py3.6.egg/django/core/management/__init__.py", line 338, in execute django.setup() File "/home/obrien98/webapps/core/lib/python3.6/Django-1.11.5-py3.6.egg/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/home/obrien98/webapps/core/lib/python3.6/Django-1.11.5-py3.6.egg/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/home/obrien98/webapps/core/lib/python3.6/Django-1.11.5-py3.6.egg/django/apps/config.py", line 94, in create module = import_module(entry) File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked ModuleNotFoundError: No module named 'crispy_forms' Any help would be appreciated