Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Calling Django child model method from parent requires InheritanceManager?
I have a Post class for my Django app that has several subclasses TextPost, AudioPost, etc, each with their own render_html() method. class Post(models.Model): author = models.ForeinKey(User,...) title = models.CharField(...) pub_date = models.DateTimeField(...) ... def render_html(self): return "rendered title, author date" class AudioPost(Post): audioFile = FileField(...) def render_html(self): return "Correct audio html" ... each of these child models has an ModelForm with rules for uploading, validation, and saving. In a home page view, I'd like to take all posts, arrange them by date, and render them. To me this should be as simple as ## in view context = { 'posts' : Post.objects.order_by('-pub_date')[:5] } and ## in template {{ post.render_html() | safe }} I remember things working this way for abstract classes in Java. But when I do it this way in Python, the render_html method gets called as if they are each members of the parent class. I've looked up how Django does multi-table inheritence, it seems like I either need to check the generated OneToOneFields one by one until I've found one that doesn't raise an exception, or use the InheritanceManager utility manager. Is one of those two ways the best way to do this or should I … -
uWSGI, Django, CentOS 7: No module named 'encodings'
Have read a few questions regarding uWSGI and mod_wsgi, but haven't solved my issue. Here is one of the related questions: uWSGI Fails with No module named encoding Error I have been following this article on how to install and configure: https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-centos-7 Really can't even get the "quick test" working. My virtualenv has -p python3.6 so doesn't appear to be an issue with a wrong version of Python. Also install sudo yum install python36u-devel gcc. Did the sudo pip install uwsgi as suggested. Go to run: uwsgi --http :8000 --home /home/dev/.venv/app --chdir /home/dev/app-demo/app/config -w wsgi.py Which just outputs: *** Starting uWSGI 2.0.15 (64bit) on [Thu Jun 22 12:56:26 2017] *** compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-11) on 22 June 2017 12:39:02 os: Linux-3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 nodename: centos.org.us machine: x86_64 clock source: unix detected number of CPU cores: 8 current working directory: /home/dev/app-demo/app detected binary path: /usr/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! chdir() to /home/dev/app-demo/app/config *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 4096 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: … -
Django: How to list model object in range?
I have a django project that is a simple blog. I want to use template tagging to list half of the blog post on one column and the other half in the second column in my post_list.html. **My question basically is: ** How do I do this? My project tree is: https://gyazo.com/00473a1609878a6d4e5796841a04569e My blog app tree is: https://gyazo.com/0deaf28180dd18d24cea19402ca22d70 My models.py: class Post(models.Model): author = models.ForeignKey('auth.User') title = models.CharField(max_length=200) photo = models.ImageField(upload_to='Post', blank=True, null=True) text = models.TextField() create_date = models.DateTimeField(default=timezone.now()) published_date = models.DateTimeField(blank=True,null=True) def publish(self): self.published_date = timezone.now() self.save() def approve_comments(self): return self.comments.filter(approved_comment=True) # approved_comment has to match with approved_comment in comment class def get_absolute_url(self): return reverse("post_detail",kwargs={'pk':self.pk}) # after creating post go to post_detail page for that post def __str__(self): return self.title My post_list.html: <div class="col-md-6"> {% for post in post_list %} <div class="c-content-blog-post-card-1 c-option-2 c-bordered"> <div class="c-media c-content-overlay"> <div class="c-overlay-wrapper"> <div class="c-overlay-content"> <a href="{{ post.photo.url }}"> <i class="icon-link"></i> </a> <a href="{{ post.photo.url }}" data-lightbox="fancybox" data-fancybox-group="gallery"> <i class="icon-magnifier"></i> </a> </div> </div> <img class="c-overlay-object img-responsive" src="{{ post.photo.url }}" alt=""> </div> <div class="c-body"> <div class="c-title c-font-bold c-font-uppercase"> <a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a> </div> <div class="c-author"> By <a href="{% url 'post_detail' pk=post.pk %}"> <span class="c-font-uppercase">{{ post.author }}</span> </a> on <span class="c-font-uppercase">{{ … -
How to upload a file using Ajax on POST?
I know the topics aren't missing on this subject that's why I looked into a huge amount of posts about this topic and couldn't find something that'd satisfy me, so I'm trying to build it by myself. All I want to do is to upload a file using Ajax with Django to avoid page refresh. Here's what I did : basic_upload.html : <form method="post" id="creationOptionsForm" enctype="multipart/form-data"> {% csrf_token %} <div> {{ form.name.errors }} {{ form.name }} </div> <div> {{ form.email.errors }} {{ form.email }} </div> <div> {{ form.logo.errors }} {{ form.logo }} </div> <input type="submit" value="submit"> </form> Ajax.js : $(document).on('submit', '#creationOptionsForm', function(e){ e.preventDefault(); var form_data = new FormData(); form_data.append('file', $('#creationOptionsForm').get(0).files); $.ajax({ type:'POST', url:'/designer/results/', processData: false, contentType: false, data:{ organisation:$('#id_organisation').val(), email:$('#id_email').val(), logo:form_data, csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val(), }, }); }); Views.py : def creationResult(request): if request.method == 'POST': form = UserInfos(request.POST, request.FILES) if form.is_valid(): photo = form.save() ... ... (forms.py & urls.py are correctly configured, it is not necessary to include them). I guess there's an issue with the way I do on the ajax.js since on debug (pdb) request.POST return every datas except logo. What am I doing incorectly ? -
django-channels/websockets: WebSocketBadStatusException: Handshake status 200
I am following this tutorial: https://gearheart.io/blog/creating-a-chat-with-django-channels/ And I get this error with the following code while running manage.py runserver #settings.py redis_host = os.environ.get('REDIS_HOST', 'localhost') # Channel layer definitions # http://channels.readthedocs.org/en/latest/deploying.html#setting-up-a-channel-backend CHANNEL_LAYERS = { "default": { # This example app uses the Redis channel layer implementation asgi_redis "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { "hosts": [(redis_host, 6379)], }, "ROUTING": "gameapollius.routing.channel_routing", # We will create it in a moment }, } #routing.py from channels import route,include def message_handler(message): print(message['text']) channel_routing = [ route('websocket.receive', message_handler) ] #traceback In [1]: import websocket In [2]: ws = websocket.WebSocket() In [3]: ws.connect("ws://localhost:8000") --------------------------------------------------------------------------- WebSocketBadStatusException Traceback (most recent call last) <ipython-input-3-43b98f503495> in <module>() ----> 1 ws.connect("ws://localhost:8000") c:\Python27\lib\site-packages\websocket\_core.pyc in connect(self, url, **options) 212 213 try: --> 214 self.handshake_response = handshake(self.sock, *addrs, **options) 215 self.connected = True 216 except: c:\Python27\lib\site-packages\websocket\_handshake.pyc in handshake(sock, hostname, port, resource, **options) 67 dump("request header", header_str) 68 ---> 69 status, resp = _get_resp_headers(sock) 70 success, subproto = _validate(resp, key, options.get("subprotocols")) 71 if not success: c:\Python27\lib\site-packages\websocket\_handshake.pyc in _get_resp_headers(sock, success_status) 127 status, resp_headers = read_headers(sock) 128 if status != success_status: --> 129 raise WebSocketBadStatusException("Handshake status %d", status) 130 return status, resp_headers 131 WebSocketBadStatusException: Handshake status 200 What am I doing wrong? I have followed the tutorial to the T up … -
Bokeh: How to change y axis scale from subunits of integers to just integers (i.e. 1, 2, 3)
[The improperly formatted y axis graph units][1] Here is the attendant python code in my Django app views.py [1]: https://i.stack.imgur.com/HTQ4w.png ` plot2 = figure(title= title2, x_axis_label= 'Date', x_axis_type= 'datetime', y_axis_label= 'Ease of Sleep', y_axis_type='linear', plot_width =400, plot_height=400) plot1.scatter(chart_values_x_graph1, chart_values_y_graph1, legend= 'f(x)', line_width = 2) script1, div1 = components(plot1, CDN) plot2.scatter(chart_values_x_graph2, chart_values_y_graph2, legend= '1 = Easily; 2 = After Some Time; 3 = With Difficulty', line_width = 2) script2, div2 = components(plot2, CDN) -
Django: Call function on form submit
I have the following issue. I basically want to have a own login page. views.py from django.contrib.auth import authenticate, login, logout from django.shortcuts import render, redirect def index(request): return render(request, 'home/index.html') def login_page(request): return render(request, 'home/login.html') def user_login(request): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: login(request, user) # Redirect to a success page. return redirect('/profil/') else: # Return an 'invalid login' error message. return redirect('/login/') urls.py from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^login/', views.login_page, name='login'), url(r'^login/login', views.user_login, name='login_action'), url(r'^logout/', views.user_logout, name='logout') ] login.html {% extends 'base.html' %} {% block body %} <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4" id="login-page"> <h1>Login</h1> <form class="form" action="{% url 'login_action' %}" method="post"> {% csrf_token %} <div class="form-group"> <label for="username">Benutzername</label> <input type="text" id="username" class="form-control" name="username"/> </div> <div class="form-group"> <label for="password">Passwort</label> <input id="password" type="password" class="form-control" name="password"/> </div> <div> <button type="submit" class="btn btn-primary">Anmelden</button> </div> </form> </div> </div> </div> {% endblock %} The problem is now that when I hit the submit button then I land on the page login/login, but I am not redirected. I have also tried to add a print statement in the user_login method in order to check whether … -
Invalid JSON Payload error with python google sheets API
I'm trying to use the google sheets API to append new rows to an existing google sheet. Authentication already happens successfully and code is able to read the contents of the sheet. However, when I try to use service.spreadsheets().values().append(...), I get the following HttpError: "Invalid JSON payload received. Unknown name "": Root element must be a message." Here is my code: from json import dumps as jsdumps credentials = get_credentials() http = credentials.authorize(httplib2.Http()) discoveryUrl = discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?version=v4') service = discovery.build('sheets', 'v4', http=http, discoveryServiceUrl=discoveryUrl) spreadsheetId = '{...}' rangeName = "Sheet1" value_input_option = 'RAW' insert_data_option = 'INSERT_ROWS' value_range_body = { "range": rangeName, "majorDimension:": "ROWS", "values": list(rd.values()), # rd is just a dictionary with some stuff in it } So then when I try to send it: request = service.spreadsheets().values().append(spreadsheetId=spreadsheetId, range=rangeName, valueInputOption=value_input_option, insertDataOption=insert_data_option, body=jsdumps(value_range_body)) After running request.execute(), I get the error listed above. -
Django 'SECRET_KEY' must not be empty' error
I checked in settings.py and there is indeed a secret key. Why is this error occurring? -
Django/DRF/JWT doesn't go to the DB when authenticating token, but request.user has all the details?
How is it possible that JWT does not go through the database to authenticate a user request.user is a fully featured object with all the fields already populated. Which one is true? The database is used Every field of User is encoded onto the token and decoded at request time to be made available. -
django-channels databinding on model.save()
I have a channels app that is using databinding. When changes are made with django admin they are being pushed to the web as expected. I have loop set up on a socket connection to do some long polling on a gpio unit and update the db, these changes are not being pushed to the web. Channels documentation says: Signals are used to power outbound binding, so if you change the values of a model outside of Django (or use the .update() method on a QuerySet), the signals are not triggered and the change will not be sent out. You can trigger changes yourself, but you’ll need to source the events from the right place for your system. How do I go about triggering these changes, as it happens with admin? Thanks and please let me know if this is to vague. -
Angular URL marked as unsafe
I have a AngularJS and Django framework. The api returns a image url like 127.0.0.1:8000/get-badge?id=1 This url is valid. In the frontend, I'm attempting to display it via: <img ng-src="{{item.api_image_url|trustUrl}}" style='width:200px; max-width:100%;' /> The filter looks like this: .filter('trustUrl', function ($sce) { return function(url) { return $sce.trustAsResourceUrl(url); }; }); I am getting this error when the image loads: GET unsafe:127.0.0.1:8000/get-badge?id=1 net::ERR_UNKNOWN_URL_SCHEME The filter looks like it should have fixed things but it is not. -
creating Django back office application to scale to +1000 users
I am looking into the steps needed to create a back office reporting application which could scale to +1000 users. Each user would have its own back office. I was thinking using Django to create the MVC and host it on AWS. Anyone could explain the additional technologies I would need? thanks -
how to retain text box and submit button and display the output in the same page
views.py def nslookups(request): dig = NameForm r = [] #dig = form_class(request.POST or None) if request.method == 'POST': dig = NameForm(request.POST) if dig.is_valid(): fqdn = dig.cleaned_data['lookup'] answers = dns.resolver.query( fqdn,'A') for a in answers: r.append(a.address) print(r) return render(request,'accounts/dns.html',{'nslookup': r}) else: dig = NameForm() return render(request, 'accounts/dns.html',{'dig': dig}) dns.html {% extends 'base.html' %} {% block content %} <h3>Welcome</h3> <h3>DNS</h3> <form method="post"> {% csrf_token %} {{ dig }} <input type="submit" value="Submit"> </form> {{ nslookup }} {% endblock %} Requirement is to input dns record in text box and then display the result in the same page along with text box and submit button. -
Filtros de ChoiceField no Django 1.10.7
Olá, Estou tendo dificuldades quanto à um filtro em um aplicativo web que estou desenvolvendo. O aplicativo é bem simples. Quando um cliente tem algum problema que não consegue solucionar, ele abre uma solicitação de suporte para nossa equipe. Para os mais avançados, isso é básicamente um servicedesk. Ao criar a solicitação, existem todos os campos que devem ser preenchidos no form e dentre eles, três ChoiceFields. Estes Choicefields são os seguintes: Categoria, Sub-Categoria e Item. Problema: Ao selecionar uma categoria (por exemplo Banco de dados) gostaria que em subcategorias aparecessem somente itens que possuem a FK de Categoria (exemplo: Erro de Backup), e a mesma coisa de SubCategoria para Item (Exemplo: SLA). Abaixo, meus códigos: URLS.PY # /servicedesk/add/ url(r'^add/$', views.addChamado.as_view(), name='add-chamado'), VIEWS.PY class addChamado(CreateView): form_class = AddChamado template_name = 'servicedesk/registrochamado_form.html' FORMS.PY class AddChamado(forms.ModelForm): import datetime DataInicio = forms.DateField(initial=datetime.date.today, widget=forms.DateInput(format='%Y-%m-%d')) Descricao = forms.CharField(widget=forms.Textarea(attrs={'cols': 50, 'rows': 10})) class Meta: model = Chamado fields = [ "DataInicio", "Empresa", "Tecnico", "Prioridade", "Categoria", "SubCategoria", "Item", "Estado", "Assunto", "Descricao", ] MODELS.PY class Chamado(models.Model): DataInicio = models.DateTimeField(auto_now_add=False) DataCriacao = models.DateTimeField(auto_now_add=True) Assunto = models.CharField(max_length=500) Descricao = models.CharField(max_length=4000) Empresa = models.ForeignKey(Empresa, on_delete=models.CASCADE) Tecnico = models.ForeignKey(Usuario, on_delete=models.CASCADE) Prioridade = models.ForeignKey(Prioridade, on_delete=models.CASCADE) Categoria = models.ForeignKey(Categoria, on_delete=models.CASCADE) SubCategoria = models.ForeignKey(SubCategoria, on_delete=models.CASCADE) … -
Django Pagination
So I have a long/endless querySet of Pictures which are currently loaded all at once and I would like to load them in smaller pieces(like Imgur, Facebook, Twitter etc.) I tried to work with "el-Paginator" and "django-pagination" but I have the bad feeling that i will mess around with the code forever and than realize that it could be done way easier with another package. Considering I have this line in my template: {% for post in newSet %} <h3><a href=".../">{{post.title}}</a></h3> <img src="{{ post.image_url }}" class="img-responsive" /> ...//around 150 lines {% endfor%} What I need: load in set of 3 or 4 Pictures endless scrolling so there is no "next page" Which Package would you recommend? el-Paginator seems promising but I had all kinds of errors when I tried to make it run and it seems that nobody is using it so there is nobody to ask for help. The normal Pagination is a pain because I have to give IDs etc to each Post and this is not a static site, Posts are loaded individuell for each Usergroup so I cannot hardcode Ids for the Posts. I know this is probably off-topic but I don't want to spend 2 … -
How to connect Celery worker to django test databas
I could like get my celery worker process to talk to the django test database. Its an oracle database, so I believe the database/user is already created. I am just trying to figure out what to pass the Celery/App configuration to get it to talk to the "TEST" database. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.oracle', ............. 'TEST': { 'USER': WIT_TEST_DB_USER, 'PASSWORD': WIT_TEST_DB_USER, } } } I have seen a stackoverflow article that talks about passing the settings.conf from the parent test setup() to the worker process. That may be necessary when the test database file is automatically generated in case of sqllite databases. In my case, its a well defined oracle test database that I think is already part of the conffig/settings files. so I am looking for a way to directly start work process independet of the testrunner/testcase code. Can some one suggest an approach to doing this? -
I'm getting the following error: view didn't return an HttpResponse object. It returned None instead
After submitting my form i'm getting the following error: The view papa.views.record_case didn't return an HttpResponse object. It returned None instead. I've tried the following solutions view didn't return a response object and the solution explained here but not always resolved. Her is my view.py code: def record_case(request): if request.method=="GET": form=EnfantForm() context={ "form":form, } return render(request,"papa/enfant.html",context) elif request.method=="POST": form=EnfantForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('papa:record_case')) and my model.py file: SEXE_CHOICES = ( (0, 'M'), (1, 'F'), ) class Maladie(models.Model): nom=models.CharField(max_length=50) def __str__(self): return self.nom class Traitement(models.Model): code=models.CharField(primary_key=True,max_length=25,verbose_name="Code du traitement") nom=models.CharField(max_length=200,verbose_name="Nom du traitement") maladie=models.ForeignKey(Maladie,on_delete=models.CASCADE) age=models.ForeignKey("Age",on_delete=models.CASCADE) def __str__(self): return self.code class Age(models.Model): tranche=models.CharField(max_length=100) def __str__(self): return self.tranche class Enfant(models.Model): sexe=models.CharField(max_length=1,choices=SEXE_CHOICES) poid=models.FloatField() age=models.ForeignKey(Age,on_delete=models.CASCADE) maladie=models.ManyToManyField(Maladie) def __str__(self): return self.sexe -
Copy Django object and preserve model_set items
In my project, i have 2 models: class Product(models.Model): name = models.CharField(max_length=200) class Material(models.Model): name = models.CharField(max_length=200) product = models.ForeignKey(Product) Now, I want to make a cop of Product and keep all of the assigned materials. This is what I tried: new_product = Product.object.get(pk='someexistingpk') new_product.pk = None new_product.name += ' (Copy)' new_product.save() Another variant I tried: new_product = deepcopy(Product.object.get(pk='someexistingpk')) new_product.pk = None new_product.name += ' (Copy)' new_product.save() But in both cases, the resulting model_set is empty. None of the attached items are kept. new_product.material_set.all() <QuerySet []> How can I resolve this? Ideally without iterating over every item in the original material_set. -
flake8 max-complexity per file
I have a legacy project using flake8 to check code quality and complexity, but the project has some very complicated (terrible) services which are returning complexity WARNING messages: ./service1.py:127:1: C901 'some_method' is too complex (50) We are slowly transitioning into making them better, but we need to make jenkins (which is running tests and flake8) pass. Is there a way to specify ignoring a code error or complexity per file, or even per method? -
pagination through ajax_view in Django
feature: I am implementing pagination for one of my views(i.e. customer Report). Existing implementation: In a existing implementation cust report is dumping the info in views itself for that I implemented pagination. My implementation : Instead of dumping the servers info in views , I am rendering through ajax_view. customer info coming properly in ajax_view but same content is not rendering to views. When I tested I see pagination(page numbers) is coming at view but view shows white screen. What exactly I am missing here? Could you please help on this. -
Initialise a Django multiple file field form
I have a django form defined as: class FileFieldForm(forms.Form): file_field = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True})) When I load this form in my views I'm using: file_form = FileFieldForm(request.POST, request.FILES) files = request.FILES.getlist('file_field') if file_form.is_valid(): for f in files: m = MyImages ( image = f, item = item ) m.save() I now want to initialise the form with those files in it and allow the user to change, delete, update the files. My questions are: 1. How do I initialise the form in this case? 2. How do I check if they're changed when the user resubmits? Thanks for your help -
What's the main differences between Django and Angular 2?
I'd like to know the main differences and in what situation each framework is best used. -
How to replace or edit the lookup parameter in a django rest framework Router?
I have set up a Django Rest Framework ModelViewSet for a Product model. The Product has a uuid4 primary key field. The API list views are working, but I can't access the detail views using the default router, I guess because the uuid4 primary key doesn't fit the pk integer regex the router expects? From the router documentation, I believe I need a custom router, but I don't understand how to replace the {lookup} field from an integer pk regex to a uuid4 regex (?P<uuid>[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}). I think the relevant part of the source code is here. My present url config is as follows: from .views.API.product import ProductViewSet from django.conf.urls import include from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register(r'product', ProductViewSet, base_name='product') urlpatterns += [ url(r'^API/0.1/', include(router.urls)), ] -
Angular-Upload not working on iOS
I have an Angular/Django app where I am using angular-upload so that users can upload photos in one of my angular controller templates. I have custom styled boxes, that when clicked trigger a hidden input with type file, and with angular-upload sends the file to one of my Django view functions. It all works out on desktop, and android devices, but just does not want to work on iOS devices. relevant HTML <div class="col-xs-4 outer-left"> <div style="background: #ccc url('{{ trade_in.photo_one }}') no-repeat center;" ng-class="{'no-photo': trade_in.photo_one == '/static/images/plus-sign.png', 'photo-square': trade_in.photo_one != '/static/images/plus-sign.png'}" id="photo-square-1" ng-click="initFileUpload('photo_one')" legal-touch> <div class="mask" ng-if="trade_in.photo_one != '/static/images/plus-sign.png'"></div> </div> <img src="/static/images/icon_delete.png" alt="" ng-if="trade_in.photo_one != '/static/images/plus-sign.png'" class="delete-photo" ng-click="deletePhoto('one')"> </div> <div class="col-xs-4"> <div style="background: #ccc url('{{ trade_in.photo_two }}') no-repeat center;" ng-class="{'no-photo': trade_in.photo_two == '/static/images/plus-sign.png', 'photo-square': trade_in.photo_two != '/static/images/plus-sign.png'}" id="photo-square-2" ng-click="initFileUpload('photo_two')" legal-touch> <div class="mask" ng-if="trade_in.photo_two != '/static/images/plus-sign.png'"></div> </div> <img src="/static/images/icon_delete.png" alt="" ng-if="trade_in.photo_two != '/static/images/plus-sign.png'" class="delete-photo" ng-click="deletePhoto('two')"> </div> <div class="col-xs-4 outer-right"> <div style="background: #ccc url('{{ trade_in.photo_three }}') no-repeat center;" ng-class="{'no-photo': trade_in.photo_three == '/static/images/plus-sign.png', 'photo-square': trade_in.photo_three != '/static/images/plus-sign.png'}" id="photo-square-3" ng-click="initFileUpload('photo_three')" legal-touch> <div class="mask" ng-if="trade_in.photo_three != '/static/images/plus-sign.png'"></div> </div> <img src="/static/images/icon_delete.png" alt="" ng-if="trade_in.photo_three != '/static/images/plus-sign.png'" class="delete-photo" ng-click="deletePhoto('three')"> </div> <div class="col-xs-4 outer-left"> <div style="background: #ccc url('{{ trade_in.photo_four }}') no-repeat center;" ng-class="{'no-photo': trade_in.photo_four == '/static/images/plus-sign.png', 'photo-square': trade_in.photo_four != …