Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can't login to instagram from app - Redirect URI does not match registered redirect URI
I have django app (Djnago 1.11) with social-auth-app-django==2.1.0 My problem is error: {"error_type": "OAuthException", "code": 400, "error_message": "Redirect URI does not match registered redirect URI"} when I try login with: <a href="{% url 'social:begin' 'instagram' %}">Connect to instagram</a> My settings: SOCIAL_AUTH_INSTAGRAM_KEY = '#############' SOCIAL_AUTH_INSTAGRAM_SECRET = '###########' SOCIAL_AUTH_INSTAGRAM_AUTH_EXTRA_ARGUMENTS = {'scope': 'likes comments relationships'} SOCIAL_AUTH_INSTAGRAM_REDIRECT_URL = 'http://localhost:8000/' On instagram site I have also: redirect url set as: http://localhost:8000/ -
Django MySQL 'utf8' is currently an alias for the character set UTF8MB3, which will be replaced by UTF8MB4
I am using Django 2.0.4, mysql 8.0.11, mysqlclient-1.3.12 and python 3.6.5 on Mac Sierra. I get the warning /lib/python3.6/site-packages/django/db/backends/mysql/base.py:71: Warning: (3719, "'utf8' is currently an alias for the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.") I know it's just a warning, but I still don't like seeing it and have been searching for a solution to it. I have tried a number of things including dropping and recreating my Schema with a variety of options from UTF8 Collation UTF8-bin and UTF8MB4 Collation UTF8MB4-bin but nothing seems to work. This warning is coming from mysql/base.py but I don't know who is making the call with 'utf8' that mySQL is objecting to. Anyone have any ideas? -
django graphene strangely does not include one of my model fields
I spent hours on this and no luck it looks like a bug. All fields show up in the results of my query but the "type" and there is no difference between the "type" and the "issuer" for example, both are foriegn keys. Graphene randomly removes the type while it is there and when I print it in the resolver i see it has a value. When I try to query the field type in graphiql i get the following error: "Cannot query field \"type\" on type \"Post\"." Any thought? class T(models.Model): type=models.CharField(default="type 1",null=False,blank=False,max_length=40) def str(self): return self.type class Post(models.Model): slug=models.SlugField(unique=True) issuer=models.ForeignKey(User,on_delete=models.SET_NULL,blank=False,null=True,related_name="posts") date_created=models.DateTimeField(default=timezone.now) last_edited=models.DateTimeField(null=True) num_interests = models.IntegerField(verbose_name="Number of interests so far",default=0) status=models.CharField(max_length=30,default="posted") tags=TaggableManager() title=models.CharField (max_length=200,blank=False) description =models.TextField(max_length=settings.MAX_TEXTAREA_LEN,default="", validators=[MaxLengthValidatorFactory(settings.MAX_TEXTAREA_LEN)],blank=False) goodUntil = models.DateField(verbose_name=_("Date"),default=datetime.now()+timedelta(days=7)) subjects=models.ManyToManyField(to=Subject,related_name='posts',blank=False) type=models.ForeignKey(T,on_delete=models.SET_NULL,blank=False,null=True,related_name="type") -
Django ORM with UUID fields using sqlite3
I have multiple models with the following structure: class Element(models.Model): api_id = models.UUIDField(null=False, blank=False, default=uuid.uuid4) .... class Category(models.Model): api_id = models.UUIDField(null=False, blank=False, default=uuid.uuid4) .... and so on. Then, I can fetch objects from the Element table: element = Element.objects.first() element.api_id UUID('8b278133-b8a2-4540-9dd0-129dd1394fcc') Element.objects.filter(api_id='8b278133-b8a2-4540-9dd0-129dd1394fcc').count() 1 so far, so good. The error comes when I do the same on the Category table: category = Category.objects.first() category.api_id UUID('f63b5052-fba1-4ad1-a8ec-673efc673f44') Category.objects.filter(api_id='f63b5052-fba1-4ad1-a8ec-673efc673f44').count() 0 The same occurs if I explicity convert to UUID: Category.objects.filter(api_id=uuid.UUID('f63b5052-fba1-4ad1-a8ec-673efc673f44')).count() 0 Both queries are converting the api_id to an integer: str(Element.objects.filter(api_id='8b278133-b8a2-4540-9dd0-129dd1394fcc').query) SELECT ... FROM "element" WHERE "element"."api_id" = 8b278133b8a245409dd0129dd1394fcc str(Category.objects.filter(api_id='f63b5052-fba1-4ad1-a8ec-673efc673f44').query) SELECT ... FROM "category" WHERE "category"."api_id" = f63b5052fba14ad1a8ec673efc673f44 Note that the Element query works as expecetd. and in the database, both fields are created as char (32): CREATE TABLE "element" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "api_id" char(32) NOT NULL, ...) CREATE TABLE "category" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "api_id" char(32) NOT NULL, ...) Then, if everything is equal for all the tables, why the Category queries are not finding nothing by this uuid field? I'm using Python 3.5, Django 2.0, and SQLite 3. I tested with Postgres 9.5 and it works as expected. Only happens with SQLite3. Thank you very … -
Django JsonResponse parsing error in Android
This is the JSON response I am getting from the server : { "0": { "pk": 41, "fields": { "heading": "Empty Lecture Slot", "notification": "There is a free lecture available right now for TE B on 2018-05-02 8:00-9:00", "date": "2018-04-25", "priority": 1, "has_read": false, "action": "/dashboard/set_substitute/91959" }, "model": "Dashboard.specificnotification" } } Here is the Java code used for parsing this JSON object : JSONObject jsonObject = new JSONObject(response); This is the error I am getting in the catch block : org.json.JSONException: No value for {"0": {"pk": 41, "fields": {"heading": "Empty Lecture Slot", "notification": "There is a free lecture available right now for TE B on 2018-05-02 8:00-9:00", "date": "2018-04-25", "priority": 1, "has_read": false, "action": "/dashboard/set_substitute/91959"}, "model": "Dashboard.specificnotification"}} How do I parse this object in Android. -
I lost all data in sqlite3 in my Django project. Where does Django store all DB information of sqlite3?
So, I have my Django project in my local drive, and since there was something wrong, I removed it and cloned the project in my Github. However, the problem is I put db.sqlite3 in my .gitignore file, so the db was not actually commited to the Github. So, that's why I got nothing when I cloned the project. The good thing is I archived the original project before deleting, so I think I can restore the DB data of the original one. But, I'm confused where I can get the actual DB data in my Django project. I thought everything is in db.sqlite3, so I copied and pasted the file to the new project, but I still don't have the superuser account and the data too. Where can I find the DB data? -
Django-oscar: Type Error following the tutorial
I'm following the tutorial of oscar 1.6 with Django, after the migration I tried to run the server and got this problem. I don't know what could be the issue to fix, I don't understand what it's telling me the Type Error and how to correct it. Any advice would be welcome The Error: System check identified no issues (0 silenced). April 25, 2018 - 20:40:21 Django version 1.11.12, using settings 'frobshop.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f53a7ad29d8> Traceback (most recent call last): File "/home/scripts/oscar/shop/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/home/scripts/oscar/shop/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 146, in inner_run handler = self.get_handler(*args, **options) File "/home/scripts/oscar/shop/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 28, in get_handler handler = super(Command, self).get_handler(*args, **options) File "/home/scripts/oscar/shop/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 67, in get_handler return get_internal_wsgi_application() File "/home/scripts/oscar/shop/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 47, in get_internal_wsgi_application return import_string(app_path) File "/home/scripts/oscar/shop/lib/python3.6/site-packages/django/utils/module_loading.py", line 20, in import_string module = import_module(module_path) File "/home/scripts/oscar/shop/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line … -
Lost user name and password of postgres on docker
docker file is provided by django cookie cutter. I tried a lot on google how to get the details but I couldn't. now when ever I try to make the project up using local.yml file always it throws PostgreSQL is unavailable (sleeping)... postgres_1 | 2018-04-25 19:40:54.467 UTC [50] FATAL: password authentication failed for user "SFMCLLrMQcWwGOTuyonmxmGLFafJLvIR" postgres_1 | 2018-04-25 19:40:54.467 UTC [50] DETAIL: Role "SFMCLLrMQcWwGOTuyonmxmGLFafJLvIR" does not exist. postgres_1 | Connection matched pg_hba.conf line 95: "host all all all md5" django_1 | PostgreSQL is unavailable (sleeping)... -
Django multiple databases depending on models
on my site I have a database of projects and each project corresponds to a physical directory on the machine : class Project(models.Model): path = models.CharField() In my project creation view I do something like : Project.objects.create(path=p) os.mkdir(p) Some external non django app creates one sqlite db per per project, each project has the same database structure ({project1.path}/db.sqlite3, {project2.path}/db.sqlite3 have the same tables). I would like to read (and maybe write) from these db using the Django Object Model. Let's say each sqlite file contains a table cookie with 2 columns tastiness, price. I would like to write a class Cake(models.Model): tastiness = models.Charfield() price = models.IntegerField() Then, I wouldn't do any migrations (the tables would just match) and I could read the db with something like: p = Project.objects.get(id=5) L = Cake.objects.using(p.path + '/db.sqlite').filter(price__gt=10) I've read the article on multiple db but that doesn't seem to solve my problem. Maybe another package than django would do the trick ? I know I could go raw import sqlite3 but I would't benefit from the django ORM. -
django heroku, import error: no module named photos.apps
I'm new to the web development and especially server deployment, so have been reading, searching and working my way through. However, I'm getting stuck on the deploying to the Heroku, I think I should have the correct procfile setting, which is as following (the mysite is the root folder for the project, and the app under that is called photos) web: gunicorn mysite.wsgi I tried on my location machine, either one of the following can get me started; python manager.py runserver guricorn mysite.wsgi But when I deploy it on to the Heroku, I got error message saying, ImportError: No module named photos.apps 2018-04-25T20:28:48.321352+00:00 app[web.1]: [2018-04-25 20:28:48 +0000] [10] [INFO] Worker exiting (pid: 10) 2018-04-25T20:28:48.346604+00:00 app[web.1]: [2018-04-25 20:28:48 +0000] [9] [ERROR] Exception in worker process Given the same command can be ran locally to start up the server, I'm really not sure why the error message. Hope someone can point me to the right direction. Thanks Jimmy -
Django rest and Angular 5 Upload Image
here grabs the image of the form, and I call the service to pass the data handleFileInput(file: FileList) { this.fileToUpload = file.item(0); } CreateDetailProduct(){ let form = this.FormDetailProductCreate.value; let detailproduct = new Detailproduct(); detailproduct.Id_Product = form.Id_Product.id; detailproduct.Id_TypeProduct = form.Id_TypeProduct.id; detailproduct.Id_Provider = form.Id_Provider.id; detailproduct.TotalPrice = form.TotalPrice; detailproduct.Quantity = form.Quantity; detailproduct.Image = this.fileToUpload; this.servicedetailproduct.postDetailProduct(detailproduct).subscribe(); } <div class="button-row"> <button matSuffix mat-mini-fab color="primary" (click)="imgFileInput.click()"> <mat-icon>attachment</mat-icon> </button> <input formControlName="Image" hidden type="file" #imgFileInput accept="image/*" (change)="handleFileInput($event.target.files)"/> <img class="imagesize" [src]="imagesUrl" alt=""> </div> from django.db import models from Product.models import ProductModel from TipoProducto.models import TipoProductoModel from Proveedor.models import ProveedorModel from LoteProducto.models import LoteProductoModel class ProductDetailModel(models.Model): Id_Product = models.ForeignKey(ProductModel, null =False, blank=False, on_delete=models.CASCADE) Id_TypeProduct = models.ForeignKey(TipoProductoModel, null =False, blank=False, on_delete=models.CASCADE) Id_Lote = models.ForeignKey(LoteProductoModel, null =False, blank=False, on_delete=models.CASCADE) Id_Provider = models.ForeignKey(ProveedorModel, null =False, blank=False, on_delete=models.CASCADE) TotalPrice = models.FloatField() Quantity = models.IntegerField() Image = models.ImageField(upload_to="ProductDetail/images/", null=True, blank=True) I get this error when you sent the image {Image: ["The submitted data was not a file. Check the encoding type on the form."]} how can I do to load the image in angular 5 to django, or what am I doing wrong -
ValueError: The view accounts.views.register didn't return an HttpResponse object. It returned None instead. When attempting to register user
When attempting to register a user (after changing my project from default user model to custom user model) I get this value error. The following is my View. def register(request): if request.method =='POST': form = RegisterForm(request.POST) if form.is_valid(): form.save() email= request.POST.get('email') password = request.POST.get('password1') user = authenticate( request, email=email, password=password, ) login(request, user) return redirect(reverse('accounts:view_profile')) else: form = RegisterForm() args = {'form': form} return render(request, 'accounts/reg_form.html', args) -
Using django, pass user input from html to python application and display in html
I am working on a django project and I have a simple python application that does some basic functions. However I am trying to implement this on the web using django. I have basic formatting set up, but I am having trouble figuring out how to pass user input from html to the python application and then output an answer back into html. -
django m2m field return objects instead of keys
I have a model: class Scenario(models.Model): tasks = models.ManyToManyField(Task, blank=True) Its serializer: class ScenarioSerializer(serializers.ModelSerializer): class Meta: model = Scenario fields = '__all__' And a view to retrieve Scenarios: @api_view(['GET', 'POST']) def scenarios_list(request): """ List all scenarios, or create a new. """ if request.method == 'GET': scenarios = Scenario.objects.all() serializer = ScenarioSerializer(scenarios, many=True) return Response(serializer.data) This gives me data as following: [{"id":1,"tasks":[1,3]},{"id":2,"tasks":[2,4,5,10]},{"id":3,"tasks":[2,5,6]},{"id":4,"tasks":[2,6,10]}] I want to receive task objects instead of their ids. How can I achieve that? -
How to create sqlite table in Django automatically?
Im using Django 2.0. My task is to write a large dataset that after being analized it'll be dropped every day. I've decided to write that data in SQLite using database routers that generates the file automatically but it does not create the model table and throws an OperationalError cause the table does not exist. Which (if someone had a similar situation) should be a nice solution for this? Thanks in advance! -
what its the best way to make full history for a model in django?
how to make history for a model that show me the old value and the new changed value in a field .. in my mind i think to make history model to each model which have the same fields and when the user create new or update the data from the first model go to the second model too. i searched alot for this problem and i found a packet called django-reversion but i didn't understand it how to make it store the old value and new value if any one can help me for this problem please tell me . -
Django: Show Choices "verbose" name when querying (and the choice is in a related model)
I'm attempting to write a view that shows a table with number of items per status. A simplified view of my models is as follows: from django.db import models class Entity(models.Model): name = models.CharField(max_length=20) class Status(models.Model): BAD = 0 NICE = 1 GREAT = 2 STATUS_CHOICES = ( (BAD, 'Bad'), (NICE, 'Nice'), (GREAT, 'Great') ) entity = models.OneToOneField(Entity, on_delete=models.CASCADE, related_name='status') status = models.IntegerField(choices=STATUS_CHOICES, db_index=True) So, in my views.py file, I have a view like this: from django.shortcuts import render from django.db.models import Count def my_summary(request): q = Entity.objects.values('status__status').annotate(n=Count('pk')) context = {'table_data':q} return render(request, 'my_app/summary_template.html', context) The issue I'm facing is that, when I render the template, I only get the number of the status, and I need to show the Label of that status. So, instead of showing status | entities -------+--------- 0 | 3 1 | 5 2 | 9 I'd like to show: status | entities --------+--------- BAD | 3 NICE | 5 GREAT | 9 Is there a way to do it? Can anyone point me in the right direction? -
Django ProgrammingError: relation already exists after a migration created in the Django source code?
I recently checked out the master branch of a project, and there were model changes not yet reflected in a migration: (venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py migrate Operations to perform: Apply all migrations: admin, auditlog, auth, contenttypes, lucy_web, oauth2_provider, otp_static, otp_totp, sessions, two_factor Running migrations: No migrations to apply. Your models have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. Following the instructions, I ran makemigrations to create them: (venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py makemigrations Migrations for 'auth': venv/lib/python3.6/site-packages/django/contrib/auth/migrations/0009_auto_20180425_1129.py - Alter field email on user Migrations for 'lucy_web': lucy_web/migrations/0146_auto_20180425_1129.py - Alter field description on sessiontype - Alter field short_description on sessiontype Interestingly, the 0009_auto_20180425_1129.py migration was created in the venv containing Django's source code (version 1.11.9), which I don't believe anyone on our team changed. Here is this migration: # -*- coding: utf-8 -*- # Generated by Django 1.11.9 on 2018-04-25 18:29 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('auth', '0008_alter_user_username_max_length'), ] operations = [ migrations.AlterField( model_name='user', name='email', field=models.EmailField(blank=True, max_length=254, unique=True, verbose_name='email address'), ), ] It seems 'innocent enough', but when I … -
Trying to edit a form using django and python
I'm trying to edit the form via my edit button. When i click update button in my form i'm getting FieldError at /studentapp/editrow/72/ Cannot resolve keyword 'rowid' into field Choices are: address, course, id, name, pub_date, roll My traceback shows item = get_object_or_404(Studentapp, rowid=id) this line. My models.py is: class Studentapp(models.Model): name = models.CharField(max_length=100) roll = models.IntegerField() course = models.CharField(max_length=100) address = models.CharField(max_length=100) pub_date = models.DateTimeField('date published', auto_now=True) def __str__(self): return '%s %s %s %s' % (self.name, self.roll, self.course, self.address) def published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) -
vesta control panel and django deployment
I am new in development, so I apologize for somet of the "mistakes" that I am about to post. I created a django project, which I successfully deployed in DigitalOcean using Nginx and Gunicorn. Now I am trying to deploy the same project in DigitalOcean Ubuntu 16.4 using Vestacp. I already setup Vestacp and it is working fine. Though, I am looking for some information/direction on how to deploy my site. See the information that I have right now: This is the code for the django.wsgi file import os, sys sys.path.insert(0, '/home/admin/web/devbinit.com/private/django/devbinit.com/env/lib/python2.6/site-packages') sys.path.insert(0, '/home/admin/web/devbinit.com/private/django/devbinit.com/project/src/shared/') sys.path.insert(0, '/home/admin/web/devbinit.com/private/django/devbinit.com/project/src/') os.environ['DJANGO_SETTINGS_MODULE'] = 'main.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() This is the code for my .htacess file: # Wsgi template AddHandler wsgi-script .wsgi RewriteEngine On RewriteCond %{HTTP_HOST} ^www.devbinit.com\.ru$ [NC] RewriteRule ^(.*)$ http://devbinit.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /django.wsgi/$1 [QSA,PT,L] Folder structure for web, portfolio is my project Web setup in vest cp When I try to access my site at devbinit.com I get the 500 Internal server error. I would appreciate if you let me know what other information do you need to be able to assist me; or if you can direct me to some literature that can give me an idea of … -
Can not save Django Proxy user model from Admin
I am getting the following error message when I save the user object. I have searched on the internet for the error message, but I can not find any help. It maybe somthing very abvious that I am missing, but I am not able to find any help available. Can someone take a look and let me know what the error here is? admin.py from django.contrib.auth.admin import UserAdmin class UserAdmin(UserAdmin): list_display = ('username', 'email', 'first_name', 'last_name', 'is_active', roles, login) list_filter = ('groups',) def save_model(self, request, obj, form, change): queryset = MyUser.objects.filter(id=obj.id) if obj.is_active: logger.info('User is marked active') elif not obj.is_active: logger.info('User is marked inactive') obj.save() def add_view(self, *args, **kwargs): self.inlines = [] return super(UserAdmin, self).add_view(*args, **kwargs) def change_view(self, request, object_id, form_url='', extra_context=None): self.inlines = (ProfileInline,) return super(UserAdmin, self).change_view(request, object_id, form_url, extra_context) User Model models.py class MyUser(User, URLGenerator): objects = models.Manager() # The default manager. safe = SafeUserManager() class Meta: proxy = True ordering = ['username'] def __unicode__(self): return self.get_full_name() ERROR console log Internal Server Error: /admin/public/myuser/1/change/ Traceback (most recent call last): File "/dp/app/venv/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/dp/app/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/dp/app/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File … -
Access Denied - CloudFront + Django Compressor
Just started using django compressor along with my AWS/Cloudfront setup on Heroku. Having an issue on my local machine where the compressed CSS and JS files are not loading for the page and when i view the source (CSS Example) It is showing as “Access Denied” https://d3dycr1vdfv0cd.cloudfront.net/static/CACHE/css/50c1fe094e5d.css I thought this might be a permissions issue on my S3 bucket and clicked on “Make Public” on my CSS folder in S3. But still no luck. any ideas? -
django-numpy gives error with pip
I've been using django-numpy for some time now. But suddenly it gives an error, when I try to install it in a django project. I've tried different approaches installing django-numpy - made a new venv - tried with another version og both django and django-numpy. The error I get, when doing a pip install -r requirements.txt is: Collecting django-numpy==1.0.1 (from -r requirements.txt (line 2)) Using cached https://files.pythonhosted.org/packages/35/b0/1f0be2e9c4df3b0736b09067dd041eb4475a6199b583428b241eb8576d7d/django-numpy-1.0.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-4qp99vp2/django-numpy/setup.py", line 6, in <module> from pip.download import PipSession ModuleNotFoundError: No module named 'pip.download' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-4qp99vp2/django-numpy/ I've tried installing different packages via requirements, with no problems. It's only django-numpy that gives an error? I do not know if I should make an issue on django-numpy's github? -
Changing active class in bootstrap navbar not staying in inherited Django template
My navbar lives in a base.html template which is extended by all pages. When I click a link in the navbar the active class is added but right after when I travel to that page it reverts to its previous state when only the initial page was highlighted. Here is my base.html template {% load static %} <!-- DOCTYPE html --> <html> <head> <title>Title</title> <!-- new bootstrap --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="https://use.fontawesome.com/a0c7be9623.js"></script> <!-- css --> <link rel='stylesheet' href='{% static "css/base.css" %}' /> </head> <body> <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top"> <a class="navbar-brand" href='{% url "home" %}'>Maximum Likelihood</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNavAltMarkup"> <div class="navbar-nav mr-auto"> <a class="nav-item nav-link active" href='{% url "home" %}'>Book Materials <span class="sr-only">(current)</span></a> <a class="nav-item nav-link" href='{% url "about" %}'>About</a> <a class="nav-item nav-link" href='{% url "stuff" %}'>Stuff</a> </div> <div class="navbar-nav"> <a class="nav-item nav-link ml-auto" href='google.com'>Outside link</a> </div> </div> </nav> {% block content %} {% endblock content %} <br> <!-- <!-- bootstrap's js stuff --> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script> <script src='{% static "js/nav.js" %}'/></script> </body> Here is my nav.js $(".nav-link").on("click", function(){ $(".nav").find(".active").removeClass("active"); $(this).addClass("active"); }); -
How do I set up Python3 as the default Python version on Mac OS X?
I have both Python 2.7 and Python 3.6 installed, and I can access either by typing "python" or "python3". However, when I try to install the latest version of Django with pip install Django==2.0.4, Python 2.7 is detected and the highest version that can be installed is version 1.11, since Django 2.0.4 requires Python3. In summary I need the default version of Python on my machine to be Python3, and I'm not sure how to accomplish this. Using an alias won't work, since I'm trying to make it so that other apps detect the correct version. My which python result should be Python3. Assumed Answer I would imagine that I need to edit my Path in a way that prefers Python3 over Python 2, but I'm unsure of how to do so. When I type echo $PATH I get /anaconda2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. I'm not sure if that helps or not. Any ideas on what to do? Also, I'd prefer for Python3 to be the default, so I'd rather not use a virtualenv.