django

AWS Elastic Beanstalk gives “could not translate host name ”db“ to address” error

一世执手 提交于 2021-02-16 18:59:07
问题 I've been trying to deploy my docker consisted of Django, Postgresql and Nginx. It works fine when I do sudo docker-compose up However when deploy it on AWS EB, it gives me could not translate host name "db" to address: Name or service not known What I've done is I pushed my docker to docker hub using sudo docker build -t myname/dockername -f Dockerfile . and I simply do eb deploy File Structure myproject myproject settings.py urls.py ... Dockerfile Dockerrun.aws.json manage.py requirements

AWS Elastic Beanstalk gives “could not translate host name ”db“ to address” error

☆樱花仙子☆ 提交于 2021-02-16 18:57:12
问题 I've been trying to deploy my docker consisted of Django, Postgresql and Nginx. It works fine when I do sudo docker-compose up However when deploy it on AWS EB, it gives me could not translate host name "db" to address: Name or service not known What I've done is I pushed my docker to docker hub using sudo docker build -t myname/dockername -f Dockerfile . and I simply do eb deploy File Structure myproject myproject settings.py urls.py ... Dockerfile Dockerrun.aws.json manage.py requirements

How can I redirect to a different URL in Django?

天涯浪子 提交于 2021-02-16 18:51:46
问题 I have two pages, one which is to display details for a specific item and another to search for items. Let's say that the urls.py is properly configured for both of them and within views.py for my app, I have: def item(request, id): return render(request, 'item.html', data) def search(request): #use GET to get query parameters if len(query)==1: #here, I want to redirect my request to item, passing in the id return render(request, 'search.html', data) What do I do to properly redirect the

Django loaddata returns a permission denied for relation

China☆狼群 提交于 2021-02-16 18:24:05
问题 I am trying to load some data from a json file generated from a dumpdata on a django project to a new one with a new database using loaddata. The connection to the db seems to work but almost right away I receive a permission denied for relation django_content_type. I don't get what permission we are talking about. the db is postgres on a separate server and I connect to it through a vagrant virtual machine on my laptop that has a virtual environment and the settings.py has the settings to

Upload file to Django with dynamic path

老子叫甜甜 提交于 2021-02-16 15:39:07
问题 I am trying to upload files and organise the directory structure in the media folder. In specific I want the upload to create subfolders basis one of the values in the model. The issue I face is that in the view I add information to the instance (in my example code this is the relevant profile ). I would like to use this information for the subfolder, but it does not exist in my model until the save which is after the upload... What would be the appropriate approach to get the information

Upload file to Django with dynamic path

怎甘沉沦 提交于 2021-02-16 15:38:17
问题 I am trying to upload files and organise the directory structure in the media folder. In specific I want the upload to create subfolders basis one of the values in the model. The issue I face is that in the view I add information to the instance (in my example code this is the relevant profile ). I would like to use this information for the subfolder, but it does not exist in my model until the save which is after the upload... What would be the appropriate approach to get the information

Mocked unit test raises a “stop called on unstarted patcher” error

谁说胖子不能爱 提交于 2021-02-16 14:45:38
问题 When running the test bellow, I got a stop called on unstarted patcher . def test_get_subvention_internal_no_triggered_admission(self): billing_cluster = BillingClusterFactory() subvention = SubventionFactory(billing_cluster=billing_cluster) convive_sub = ConviveFactory(subvention=subvention, billing_cluster=billing_cluster) order_5 = OrderFactory(beneficiary=convive_sub) order_operation_5 = CreationOrderOperationFactory(order=order_5) with patch('orders.models.Order.subvention_triggered_same

Modelform with reverse foriegnkey

∥☆過路亽.° 提交于 2021-02-16 14:41:10
问题 I am trying to create a ModelForm for musician Model from which it must be possible to select a number of albums for each musician.Since album is reverse foreignkey i think ModelForm doesn't saves album values to the database.Is there any possible methods to get this working please help me and thanks in advance here is my modelform: class musicianForm(forms.ModelForm): album=forms.ModelMultipleChoiceField(queryset=Musician.objects.all(), widget=forms.widgets.CheckboxSelectMultiple()) class

Django-Celery in production?

风格不统一 提交于 2021-02-16 13:38:28
问题 So I've been trying to figure out how to make scheduled tasks, I've found Celery and been able to to make simple scheduled tasks. To do this I need to open up a command line and run celery -A proj beat for the tasks to happen. This works fine in a development environment, but when putting this into production that will be an issue. So how can I get celery to work without the command line use? When my production server is online, how can I make sure my scheduler goes up with it? Can Celery do

Django-Celery in production?

蹲街弑〆低调 提交于 2021-02-16 13:38:12
问题 So I've been trying to figure out how to make scheduled tasks, I've found Celery and been able to to make simple scheduled tasks. To do this I need to open up a command line and run celery -A proj beat for the tasks to happen. This works fine in a development environment, but when putting this into production that will be an issue. So how can I get celery to work without the command line use? When my production server is online, how can I make sure my scheduler goes up with it? Can Celery do