Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django QuerySet.exclude(): Why are all excluded?
I have a situation like this: ids = [None, None, None] foo = Foo.objects.filter(common=True).exclude(id__in=ids) This seems to exclude all always. Why is id of id__in threated as None in this case? pk__in didn't work either. I expect it to not exclude anything as all objects have valid id's. foo = Foo.objects.filter(common=True) Returns all objects like expected. -
Django - Supervisor : excited too quickly
I try to deploy my website in Django+Supervisor+NGINX on Ubuntu server 16.04. Here is my .conf (supervisor): [program:sitepro] command = /home/user/sitepro/bin/gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002 user = user autostart = true autorestart = true My NGINX config file : server { listen 80; server_name .mywebsite.fr; charset utf-8; root /home/user/sitepro/site/sitepro; access_log /home/user/sitepro/site/logs/nginx/access.log; error_log /home/user/sitepro/site/logs/nginx/error.log; location /static { alias /home/user/sitepro/site/static; } location / { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_redirect off; proxy_pass http://127.0.0.1:8002; } } When I try to launch gunicorn on the root of my project, everything goes right : (sitepro) user@mybps:~/sitepro/site$ gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002 [2017-11-01 16:09:37 +0000] [1920] [INFO] Starting gunicorn 19.7.1 [2017-11-01 16:09:37 +0000] [1920] [INFO] Listening at: http://79.137.39.12:8002 (1920) [2017-11-01 16:09:37 +0000] [1920] [INFO] Using worker: sync [2017-11-01 16:09:37 +0000] [1925] [INFO] Booting worker with pid: 1925 I've done a supervisorctrl reread and update (worked). And if I make supervisorctl status sitepro sitepro FATAL Exited too quickly (process log may have details) And if I access my website I've got the "Welcome to Nginx" default page. I've tried many tutorials for deploy django : I'm lost and tried many things. Could someone give me a simple and fast tutorial to deploy Django that he used for his … -
Correct NoReverseMatch error with authentication algorithm
I want to allow the user to reset password when the user is signed out and cannot remember the password. I am using the django authentication framework and have created the reset_password and password_reset_done mappers. Issue : Though I have created the password_reset_done function I continue to get the below error. Is there a step that I missed that is causing this error? I do not know what I have done wrong. I have posted all the code that I think is relevant to what I attempting to do. Here is the code : relative urls.py from django.conf.urls import url from . import views from django.contrib.auth.views import login, logout, password_reset, password_reset_done urlpatterns = [ url(r'^$', views.vedic_view, name = 'vedic_home_view'), url(r'^login/$', login, {'template_name' : 'exist/login.html'}, name = 'login'), url(r'^logout/$', logout, {'template_name' : 'exist/logout.html'}, name = 'logout'), url(r'^register/$', views.register_view, name = 'register'), url(r'^profile/$', views.view_profile, name = 'view_profile'), url(r'^profile/edit/$', views.edit_profile, name = 'edit_profile'), url(r'^change-password/$', views.change_password, name = 'change_password'), url(r'^reset-password/$', password_reset, name = 'reset_password'), url(r'^reset-password/done/$', password_reset_done, name = 'password_reset_done') ] main urls.py from django.conf.urls import url from django.contrib import admin from django.conf import settings from django.conf.urls.static import static urlpatterns = [ url(r'^admin/', admin.site.urls), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) from django.conf.urls import include from django.views.generic import … -
Cannot connect django 1.11.6 to MS SQL Server using django-pyodbc-azure
I am working on a django app which needs to connect to MS SQL Server 2008. I use django-pyodbc-azure backend. Environment: Ubuntu 16.04 Apache 2.4 python 3.5.2 django 1.11.6 django-pyodbc 1.1.1 django-pyodbc-azure 1.11.0.0 I have also installed dependents: unixodbc unixodbc-dev tdsodbc freetds-dev In /etc/freetds/freetds.conf: [sqlserver] host = mysqlserverhost.com port = 6789 tds version = 8.0 In /etc/odbc.ini: [sqlserverdatasource] Driver = FreeTDS Description = ODBC connection via FreeTDS Servername = sqlserver Database = test TDS_Version = 8.0 In /etc/odbcinst.ini: [ODBC] Trace = Yes TraceFile = /tmp/odbc.log [FreeTDS] Description = TDS driver (Sybase/MS SQL) Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so CPTimeout = CPReuse = FileUsage = 1 Then I tested the connection with the following. import pyodbc db = pyodbc.connect('DRIVER={FreeTDS};SERVER=mysqlserverhost.com,6789;DATABASE=test;UID=admin;PWD=password;TDS_Version=8.0') cursor = db.cursor() cursor.execute("SELECT @@version;") row = cursor.fetchone() while row: print(row[0]) row = cursor.fetchone() I can see the version of SQL Server from the above codes. Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) In django projects settings.py, I configured the database backend. DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'test', 'USER': 'admin', 'PASSWORD': 'password', 'HOST': 'mysqlserverhost.com', 'PORT': '6789', 'OPTIONS': { … -
Query Database Table Without Using Foreign Key Django Postgresql
I am trying to query a table where I have many records with the same name, on purpose. In my example, I'm using the make of the car, and unfortunately I've already ruled out using a foreignkey. Long story. Anyway, I've been able to determine that I can query the table using a ModelChoiceField and using the distinct command as I'm using Postgresql as shown below: class Vehicle(forms.Form): dropdown = forms.ModelChoiceField(queryset=Car.objects.none()) def __init__(self, *args, **kwargs): super(Vehicle, self).__init__(*args, **kwargs) self.fields['dropdown'].empty_label = '' qs = Car.objects.distinct('vehicle_make') The code above does, what I need related to the dropdown, it limits the ModelChoiceField to just the unique values of the vehicle_make of the car. The challenge is when I go to try to display all of the records with that vehicle_make in my template. I've tried to do a Detail View, but it is only showing me that individual record. That make sense since detail view is just for that record, but I'm trying to figure out how to query the table to show me all of the records with that vehicle_make. I've explored the ChoiceField as well, but can't seem to get this to work either. I've tried several variations of the code … -
Not able to run django-admin script on ubuntu
When I ran the following command : django-admin startproject project_name I got the following error : The program 'django-admin' is currently not installed. You can install it by typing: sudo apt install python-django-common I did what it told me to and nwo I get the following error: Cannot find installed version of python-django or python3-django. on running the same command, I am not able to understand if I had installed django , then why was django-admin script not installed Note that django is installed which is verified by the following: $ python -c "import django; print(django.get_version())" 1.7 -
JavaScript VS Django(python)
I started to learn django not long ago and I was wondered if you can do the same things (such as vars,Forms,etc..) as there in JavaScript in Django ? I mean I did learn python for few months and have some basic knowledge in it. I never tried JS (I am learning java). Should I stay with Django and do the same things or start learning js :P Thanks in advance. -
Python - File or Folder Content Version Control
We're using CKEditor to generate HTML content when author writes his book. We're storing that content to a separate HTML file on the disk using python-django. But now, we have got a requirement from client to show the history/revision of the files (list of time stamps in a sidebar whenever author has pressed ctrl+s), like the Eclipse does: I am planning to use diff by taking intersection of the html texts stored at 2 different times. But I am not getting any idea about how to take the diff of images, audios and videos. Any idea how git, eclipse or Vesrsion control systems do that? Do they use any kind of encoding such as SHA to store it on the disk? Please suggest if any other method I can use to do this. -
Django-graphene: how to filter with an OR operator
I am pretty new with both Django and Graphene, and couldn't get around a problem which might be fairly simple, but I had no luck with the docs or google to get an answer. Let's say I have the following model: class Law(models.Model): year = models.IntegerField(default=None) number = models.IntegerField(default=None) description = TextField(default=None) body = models.TextField(default=None) And the following schema: class LawType(DjangoObjectType): class Meta: model = models.Law filter_fields = { "year": ["exact"], "number": ["exact"], "description": ["contains"], "body": ["icontains"], } interfaces = (graphene.Node, ) class Query(graphene.AbstractType): all_laws = DjangoFilterConnectionField(LawType) def resolve_all_laws(self, args, context, info): return models.Law.objects.all() How do I make a query or define a FilterSet class so that it will return a list of objects such that a word is found in the description or in the body? { allLaws(description_Icontains: "criminal", body_Icontains: "criminal") { edges{ node{ year number } } } } I couldn't find an answer in the graphene-django documentation nor in the django-filter documentation. Any clues? Thanks in advance -
How to accommodate a querystring in django mock
I'm completely stumped on this in that I don't even know what to google. I'm not well versed in python testing (I work mainly in javascript). I have an endpoint in python/django that I added a querystring to. This is the endpoint (I've changed some names to make it more generic): class ThingSeriesView(APIView): """ Ajax Request for just the Thing Series data """ renderer_classes = (JSONRenderer, ) def get(self, request, pk, **kwargs): # pylint: disable=invalid-name """ :param request: :param pk: :return: """ thing = get_object_or_404(models.Thing, pk=pk) frequency = float(request.GET.get('frequency', '1.0')) serializer = ChartDataSeriesSerializer( thing.get_series(frequency)) return Response(serializer.data) The line I added was (and this is causing the problem): frequency = float(request.GET.get('frequency', '1.0')) And thing.get_series was originally just passed '1.0' for everything. This is fine, and it does what I need to it to, however it breaks a test: class TestThingSeriesView(object): """ Test the ThingSeries view """ def test_get(self): thing = models.Thing() # pylint: disable=line-too-long with patch('main.endpoints.get_object_or_404', new_callable=Mock) as mock_get_obj,\ patch('main.endpoints.Response', new_callable=Mock) as mock_response,\ patch.object(thing, 'get_series') as series_method: endpoint = endpoints.ThingSeriesView() mock_get_obj.return_value = thing assert endpoint.get(Mock, 'foo') == mock_response.return_value mock_get_obj.assert_called_once() series_method.assert_called_with(1.0) This is the error I get: > frequency = float(request.GET.get('frequency', '1.0')) E AttributeError: type object 'Mock' has no attribute 'GET' How … -
signup error in django
i have a problem i created a signup page to add users to my django but the problem is when i used a code to check usernames from the existing usenames and tell the users to change the username if someone already used that user and here is my code snippet: from signup.html from django.shortcuts import render from django.contrib.auth.models import User # Create your views here. def signup(request): if request.method == 'POST': if request.POST.get('password1') == request.POST.get('password2'): try: user=User.objects.get(username=request.POST.get('username')) return render (request,'accounts/signup.html',{'error':'usename has been aleady used'}) except User.DoesNotExist: User.objects.create_user(username=request.POST.get('username') , password=request.POST.get('password1')) return render (request,'accounts/signup.html') else: return render (request,'accounts/signup.html',{'error':'passwod didnt match'}) else: return render (request,'accounts/signup.html') and i dont know whats wrong with this code but when i open localserver:8000/signup and after entering all those deatils and submitting i have been always getting an error as the password is not same in both cases but if i remove the code lines that checks regarding username then i can submit and add users to my website -
Django filter by list of foreign keys
I'm new to Django and Python overall so bare with me, please. I'm also using fixtures for mock data. I have tags.json that simply contains all possible tags like so { "model": "app.tag", "pk": 1, "fields": { "name": "Foo" } }. I also have links.json that contains links like this { "model": "app.link", "pk": 1, "fields": { "title: "Lorem ipsum", ... "tags": [1, 3, 2], ... } } In my views.py I have my_tags argument which is a string that I split(','). So when I go to http://www.example.com/tags/foo,bar I end up with ['foo','bar'] in my view. So what I want to do is something like Link.objects.filter(tags: my_tags) so that I only receive links that have both foo and bar tags. Can someone help me out and explain how to achieve this? -
VSCode starts up when I use ".py" extension with CMD commands
I don't know when and how it started but now I have such a glitch: open CMD enter python command: "django-admin.py help" Visual Studio Code starts up and opens manage.py for editing. The CMD command itself does not return anything. on the other hand, if I enter: "django-admin help" (without .py) the CMD shows help and VSCODE does not react in any way. What is this magic? How to change VSCODE reaction to .py mentioning? -
What form field type to use for arrays (lists)
I'm expecting json data to be submitted to my form, with one field being an array of up to N strings of M chars each. The model uses a django.contrib.postgres.fields.ArrayField - what type of field should I declare it as in the form? -
ProgrammingError at "url" relation "app_model" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "app_model"
I've searched every Stack Overflow question on this error but none of the responses helped. I'm getting this error when trying to access the admin page of this particular model (AgentBasicInfo). 'manage.py makemigrations' works fine. 'manage.py migrate' also works fine. 'manage.py runserver' works fine, the whole website works fine until I try to go onto the admin page of this model. The app is correctly installed in INSTALLED_APPS in settings.py. I am using Postgres for the database. I have tried... Deleting migrations and re-running makemigrations/migrate Deleting the entire migrations folder for this app and rerunning makemigrations/migrate Deleting all the migrations from all my apps and re-running makemigrations/migrate I have tried running 'manage.py migrate' and 'mangae.py migrate app_name'. I still get the same error. This model (see code below) is quite basic. I have several other models in my project and they work just fine in the admin, but just this particular model doesn't work. models.py class AgentBasicInfo(models.Model): preferred_email = models.EmailField() office_phone_number = models.IntegerField() brokerage_of_agent = models.CharField(max_length=50) agent_title = models.CharField(max_length=20) def __str__(self): return self.preferred_email settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': 'lagger123', 'HOST': '127.0.0.1', 'PORT': '5432', } } -
Using django with mysql fails
Am new to django and i wanted to setup mysql instead of the default sqlite so i have DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', //..mysql settings here } } Now am getting an error ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python? I have run sudo apt-get install libmysqlclient-dev which runs successifully but doesnt clear the improperly configured error In my Computer(Linux) i already have set apache2 and mysql server. What could be wrong or how do i resolve this? -
Django: lowest class based view or mixin with request attribute
What's the minimum class based view or mixin I can inherit from to have access to Django request object via the request attribute in my view? -
Only last label input value being returned in Django
I am pretty new in Django and I guess there is something I am overlooking. I have a form that I am populating dynamically as shown below <form method="post"> {% csrf_token %} {{ profile.days }}//Only prints last radio button value {% for period, value in profile.periods.items %} <h2>{{ period }} Reports</h2> <label> <input name="days" value={{ value }} type="hidden"> <input name="reports_allowed" type="radio" {% if profile.reports_allowed and profile.days == value %} checked {% endif %}> Each {{ value }} send me a summary of my checks </label> {% endfor %} <button name="update_reports_allowed" type="submit" class="btn btn-default pull-right">Save</button> </form> I want to be able to access the value of the selected radio button which I am doing as follows form = ReportSettingsForm(request.POST) if form.is_valid(): print(form.cleaned_data) days = form.cleaned_data["days"] print(days)# Prints only the last value always Any help on how to get value of radio button clicked will be highly appleciated. -
Modified Django admin clean() method not being invoked
I have developed a tool (to be used internally) based on the Django admin site. I have model validators in place which work brilliantly, but to do more complex validations, I am attempting to overwrite the clean() method in admin.py My admin.py looks like this: from django.contrib import admin from .models import Provider, Employer, Person, Learnership, Qualification, Unit_Standard from django import forms class ProviderForm(forms.ModelForm): class Meta: model = Provider fields = 'all' def clean(self): provider_start_date = self.cleaned_data.get('provider_start_date') provider_end_date = self.cleaned_data.get('provider_end_date') if provider_start_date > provider_end_date: raise forms.ValidationError("Start date can't be after end date") return self.cleaned_data admin.site.register(Provider) The models.py for the Provider Model: class Provider(models.Model): ... lots of stuff here ... provider_start_date = models.DateField() provider_end_date = models.DateField(blank=True, null=True) ... lots of stuff here ... def __str__(self): return '%s %s' % (self.provider_name, self.provider_code) The problem is that the code displayed in the admin.py doesn't seem to fire, and you can save the record with the end date before the start date. The Django admin interface is really an amazing feature of the framework, and I think that other people have probably also run into this problem of more advanced validations not being possible, so it would help them as well. -
django 1.11 - OperationalError no such column
I have tried to py manage.py makemigrations and then py manage.py migrate but when I add a new field to my model, this error occurs. I also have tried deleting all the migrations and doing the makemigrations and migrate things again but it still does not solve the problem. Basically I have a model Schedule and I added a Customer field in it which the relationship is customer = models.ForeignKey(Customer) EDIT: Here is my model class Schedule(models.Model): name = models.CharField(max_length=250) deadline_date = models.DateField() is_completed = models.BooleanField(default=False) description = models.CharField(max_length=1000, default="") customer = models.ForeignKey(Customer) Here is the traceback: Traceback: File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\utils.py" in execute 65. return self.cursor.execute(sql, params) File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\sqlite3\base.py" in execute 328. return Database.Cursor.execute(self, query, params) The above exception (no such column: schedule_schedule.customer_id) was the direct cause of the following exception: File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\core\handlers\exception.py" in inner 41. response = get_response(request) File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\contrib\admin\options.py" in wrapper 551. return self.admin_site.admin_view(view)(*args, **kwargs) File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\utils\decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs) File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\views\decorators\cache.py" in _wrapped_view_func 57. response = view_func(request, *args, … -
Django context processor to show images
I want show a random images in my webpage, then I made a context processor of this way (previously added in my context_processors settings ...): # -*- coding: utf-8 -*- from random import choice images_people = ['https://s3-sa-east-1.amazonaws.com/ihost-project/assets/img/bolivia2.jpg','2', 'https://s3-sa-east-1.amazonaws.com/ihost-project/assets/img/bolivia3.jpg', 'https://s3-sa-east-1.amazonaws.com/ihost-project/assets/img/bolivia4.jpg', 'https://s3-sa-east-1.amazonaws.com/ihost-project/assets/img/bolivia-children.jpg', 'https://s3-sa-east-1.amazonaws.com/ihost-project/assets/img/ElZocalo.jpg', 'https://s3-sa-east-1.amazonaws.com/ihost-project/assets/img/israel.jpg', ] def images(request): return {'images': choice(images_people)} In my template I am invoking this context_processor of this way: <div class="portrait"> <div class="img-cont" style="background: url('{{ images }}') no-repeat center; background-size:cover;"> </div> # Add caption to image <!-- <span></span> --> </div> How to can add caption to each image in my images_people list? This context_processor can be improved in the level practices sense? -
CSRF token missing or incorrect, 404
This is a widely asked question, but most of them have a different scenario, and I believe mine too. Below are my project details apps.ulrs.py: urlpatterns = [ url(r'^index/$', views.IndexView, name='index'), url(r'^signup/$', views.signupview, name='sign_up'), ] models.py: from django.db import models from django.core.urlresolvers import reverse #from django.core.urlresolvers import reverse from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver class Registration(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) username = models.CharField(max_length = 250) password = models.CharField(max_length = 250) email = models.CharField(max_length = 250) @receiver(post_save, sender=User) def update_user_profile(sender, instance, created, **kwargs): if created: Registration.objects.create(user=instance) instance.registration.save() views.py: from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login from django.contrib.auth.forms import UserCreationForm from .forms import SignUpForm #from django.corecontext_processors import csrf from django.template import RequestContext from django.shortcuts import render_to_response from django.views import generic class IndexView(generic.View): templet_name = 'user_info/index.html' def signupview(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('registration_form.html') else: form = SignUpForm() #return render(request,'user_info/registration_form.html', {'form': form}) return render_to_response('user_info/registration_form.html', {'form': form, }, context_instance = RequestContext(request)) I doing some research I came to know that we need to import "csrf" in my views.py , so I tried below: #from django.corecontext_processors import csrf … -
Adding a file through Django shell
Django 1.11.6 I am trying to save a file through Django shell. Could you have a look at the traceback and tell me what I do wrongly? Model: class ItemFile(ChecksumMixin, models.Model): item = models.ForeignKey(Item, on_delete=models.PROTECT, verbose_name=_("item")) file = models.FileField(blank=False, max_length=255, upload_to=get_item_path, verbose_name=_("file")) In the shell: from django.core.files import File f = File('/home/michael/PycharmProjects/photoarchive_4/general/static/test/text_1.pdf', 'rb') i = Item.objects.get(pk=1) ItemFile.objects.create(item=i, file=f) Traceback: Traceback (most recent call last): File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1059, in <listcomp> for obj in self.query.objs File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1058, in <listcomp> [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields] File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1008, in pre_save_val return field.pre_save(obj, add=True) File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/db/models/fields/files.py", line 296, in pre_save file.save(file.name, file.file, save=False) File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/db/models/fields/files.py", line 94, in save self.name = self.storage.save(name, content, max_length=self.field.max_length) File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/core/files/storage.py", line 54, in save return self._save(name, content) File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/core/files/storage.py", line 351, in _save for chunk in content.chunks(): File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/core/files/base.py", line 81, in chunks data = self.read(chunk_size) File "/home/michael/PycharmProjects/venv/photoarchive_4/lib/python3.6/site-packages/django/core/files/utils.py", line 16, in <lambda> read = property(lambda self: self.file.read) AttributeError: 'str' object has no attribute 'read' -
Range of dates in a django model and admin
How to register a range of dates in the model and have in admin a widget similar to this? Exemple to widget It's possible to use DateTimeField or calendar? -
Cannot connect to Heroku through cmd line
I have a Django project that I have deployed on a heroku web server and use PyCharm as my IDE. I used to be able to interact with my web server with "heroku run bash", however, now when I try running "heroku run bash" I get: ▸ stat /.local/share/heroku/client/bin/heroku: not a directory ▸ fork/exec /.local/share/heroku/client/bin/heroku: not a directory I'm not sure what has changed, but I can't seem to connect to my heroku webserver anymore. I can still push changes using git push heroku master, but any other interaction with my heroku server doesn't seem to work anymore. I've already checked with Heroku and their systems are running just fine. How do I reconnect to my heroku web server again with PyCharm? Or just in general? Thanks in advance for your help!