Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
AttributeError: 'TaggableManager' object has no attribute 'rel' error
I am new to django and i can't locate this error: File "E:\charmi\mysite\personal\models.py", line 113, in <module> class Disease(models.Model): File "E:\charmi\mysite\personal\models.py", line 118, in Disease symptoms.rel.related_name = "+" AttributeError: 'TaggableManager' object has no attribute 'rel' This my model file: class TaggedSymptoms(TaggedItemBase): content_object = models.ForeignKey("Disease",on_delete=models.CASCADE) class Disease(models.Model): did = models.AutoField(verbose_name='Disease id',primary_key=True,auto_created=True) dName = models.CharField(max_length=100,unique=True) symptoms = TaggableManager(verbose_name='symptoms list',through=TaggedSymptoms) symptoms.rel.related_name = "+" -
Django rest serializer nested objects serialized as OrderedDict instead of pure JSON
How to make Django serializer to serialize nested objects as json instead of ordereddict? class SummaryGroupContract: class Serializer(serializers.Serializer): total = serializers.DecimalField(max_digits = 10, decimal_places = 2) def __init__(self, total: Decimal): self.total = total class SummaryResponse: class Serializer(serializers.Serializer): income = SummaryGroupContract.Serializer(required=False) expenses = SummaryGroupContract.Serializer(required=False) def __init__(self, income: SummaryGroupContract, expenses: SummaryGroupContract): self.income = income; self.expenses = expenses; class SummaryViewSet(viewsets.ViewSet): def list(self, request): income = SummaryGroupContract(10.0) expenses = SummaryGroupContract(-90.0) return Response(SummaryResponse.Serializer(SummaryResponse(income, expenses)).data) returns {'income': OrderedDict([('total', '10.00')]), 'expenses': OrderedDict([('total', '-90.00')])} expected {'income': {'total': '10.00'}, 'expenses': {'total': '-90.00'}} -
Django url variable not passing
I'm trying to get a variable from url and display it in template using django. Here's the page with the link to the bucket's page: <div id="left"> <a href="{% url 'project:bucket' bucket=bucket.bucketName %}"><h4 id='s3ItemName'>{{ bucket.bucketName }}</h4></a> </div> This displays the bucket name properly and contains a link to abucket detail page. My urls.py look like this: url(r'bienbox/bucket/(?P<bucket>\w+)$',views.bucketPage.as_view(),name='bucket') Now, here's views.py class bucketPage(TemplateView): template_name = "project/bucket.html" def get(self, request, bucket): bucketName = request.GET.get('bucket') return render(request,self.template_name,{'bucketName': bucketName}) So I'm passing the bucketName variable here, however when the page opens I get "None" instead of the variable name. Here's the bucket.html: <div class="mainPage"> <div class="s3Wrapper"> <h2>{{ bucketName }}</h2> </div> </div> What am I doing wrong? Why is the variable not passed? Thanks. -
Can I use a hosted PayPal button with the Django PayPal package?
I'm new to PayPal but I created a hosted button using the form on the PayPal developer website: <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="XXXXXXXXXXXXX"> <table> <tr> <td> <input type="hidden" name="on0" value=""> </td> </tr> <tr> <td> <select name="os0"> <option value="Foo">Foo : £10.00 GBP - monthly</option> <option value="Bar">Bar : £15.00 GBP - monthly</option> </select> </td> </tr> </table> <input type="hidden" name="currency_code" value="GBP"> <input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form> I searched the documentation for the Django PayPal package (https://django-paypal.readthedocs.io/en/stable/) but I didn't see any mention of hosted buttons. Can I use this HTML code as is with Django PayPal, do I have to generate a new button through Django PayPal, or can I somehow point Django PayPal to this hosted button? -
Django intermediate M2M a[href] not saving data to database
Working on a project with Django (social platform) where user can create group for other users to join or leave. This is my first Django project, i'm not sure if my implementation of the join and leave group logic is right. i have a join button which is an a[href] tag: <a href="{% url 'join' group.id %}" class="btn btn-primary">Join Group</a> Clicking it supposed to add the user to the group. Below are the models and views: models.py: @python_2_unicode_compatible class Group(models.Model): title = models.CharField(max_length=255, null=False, unique=True) description = models.TextField(max_length=2000, null=False) location = models.CharField(max_length=255, null=False) date = models.DateTimeField(auto_now_add=True) creator = models.ForeignKey(User, related_name="creator") members = models.ManyToManyField(User, through='Membership') counter = models.IntegerField(blank=False, null=True) @python_2_unicode_compatible class Membership(models.Model): person = models.ForeignKey(User) group = models.ForeignKey(Group) date_joined = models.DateField(auto_now_add=True) views.py: @login_required def group(request, pk): group = get_object_or_404(Group, pk=pk) return render(request, 'group/group.html', {'group': group}) @login_required def join(request, pk): _group = get_object_or_404(Group, pk=pk) membership = Membership() membership.group = _group membership.person = request.user membership.save() return group(request, pk) The user doesn't get saved to the membership table. What is the best way to approach this? Any help will be very much appreciated. Also tried this view function for the join button: @login_required def join(request, pk): _group = get_object_or_404(Group, pk=pk) membership = Membership.objects.create(user=request.user, group=_group) … -
How to make a layout like Youtube? Is there a template in HTML5/CSS3 that I can follow?
How to make an layout like current Youtube's homepage in HTML5/CSS3? I've learned the basics of HTML5/CSS3, Javascript, and Python Django. However, I have no idea about how to find a template to make websites like Youtube or where to find the template. If anyone knows the answers, please let me know. Appreciated!! -
Django 2.0: sqlite IntegrityError: FOREIGN KEY constraint failed
I'm working on adding Django 2.0 support to the django-pagetree library. During automated testing, using an sqlite in-memory database, I'm getting a bunch of errors like this: File "/home/nnyby/src/django-pagetree/pagetree/tests/test_models.py", line 638, in setUp 'children': [], File "/home/nnyby/src/django-pagetree/pagetree/models.py", line 586, in add_child_section_from_dict ... File "/home/nnyby/src/django-pagetree/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 239, in _commit return self.connection.commit() django.db.utils.IntegrityError: FOREIGN KEY constraint failed This is noted in the Django 2.0 release notes: https://docs.djangoproject.com/en/2.0/releases/2.0/#foreign-key-constraints-are-now-enabled-on-sqlite From that description, which I don't fully understand, this shouldn't apply for test databases that aren't persistent, right? Wouldn't my sqlite test db get created with the appropriate options when using Django 2.0? The app settings I'm using for testing are here: https://github.com/ccnmtl/django-pagetree/blob/master/runtests.py -
using a if statement in a generic detail view
I am having trouble to figure out how to manage my error: my app is built that way : a user create a project the user is redirected to a project detail page The user is asked to create a team and add members to that project The user is again redirected to the project detail page rendering now the team name and a list of all the team members. My problem is that I wanted to add a context_data to render in my HTML def get_context_data(self, **kwargs): context = super(ProjectDetailView, self).get_context_data(**kwargs) team_name = Project.objects.get(id=self.kwargs['pk']).team_id.members.all() context['team_name'] = team_name return context but now when I create a project since there is no team and member yet, I am getting an error 'NoneType' object has no attribute 'members' How can I do? is there a way to add a if statement in a view ? -
Django sometimes gives 404 and sometimes gives 200
With the same configuration in Django, visiting the same URL served sometimes gives me a 404 while it will give me a 200 later. Any idea how would this happen and how to solve it? -
Django Model Inheritance - get child
Is there a way to access the actual child of the base model, means: Staying with the example from the django Docs, let's assume I am modeling different delivery restaurants, that just have in common name all have a deliver method as of this: class Place(models.Model): name = models.CharField(max_length=10) class Pizzeria(Place): topping = models.CharField(max_length=10) tip = models.IntegerField() def deliver(self): deliver_with_topping(self.topping) ask_for_tip(self.tip) class Shoarma(Place): sauce = models.CharField(max_length=10) meat = models.CharField(max_lenght=10) def deliver(self): prepare_sauce_with_meat(self.sauce, self.meat) I would now like to execute: Place.objects.get(name="my_place").<GENERIC_CHILD>.deliver() i.e. I don't need to know what the place is actually, just the common deliver method. The model then 'knows' what to call. Is there something like <GENERIC_CHILD>? -
unable to download csv from django admin on HEROKU
This is my code for downloading csv, pretty straight forward, @admin.register(User) class UserAdmin(admin.ModelAdmin): actions = ['download_csv_file','send_mail'] def download_csv_file(self, request, queryset): import StringIO f = StringIO.StringIO() import csv writer = csv.writer(f) writer.writerow(['first name','mobile','email','gender']) for i in queryset: print(i) writer.writerow([i.first_name,i.mobile,i.email,i.gender]) f.seek(0) from django.http import HttpResponse response = HttpResponse(f, content_type='text/csv') response['Content-Disposition'] = 'attachment; filename=User-info.csv' return response This works perfectly on my localhost. But I am unable to download csv when I deployed it on heroku. It gives a 500 interval server error. This is the corresponding log record, 2017-12-03T14:36:06.940950+00:00 heroku[router]: at=info method=POST path="/admin/bookings/user/" host=xxxxx-xx.herokuapp.com request_id=xxxx fwd="xx.xx.xx.xx" dyno=web.1 connect=0ms service=47ms status=500 bytes=234 protocol=https I couldnt get Why is it happening on heroku. Where is the problem? -
Which available UI JavaScript framework should I use to build magazine editor?
I would like to build a single page web application in which user will create its own magazine in predefined templates. The main features which it should have include: upload images or obtain them from social networks move, rotate, scale images fill in texts print final work in pdf The backend part will be written in Django and I am considering one of UI Javascript framework for front-end. Could you please give me an advice which of the following would you prefer: Angular, React or Ember? Or do you have some other framework in mind which would suit for this project? -
django, make pk's child form_class in CBV
I can't understand how to make pk's child object's form in UpdateView for an instance model.py class User(models.Model): id name class A(models.Model): user = models.ForeignKey(User,related_name='shipping_user',on_delete=models.CASCADE) a_name = char form.py class A_Form(ModelForm): class Meta: model=User fields = ('a_name',) widgets = {'a_name': forms.TextInput()} view.py class UPDATE_A(UpdateView): """ update user's A in this class """ model = A form_class = A_Form template_name = "template" success_url = "success_url" def form_valid(self, form): if form.is_valid: form.save() print "success!!" return super(UPDATE_A, self).form_valid(form) and urls.py #<pk> gets user's ID url(r'^update_user_a/(?P<pk>\d+)/$', views.UPDATE_A.as_view()), What I want is ,in view function, finding the A object from user_id given url parameter. And make modelform of A. But I don't know how to make it... *The relation between User and A is 1 to 1. Anyone knows solutions? -
Django-channels - recieve data based on url
I'm very new to django-channels so this is probably a very simple question. On our website, there is a permanent button "Messages" in the header. I want user to be notified about new message immediately. So I use channels for this purpose. If there is a new message created, I send a number of not readed conversations through channels to client: class Message(..): def save(...): notify_recipient(self) def notify_recipient(self): Group('%s' % self.recipient).send({ "text": json.dumps({ "message":{"text":truncatechars(self.text,100)}, "unreaded_conversations":Conversation.objects.get_unreaded_conversations(self.recipient).count(), }), }) And in base.html: const webSocketBridge = new channels.WebSocketBridge(); webSocketBridge.connect('/notifications/'); webSocketBridge.listen(function (action, stream) { console.log(action, stream); var conversations_sidebar = $('#id_conversations_sidebar'); var messages_list = $('#messagesList'); if (action.unreaded_conversations) { $('#id_unreaded_conversations_count').text(action.unreaded_conversations); } On the other hand, there is a page /chat/detail/<username>/ where users chat with each other. This chat should be live so I need to recieve messages through channels. For now, I've added rendered message to the notify_recipient method but the problem is that it has to render the message allways, even when user is not on this /chat/detail/<username>/ url which is not efficient. Do you know how to recieve rendered messages only when user is in the current chat? routing.py @channel_session_user def message_handler(message): message.reply_channel.send({"accept": True}) @channel_session_user_from_http def ws_connect(message,): Group("%s" % message.user).add(message.reply_channel) message.reply_channel.send({"accept": True}) channel_routing = … -
django : table doctor_dschedule has no column named morning_2(Django version1.11)
I am using python and when changing a model in my program i came through this error. I tried to change model's column from morning_1 to morning_2 and used migrate -fake to migrate .But when using the existed database the error says there is no morning_2 column.So i am quite confused,and don't know what to do. -
ImportError: No module named 'django.contrib.admindjango' creating django login app
I am working from a django tutorial on creating a social login system, and I've been getting the error below. The tutorial: https://medium.com/@jainsahil1997/simple-google-authentication-in-django-58101a34736b The error: Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/Users/xxxx/Documents/login/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/Users/xxxx/Documents/login/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 337, in execute django.setup() File "/Users/xxxx/Documents/login/env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/xxxx/Documents/login/env/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Users/xxxx/Documents/login/env/lib/python3.5/site-packages/django/apps/config.py", line 120, in create mod = import_module(mod_path) File "/Users/xxxx/Documents/login/env/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "<frozen … -
wagtail formbuilder show 'required' in template
I am implementing a Formbuilder form in a wagtail website, but like to get the required value while looping over the form fields so I can show a required icon. The required seems to be in the query, but nothing I try shows me a result. -
How to validate on read only field in Django Rest Framework
I'm trying to add a vote functionality to the code found in tutorial of Django Rest Framework. On top of Snippet model, I added a Vote model: class Vote(models.Model): created = models.DateTimeField(auto_now_add=True) voter = models.ForeignKey(User, on_delete=models.CASCADE) snippet = models.ForeignKey(Snippet, related_name='votes', on_delete=models.CASCADE) class Meta: ordering = ('created',) In my serializer, I'm trying to validate the fact that user cannot vote more than once and cannot vote for his own snippet: class VoteSerializer(serializers.HyperlinkedModelSerializer): voter = serializers.ReadOnlyField(source='voter.username',validators=[UniqueValidator(queryset=Vote.objects.all(), message=already_voted)]) snippet = serializers.PrimaryKeyRelatedField(queryset=Snippet.objects.all()) def validate(self, data): snippet = data.get('snippet') voter = data.get('voter') if voter==data['snippet'].owner: raise serializers.ValidationError(u"Voter cannot vote for himself.") return data Voter field must be read-only. Problem is that ReadOnlyField is not available in data structure. How can I validate with read only field? -
Best practice setup for two websites with different style sheets and templates, but similar Django back end
I'm working on a Django back end that will be used by two websites (i.e., a job board for non-profits and a job board for for-profit companies), but I'm not sure how this is best structured to make it easy to push/pull updates to the two websites. The Django code for the websites is highly similar (let's say over 95% overlap), but the websites have slightly different templates and separate CSS style sheets, in order to give each a distinct look and feel. My inclination would be to set this up as a single Django project that stores the CSS style sheets for both websites, has a different templates folder for each website, and has multiple settings files (e.g., base, production_fprofit, production_nprofit). To facilitate any current or future differences in the back end, a settings variable would indicate the platform for which the code is used (e.g., FPROFIT = True/FPROFIT = False) and this variable is called when necessary (e.g., if settings.FPROFIT == True: self.context_dict["profile_form"] = TRUE). Whenever the Django code changes, the code is pushed to GIT and pulled by the two platforms - each running on a separate virtual host, with their own testing, staging, and production environments. … -
Sending Django/Python with image rendered in html template?
I would like to send a HTML-Mail with Python-Django including a picture at a specified place within my template ExampleMail.html ExampleMail.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>MyMail</title> </head> <body> <table width="800"> <tr> <td align="right"><img src={{mylogo}} alt="no picture...?" align="right"></td> </tr> </table> <table width="800"> <tr> <td align="left"> {{name}} {{user}}<br> </td> </table> </body> </html> When sending the Mail to me as a test I get the picture as attachement but not in the ExampleMail.html template. This is how I send the Mail with myMailExample.py and render my mail with params. myMailExample.py from django.core.mail import EmailMultiAlternatives from email.mime.image import MIMEImage from django.template.loader import render_to_string def send_mail_with_picture(): params = {'mylogo':'mylogo.jpg'} html_body = render_to_string('ExampleMAIL.html', params) text_body = render_to_string('ExampleMAIL.html', params) img_data = open("mylogo.jpg", 'rb').read() img = MIMEImage(img_data) img.add_header('Content-ID', 'mylogo') img.add_header('Content-Disposition', 'inline', filename="mylogo.jpg") email = EmailMultiAlternatives( subject="Here is your mail", body=text_body, from_email='noreply@example.com', to=['info@dldlkjgklflskdjf.com',] ) email.attach_alternative(html_body, "text/html") email.mixed_subtype = 'related' email.attach(img) email.send(fail_silently=False) Can you help me on this to render the mail with the picture in place of the table and not as attachement? HA -
Django : how to extract items of another table from one table if they are related by foreign key
I have two tables : User and Details(which includes details of books).They are linked with each other by a foreign key as shown: class Details(models.Model): user= models.ForeignKey(settings.AUTH_USER_MODEL, null=True) BName= models.CharField(max_length=200) BPublisher= models.CharField(max_length=200) BEdition= models.CharField(max_length=100) BAuthor= models.CharField(max_length=200) BClass= models.CharField(max_length=100) Now i need to extract all the books from the table-Details posted by distinct user. How can I do this ? The Filed in Django admin looks like :enter image description here -
HTTP 404, Not Found. Django
I am developing an e-learning website on django 1.11. When going through the website, I am getting HTTP 404, Not Found in the terminal (as shown in the image). This is not the usual 404 error caused by misspelling of the url, because on the browser side the page renders properly (but sometimes keeps on waiting and waiting) and I am not sure what is causing the error. The error looks like this: Error in Powershell In this image, we can see that HTTP returns 200, when asked for subject list page. When the subject select page is requested it first returns 200 (success) but then it returns two 404 errors (I am not sure where they are coming from.) This error has not stopped the server but I do not know whether this error is harmful for production or not. What kind of error is this? How can I get rid of this? Codes: models.py class Subject(models.Model): subject_name = models.CharField(max_length=120) slug = models.SlugField(unique=True, blank=True) faculty = models.CharField(max_length = 120, blank=True) poster_image = models.ImageField(upload_to = None, null=True, blank=True, width_field = "width_field", height_field = "height_field") height_field = models.IntegerField(default = 0, blank=True, null=True) width_field = models.IntegerField(default = 0, blank=True, null=True) def get_subject_select_url(self): … -
Make all fields of ManyToMany Model appear in form
I am all new to coding, for my first project I decided to work with Django. I am coding a web application that will permit a user to create specification sheets very easily, by completing a form that creates a pdf document (a specification sheet). My main model is "Fiches", from which I have m2m links to my other models that can contain 1 or several attributes each. All my codes are below. model.py (not finished setting the parameters, just to have something to work with) -- coding: utf-8 -- from django.db import models from django.conf import settings from django.utils import timezone class Utilisateurs(models.Model): nom = models.CharField(max_length=200) prenom = models.CharField(max_length=200) pays = models.CharField(max_length=200) class Calibres(models.Model): calibre = models.CharField(max_length=200) tolerance = models.CharField(max_length=200) class Additifs(models.Model): denomination_FR = models.CharField(max_length=200) denomination_EN = models.CharField(max_length=200) denomination_ES = models.CharField(max_length=200) class Ingredients(models.Model): denomination_FR = models.CharField(max_length=200) denomination_EN = models.CharField(max_length=200) denomination_ES = models.CharField(max_length=200) class Formes(models.Model): denomination_FR = models.CharField(max_length=200) Denomination_EN = models.CharField(max_length=200) Denomination_ES = models.CharField(max_length=200) class DimensionsProduit(models.Model): denomination_FR = models.CharField(max_length=200) denomination_EN = models.CharField(max_length=200) denomination_ES = models.CharField(max_length=200) Valeur = models.CharField(max_length=200) class Conditionnements(models.Model): primSec_FR = models.CharField(max_length=200) primSec_EN = models.CharField(max_length=200) primSec_ES = models.CharField(max_length=200) nature_FR = models.CharField(max_length=200) nature_EN = models.CharField(max_length=200) nature_ES = models.CharField(max_length=200) compose_FR = models.CharField(max_length=200) compose_EN = models.CharField(max_length=200) compose_ES = models.CharField(max_length=200) couleur_FR = models.CharField(max_length=200) … -
Django, ModuleNotFoundError: No module named 'mysqlclient'
After I set up the virtual environment, I activated it and pip installed a few packages, with pip freeze, I also get what I installed in this virtual-envs: (django-ml) C:\Users\LyuMing\Envs\django-ml\aspolimi> pip freeze Django==1.11.7 django-toolbelt==0.0.1 gunicorn==19.7.1 Jinja2==2.10 MarkupSafe==1.0 mysqlclient==1.3.12 numpy==1.13.3 psycopg2==2.7.3.2 PyMySQL==0.7.11 python-dateutil==2.6.1 But when I try to load the module in the editor, or django shell, for instance, when I try to load mysqlclient, there is an error: ModuleNotFoundError: No module named 'mysqlclient' (django-ml) PS C:\Users\LyuMing\Envs\django-ml> python manage.py shell >>>import mysqlclient Traceback (most recent call last): File "<console>", line 1, in <module> ModuleNotFoundError: No module named 'mysqlclient' then I import sys module to check PATH variables, These modules I installed are in the system path, but why can't I import them? ['C:\\Users\\LyuMing\\Envs\\django-ml\\aspolimi', 'C:\\Users\\LyuMing\\Envs\\django-ml\\Scripts\\python36.zip', 'C:\\Use rs\\LyuMing\\Envs\\django-ml\\DLLs', 'C:\\Users\\LyuMing\\Envs\\django- ml\\lib', 'C:\\Users\\LyuMing\\Envs\\django-ml\\S cripts', 'c:\\python36\\Lib', 'c:\\python36\\DLLs', 'C:\\Users\\LyuMing\\Envs\\django-ml', 'C:\\Users\\LyuMing\\Envs\\dj ango-ml\\lib\\site-packages'] -
How to show content by scrolling down?
I have written some html code for my webpage in which multiple images are shown. the problem is, all the images are loaded at the starting itself. I want to change that to show extra images by scrolling down. How to do that with jQuery? The code is: {% extends "base.html" %} {% load staticfiles %} {% block content %} <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="container"> <h2>Pictures of Coffee</h2> <div class="row"> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/04LDEYRW59.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/90V03Q5Y60.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/O83SF2RB6D.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/5JVPSVP7EI.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/C5Y10KIIHA.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/YSSFRY5B25.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/04LDEYRW59.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/90V03Q5Y60.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/O83SF2RB6D.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/5JVPSVP7EI.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/C5Y10KIIHA.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/YSSFRY5B25.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/04LDEYRW59.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/90V03Q5Y60.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/O83SF2RB6D.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/5JVPSVP7EI.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/C5Y10KIIHA.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/YSSFRY5B25.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/04LDEYRW59.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/90V03Q5Y60.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/O83SF2RB6D.jpg" alt=""></div> <div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/5JVPSVP7EI.jpg" …