Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Automated answer in django's makemigrations
I want to automate the python manage.py makemigrations as in if a user encounters Did you rename game.last to game.las (a CharField)? [y/N] then the input will always be y but if the user encounters You are trying to add a non-nullable field 'las' to game without a default then it will automatically and continuously enter 1. I tried yes | python manage.py makemigrations as researched however this will just throw an infinite loop of Please select a valid option if the default input is asked My desire is the automation between 1 and y value as mentioned on my first paragraph or just throw an error if I input a wrong option on the default input -
Django multiple choice field on update
I am using Django multiple choice field to show check boxes and I am using same form for create and update group permissions.While updating group permissions I want all permissions which belongs to that group only. forms.py list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] queryset = Permission.objects.all().exclude(content_type_id__in=list) OPTIONS = () for item in queryset: OPTIONS = OPTIONS +((item.name, item.name),) group_name = forms.CharField(widget=forms.TextInput(attrs={'id': 'group_name','class': 'form-control'}),label='Group Name') name = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=OPTIONS, label="Permission") views.py class AssignPermission(LoginRequiredMixin, View): login_url = '/accounts/login/' redirect_field_name = 'next' form_class = AssignPermissionForm initial = {'name': ''} template_name = 'permission/assign.html' def get(self, request, *args, **kwargs): form = self.form_class(initial=self.initial) group = Group.objects.all() user_list = [] for item in group: try: permission = item.permissions.all() if len(permission): user_list.append({'group_name':item.name, 'group_id':item.id, "permission":permission}) except: permission = None return render(request, self.template_name, {'results': user_list, 'form': form}) -
edit another model after creating an instance
I am trouble to figure out what I am trying to do. My app is the following. A user create a project. Now to that project he can or link a previous team that he created or create a new team. A team can be part of many project but a project is link to only ONE team. My model is the follwing: class Team(models.Model): team_name = models.CharField(max_length=100, default = '') team_hr_admin = models.ForeignKey(MyUser, blank=True, null=True) def __str__(self): return self.team_name class TeamMember(models.Model): user = models.ForeignKey(MyUser) team = models.ForeignKey(Team) def __str__(self): return self.user.first_name class Project(models.Model): name = models.CharField(max_length=250) team_id = models.ForeignKey(Team, blank=True, null=True) project_hr_admin = models.ForeignKey(MyUser, blank=True, null=True) def get_absolute_url(self): return reverse('website:ProjectDetails', kwargs = {'pk' : self.pk}) def __str__(self): return self.name my views : class ProjectCreate(CreateView): model = Project fields = ['name'] template_name = 'project_form.html' def form_valid(self, form): form.instance.project_hr_admin = self.request.user return super(ProjectCreate, self).form_valid(form) class ProjectDetailView(generic.DetailView): model = Project template_name = 'project_details.html' class TeamCreate(CreateView): model = Team fields = ['team_name'] template_name = 'team_form.html' def form_valid(self, form): obj = form.save(commit=False) obj2 = Project.team_id obj2 = obj.team_id obj2.save() print("sucess") I would like that when a user create a team, when the team is created it add automatically to the Project models the team_id … -
Django heroku connection refused
Deployment of my site to heroku seems to be working, until I try to use my login feature then it throws an error: OperationalError at /login/ could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? This error seems to occur during template rendering of a form (captcha). my procfile: web: waitress-serve --port=$PORT capstonenotespool.wsgi:application settings.py: import dj_database_url DATABASES = { 'default': dj_database_url.config() } DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'capstonenotespool', 'USER': 'postgres', 'PASSWORD': '****', 'HOST': 'localhost', 'PORT': '', } } I've tried changing $PORT in the procile to 5432, but this does not work. I've also tried manually setting the PORT in settings to 5432 but this also doesn't work. I also noted that Django error logs produces these variables: SERVER_NAME 'localhost' SERVER_PORT '23994' SERVER_PROTOCOL 'HTTP/1.1' SERVER_SOFTWARE 'waitress' -
Can not trigger onclick function using Django,Python and javascript
I have an issue. I could not trigger the onclick event on the link using Django and Python. I am explaining my code below. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> {% load static %} <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> var query=''; function pageTransition(){ var full_url = window.location.search; var url = full_url.replace("?", ''); query=url.file; console.log('query',query); var url="'"+query+"'"; $.getScript(url,function(){ $('a').velocity("scroll", { duration: 1000 }); }) } </script> </head> <body> <header> <h1>Nuclear Reactor</h1> {% if count > 0 %} <b>Hi, {{ user.username }}</b> <a href="{% url 'home' %}?file=//cdnjs.cloudflare.com/ajax/libs/velocity/1.5.0/velocity.min.js" onclick="pageTransition();">Home</a> <a href="{% url 'view_reactor' %}?file=//cdnjs.cloudflare.com/ajax/libs/velocity/1.5.0/velocity.min.js" onclick="pageTransition();">View Reactor status</a> <a href="{% url 'logout' %}">logout</a> {% else %} <a href="{% url 'login' %}">login</a> / <a href="{% url 'signup' %}">signup</a> {% endif %} <hr> </header> <main> {% block content %} {% endblock %} </main> </body> </html> home.html: {% extends 'base.html' %} {% block content %} <center><h1>Welcome</h1> <p>This App allow to control the life cycle of the Nuclear Reactor and Retrive the status report </p> <p><a href="{% url 'status' %}">Status report</a><a href="{% url 'control' %}">Control panel</a></p> </center> {% endblock %} Here I need to get that query string value and include it inside that javascript function but the javascript function is not called at all.Please help me … -
AttributeError: type object 'User' has no attribute 'EXECUTOR'
My project doesn't run. Where is my mistake? I make simple freelance platform with api. My project structure is freelance api init.py apps.py models.py serializers.py urls.py views.py billing init.py admin.py apps.py models.py tests.py views.py base statics templates users init.py settings.py urls.py wsgi.py task migrations init.py admin.py apps.py models.py tests.py views.py users migrations init.py admin.py apps.py models.py tests.py views.py it is my api.views import json from django.db import transaction from rest_framework import viewsets, status from rest_framework.decorators import detail_route from rest_framework.response import Response from billing.models import TaskExpense from task.models import Task from users.models import User from .serializers import UserSerializer, TaskSerializer class ExecutorViewSet(viewsets.ModelViewSet): queryset = User.objects.filter(user_type=User.EXECUTOR) serializer_class = UserSerializer class CustomerViewSet(viewsets.ModelViewSet): queryset = User.objects.filter(user_type=User.CUSTOMER) serializer_class = UserSerializer class TaskViewSet(viewsets.ModelViewSet): queryset = Task.objects.all() serializer_class = TaskSerializer def create(self, request, *args, **kwargs): request.data['created_by'] = request.user.pk serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) self.perform_create(serializer) headers = self.get_success_headers(serializer.data) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) @detail_route(methods=['POST', 'GET']) def assign(self, request, pk): try: task = Task.objects.get(pk=pk, assignee=None) except Task.DoesNotExist: return Response(json.dumps({"message": "Already taken"}), status=status.HTTP_400_BAD_REQUEST) expense, created = TaskExpense.objects.get_or_create( task=task, executor_id=request.user.pk, money=task.money) if created: with transaction.atomic(): request.user.update_balance(u"Взял задачу", task.money, task=task) Task.objects.filter(pk=pk, assignee=None).update(assignee=request.user) return Response(json.dumps({'message': "Taken"}), status=status.HTTP_200_OK) That is users.models from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): CUSTOMER = 1 EXECUTER = 2 … -
Django: Loop through objects and their feilds on template
I want to do something like this on template: {% for account in integrations %} <tbody> <tr> <td>#</td> <td> <p>{{ account.label }}</p> </td> <td> <button type="button" class="btn btn-success btn-xs">{{ account.link }}</button> </td> </tr> </tbody> {% endfor %} My views.py file: all_integrations = Worker.objects.filter(user=user) if all_integrations != 0: return render(request, 'integrations/index.html', {'section': 'integrations', 'integrations': zip(all_integrations)}) My models.py file: class Worker(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) a_key = models.CharField(max_length=255) a_secret = models.CharField(max_length=255) label = models.CharField(max_length=255) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) def __str__(self): return self.id My web page return the result but it's empty. i.e. one row but the account.label is empty. Also if I don't zip, it shows 10 empty rows whereas there's only one object. -
Display Information of table in Div on click with Django and Bokeh
the problem is that the bokeh documentation does not provide an example of using the event.Tab in combination with created elements that will give me the individual circle information. I was searching intensely on google, throughout StackOverflow and GitHub without success finding something that would point me in the right direction. My current Code: from Django.shortcuts import render from bokeh.plotting import figure from bokeh.embed import components from bokeh.models import Div, ColumnDataSource, Range1d, HoverTool, CustomJS from bokeh.layouts import column, row from bokeh import events from .models import Company, News import pandas as pd import math def index(request): def display_event(div, attributes=[], style = 'float:left;clear:left;font_size=0.5pt'): return CustomJS(args=dict(div=div), code=""" var attrs = %s; var args = []; for (var i=0; i<attrs.length; i++ ) { args.push(attrs[i] + '=' + Number(cb_obj[attrs[i]]).toFixed(2)); } var line = "<span style=%r><b>" + cb_obj.event_name + "</b>(" + args.join(", ") + ")</span>\\n"; var text = div.text.concat(line); var lines = text.split("\\n") if ( lines.length > 35 ) { lines.shift(); } div.text = lines.join("\\n"); """ % (attributes, style)) hover = HoverTool(tooltips=[ ("Company Name ", "@company"), ("score ", "@x"), ]) page_logo = figure(plot_width = 800, plot_height = 600, title="",tools=[hover]) page_logo.toolbar.logo = None page_logo.toolbar_location = None page_logo.xgrid.grid_line_color = None page_logo.ygrid.grid_line_color = None page_logo.yaxis.visible = None page_logo.xaxis.axis_label … -
How to add 1 day to timeuntil in django
I have a table in which I am displaying timeuntil for the difference between the dates.My timeuntil is showing in this way: Applied leave from Sept. 19, 2017 to Sept. 21, 2017 for 2 days,..But I need 3 days.How to achieve it? My Query is: Applied leave from {{pl.start_date}} to {{pl.end_date}} for {{ pl.end_date|timeuntil:pl.start_date }} -
Django: Adding User in a Group
Here's the model, class Groupchat(models.Model): admin = models.ForeignKey(User, related_name="admin") members = models.ManyToManyField(User, related_name="members", blank=True) name = models.CharField(max_length=50) I've no idea how can 'admin' add any user to the Group that he/she created. How can I do that or at least what is the right way to do so? Please helpme! -
Django Content-Type for text/xsl
I have been trying to set the content type for an xsl file. This is what I have done so far def xsl_content_type(): filename = static('sitemap.xsl') response = HttpResponse(filename) response['Content-Type'] = "text/xsl" response['Content-Length'] = len(filename) return response This returns HTTP/1.0 200 OK Date: Wed, 13 Sep 2017 05:04:46 GMT Server: WSGIServer/0.2 CPython/3.6.1 Last-Modified: Tue, 13 Jun 2017 03:54:17 GMT Content-Length: 7134 Content-Type: application/octet-stream Cache-Control: max-age=0, public Access-Control-Allow-Origin: * Even thought I did setup the Content-Type as text/xsl, all I get is application/octet-stream. I have also tried doing response = HttpResponse(filename, content_type="text/xsl"), but the content type is the same. What am I missing here? -
I wanna put data to upper1000 of Price model
I wanna put data to upper1000 of Price model. So I think I have to read upper1000 of Price,so I wrote price = Price.objects.create(city=city) price_u1000 = price.upper1000.create(city=city) but AttributeError: 'NoneType' object has no attribute 'create' error happens. models.py is class Price(models.Model): upper1000 = models.CharField(max_length=20, verbose_name='1000', null=True) from500to1000 = models.CharField(max_length=20, verbose_name='500~1000', null=True) Why does this error happen?What is wrong?How can I fix this? -
howto to post my html form to django model and save it?
i'm stuck with django forms. i have html form which i want to send and save to django model. when i try to send message i get error : ValueError at /account/userinfo/akylson/ "" needs to have a value for field "id" before this many-to-many relationship can be used. Request Method: POST Request URL: http://localhost:8000/account/userinfo/akylson/ Django Version: 1.11.3 Exception Type: ValueError Exception Value: "" needs to have a value for field "id" before this many-to-many relationship can be used. You can see my code below. Here is my html form <form role="form" class="form-horizontal" method="post"> {% csrf_token %} <div class="form-group"> <input type="checkbox" id="id_receiver" name="receiver" value="{{ user.username }}" checked hidden> <label class="col-lg-2 control-label">Тема</label> <div class="col-lg-10"> <input type="text" placeholder="" id="id_subject" name="subject" value="{{ subject }}" class="form-control"> </div> </div> <div class="form-group"> <label class="col-lg-2 control-label">Сообщение</label> <div class="col-lg-10"> <textarea rows="10" cols="30" class="form-control" id="id_message" name="message"></textarea> </div> </div> <div class="form-group"> <div class="col-lg-offset-2 col-lg-10"> <span class="btn green fileinput-button"><i class="fa fa-plus fa fa-white"></i> <span>Приложение</span><input type="file" name="files[]" multiple=""></span> <button class="btn btn-send" value="submit" type="submit">Send</button> </div> </div> </form> Here is my view.py: @login_required() def userinfo(request, username): username = User.objects.get(username=username) args = {} args['user'] = username if request.method == 'POST': sender = request.user receiver = request.POST['receiver'] subject = request.POST['subject'] message = request.POST['message'] b = Mail.objects.create(sender=sender, receiver=receiver, … -
Permission error when accessing apache2 application
I had deployed my python Django application in apache2.4.7 server in Ubuntu14.04 My 000-default.conf under /etc/apache2/sites-available looks like this <VirtualHost *:2080> DocumentRoot "/home/ubuntu/Webgis" #Coankry# Alias /conakry/static /home/ubuntu/Webgis/Map_Viewer/static <Directory /home/ubuntu/Webgis/Map_Viewer/static> Require all granted </Directory> Alias /conakry/media /home/ubuntu/Webgis/Map_Viewer/media <Directory /home/ubuntu/Webgis/Map_Viewer/media> Require all granted </Directory> <Directory /home/ubuntu/Webgis/Map_Viewer/Map_Viewer> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess conakry python-path=/home/ubuntu/Webgis/Map_Viewer python-home=/home/ubuntu/Webgis/Map_Viewer/env WSGIProcessGroup conakry WSGIScriptAlias /conakry /home/ubuntu/Webgis/Map_Viewer/Map_Viewer/wsgi.py process-group=conakry I am getting 404 forbidden error You don't have permission to access /conakry/ on this server. when i try to access the application from browser. But when it is configured to default 80 port, its working fine. I think this a permission issue. -
Django Rest Framework custom validation on ForeignKey
I have a ModelSerializer that has a ForeignKey field. This is the code for the model: class Attendance(models.Model): employee = models.ForeignKey(Employee, related_name='attendance_times') datetime = models.DateTimeField() and this is the serializer: class AttendanceSerializer(serializers.ModelSerializer): def validate_employee(self, value): try: Employee.objects.get(pk=value) except Employee.DoesNotExist: Employee.objects.create(pk=value) return value class Meta: model = Attendance fields = ('employee', 'datetime') the problem is when I send a post request to create a new object, the function validate_employee is not called and the serializer returns a validation error saying: Invalid pk "1321" - object does not exist. Why is this happening? Am I doing something wrong? Is there another validator that is being called before my validator? -
Search string in database column django query
I have a field in db which contains string like "Food,Financial,Health" . I need to search string which is startswith "Fi" in that field. I can search string using contains but i need to search startswith in django query. Anyone suggest me to do that. -
ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host=u'localhost', port=9200): Read timed out. (read timeout=10))
In local system elastic search works perfectly but when i'm trying to search in server system it shows in console : "ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host=u'localhost', port=9200): Read timed out. (read timeout=10))" -
django prefetch_related reverse relationship with nested serializer
I wanted to know that, how can I optimize my sql query with django's prefetch_related() method on a reverse foreignkey relationship and nested serializer models.py class Dataset(models.Model): name = models.CharField(max_length=30) run = models.ForeignKey('Run') class Spider(models.Model): name = models.CharField(max_length=20) status = models.BooleanField() class Run(models.Model): name = models.CharField(max_length=10) spider = models.ForeignKey(Spider) serializers.py class SpiderDetailSerializer(serializers.ModelSerializer): latest_run = serializers.SerializerMethodField(read_only=True) def get_latest_run(self, model): latest_run = model.run_set.first() if latest_run: return RunDetailSerializer(latest_run).data return None @staticmethod def setup_eager_loading(queryset): # stuff to make optimize # code return queryset class RunDetailSerializer(serializers.ModelSerializer): spider = SpiderAllSerializer(read_only=True) datasets = DatasetSerializer(many=True, read_only=True, source='dataset_set') class SpiderAllSerializer(serializers.ModelSerializer): class Meta: model = Spider fields = ('id', 'name', 'status') class DatasetSerializer(serializers.ModelSerializer): class Meta: model = Spider fields = ('id', 'name', 'run') I want to implement setup_eager_loading() on SpiderDetailSerialize ( I don't know whether it's good method or not ). While calling SpiderDetailSerialize many Dataset will be retrived. If it's not a good way to implement prefetch_related() on SpiderDetailSerialize , kindly suggest better way to optimize the process -
Django performance with render_to_response
I have Django app, which have following statements: response = render_to_response('template.html', {'s':s, 'r':r}, context_instance=RequestContext(request)) The typical statement at template.html is: <tbody>{%for m in r.m_set.all %}<tr> <td>{{m.id}}</td> <td>{{m.Name}}</td> <td>{{m.MaterialLot.id}}</td> <td>{{m.MaterialSublot.id}}</td> <td>{{m.Description|truncatechars:20}}</td> <td>{{m.StorageLocation.id}} - {{m.StorageLocation.Name}}</td> <td>{{m.Quantity|floatformat:"-3"}}</td> <td>{{m.QuantityUnitOfMeasure.id}}</td> <td>{{m.Status.id}}</td></tr> {%endfor%}</tbody> There are about 10 thousands records. the page response time take about 3 minutes(ThinkServer, Linux, Apache, mod_wsgi, Python3.4, Django 1.9.4, MySQL), is this normal? Thanks! -
FormView updating context after redirecting same template
index.html <form class="form-horizontal" method="POST" action=""> {% csrf_token %} {{ form.as_p }} <div class="control-group"> <div class="controls"> <button type="submit" class="btn btn-primary">Go</button> </div> </div> </form> {% if my_list %} {% for a, b in my_list %} {{ a }} {{ b }} {% endfor %} {% endif %} views.py class MyView(FormView): template_name = 'index.html' form_class = MyForm success_url = reverse_lazy('myapp:index') def form_valid(self, form): # get URL value from form field url = form.cleaned_data['url'] # do some stuf to populate my_list ... self.my_list = [('test','a'), ('test2','b')] return super(ScraperFormView, self).form_valid(form) forms.py class MyForm(forms.Form): url = forms.URLField(label='URL', required=True) There's only one page (index.html) with a form so the user can submit an URL. Then the URL is processed in MyView and my_list var is created in the form_valid method. After returning from this method, the context data should be updated adding my_list var, so the template (index.html, same success_url) is populated. I've tried to solve this overriding get_context_data, but cannot figure out how to redirect to success_url updating the context with my_list. -
Mezzanine 4.2.2 / 4.2.3: Search breaks when USE_MODELTRANSLATION = True
I've been having quite the time trying to get my search functionality to work correctly on my mezzanine project using django-modeltranslation. I am fairly new to Django, Mezzanine, and Python as well so no surprise as to why I'm having difficulty figuring this issue out. My translations work fine. No issues there. However, each time I set USE_MODELTRANSLATION = True in my settings.py and perform a search query I just get re-directed to my homepage each time rather than the expected search results page and in my console output I'll see "POST /i18n/ HTTP/1.1" 302 0. For the latter, if I set USE_MODELTRANSLATION = False and perform a search query I get the expected search result and in my output "GET /search/?q=test HTTP/1.1" 200 12972. I also noticed that each POST is also passing the language parameter in the headers which I suspect to be part of the problem. I also suspected some issues with my urls.py and attempted many combinations specific to the search url but didn't have any luck with that either. I am almost certain the issue may be with modeltranslation set_language. So far I've tested my scenario with the following combinations but no resolve: Mezzanine 4.2.3 … -
AttributeError: 'DeferredAttribute' object has no attribute 'objects'
I got an error,AttributeError: 'DeferredAttribute' object has no attribute 'objects'. I wanna parse excel and put it to the model(City&Prefecture&Area&User) . I wrote user3 = User.objects.filter(corporation_id=val3).first() if user3: area = Area.objects.filter(name="America").first() pref = Prefecture.objects.create(name="prefecture", area=user3.area) city = City.objects.create(name="city", prefecture=pref) price_u1000 = Price.upper1000.objects.get(city=city) price_500_1000 = Price.from500to1000.objects.get(city=city) price_u500 = Price.under500.objects.get(city=city) pref.name = "NY" pref.save() for i in range(2,len(fourrows_transpose)): city.name = fourrows_transpose[i][1] city.save() print(fourrows_transpose[i][1]) price_u1000.name = fourrows_transpose[i][2] price_u1000.save() print(fourrows_transpose[i][2]) price_500_1000.name = fourrows_transpose[i][3] price_500_1000.save() print(fourrows_transpose[i][3]) price_u500.name = fourrows_transpose[i][4] price_u500.save() print(fourrows_transpose[i][4]) Traceback says this code price_u1000 = Price.upper700.objects.get(city=city) is wrong. models.py is class Area(models.Model): name = models.CharField(max_length=20, verbose_name='area', null=True) class User(models.Model): user_id = models.CharField(max_length=200,null=True) area = models.ForeignKey('Area',null=True, blank=True) class Prefecture(models.Model): name = models.CharField(max_length=20, verbose_name='prefecture') area = models.ForeignKey('Area', null=True, blank=True) class City(models.Model): name = models.CharField(max_length=20, verbose_name='city') prefecture = models.ForeignKey('Prefecture', null=True, blank=True) class Price(models.Model): upper1000 = models.CharField(max_length=20, verbose_name='u1000', null=True) from500to1000 = models.CharField(max_length=20, verbose_name='500~1000', null=True) under500 = models.CharField(max_length=20, verbose_name='d500', null=True) city = models.ForeignKey('City', null=True, blank=True) What should I do to fix this?How should I write it? -
Increment integer field dynamically - Django
So I have the following model: from django.db import models class Person(models.Model): name = models.CharField(max_length=254) image_url = models.CharField(max_length=254) title = models.CharField(max_length=254) bio = models.CharField(max_length=20000) vote = models.IntegerField(default=0) def __str__(self): return self.name Where Vote is the attribute that I want to increment by one on every click. The following Views: import json from rest_framework.views import APIView from rest_framework.response import Response from urllib.request import urlopen from .models import Person from .serializers import PersonSerializer from django.views.generic import ListView class PersonApiView(APIView): def get(self, request): persons = Person.objects.all() serializer = PersonSerializer(persons, many=True) return Response(serializer.data) class PersonView(ListView): data = urlopen("https://api.myjson.com/bins/16roa3").read() json_persons = json.loads(data) persons = Person.objects.all() for person in json_persons: if person['id'] not in [i.id for i in persons]: Person.objects.create(id=person['id'], name=person['name'], image_url=person['image_url'], title=person['title'], bio=person['bio']) model = Person context_object_name = 'persons' In the views, I'm doing 2 things: Show in my /api/ URL all my objects after being serialized. Create objects using an external JSON URL This what I have in my html: {% for person in persons %} <div class="container"> <div ng-controller="mainController"> <div class="row"> <div class="col-xs-12 col-sm-5 col-md-4 col-lg-3"> <img ng-src="{{person.image_url}}"/> </div> <div class="col-xs-12 col-sm-7 col-md-8 col-lg-9"> <h2>{{ person.name }}</h2> <h3>{{ person.title }}</h3> <p>{{ person.bio }}</p> <form method="POST"> <h4>Want to work with {{ person.name }}? <img … -
connect to database on web hosting and my django applicattion
hello everyone i'm knew in develloping i'm creating a web application for car tracking where i use a gprs card that must send data to my hosting web database so i want to know how to connect between my web site and django app thank you :D -
how can I create a project with django?
i install python and Django on mac with pip , but when i want start project with Django by this command i have message error : macs-MacBook:desktop mac$ django-admin.py startproject blog pkg_resources.DistributionNotFound: The 'pytz' distribution was not found and is required by Django i try solve that with this command but i have same error : sudo pip install -U djangorestframework how can i solve that and create project ?