Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Overflow after inserting image in column
I know this is a one setting issue but I'm quite new and don't know what the exact terminology to get the answer i'm looking for. I'm using Bootstrap CSS 3.3.7 on Django 1.11 When I insert an image the first column and row I get an overflow into the second column. With image Columns without image works correctly. <div class="tab-content"> <div class="tab-pane active" id="{{vg.grouper.id}}{{fg.grouper.id}}hari_ini"> <div class="row"> {% for sg in show_list2 %} {% if sg.grouper %} {% for sh in sg.list %} <div class="col-xs-3 col-xs-spl col-xs-npr"> <div class="contain"> {% load static %} {% ifchanged %} {% static sh.film.poster %}' width= 100% /> {% endifchanged %} </div> </div> <div class="col-xs-3 col-xs-npl col-xs-npr"> <div class="content"> <ul> <li> <p class=p1>{{ sh.show_time_today }}</p> </li> </ul> </div> </div> <div class="col-xs-3 col-xs-npl col-xs-npr"> <div class="content"> <ul> <li> <p class=p1>{{ sh.rps_price }}</p> </li> </ul> </div> </div> <div class="col-xs-3 col-xs-npl col-xs-npr"> <div class="content"> <ul> <li> <p class=p1>{{ sh.rps_price }}</p> </li> </ul> </div> </div> {% endfor %} {% endif %} {% endfor %} </div> </div> I've tried the css below which does not help. .contain { height: /* max height you want */ width: 95% /* max width you want */ overflow: hidden; } I've tried adding a … -
unknown BadRequestError - No exception message supplied- Django - SynapseAPI
I am getting an error and i have no idea what it means in relation to the project that I am working on. I am trying to create a user though the synapse api. After a profile is created, I want to call the method that creates the user and grab information from the newly created profile within the application, to create a user in the synapse api. The error I am getting is a lack of exception message. I have no idea what this means or how to fix it. can anyone help me. Here is the code that I have. Here is the profile processing and the call to create the user is at the bottom of the snippet: cd = form.cleaned_data first_name = cd['first_name'] last_name = cd['last_name'] dob = cd['dob'] city = cd['city'] state = cd['state'] phone = cd['phone'] privacy = cd['privacy'] ssn = cd['ssn'] # this is the new record that is going to be created and saved new_profile = Profile.objects.create( user = currentUser, first_name = first_name, last_name = last_name, dob = dob, city = city, state = state, phone = phone, privacy = privacy, ) # createUserDwolla(request, ssn) # searchUserDwolla(request) createUserSynapse(request) return redirect('home_page') Here is … -
Hello everybody. I would like to ask you How i can connect and implement websockets with django?
I would like to use websockets for my projects , but i have no idea what do i need to do. I use django for back end. how I can combine them.? this is the only question i have. thanks guys.) -
Wordpress on subdirectory of django site via alias in virtual host
I'm trying to run wordpress on the /blog subdirectory of my main django site. I tried many things but no matter what, I keep getting the 404 page of the root site when I go to example.com/blog. For some reason the server isn't picking up the alias... Here is the code from my default virtual host file: Alias /blog "/var/www/blog" <Directory "/var/www/blog"> Options FollowSymLinks AllowOverride All </Directory> and in my .htaccess I have RewriteBase /blog/ Any idea what the problem could be? Thanks ahead of time -
TypeError: __init__() missing 1 required positional argument: 'get_response'
when i run my server python3 manage.py runserver the browser returns A server error occurred. Please contact the administrator. then i get this error `Traceback (most recent call last): File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__ return self.application(environ, start_response) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/wsgi.py", line 170, in __call__ self.load_middleware() File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 52, in load_middleware mw_instance = mw_class() TypeError: __init__() missing 1 required positional argument: 'get_response' my settings file is like that INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'accounts', ] MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'web.middleware.LoginRequiredMiddleware', ] and in may project i created middleware.py and also it looks like this from django.conf import settings class LoginRequiredMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): response = self.get_response(request) return response so anay idea?! -
filter correctly by client Date a DateTime UTC field
I have a Django API, where i want to filter by date a DateTimeField. I store everything in the database in UTC format. date_created = DateTimeField(auto_add=now) For example: A user in the frond end selects a date in date picker: 09/22/2017 ( which i send to django as 2017-09-22 ) and i want to filter down every record thats less or equal for this date. client_date= request.POST.get('client_date') books = Books.object.filter(date_created__lte=client_date) But will this date, I'm not filtering in UTC, and i don't get the correct results, i need somehow to convert client_date to UTC format from 'America/Chicago' but i dont know how -
Django Querying the Database
Here's my Answer Model, class Answer(models.Model): likes = models.ManyToManyField(User, related_name='answer_likes') timestamp = models.DateTimeField(auto_now=False, auto_now_add=True) I wants to filter out the Answers which received Maximum likes in last 24 Hours. How can I do that in view? Thank You :) -
TypeError: getattr(): attribute name must be string in Django
I'm writting a Django blog. I registered two models in Django admin (Category, Post). I wanted to add a new post with some category but I got following error: Internal Server Error: /admin/blog/post/add/ Traceback (most recent call last): File "/home/pecan/env/lib/python3.4/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/pecan/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/pecan/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/pecan/env/lib/python3.4/site-packages/django/contrib/admin/options.py", line 551, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/home/pecan/env/lib/python3.4/site-packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/pecan/env/lib/python3.4/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/home/pecan/env/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 224, in inner return view(request, *args, **kwargs) File "/home/pecan/env/lib/python3.4/site-packages/django/contrib/admin/options.py", line 1508, in add_view return self.changeform_view(request, None, form_url, extra_context) File "/home/pecan/env/lib/python3.4/site-packages/django/utils/decorators.py", line 67, in _wrapper return bound_func(*args, **kwargs) File "/home/pecan/env/lib/python3.4/site-packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/pecan/env/lib/python3.4/site-packages/django/utils/decorators.py", line 63, in bound_func return func.__get__(self, type(self))(*args2, **kwargs2) File "/home/pecan/env/lib/python3.4/site-packages/django/contrib/admin/options.py", line 1408, in changeform_view return self._changeform_view(request, object_id, form_url, extra_context) File "/home/pecan/env/lib/python3.4/site-packages/django/contrib/admin/options.py", line 1440, in _changeform_view if form.is_valid(): File "/home/pecan/env/lib/python3.4/site-packages/django/forms/forms.py", line 183, in is_valid return self.is_bound and not self.errors File "/home/pecan/env/lib/python3.4/site-packages/django/forms/forms.py", line 175, in errors self.full_clean() File "/home/pecan/env/lib/python3.4/site-packages/django/forms/forms.py", line 386, in full_clean self._post_clean() File "/home/pecan/env/lib/python3.4/site-packages/django/forms/models.py", line 414, in _post_clean … -
How to filter a nested filed averaged on Django Rest Framework?
My serializer is made with an aggregation of a nested field, and I compute an average of a number on these nested objects. The Question object is nested with a Difficulty_Question Object (a 'ForeignKey' relation on the Difficulty_Question Object). Difficulty_Question have a 'difficulty' field that I averaged and aggregated on the Question object. (see get_difficulty function) I would like to filter the Question object with a range of difficulty. My serializer looks like: serializer.py: class QuestionListSerializer(ModelSerializer): difficulty = serializers.SerializerMethodField() def get_difficulty(self, obj): average = obj.difficulty_questions.all().aggregate(Avg('difficulty')).get('difficulty__avg') if average is None: return 0 return average class Meta: model = models.Question fields = ( 'id', 'name', 'difficulty', ) I try to filter this django object by difficulty, but all I can do is filtering all the objects of the nested field, not the average of all the objects.. view.py class QuestionFilter(FilterSet): difficulty_questions__difficulty__gt = django_filters.NumberFilter(name='difficulty_questions__difficulty', lookup_expr='gt') difficulty_questions__difficulty__lt = django_filters.NumberFilter(name='difficulty_questions__difficulty', lookup_expr='lt') class Meta: model = models.Question fields = {'difficulty_questions__difficulty': ['lt', 'gt']} class QuestionViewSet(ModelViewSet): queryset = models.Question.objects.all() serializer_class = serializers.QuestionSerializer action_serializers = { 'retrieve': serializers.QuestionSerializer, 'list': serializers.QuestionListSerializer, 'create': serializers.QuestionSerializer } filter_class = QuestionFilter def get_serializer_class(self): if hasattr(self, 'action_serializers'): if self.action in self.action_serializers: return self.action_serializers[self.action] return super(QuestionViewSet, self).get_serializer_class() I also use different serializers for the detail and … -
How to get only latest record on filter of foreign key django
I have a table like this Event table | id | status | date |order(FK)| | 1 | Planned | 05-02-2015 | 1 | | 2 | Delivered | 04-02-2015 | 2 | | 3 | Packed | 03-02-2015 | 3 | | 4 | Return | 06-02-2015 | 1 | I want output like this | id | status | date |order(FK)| | 2 | Delivered | 04-02-2015 | 2 | | 3 | Packed | 03-02-2015 | 3 | | 4 | Return | 06-02-2015 | 1 | I tried with query = Event.objects.annotate(order_num=Max('date')) but didn't got the expected result. How can i achieve this output -
wagtail django list index out of range
Can you please help me with this issue. I am trying to add show only tranlated menu title. And adding this code to my tags file: @register.inclusion_tag('home/tags/top_menu.html', takes_context=True) def top_menu(context, parent, calling_page=None): request = context['request'] language_code = request.LANGUAGE_CODE menuitems = parent.get_children().live().in_menu().filter(title = language_code)[0].get_children() for menuitem in menuitems: menuitem.show_dropdown = has_menu_children(menuitem) menuitem.active = (calling_page.path.startswith(menuitem.path) if calling_page else False) return { 'calling_page': calling_page, 'menuitems': menuitems, 'request': context['request'], } But I am getting this error on page : list index out of range and highlighted code {% top_menu parent=site_root calling_page=self %} Using Wagtail 1.12 and Python 3.6.2 -
How to programmatically execute WHEN and THEN on MySQL update using Python and Django?
I would like to update multiple rows in one single query by using UPDATE CASE scenario in mySQL. I am building my web app using python and Django. Here is my code: UPDATE order SET priority_number = CASE priority_number WHEN 2 THEN 3 WHEN 3 THEN 4 WHEN 1 THEN 5 WHEN 4 THEN 2 WHEN 5 THEN 1 END So this single query will update all field as I desire. My question is, how can I program this if I have an unknown number of rows to update? Lets say all these numbers comes from an array that I will pass into my views and I don’t know how many WHEN and THEN statement I need to write? thanks for your help! -
Django Models: Linking recipes and keeping track of quantities
Problem Description Suppose I have a database with multiple models running with a Django front-end. One of the tables in the Inventory. The inventory consists of entries with the following specifications: class InventoryItem(models.Model): item_name = models.TextField(max_length=10) #apple, orange, cilantro, etc... item_quantity = models.DecimalField(...) The next model will be to describe what is made with those ingredients class Product(models.Model): product_name = models.TextField(...) product_description = models.TextField(...) The ProductItem model also needs to keep track of the ingredients taken from inventory by specifying the InventoryItem and the quantity used from that inventory item used. Previous Experience In a previous experience, I have done something similar with EntityFramework in C# with MySQL. The way I achieved that was using another table/model called RecipeElement, where each one of those would be foreign-keyed to a ProductItem entry. The RecipeElement model looked like the following: class RecipeElement(models.Model): inventory_item = models.ForeignKey(InventoryItem, on_delete = models.CASCADE) quantity_used = models.DecimalField(...) product_item = models.ForeignKey(ProductItem, on_delete = models.CASCADE) The Issue My issue with that approach in Django is twofold: How would I retrieve the RecipeElement entries associated with a ProductItem entry How would the user input the RecipeElement entries and the ProductItem entries on one page. (The number of RecipeElements for each ProductItem … -
How to add method fields to ModelSerializer
In the DRF documentation for SerializerMethodField it gives the following usage example from django.contrib.auth.models import User from django.utils.timezone import now from rest_framework import serializers class UserSerializer(serializers.ModelSerializer): days_since_joined = serializers.SerializerMethodField() class Meta: model = User def get_days_since_joined(self, obj): return (now() - obj.date_joined).days Unfortunately it fails in the latest release of DRF because ModelSerializer expects either fields or exclude to be present in the Meta. This presents a problem. If I list the method field in the fields list, I get an error django.core.exceptions.ImproperlyConfigured: Field name `days_since_joined` is not valid for model `User`. And if I do not include the method field or if I use fields = "__all__" or if I use exclude the method field ends up missing in the serialized data. How do I include the method field in a model serializer? -
Packing Django, Python and Chromium together
I would really like to distribute something like Electron for Python web applications build using Django framework. I didn't find a solution yet, so I would aks if there is one available. If not, how could I create one easily on my own? I use the latest versions of Django and Python. I would also use Chromium, because I have to care about accessibility for screen reader users and I know that Chromium is fully accessible to that users group. -
Cannot import form class into view
Django newbie here. My view function cannot import the PostForm class. All three py files are siblings. The Post class from model gets imported successfully though. Could you please help with this? Error Message: File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/ubuntu/workspace/django_projects/urls.py", line 1, in <module> import blog_app.blog_urls File "/home/ubuntu/workspace/blog_app/blog_urls.py", line 2, in <module> from . import views File "/home/ubuntu/workspace/blog_app/views.py", line 8, in <module> from .forms import PostForm ImportError: cannot import name PostForm views.py: from __future__ import unicode_literals from django.shortcuts import render, get_object_or_404 from .models import Post from .forms import PostForm def post_new(request): form = PostForm() return render(request, 'blog_app/post_edit.html', {'form': form}) forms.py: from django import forms from .models import Post class PostForm(forms.ModelForm): class Meta: model = Post fields = ('title', 'text',) models.py: from django.utils import timezone class Post(models.Model): author = models.ForeignKey('auth.User') title = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True) def publish(self): self.published_date = timezone.now() def __str__(self): return self.title -
Not Null Constraint Fail
I looked at a ton of these issues on stack overflow, but none of the solutions seemed to help me. I've tried Null=True and Blank=True as well as default=None and they all give errors. Anyone have any ideas? Thanks so much! My models: class Trip(models.Model): title = models.CharField(max_length = 50) destination = models.CharField(max_length = 255) description = models.TextField() start_date = models.DateField(auto_now_add=False) end_date = models.DateField(auto_now_add=False) creator = models.ForeignKey(User, related_name="created_trips") participants = models.ManyToManyField(User, related_name="joined_trips", default=None) messages = models.ForeignKey(Message, related_name="messages", default=None ) notes = models.ForeignKey(Note, related_name="notes", default=None) created_at = models.DateTimeField(auto_now_add = True) updated_at = models.DateTimeField(auto_now_add = True) class Message(models.Model): content = models.TextField() author = models.ForeignKey(User, related_name="author") created_at = models.DateTimeField(auto_now_add = True) updated_at = models.DateTimeField(auto_now_add = True) class Note(models.Model): content = models.CharField(max_length=45) user = models.ForeignKey(User, related_name="notes") My Views: def create(request): user = current_user(request) print user.id return render(request, 'first_app/create_trip.html') def add(request): user = current_user(request) print user trip = Trip.objects.create( title = request.POST.get('title'), destination = request.POST.get('destination'), description = request.POST.get('description'), start_date = request.POST.get('start_date'), end_date = request.POST.get('end_date'), creator = user ) print trip return redirect('/user_profile') -
Django - How refresh template after db update
I've tried implementing a hex board. Every single hex has his own field and data under each field. Right now I'm trying to set button who enable set some portion of data in the field, after page refresh. During creating the new object, the CityField object change if_electricity to True for change the final view in the template and show new information. The point is the hex table with information has no changed after templated reload. I've thought about some AJAX solution, but: 1.How? 2.Maybe there is the simplest solution? main_view.html {% extends 'base_city.html' %} {% load staticfiles %} {% block script %} <script src="{% static 'js/hex_events.js' %}"></script> {% endblock %} {% block title %}Miasto {{ city.name }}{% endblock %} {% block content %} <h1>Miasto: {{ city.name }}</h1> <h1>Mieszkańcy: {{ current_population }}/{{ max_population }}</h1> <h1>Domy: {{ house_number }}</h1> <h1>Dochody: {{ income }}</h1> <h1>Pieniądze: {{ city.cash }}</h1> <h1>{{ profile.current_turn }}/12</h1> {% if profile.current_turn <= 11 %} <button><a href="/turn_calculations">Kolejna tura</a></button> {% endif %} <button id="hex-change">Zmień hexy</button> <button id="buildPowerPlant">Zbuduj elektrownie</button> <div id="board"> <h1>Plansza wygenerowana z Djagno</h1> {{ hex_table }} </div> <div id="hexInfoBox"> <h1>Podgląd hexa</h1> {{ hex_detail_info_table }} </div> {% endblock %} board.py from .models import CityField, Residential, ProductionBuilding, PowerPlant hex_table = '' hex_detail_info_table … -
How would you implement a Generic view with the authenticated user as the context object?
Lets say I have a custom route '/some-route' with no url params so it won't have '/some-route/'. I want to create a generic view that will use the authenticated user as the context object. This is how I would do it, but I figured there might be a better way to do it. UserDetail(DetailView): def get_object(self, queryset=None): return self.request.user The biggest problem I can think of with this is that its expecting a pk kwarg to be past from the route. I don't want specify any route args though. Any ideas? Ty. -
Django 1.11 cant view the posts for the specific group?
Django Developers, I'm currently developing a web app for my school, and i'm experiencing some troubles displaying posts for a specific class, ill explain more: In my application, I have a feature where you can post to a specific group or class, whenever I post to a specific group it shows under the group detail page which basically shows the class and all the posts, here's a pic: this is the pic for the group detail so i wanted to change how the site looked and instead of having all the posts show under the group detail, i made a Anchor tag and put the href to post list, which is the file that displays the list of all the posts to that specific group(I'll provide all the files in a bit), here is a pic : this is the image for the group detail with the anchor tag But there was one probelm with this, its that once the user clicks on the POSTS anchor tag that i showed, it shows all posts that are posted even if it is not for that group, why is that? i want it, so that when the user clicks on the posts … -
User Model Primary Key
By default the User model in Django has id as a primary key. I have several other tables in my pre-existing data model that have a unique ID to each user, but the field name varies based on a job role such as CFO but we'll call this field ntname, cfontname, employee_ntname, based on three tables. I'd like to associate every username which is the ntname to the employee_ntname/cfo_ntname in the following model: class AllEeActive(models.Model): employee_last_name = models.CharField(db_column='Employee_Last_Name', max_length=50, blank=True, null=True) # Field name made lowercase. employee_first_name = models.CharField(db_column='Employee_First_Name', max_length=50, blank=True, null=True) # Field name made lowercase. employee_ntname = models.CharField(db_column='Employee_NTName',primary_key=True, serialize=False, max_length=50) # Field name made lowercase. b_level = models.CharField(db_column='B_Level', max_length=10, blank=True, null=True) # Field name made lowercase. group_name = models.CharField(db_column='Group_Name', max_length=100, blank=True, null=True) # Field name made lowercase. r_level = models.CharField(db_column='R_Level', max_length=10, blank=True, null=True) # Field name made lowercase. division_name = models.CharField(db_column='Division_Name', max_length=100, blank=True, null=True) # Field name made lowercase. d_level = models.CharField(db_column='D_Level', max_length=10, blank=True, null=True) # Field name made lowercase. market_name = models.CharField(db_column='Market_Name', max_length=100, blank=True, null=True) # Field name made lowercase. coid = models.CharField(db_column='COID', max_length=50, blank=True, null=True) # Field name made lowercase. unit_no = models.CharField(db_column='Unit_No', max_length=50, blank=True, null=True) # Field name made lowercase. dept_no = models.CharField(db_column='Dept_No', max_length=50, blank=True, … -
How can I use javascript and python to build an online game
I'm trying to build an online chess game using python, however I found out that there is an open source library for chess in javascript that has the bored and the movements I need. So this library will save me lot of time since it has the graphics ready , so my question is what framework should I use that will be suitable for my work, where javascript and html will handle the interface and python will handle the actual computing of the game and the online feature. I have looked up many frameworks like flask ,django , TurboGears but I still don't know the best fit for my work. Thanks -
Django.db.utils.OperationalError: FATAL: password authentication failed for user "mydbuser
How I created the user: mydb=# SELECT usename FROM pg_user; usename ----------- postgres mydbuser (2 rows) mydb=# alter user mydbuser with password 'myd5'; Django setting: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'mydb', 'USER': 'mydbuser', 'PASSWORD': 'myd5', 'HOST': 'localhost', 'PORT': '', } } Thanks -
Django inline formset data not saved
I'm working in Django 1.11 I have three models, business, business_address, business_phone where business_address and business_phon are associated with business. I want to create fields for business_address as well as business_phone along with business whenever a new business is added. To achieve this, I have implemented ` models.py class Business(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=200) business_type = models.ForeignKey(BusinessType, on_delete=models.CASCADE) class Meta: verbose_name = 'business' verbose_name_plural = 'businesses' db_table = 'businesses' def __str__(self): return self.name class BusinessAddress(models.Model): business = models.OneToOneField(Business, on_delete=models.CASCADE) line_1 = models.CharField(max_length=200) line_2 = models.CharField(max_length=200) city = models.CharField(max_length=200) state = models.ForeignKey(State, on_delete=models.PROTECT) postal_code = models.CharField(max_length=15) class Meta: verbose_name = 'business address' verbose_name_plural = 'business addresses' db_table = 'business_addresses' def __str__(self): return '%s, %s, %s, %s' % (self.line_1, self.line_2, self.city, self.state) class BusinessPhone(models.Model): business = models.ForeignKey(Business, on_delete=models.CASCADE) phone_number = models.CharField(max_length=15, default=None) class Meta: db_table = 'business_phones' def __str__(self): return self.phone_number forms.py class BusinessForm(ModelForm): class Meta: model = Business exclude = () BusinessAddressFormSet = inlineformset_factory( Business, BusinessAddress, form=BusinessForm, extra=1, can_delete=False ) BusinessPhoneFormSet = inlineformset_factory( Business, BusinessPhone, form=BusinessForm, extra=1, can_delete=False ) views.py class BusinessCreate(CreateView): model = Business fields = ['name', 'business_type'] def get_context_data(self, **kwargs): data = super( BusinessCreate, self ).get_context_data(**kwargs) if self.request.POST: data['business_address'] = BusinessAddressFormSet(self.request.POST) data['business_phone'] = BusinessPhoneFormSet(self.request.POST) else: data['business_address'] … -
Trying to connect Django dev server from remote
I have deployed my django application in server or machine A. I want to access my web page from machine B. My machine B runs in a virtual box and I did a ssh to machine A. I started the django development server at machine A using the command: python manage.py runserver 0.0.0.0:8000 I go to machine B try to access my webpage using: http://ip-machine-A:8000/appname/login/ However,I'm unable to connect. I have been through similar questions and I have tried all the solutions like modifying allowed_hosts in settings.py to ['*']. I also tried to ping the machine A and I got the response. And I also checked if the port is open by issuing the following command and it worked too. netstat -anp | grep 8000 Is there anything else I should work on to make this work? Or is this issue associated with Django development server.