Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Image not getting displayed - HTTP/1.1" 404 2665 Warning
The profile page is not displaying the profile image which is uploaded using upload_to function in models.py def upload_to(instance, filename): return 'users/%s/%s' % (instance.user, filename) ImageField --> img = models.ImageField(upload_to=upload_to, blank=True, db_index=True) url used for the user_profile is url(r'^users/(?P<username>[\w-]+)/$', views.user_profile, name='profile'), the html page for user_profile.html is something like this <li> I am The Image <img src="{{ image }}" alt="img"> </li> the views.py ----> @login_required def user_profile(request, username): image = request.user.profile.img image = str(image) image = image.strip('users/%s' % username) return render(request, 'user_profile.html', {'username': request.user.username, 'image': image}) The url showed in the server console is /users/rony/f4098984_Kgo0lqi.jpg HTTP/1.1" 404 2665 in the above block code when clicked on the jpg image link mentioned above the image is available at the mentioned link but still the image is not getting displayed in the webpage the github issue link is provided below. https://github.com/bikirandas/OmexOnline/issues/2 -
Datetimes and optimization
The app I'm trying to create will let the user start a timer, stop it and store the history of that. I guess I could use DateTimeField, but I have some questions on its efficiency: -Supposing the timer gets started and stopped 100 times in one year, does Django store 100 times the same year? In case he does, would be considered more efficient to have a Month class pointing to a Year class with a ForeignKeyField? -I know that I can select specific attributes like datetime.datetime.now().year, but what if I want them all but one? Is there a way to exclude them? Supposing I don't care about storing seconds, would it be worth to exclude them for the sake of efficiency? -If I want to track the date at which the timer stops, would it be more efficient to only use an IntegerField to store timedelta relative to when the timer started, and then have a method to calculate it, or should I just go with two DateTimeField, one for when the timer starts and one for when the timer stops? I'm kinda obsessed with efficiency, so I'd like to know when it makes sense and when it's just … -
Django app goes haywire when deployed. Race conditions?
I wrote a django app for quizzing, and it checks the user's answers and updates scores as soon as the user submits an answer. Here is the corresponding view to do this - def check_answer(request): current_user = request.user current_team = Team.objects.get(user = current_user) current_score = current_team.score if request.method == "POST": answer = request.POST.get('answer') question = Question.objects.get(id = current_question_key) if answer == question.answer: if question in current_team.questions_answered.all(): #This is required to prevent the score from increasing if the somebody submits a correct answer to the same question more than once pass else: current_team.score = current_score + question.score_increment current_team.questions_answered.add(question) current_team.save() else: # This is required to prevent the score from decreasing if someone has answered it correctly earlier if question in current_team.questions_answered.all(): pass else : current_team.score = current_score - question.score_increment//negative_marking_factor current_team.save() return HttpResponse(status=204) #This means that the server has successfully processed the request and is not going to return any data. else: return HttpResponse("Error404") When tested on django's development server, this worked perfectly fine even when around 10 people were using it simultaneously. But, as soon as I tried to serve it with nginx (hosted on my laptop, with 5 simultaneous users), the app went totally haywire and even correct answers were … -
Handling RACE CONDITION in Docker containers of a django app which include postgres,nginx,celery,redis,elasticsearch
I am new with docker. I am having trouble with multiple containers deploy at a same time, it's occurring race condition. Every time I enter docker-compose up --build command elasticsearch or redis starts first and database starts and exits with error code 0 as well as celery and nginx. I tried using "sleep" command, but no luck(maybe I missed something). Here is my docker-compose.yml file - version: "3" services: db: image: postgres:9.6-alpine container_name: myblogdb environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=password - POSTGRES_DB=mydb volumes: - myblogdb_data:/var/lib/postgresql/data/ ports: - "4949:5432" web: build: ./app command: sh -c "gunicorn djangoApp.wsgi:application --bind 0.0.0.0:8000" volumes: - ./app:/usr/src/app/ - my_blog_static_volume:/usr/src/app/djangoApp/settings/staticfiles - my_blog_media_volume:/usr/src/app/mediafiles ports: - "8000:8000" depends_on: - db - redis - es nginx: restart: always build: ./nginx volumes: - my_blog_static_volume:/usr/src/app/djangoApp/settings/staticfiles - my_blog_media_volume:/usr/src/app/mediafiles ports: - "1337:80" depends_on: - web redis: image: "redis:alpine" es: image: elasticsearch:5.6.15-alpine environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms256M -Xmx256M" volumes: - my_blog_esdata:/usr/share/elasticsearch/data/ ports: - "9200:9200" celery: restart: always build: ./app command: sh -c "celery -A djangoApp worker -l info" volumes: - ./app:/usr/src/app/ depends_on: - db - redis - web celery-beat: restart: always build: ./app command: sh -c "celery -A djangoApp beat -l info" volumes: - ./app:/usr/src/app/ depends_on: - db - redis - web volumes: myblogdb_data: … -
Django: Check the data in a Django-admin form
Hello I have 2 models Sight and SightPic, The problem is that I want to make validation that will submit the form in only certain rules. I want to have only one picture to be is_front ==True and make validation of the form if there are more than one or none to throw an error In My clean functuion if I print(len(images.filter(is_front=True))) It will show me data that is not the data in the form but the data in the database (Which is normal) how can I check the data in the form? models.py class Sight(models.Model): name=Charfield(...) description=Charfield(...) ... class SightPicture(models.Model): sight=ForeignKey(Sight) picture=ImageField(...) is_front=BooleanField Admin.py class SightPicInline(admin.TabularInline): model = SightPic fields = ("image_tag", "picture", "is_front") readonly_fields = ("image_tag",) class SightAdmin(admin.ModelAdmin): model = Sight inlines = [SightPicInline, ...., ....] admin.site.register(Sight, SightAdmin) -
How to setup JupyterHub with Django?
I'm trying to build a Django web application that will have Jupyter notebook through the JupyterHub server embedded within the app, where users could login via the app and can access the notebook once they are in. I'm trying to use OAuth2 where JupyterHub verifies the authenticated users that Django provides. I am using django-oauth-toolkit for the authentication service and linking it using DjangoOAuthentication. I have the DjangoOAuthenticator oauth_callback_url linked to 'http://localhost:8081/hub/oauth_callback' I have the Redirect uris (on Django) linked to 'http://localhost:8081/hub/oauth_callback' I get: 404 : Not Found Jupyter has lots of moons, but this is not one... [I 2019-03-18 16:28:54.195 JupyterHub oauth2:82] OAuth redirect: 'http://localhost:8081/hub/oauth_callback' [I 2019-03-18 16:28:54.198 JupyterHub log:158] 302 GET /hub/oauth_login?next= -> localhost/oauth2/authorize?client_id=zkn2mFYhhNcs3bDTnwIWK0mDuLBdLAe2eMENE5Xa&response_type=code&state=[secret]&redirect_uri=http%3A%2F%2Flocalhost%3A8081%2Fhub%2Foauth_callback (@127.0.0.1) 3.94ms [W 2019-03-18 16:28:54.230 JupyterHub log:158] 404 GET /hub/localhost/oauth2/authorize?client_id=zkn2mFYhhNcs3bDTnwIWK0mDuLBdLAe2eMENE5Xa&response_type=code&state=[secret]&redirect_uri=http%3A%2F%2Flocalhost%3A8081%2Fhub%2Foauth_callback (@127.0.0.1) 17.81ms The URL it goes to: http://localhost:8081/hub/localhost/oauth2/authorize?client_id=zkn2mFYhhNcs3bDTnwIWK0mDuLBdLAe2eMENE5Xa&response_type=code&state=eyJzdGF0ZV9pZCI6ICJlZTA0MmRiYmU4YTY0ZmIxYTk0ODU0MjFiMzhhMWYwOCIsICJuZXh0X3VybCI6ICIifQ%3D%3D&redirect_uri=http%3A%2F%2Flocalhost%3A8081%2Fhub%2Foauth_callback I believe I have either the oauth_callback_url or the redirect_uri on Django set up wrong. Note: My question is not a duplicate of Use Django OAuth2 provider with JupyterHub. We have different errors. Thank you. -
Get multiple primary keys from Queryset
I need help fetching multiple primary keys from a queryset. I am developing a webapp wherein when a user selects a task from checkboxes, that task's description is shown. I want to display multiple descriptions if there are multiple selections. The code I did currently shows only one because I have set obj[0].pk. This is my guess. I want to show multiple task descriptions. Here is my views.py: @login_required def view_task_description(request): if request.method == 'POST': task_description = GetTaskDescription(data=request.POST, user=request.user) if task_description.is_valid(): obj = GetTaskDescription.get_task_description(task_description) print obj return redirect('get_task_description', pk=obj[0].pk) return render(request, 'todoapp/select_task_description.html', context={'view_tasks': GetTaskDescription(user=request.user)}) @login_required def get_task_description(request, pk): obj = get_object_or_404(Task, pk=pk) return render(request, 'todoapp/task_desc.html', context={'description': obj.description}) Here is my forms.py: class GetTaskDescription(forms.Form): get_tasks = forms.ModelMultipleChoiceField( queryset=Task.objects.none(), widget=forms.CheckboxSelectMultiple, required=True ) def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') super(GetTaskDescription, self).__init__(*args, **kwargs) self.fields['get_tasks'].queryset = self.user.task_set.all() def get_task_description(self): tasks = self.cleaned_data['get_tasks'] return tasks Here is my select_task_description.html: {% extends 'todoapp/base.html' %} {% block title %}Select a Task{% endblock %} {% block content %} <form method="post" action="{% url 'view_task_description' %}" name="view_task_description"> {% csrf_token %} {{ view_tasks }} <br/> &nbsp;&nbsp;<input type="submit" name="view_description" value="View Description"> &nbsp;&nbsp;<button onclick="location.href='{%url 'dashboard' %}?name=Go back'" type="button">Go back</button> </form> {% endblock %} Here is my task_desc.html: {% extends 'todoapp/base.html' %} {% block … -
django when a new model field is added showing error
Previously the class is class room(models.Model): name = models.CharField(max_length=60) r = models.IntegerField() c = models.IntegerField() total = models.IntegerField() inv1 = models.CharField(max_length=60, default = 'None') inv2 = models.CharField(max_length=60, default = 'None') inv3 = models.CharField(max_length=60, default = 'None') I added t = models.IntegerField() to it. When migrate, it is showing the error ValueError: invalid literal for int() with base 10: 'None' Kindly help me -
Getting attribute error : module 'matplotlib.pyplot' has no attribute 'canvas'
plt.figure(figsize=(8, 8)) sns.heatmap(conf_matrix, annot=True, fmt="d"); plt.title("Confusion matrix") plt.ylabel('True class') plt.xlabel('Predicted class') html_fig = mpld3.fig_to_html(plt,template_type='general') plt.close(plt) Code in HTML file to fetch the image : <div id="fig_container"> {{ div_figure|safe }} </div> Using latest versions of Python and Django. On executing the attribute error is displayed (module 'matplotlib.pyplot' has no attribute 'canvas'). I am new to it and unable to resolve the error. Please help!!! -
Jenkins create only one database when django settings have two
Django settings file have details of 2 databases. While running the tests from Django test, it creates 2 databases before running the tests. But the same is executed in Jenkins, it says "Creating test database for alias 'default'..." then start executing the tests. This results in the failure of tests where the second db is mentioned. Not able to make jenkins create the second db also before starting the test. Please help. -
Select which radio button is checked based from database value Django
I have an html table which is populated based from the value in database. How can i set which radio button is selected based from the database value in form load. I have tried the code below but it is not checking anything. Thanks <table class="table table-bordered table-hover table-sm"> <thead class="thead-light"> <tr> <th scope="col"><h4>Id</h4></th> <th scope="col"><h4>Requirement Name</h4></th> <th scope="col"><h4>Remarks</h4></th> <th scope="col"><h4>Date Promised</h4></th> <th scope="col"><h4>Completed</h4></th> </tr> </thead> <tbody> {% for req in requirements %} <tr> <th><input type="hidden" name="requirements_id_{{req.pk}}" value="{{ req.pk }}"><span>{{ req.pk }}</span></th> <th><span>{{ req.requirement }}</span></th> <th><textarea rows="1" cols="35" name="requirements_remarks_{{req.pk}}">{{ req.remarks }}</textarea></th> <th><input type="date" name="requirements_date_promised_{{req.pk}}" value="{{ req.date_promised|date:'Y-m-d' }}"></th> <th><input type="radio" name="requirements_completed_{{req.pk}}" value="{{ req.completed }}"> No <input type="radio" name="requirements_completed_{{req.pk}}" value="{{ req.completed }}"> Yes</th> </tr> {% endfor %} </tbody> </table> -
Django Model Object level permission to users
I have two types of users Superadmin, staff/manager. And I have a model called Company class Company(models.Model): name = models.CharField(max_length=100) website = models.CharField(max_length=200) employee_count = models.IntegerField(null=True, default=0) Managers are allowed to add companies and I'm using Django admin to do this job. Consider two managers are there: managerX, managerY managerX created CompanyA, CompanyB, CompanyC managerY created CompanyD, CompanyE The use case I want to achieve from this is: when the managerX login to the admin site and click on company model, only CompanyA, CompanyB, CompanyC, should be visible when the managerY login to the admin site and click on company model, only CompanyD, CompanyE should be visible When super admin login to the admin site and click on company model he can see all companies The thing I want to achieve here is object level restriction to the user inside a model. -
Fetch multiple checkbox values from a form
I am developing a webapp which displays checkboxes for tasks. On selecting the task and submitting, the task description is showed. However, the code I have written shows only for one and not multiple. Kindly help me out. Below is my code Here is my urls.py: url(r'^view_task_description/$', views.view_task_description, name='view_task_description'), url(r'^view_task_description/(?P<pk>[0-9]+)/$', views.get_task_description, name="get_task_description"), Here is my views.py: @login_required def view_task_description(request): if request.method == 'POST': task_description = GetTaskDescription(data=request.POST, user=request.user) if task_description.is_valid(): obj = GetTaskDescription.get_task_description(task_description) return redirect('get_task_description', pk=obj[0].pk) return render(request, 'todoapp/select_task_description.html', context={'view_tasks': GetTaskDescription(user=request.user)}) @login_required def get_task_description(request, pk): obj = get_object_or_404(Task, pk=pk) return render(request, 'todoapp/task_desc.html', context={'description': obj.description}) Here is my forms.py: class GetTaskDescription(forms.Form): get_tasks = forms.ModelMultipleChoiceField( queryset=Task.objects.none(), widget=forms.CheckboxSelectMultiple, required=True ) def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') super(GetTaskDescription, self).__init__(*args, **kwargs) self.fields['get_tasks'].queryset = self.user.task_set.all() def get_task_description(self): tasks = self.cleaned_data['get_tasks'] return tasks -
Django admin Inline initial list comes populated for existing objects as well
I have a model Candidate which has an inline model Academic. For the TabularInline which is displayed within the CandidateAdmin, I show prefilled formset values if a new entry is being added. It is to help ease out the backend data entry job. In case an existing entry is being updated, this prefilled formset will not have any initial values and would only show the Academic entries saved in DB within the TabularInline. The issue is that for existing objects in the change view, the AcademicInline again shows initial data which should actually not be shown. Within the get_formset method, I am checking if obj is present and based on that I am deciding whether to send prefill data or not. Even though initial_list does not get populated for existing objects, the formset for existing objects have Academic entries from DB as well as the initial data. Below is the admin.py code for reference admin.py class AcademicInline(admin.TabularInline): model = Academic form = AcademicForm formset = AcademicInlineFormSet fields = ('passing_year', 'school', 'academic_type') can_delete = False def get_extra(self, request, obj=None, **kwargs): # Performs some checks on how many extra to display # If obj present will return 0 extras count # else … -
Passing URL pk to django modelform (django 1.4)
I want to pass the url pk in my modelform which has 2 foreign keys then make it as a filter on my field queryset. how will i do that? class myForm(forms.ModelForm): def __init__(self,*args, **kwargs): super(OrderReceivingForm, self).__init__(*args, **kwargs) for field in self.fields: self.fields['field1'].queryset = myModel1.objects.filter(Order=pk) self.fields['field2'].queryset = myModel2.objects.filter(Order=pk) this is my view def order(request,pk): myFormSet = modelformset_factory(OrderModel, form=myForm,)) if request.method == 'POST': forms = myFormSet (request.POST) if forms.is_valid(): for form in forms: order = form.save(commit=False) order.save() return HttpResponseRedirect('/foo/') form = myFormSet (queryset=OrderModel.objects.None()) return render(request, 'foo/order.html', {'form': form}) this is my url url (r'^foo/(?P[\w-]+)/', views.order), thank you in advance. -
Django Generic Create and Update View
I'm new to Django so any help would be appreciated. Here's my situation. I have a model Patient and I have classed based view for create, update, delete, details. They all are working perfectly. Now I have a dashboard where i am displaying patients details in datatable (like name, age, address etc), I also have a button which is supposed to add report for the patient (like lab tests- Urine test, Stool tests) etc. I successfully created create view but I am not being able to create update view. What I am looking for is when user clicks in report button in dashboard, it would be great if i could display create view if the report hasn't been added else display update view. I know in plain programming world, i could do database query and generate url accordingly but I am not sure how it's done in django. class CliaCreate(SuccessMessageMixin, CreateView): model = Clia fields = ['clia_ft3', ...[other fields]..., 'clia_cea', ] #success_url = reverse_lazy('labreport_create') success_message = "Record added successfully" def dispatch(self, request, *args, **kwargs): self.patient = get_object_or_404(Patient, pk=kwargs['patient_id']) return super().dispatch(request, *args, **kwargs) def form_valid(self, form): form.instance.patient = self.patient return super().form_valid(form) CreateView is working. I don't how should i write create/update … -
Separate Email Model from AbstractBaseUser Custom User Model
I was interested in breaking out the email field from AbstractBaseUser in my custom User implementation into its own model. The thought is I can require users to sign up by providing an email address and then once they verify I can go ahead and write the user entry creation to the User table. However, I'm running into an error with django/db/models/fields/related_descriptors.py when I try to make a superuser (I've already customized UserManager to not normalize_email on my email foreign key). The error reads: ValueError: Cannot assign "1": "User.email" must be a "Email" instance I'm not sure how to fix this error in particular and any help would be appreciated. Below is my implementation: *Also, is breaking the email out into its own table needlessly complex? Models.py from django.db import models from django.contrib.auth import get_user_model from django.contrib.auth.models import PermissionsMixin #, UserManager from django.contrib.auth.validators import UnicodeUsernameValidator from django.contrib.auth.base_user import AbstractBaseUser from django.core.validators import EmailValidator, MinLengthValidator from django.core.mail import send_mail from django.utils import timezone from django.utils.translation import gettext_lazy as _ from .utils import CustomUsernameValidator, username_blacklist_validator from .managers import EmailManager, UserManager from phonenumber_field.modelfields import PhoneNumberField from enum import Enum def avatar_upload_to(instance, filepath): return 'user_images/{username}/avatar/{filepath}'.format(username=instance.user.id, filepath=filepath) class GenderChoice(Enum): """Subclass of Enum for gender profile … -
How to enforce Unique together on a foreign_key and filefield
Hi i have a Django model which i want to implement unique_together of 'name' and 'image'. I'd implemented unique_together, however when i do a post call with the same name and same image, it doesn't validate. i expect it to validate 'name' and 'image name' to be unique together Please help. Thanks class testingModel(models.Model): def image_upload_to(self, filename): return os.path.join('test', str(self.name.uuid), filename) def Meta(): unique_together('name', 'image') uuid = models.UUIDField( default=py_uuid.uuid4, editable=False, db_index=True) image = models.ImageField(upload_to=image_upload_to, max_length=100) name = models.ForeignKey( 'test.name', on_delete=models.PROTECT, related_name='names') -
How can I Integrate swagger for class based views in django?
I created an API using simple function based views and used marshmallow for schema validation. API views is mentioned below : class CreateInfo(ResourceListView): """ description: This API deletes/uninstalls a device. parameters: - name: name type: string required: true location: form - name: bloodgroup type: string required: true location: form - name: birthmark type: string required: true location: form """ schema_class = CreateInfoSchema def post(self, request, *args, **kwargs): self.req_data["cattle_type"] = CType.objects.get(name=self.req_data.get("c_type")) Comp.objects.create( **self.req_data ) response_dict = build_response_dict( response_type="POST", response_text="C information updated successfully" ) return JsonResponse(self.make_response(data=response_dict), status=201) I have implemented normal django View in ResourceListView and not using DRF APIView. All the solution that I am coming across on net is implemented using APIView and if I use APIView, it works fine. How can I integrate swagger for the above case. -
Should there be auth on communtity website?
I'm enhancing the website architecture for an open-source community. I want to provide some options(or features) to authenticated users only because an open-source community always contains thousands of members which leads to a chance of spamming. I'm adding OAuth using GitHub which can prevent user spamming. All I would like to know whether should I add OAuth on an open-source community website or not? Is it a good practice? or there is some another way I should do to prevent user-spam? I want to prevent spamming, for example, user-2 can not update the profile of user-1 (just an example don't want to achieve this task) -
The view getdata.views.getview didn't return an HttpResponse object. It returned None instead
I'm trying to make a form in django. First it was not creating object of the form then it was not saving the data and now I'm getting "The view getdata.views.getview didn't return an HttpResponse object. It returned None instead." error. This is my views.py file def getview(request): if request.method == 'POST': form1 = ro_input_form(request.POST) if request.method == "POST" and form1.is_valid(): form1 = ro_input_form(request.POST) form1.origin = form1.cleaned_data['origin'] form1.destination = form1.cleaned_data['destination'] # form1. = form1.cleaned_data['time_window'] print(form1.origin, form1.destination, form1.time_window) form1.save() form1 = ro_input_form() return render(request, 'inputform.html', {'form1': form1}) This is my html file : <form method="Post"> {% csrf_token %} {{form1}} <input type="submit" class="forform" value="sumbit values"> </form> -
File to import not found or unreadable: bootstrap-sass
Trying out Django Shop. Following this tutorial: https://django-shop.readthedocs.io/en/stable/tutorial/intro.html (stable). When I run the server and open localhost, here's what I see: Error: File to import not found or unreadable: bootstrap-sass/assets/stylesheets/bootstrap/variables. Parent style sheet: /home/vm/PycharmProjects/Django-shop/django-shop/shop/static/shop/css/_variables.scss on line 1 of ../shop/static/shop/css/_variables.scss >> @import "bootstrap-sass/assets/stylesheets/bootstrap/variables"; I presume, this "bootstrap-sass" directory is supposed to be in "css" and I don't see it there. -
How can I use checkbox selected values in Django query parameters?
I am developing a webapp and its works in the manner that when users selects values from a checkbox, its description is displayed. I am currently calling a function which in turn will call another function, I am doing so as I want to use GET instead of POST because since there is no server side alteration hence GET is better instead of POST. How can I achieve this using a single function using GET and query parameters ? Below is my code. Here is my urls.py: url(r'^view_task_description/$', views.view_task_description, name='view_task_description'), url(r'^view_task_description/(?P<pk>[0-9]+)/$', views.get_task_description, name="get_task_description"), Here is my views.py: @login_required def view_task_description(request): if request.method == 'POST': task_description = GetTaskDescription(data=request.POST, user=request.user) if task_description.is_valid(): obj = GetTaskDescription.get_task_description(task_description) return redirect('get_task_description', pk=obj[0].pk) return render(request, 'todoapp/select_task_description.html', context={'view_tasks': GetTaskDescription(user=request.user)}) @login_required def get_task_description(request, pk): obj = get_object_or_404(Task, pk=pk) return render(request, 'todoapp/task_desc.html', context={'description': obj.description}) Here is my forms.py: class GetTaskDescription(forms.Form): get_tasks = forms.ModelMultipleChoiceField( queryset=Task.objects.none(), widget=forms.CheckboxSelectMultiple, required=True ) def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') super(GetTaskDescription, self).__init__(*args, **kwargs) self.fields['get_tasks'].queryset = self.user.task_set.all() def get_task_description(self): tasks = self.cleaned_data['get_tasks'] return tasks -
Gcloud app deploy fails using python+django+gunicorn + worker failed to boot
I am trying to deploy a website/webapp using django... constructed app.yaml and requirements.txt... everything done and when I hit gcloud app deploy , I have this following error log at the end.. DONE ----------------------------------------------------------------------------------------------------------------------------------------- Updating service [default] (this may take several minutes)...failed. ERROR: (gcloud.app.deploy) Error Response: [9] Application startup error: [2019-03-18 03:14:29 +0000] [1] [INFO] Starting gunicorn 19.9.0 [2019-03-18 03:14:29 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2019-03-18 03:14:29 +0000] [1] [INFO] Using worker: sync [2019-03-18 03:14:29 +0000] [9] [INFO] Booting worker with pid: 9 [2019-03-18 03:14:29 +0000] [9] [ERROR] Exception in worker process Traceback (most recent call last): File "/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 129, in init_process self.load_wsgi() File "/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi self.wsgi = self.app.wsgi() File "/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load return self.load_wsgiapp() File "/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp return util.import_app(self.app_uri) File "/env/local/lib/python2.7/site-packages/gunicorn/util.py", line 350, in import_app __import__(module) ImportError: Import by filename is not supported. [2019-03-18 03:14:29 +0000] [9] [INFO] Worker exiting (pid: 9) [2019-03-18 03:14:29 +0000] [1] [INFO] Shutting down: Master [2019-03-18 03:14:29 +0000] [1] [INFO] Reason: Worker failed to boot. here is my app.yaml runtime: python api_version: 1 threadsafe: true # the … -
GO web development over Spring/Django/PHP
Go web development is preferred over PHP/Ruby/Python/Java/Elixir/Erlang/.NET for web development Google uses GO lang for its web services. GO is also used in implementation of PAAS layers like Pivotal Cloud Foundry Complex type system in Java/C++, Modern C++ compiler has to still support old style C++ legacy code, slow compile times of C/C++ code due to memory efficient C/C++ compiler design, C/C++/Java/Python came with patching multi threading feature as these languages were introduced in times where single-thread was common & Slowness of Python has made co-inventor of UNIX operating system design introduce GO lang GO programmers don't need to worry about building & managing complex type hierarchies. GO is well suited for small scripts over Python. GO is well suited for system programming over C/C++. GO has fast compile times. Like java, GO generates a single artifact which ease version management(unlike C/C++/JavaScript). GO compile to high performance machine code. Why GO is well suited for server code? What are the advantages in web development using GO lang?