Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to get page_size set in query into pagination metadata django rest framework
I have setup custom pagination for one of my apps, the issues I am facing is the page_size shows only the default value that is set in the app but does not change according to the values sent in the query parameter. Where am I going wrong? class CustomPagination(PageNumberPagination): page_size = 10 page_size_query_param = 'page_size' def get_paginated_response(self, data): return Response({"status": True, "data": { 'results': data, "meta": { 'page_count':self.page.paginator.num_pages, 'total_results': self.page.paginator.count, 'current_page_no': self.page.number, 'limit': self.page_size, 'last_page': self.page.has_next() }}}, status=status.HTTP_200_OK) The output of page_size is always 10 even if I set the query parameter to a different value. Eg: it should change to 2 if the user set page_size =2 in the query parameters. -
django permision check box form - ACL (Access Control List)
I want to create Access Control List using permission table, similar to the image. Where I want to display permission form with a checkbox. On the check, permission should bbe given to that user and group. Please help me to create ACL. -
Query the items related to current user in template
I have two models in my Django app like the following: class Movie(models.Model): title = models.CharField() # some movie-related fields class Rating(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) movie = models.ForeignKey(Movie, on_delete=models.CASCADE) score = models.IntegerField() So users can rate any movies they want. I have also a templated named index.html and here is how I'm sending the data to this template using the views.py: def index(request): movies = Movie.objects.all() return render(request, 'index.html', {'movies': movies}) The index.html: {% for movie in movies %} {{movie.title}} <br /> # The rating score that current user has gave to this movie in the iteration {% endfor %} I've tried the following, but it displays all scores that all users have given to the movie, not only the current user: {% for rating in movie.rating_set.all %} {{rating.score}} {% endfor %} How can I display the score that current user (that is seeing the movie page) has given to the movie in the index.html page? -
Heroku does not seem to add my admin static files to static_root
This is my settings file: import os import logging import logging.config import sys import django_heroku # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'this is not my secret key' # SECURITY WARNING: don't run with debug turned on in production! # DJANGO_DEBUG must be 'true' (any case) to turn on debugging DEBUG = os.environ.get('DJANGO_DEBUG', '').lower() == 'true' ALLOWED_HOSTS = [ '*' ] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp', ] 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.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', ] ROOT_URLCONF = 'myapp.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'myapp.wsgi.application' # Database # https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/dev/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', }, ] # Internationalization # https://docs.djangoproject.com/en/dev/topics/i18n/ LANGUAGE_CODE = 'en-gb' TIME_ZONE = 'Europe/London' USE_I18N = True USE_L10N … -
Getting the list of timezones supported by PostgreSQL in Django using RawSQL
I am trying to get the list of all the timezones supported by PSQL database in my Django project, so I can validate timestamps with timezones before sending them to the the database. I asked another question and got an answer regarding the PSQL query here: How to get the list of timezones supported by PostgreSQL? Using that, I am trying to do the following: from django.db.models.expressions import RawSQL RawSQL("SELECT name, abbrev, utc_offset, is_dst FROM pg_timezone_names;", []) However, it does not seem to work. I saw the docs for RawSQL, and it usually has a model attached to it, which I can't really have. How to do solve this issue? Thanks. -
Django - ORA-01438: value larger than specified precision allowed for this column
I have a table in my Oracle database that one of her columns is a NUMBER(38,0). If I directly do an insert in the database with a number like "6688930737147338195" , the insert goes OK. But, when I use django object.save() with the number it gives me this error: django.db.utils.DatabaseError: ORA-01438: value larger than specified precision allowed for this column I ran this code in my oracle database to try fix this: ALTER TABLE XYZ MODIFY Z NUMBER(38,0); COMMIT; But the problem in Django still occurs. It gives the same error. But, for some reason, the object it's saved in the database even after this error. What should I do? -
How does Django Rest Framework serialize multi-object without using SQL Foreign key
take performance of sql server into consideration, I design the sql without using any foreign key, Instead I use the id reference to join two table. but when I use the serialization of Django Rest Framework to serialize multi-table, it's only support foreign key(is this right?). Another solution is using mysql view mapping to a django model which can represent multi joined table. In this case, I need to split GET and POST method to two separate APIView, instead of generics.ListCreateAPIView as a whole(GET for mysql view model. POST for non-myql-view model), but in restful design they are the same URI. GET /school -- mapping to mysql view for more information POST /school -- just create a new host Code: class LocationSerializer(model.Model): pass class SchoolSerializer(models.Model): pass class LocationSerializer(serializers.ModelSerializer): class Meta: model = LocationModel fields = ("region", "state", "country") class SchoolSerializer(serializers.ModelSerializer): location = LocationSerializer() class Meta: model = SchoolModel fields = ("name", "level", "location") class SchoolList(generics.ListCreateAPIView): queryset = SchoolModel.objects.all() serializer_class = SchoolSerializer class SchoolDetail(generics.RetrieveUpdateDestroyAPIView): queryset = SchoolModel.objects.all() serializer_class = SchoolSerializer -
How can i stop django background task permanently which is running parallely?
i have 3-4 django background_tasks which runs parallely,but i want to stop all tasks except a single task.i am using django background_task,which is a inbuilt library in django.how can i solve this issue? -
Can I somehow call logic from form_valid() in Django tests?
I am trying to test form for Post model creation in my simple forum application. The problem I am having is that after I try to save the form in tests I get an error NOT NULL constraint failed: forum_web_post.user_id because I am assigning the user in the form_valid() method in the view. The user is not passed via the form since the user that creates the post is the signed in user that sent the request. models.py class Post(models.Model): category = models.ForeignKey(Category, on_delete=models.PROTECT) user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=100) text = models.TextField() created_at = models.DateTimeField(auto_now=True) user is imported form django.contrib.auth.models and Category model looks like this. class Category(models.Model): name = models.CharField(max_length=100) created_at = models.DateTimeField(auto_now=True) in views.py after the user submits the form he is the redirected to his profile page views.py class PostCreate(generic.CreateView): model = Post form_class = PostForm template_name = 'forum_web/post_edit.html' def form_valid(self, form): post = form.save(commit=False) post.user = models.User.objects.get(id=self.request.user.id) post.save() return HttpResponseRedirect(reverse_lazy('forum:user_detail', kwargs={'pk': self.request.user.id})) forms.py class PostForm(ModelForm): class Meta: model = Post fields = ['category', 'title', 'text'] tests.py def test_post_form_create_should_pass(self): # this dict is in setUp() as well as the test_category but for simplicity I will include it in this method post_data = { 'category': self.test_category.pk, … -
Django admin's default autocomplete_fields combined with Chained Foreign Key of smart-selects
I am using Django 2.1.3, django-smart-selects 1.5.4 and three simple models for example Client, Billing Account and Order. What needs to be done is upon Order creation the user should choose a Client (presuming that the count of all registered clients will be a large number) as an autocomplete_field. Upon choosing Client there should be another select with all billing accounts associated for this client. In Order i have related Client as a ForeignKey and BillingAccount as a ChainedForeignKey to Client using smart-selects as following: class Order(models.Model): client = models.ForeignKey(Client, on_delete=models.PROTECT, null=True) billing_account = ChainedForeignKey(BillingAccount, chained_field="client", chained_model_field="client", show_all=False, auto_choose=True, on_delete=models.PROTECT, null=True) The problem is when the user chooses a given Client, the BillingAccount select wont autofill. Note: When Client is not associated in OrderAdmin's autocomplete_fields BillingAccount is filled as it should be with all accounts associated for this Client. -
My pre_save signal isn't applying my string generator
I wrote a simple string generator for my order_id field. I tested the generator script in shell, and it works perfectly. But when I run the server, and try to create an order in django admin, the order id field remains empty when I click save. What am I doing wrong? from datetime import date from django.db import models from django.db.models.signals import pre_save from cartapp.models import Cart class Order(models.Model): order_id = models.CharField(max_length=120) cart = models.ForeignKey(Cart, on_delete=models.CASCADE) status = models.CharField(max_length=50, default='Waiting', null=True, blank=True) order_total = models.DecimalField(default=0.0, max_digits=10, decimal_places=1) date_created = models.DateTimeField(auto_now_add=True) def order_id_generator(instance): today = date.today().strftime("%Y-%m-%d") last_order_raw = Order.objects.latest('order_id').date_created last_order_date = str(last_order_raw).split(' ')[0] if today != last_order_date: new_order_id = str(today + " 1") else: last_order = Order.objects.latest('order_id') extract = last_order.order_id.split(' ')[1] increment = int(extract) + 1 new_order_id = today + " " + str(increment) return new_order_id def pre_save_order_id(sender, instance, *args, **kwargs): if not instance.order_id: instance.order_id = order_id_generator(instance) pre_save.connect(pre_save_order_id, sender=Order) -
Incorrect django-tables2 table rendering and accessor issues
This is a two part problem. I would like to display any publications that are related to a sample, and I would like to render this publication table on the detail page for a sample. As always, any assistance is greatly appreciated. Problem 1. Rendering the table (django-tables2) When I render the table (see top row of image), a) none of the fields present themselves as hyperlinks (tables.LinkColumn) and b) the excluded fields are present in the table. While reviewing this post, I realized that I am not rendering the table I outlined in the tables/views/url!! Question 1. How do I render a table with publication objects that are related to a specific sample when the sample is a foreign key for publication model? For example, I can render the publication table as follows: #from samples/template/samples/publication_list.html {% render_table publication_table %} If I try the same code in another file I will get an error: #from samples/template/samples/sample_detail.html {% render_table publication_table %} ValueError at /samples/sample/116 ... Expected table or queryset, not str Problem 2. Hard-coding the table To get around problem 1, I hard-coded the table but cannot get the linked title_p field to go to samples/template/samples/publication_detail.html without a NoReverseMatch error. I … -
same token is getting on token request in django
Hi I am using django rest-framework, i want to implement token base authentication, i am using basic rest-framework token authentication module. but it return same token on every request. ex(87d97bb2df56e39c12b38131087bcfd232720d9a), i am getting this string on every request i sent to my server. my setting.py file INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'restApp2', # Local Apps (My project's apps) 'rest_framework', 'rest_framework.authtoken', 'rest_auth', ] REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.TokenAuthentication', # <-- And here ], } urls.py file from django.contrib import admin from django.urls import path, include from restApp2 import views from rest_framework.authtoken.views import obtain_auth_token urlpatterns = [ path('admin/', admin.site.urls), path('hello/', views.HelloView.as_view(), name='hello'), path('api-token-auth/', obtain_auth_token, name='api_token_auth'), # <-- And here ] urlpatterns += [ path('accounts/', include('django.contrib.auth.urls')), ] i am calling bellow url using post method from POSTMON. POST http://localhost:7070/rest-auth/login/ and in response i get 87d97bb2df56e39c12b38131087bcfd232720d9a. but i want different token on new request. please help me, Thank You -
Condition in Model Django
i want company_name to be unique=True when company_is_deleted=False. Similarly when company_is_deleted=True then company_name to be unique=False. Where i am using soft delete means that i am just setting company_is_deleted=True and not deleting it from database table. Company Model class Company(models.Model): company_name = models.CharField(max_length=20, unique=True) # Here company_description = models.CharField(max_length=100) company_address = models.CharField(max_length=100) company_email = models.EmailField() company_website = models.URLField() company_phone = models.CharField(max_length=30) company_monthly_payment = models.DecimalField(max_digits=5, decimal_places=2) company_logo = models.ImageField(upload_to='company_logo', default='default_company.png',blank=True, null=True) company_created = models.DateTimeField(auto_now_add=True) company_is_deleted = models.BooleanField(default=False) View.py class CompanyCreateView(LoginRequiredMixin, generic.CreateView): model = Company fields = ['company_name', 'company_description', 'company_email', 'company_website', 'company_address', 'company_phone', 'company_status', 'company_monthly_payment', 'company_logo'] -
Django-bitfield : Access a bitfield in django queryset values
I was trying to list of values of a bitfield in a django queryset but was unable to do so as i couldn't find anything related to fetching bitfield flag values. Let's say I have a field in one of my models flags = Bitfield(flags=( 'a', 'b')) now I want to use this value from a queryset is there a way to get the value in the queryset by doing something like this m=model.objects.values('flags__a__is_set') -
ReportLab: Save PDF to filesystem/server
I am working on a project in Python/Django and I am using ReportLab for PDF creation. I would like to save PDF files on my server, but I am not able to find much information about that, so I wonder if there is someone with experience of storing PDF from ReportLab to a web server? -
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10deb92f0>
Having issues running django site with python3 manage.py runserver command. When starting, I get an error below: MacBook-Pro-Lev:mysite levpolomosnov$ python3 manage.py runserver Performing system checks... Unhandled exception in thread started by <function check_errors. <locals>.wrapper at 0x10deb92f0> Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run self.check(display_num_errors=True) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check include_deployment_checks=include_deployment_checks, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks return checks.run_checks(**kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config return check_resolver(resolver) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver return check_method() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 256, in check for pattern in self.url_patterns: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 407, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 400, in urlconf_module return import_module(self.urlconf_name) File "/Library/Frameworks/Python.framework/Versions/3.6/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 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File … -
Get the list of related objects in django
I have 3 models: class Node(models.Model): ID = models.DecimalField(max_digits=19, decimal_places=10) name = models.CharField(default='node', max_length=32) connexion = models.CharField(max_length=255) # Many2one fields | Foreign keys: firm = models.ForeignKey('firme.Firme', on_delete=models.CASCADE, null=True, blank=True) class ScheduledAction(models.Model): date = models.DateTimeField(default=datetime.now, blank=True) firm = models.ForeignKey('firme.Firme', on_delete=models.CASCADE, null=True, blank=True) node_ids = models.ManyToManyField(Node) I want in ScheduledAction form to show, for a selected firm, the list of its related nodes. Normally I should do this by get: class ScheduledActionForm(forms.ModelForm): date = forms.DateTimeField() firm = forms.ModelChoiceField(queryset=Firme.objects.all()) node_ids = forms.ModelMultipleChoiceField(queryset=Node.objects.get(firm_id=firm.id), widget=forms.CheckboxSelectMultiple) class Meta: model = ScheduledAction fields = [ 'date', 'firm', 'node_ids' ] But I got this error: AttributeError: 'ModelChoiceField' object has no attribute 'id' How can I fix this? -
Django websockets auth
I use tornado + sockjs for websockets and Django rest framework for main app. Also I use rest-framework-jwt for auth on Django app. Now I have to determine user in tornado. How I see it: 1. User send jwt in message when sockjs connected to tornado server. 2. Tornado server parse jwt and determine is valid jwt or not? But for this solution I have to read database. But this operation is sync which is not good, because tornado is async. Also I thought use Celery. When user connected to tornado, tornado creats task for celery and in this task jwt will be parsed. In that case solution is not blocking tornado. But how then to notice user via websockets about check jwt? -
Changing border of group of cells in excell to thick box border with xlsxwriter
I am trying to change box border of some excell cells to "Thick Box Border". I am using django 1.9.5 and python 2.7.5 and xlsxwriter for excell. import xlsxwriter workbook = xlsxwriter.Workbook('bordertest.xlsx') worksheet = workbook.add_worksheet() format = workbook.add_format({'border': 2}) worksheet.write('B3', 'Border2', format) This is working for one cell. But i want to apply thick box border around some group of cells like below. I couldn't figure it out. I want to apply thick border to rectangle block of cells between B4-G4 & B8-G8. Between red dots the lines will be bold. But cells in the red dotted rectangle area, will be normal border. So different color group of cells will be seperated with thick border. -
Remove decimal point from number passed to django template?
I am using stripe to process payments with a django web application. The prices in the database are stored in decimal format, e.g. 100.00 Stripe takes this as $1, and ignores everything to the right of the decimal point. I need to remove the decimal point when passing this number to Stripe. Can I do this within the django template? -
Django - Supervisor : exited too quickly gunicorn-error.log(ValueError: Empty module name)
I'm fairly new to coding, this is my first deployment. I'm following this guide for deployment on digitalocean. When running sudo supervisorctl status mhh I get this error Exited too quickly (process log may have details) and log/gunicorn-error.log contains following [3000] [ERROR] Exception in worker process Traceback (most recent call last): File "/home/victor/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/home/victor/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 129, in init_process self.load_wsgi() File "/home/victor/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi self.wsgi=self.app.wsgi() File "/home/victor/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable=self.load() File "/home/victor/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load return self.load_wsgiapp() File "/home/victor/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp return util.import_app(self.app_uri) File "/home/victor/local/lib/python2.7/site-packages/gunicorn/utils.py", line 350, in import_app __import__(module) ValueError:Empty module name Here are the relevent config /home/victor/bin/gunicorn_start #!/bin/bash NAME="mhh" DIR=/home/victor/mhh USER=victor GROUP=victor WORKERS=3 BIND=unix:/home/victor/run/gunicorn.sock DJANGO_SETTINGS_MODULE=mhh.settings DJANGO_WSGI_MODULE=mhh.wsgi LOG_LEVEL=error cd $DIR source ../bin/activate export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE export PYTHONPATH=$DIR:$PYTHONPATH exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \ --name $NAME \ --workers $WORKERS \ --user=$USER \ --group=$GROUP \ --bind=$BIND \ --log-level=$LOG_LEVEL \ --log-file=- /etc/supervisor/conf.d/mhh.conf [program:mhh] command=/home/victor/bin/gunicorn_start directory=/home/victor/mhh/mhh user=victor autostart=true autorestart=true redirect_stderr=true stdout_logfile=/home/victor/logs/gunicorn-error.log -
"error": "invalid_client" django-oauth-toolkit
I am using django rest framework with django-oauth-toolkit. When i request access token on my localhost it gives me the access token as shown below ~/django_app$ curl -X POST -d "grant_type=password&username=<Your-username>&password=<your-password>" -u"<client-id>:<client-secret>" http://localhost:8000/o/token/ {"access_token": "8u92BMmeZxvto244CE0eNHdLYWhWSa", "expires_in": 36000, "refresh_token": "faW06KKK71ZN74bx32KchMXGn8yjpV", "scope": "read write", "token_type": "Bearer"} But when i request the access token from the same project hosted on live server, it give me error as invalid_client. ~/django_app$ curl -X POST -d "grant_type=password&username=<Your-username>&password=<your-password>" -u"<client-id>:<client-secret>" http://<your-domain>/o/token/ { "error": "invalid_client" } I am not able to understand where is the problem coming from. I have searched a lot and didn't find the right answer. Please advise me what to do to get rid of this error. -
Displaying dynamic data in google barchart using django and jquery
I have a table with a long list of ward number and other data. Many of the ward number are duplicates. I want to display the list of ward number without any duplicate ward number in x-axix and the sum of repeated ward number in y-axis. I'm unable to display the json data in barchart. I pass json data from view to template as given below: Array(52)0: {ward_no: "9"}1: {ward_no: "11"}2: {ward_no: "5"}3: {ward_no: "12"}4: {ward_no: "1"}5: {ward_no: "10"}6: {ward_no: "11"}7: {ward_no: "12"}8: {ward_no: "14"}9: {ward_no: "11"}10: {ward_no: "1"}11: {ward_no: "11"}12: {ward_no: "13"}13: {ward_no: "11"}14: {ward_no: "2"}15: {ward_no: "9"}16: {ward_no: "5"}17: {ward_no: "5"}18: {ward_no: "6"}19: {ward_no: "7"}20: {ward_no: "1"}21: {ward_no: "2"}22: {ward_no: "1"}23: {ward_no: "12"}24: {ward_no: "3"}25: {ward_no: "3"}26: {ward_no: "4"}27: {ward_no: "1"}28: {ward_no: "2"}29: {ward_no: "3"}30: {ward_no: "8"}31: {ward_no: "2"}32: {ward_no: "5"}33: {ward_no: "2"}34: {ward_no: "3"}35: {ward_no: "2"}36: {ward_no: "12"}37: {ward_no: "11"}38: {ward_no: "11"}39: {ward_no: "11"}40: {ward_no: "11"}41: {ward_no: "4"}42: {ward_no: "11"}43: {ward_no: "11"}44: {ward_no: "11"}45: {ward_no: "11"}46: {ward_no: "11"}47: {ward_no: "11"}48: {ward_no: "11"}49: {ward_no: "11"}50: {ward_no: "11"}51: {ward_no: "11"}length: 52__proto__: Array(0) Models.py class NewRegistration(models.Model): fiscalyear = models.ForeignKey(system_settings.models.FiscalYear) registration_date = models.DateField(max_length=20) date_and_time = models.DateTimeField(auto_now_add=True) houseowner_name_np = models.CharField(max_length=50) ward_no = models.ForeignKey(system_settings.models.Wardno) construction_type = models.ForeignKey(system_settings.models.ConstructionType) cen = models.IntegerField() is_forwarded = models.BooleanField(default=False) … -
Can't deploy django app with django-allauth to heroku
When I want to deploy my Django app to heroku with git push heroku master, I got an error like this: remote: -----> Python app detected remote: ! No 'Pipfile.lock' found! We recommend you commit this into your repository. remote: -----> Installing pip remote: -----> Installing python-3.6.7 remote: -----> Installing dependencies with Pipenv 2018.5.18… remote: Installing dependencies from Pipfile… remote: -----> Installing SQLite3 remote: -----> $ python manage.py collectstatic --noinput remote: Traceback (most recent call last): remote: File "manage.py", line 15, in <module> remote: execute_from_command_line(sys.argv) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line remote: utility.execute() remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute remote: django.setup() remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup remote: apps.populate(settings.INSTALLED_APPS) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate remote: app_config = AppConfig.create(entry) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create remote: module = import_module(entry) remote: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module remote: return _bootstrap._gcd_import(name[level:], package, level) remote: File "<frozen importlib._bootstrap>", line 994, in _gcd_import remote: File "<frozen importlib._bootstrap>", line 971, in _find_and_load remote: File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked remote: ModuleNotFoundError: No module named 'allauth' remote: remote: ! Error while running '$ python manage.py collectstatic --noinput'. remote: See traceback above for details. remote: remote: You may need to update …