Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Testing Django Wizard Views
I'm writing tests for my wizard using this excellent example from PyDoc.net. One of the methods in my TestCase is not returning the correct step in the wizard: class WizardTests(TestCase): def test_form_post_success(self): response = self.client.post('/wizard/new/step2', self.wizard_step_data[0]) wizard = response.context['wizard'] self.assertEqual(response.status_code, 200) self.assertEqual(wizard['steps'].current, 'step2') When I run this, I get back: Traceback (most recent call last): File "/var/www/app/wizard/tests.py", line 71, in test_form_post_success self.assertEqual(wizard['steps'].current, 'step2') AssertionError: 'step1' != 'step2' I am using a NamedUrlSessionWizardView, which is why my URL on the self.client.post is /wizard/new/step2, as opposed to just /wizard/ like the example above. Otherwise, I receive 404's, or 301's for /wizard/new. Do you have any ideas about what could be causing this? -
PDF print dialog when PDF is in server (Django)
Scenario : I'm trying to build an interface where, let's say, many users upload files and an admin has to print them. Expectation : For every file in a table, there will be a PRINT button, which, onclick will popup a print dialog for that file (Google Chrome). Problem : After hours of Googling and trying out stuff, I still haven't gotten how to do this. I tried opening a new window with JavaScript, using iFrames, etc. but all of them have one problem; the file URL seems to be inaccessible through django -
pagination in django without using models
I am trying to do pagination in django. I am not using models. I have a Templateview wherein I will be displaying initial set of data. I just have a get() method in my class to establish connection with MongoDB and get aggregated result. class MYCTargetAnalysisReport(TemplateView): def get(self, request, **kwargs): context = super(MonthlyYearlyCuringTargetAnalysisReportPageView, self).get_context_data(**kwargs) ..... queryset_list = list(db.mycollection.find()) paginator = Paginator(queryset_list, 1) # Records per page queryset = paginator.page(2) if request.method == 'GET' and 'q' in request.GET: page = str(request.GET.get('page')) try: queryset = paginator.page(page) except PageNotAnInteger: queryset = paginator.page(1) except EmptyPage: queryset = paginator.page(paginator.num_pages) context = {"object_list" : queryset} return render(request,"reports/MYCTargetAnalysisReport.html",context) For displaying the subsequent pages, I am trying to inherit Templateview to Listview and override the get_queryset() method. But this doesn't work well. -
How do i make the form field responsive?
I have just started to learn django few weeks. To learn more effectively i have started to build a hotel website and deployed using heroku. The website seems better on mine laptop but looks worse on my ipad or mobile. I wanted to make the form fields reponsive using css or django crispy form. I have found a lot of answers but none of them help me understand how to do it. Also any further recommendation for the website would be recommended for me as a beginner in web development. Here is the website: https://hotel-jumera.herokuapp.com (Its mine practise for building website, so sorry for in case copyright issue) form field in template: <form method='post'> {% csrf_token %} {{booking_form.as_p }} <button type="submit" class="btn btn-success"> Send </button> </form> -
Return error: 'int' object is not iterable in Django
Here is my code. today = datetime.now() past_days = (today - timedelta(days=7)).date() result = Date.objects.filter(date__gt=past_days).count() It returns error 'int' object is not iterable If remove the .count(), it can display the list of result. I just want to get the total number of the result. What's the error mean? How to solve this? -
How do you check if first and last name are unique only on creation?
I have the following model: class Person(models.Model): short_name = models.CharField(max_length=64) long_name = models.CharField(max_length=64) and I have the following form: class PersonForm(forms.ModelForm): class Meta: model = Person fields = ['short_name', 'long_name'] Right now I am using this form for both update and create. I would like this form to raise ValidationError if someone is trying to create a Person with the same short_name and long_name. However, I do not want to raise an exception if a user is modifying an existing user's data. I have thought about writing a clean method to check if Person.objects.filter(long_name=X, short_name=Y).count() returns anything but this condition incorrectly fails when I am modifying an existing instance. How would you change this? -
Having trouble configuring a URL in Django to work with username instead of id (could not resolve URL for hyperlinked relationship)
In my Django code, I have a Profile class which basically extends AbstractUser. I wanted the detail view for this user to use the username instead of the userid, and that is actually working perfectly. In my urls.py, I have url(r'^profile/view/(?P<username>[\w.@+-]+)/$', ProfileDetail.as_view(), name="profile-detail") and my ProfileDetail class looks like this: class ProfileDetail(generics.RetrieveUpdateDestroyAPIView): serializer_class = ProfileSerializer queryset = Profile.objects.all() lookup_field = 'username' accompanied by this line in my Profile serializer: url = serializers.HyperlinkedIdentityField(view_name='profile-detail', lookup_field='username'). This all works great. The problem is when I attempt to view all of my user's "Swipes". My Swipe class has a foreign key relationship with my Profile class (and related_name='swipes' in this foreign key). I added this to urls.py: url(r'^profile/view/(?P<username>[\w.@+-]+)/swipes/$', ProfileSwipesList.as_view(), name="swipe-detail") where my ProfileSwipesList class looks like: class ProfileSwipesList(generics.ListAPIView): serializer_class = SwipeSerializer def get_queryset(self, *args, **kwargs): print(self.kwargs['username']) return Swipe.objects.filter(user = Profile.objects.get(username=self.kwargs['username'])) I verified that the queryset is returning the correct thing, a queryset of Swipe objects. In my Swipe serializer, I tried adding a similar line as the one I added in my Profile serializer: url = serializers.HyperlinkedIdentityField(view_name='swipe-detail'). However, when I try accessing this URL, I get this error: Could not resolve URL for hyperlinked relationship using view name "swipe-detail". You may have failed to … -
How to get past 6 days data in Django?
I have a variable reg_dateand devc. I want to get the total number of devc in the past 6 days. I have these code in views.py todays_date = datetime.now() past_six_days = todays_date - 6 ## I'm afraid if i do like this, I will get negative number when todays_date is 1/11/2018 How can I get the total number of device where 'reg_date' is inside the 'past_six_days' range ? -
Django, serving static files from the STATIC_ROOT when running in runserver?
There's a need to do live debugging in production environment. Some (bundled) static files are only available at the STATIC_ROOT and having trouble accessing it when running runserver Is there a way to access STATIC_ROOT when running runserver? -
Is ti Possible to do a private chat with Django Channels
I want to do a one to one private chat with Django-channels, but i cant find any article/post about it, all i see is on creating group chat. It seem to me like Django-channel can only be used in creating group chat and group gaming system. I want to know if django-channels can handle a one to one private chat and how do i go about that. Thanks in advance. -
DJANGO: JSONDecodeError at /folderName/ Expecting value: line 1 column 1 (char 0)
Django 2.1.2 Python 3.6 I keep getting a JSONDecodeError when I'm trying to load a Json file in my views.py. views.py from django.shortcuts import render, HttpResponse import json def index(request): with open('data.json') as data: args = json.loads(data.read()) return render(request, 'folderName/index.html', args) data.json {"number2":{ "type":"Holiday", "content": [ {"name":"New Year's Day", "month":1, "day":1}, {"name":"Martin Luther King Jr. Day", "month":1, "day":21}, {"name":"National Wear Red Day", "month":2, "day":1}, {"name":"Groundhog Day", "month":2, "day":2}, {"name":"Valentine's Day", "month":2, "day":14}, {"name":"Presient's Day", "month":2, "day":18}, {"name":"Employee Appreciation Day", "month":3, "day":1}, {"name":"Daylight Savings Time", "month":3, "day":10}, {"name":"St. Patrick's Day", "month":3, "day":17}, {"name":"Good Friday", "month":4, "day":19}, {"name":"Easter Sunday", "month":4, "day":21}, {"name":"Cinco De Mayo", "month":5, "day":5}, {"name":"Mother's Day", "month":5, "day":12}, {"name":"Memorial Day", "month":5, "day":27}, {"name":"Flag Day", "month":6, "day":14}, {"name":"Father's Day", "month":6, "day":16}, {"name":"Independence Day", "month":7, "day":4}, {"name":"Labor Day", "month":9, "day":2}, {"name":"Columbus Day", "month":10, "day":14}, {"name":"Halloween", "month":10, "day":31}, {"name":"Daylight Savings Time", "month":11, "day":3}, {"name":"Vetern's Day", "month":11, "day":11}, {"name":"Thanksgiving Day", "month":11, "day":28}, {"name":"Black Friday", "month":11, "day":29}, {"name":"Cyber Monday", "month":12, "day":2}, {"name":"Pearl Harbor Rembrance Day", "month":12, "day":7}, {"name":"Christmas Eve", "month":12, "day":24}, {"name":"Christmas Day", "month":12, "day":25}, {"name":"New Year's Eve", "month":12, "day":31} ] }} It will decode in a separate py file when I have the same code that is ran through idle. import json with open('data.json') … -
How do i separate javacscript functions in django templates
am working with the django 2.1 framework i have a problem with the html template am using, which has several pages like home,about,contacts,and support and each has java scripts functions to automate things in the page like sliders which are at the end of each page before the So i decided to have my base.html to contain the footer and header for both pages since are similar .so the problem here is where do i put these js functions 1. leaving them in the particular page and extending the base.html they don't function 2.attaching them to base.html some properties of the functions don't work too. any advice please -
Polymorphically serializing objects in django
I have the following object inheritance model. class Room: name = models.CharField(db_index=True, unique=True, max_length=255) status = models.CharField(default=RoomStatus.ACTIVE, max_length=256, null=True) members = models.ManyToManyField(User) last_activity = models.DateTimeField(default=timezone.now) And the inherited models are, class LeagueRoom(Room): league = models.ForeignKey(League, on_delete=models.CASCADE, null=True) location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True) logo_url = models.CharField(max_length=1024, null=True) and class ClubRoom(Room): club = models.ForeignKey(Club, on_delete=models.CASCADE, null=True) location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True) logo_url = models.CharField(max_length=1024, null=True) The respective Serializers are as follows, class RoomSerializer(serializers.ModelSerializer): members = UserSerializer(read_only=True, many=True) class Meta: model = Room fields = ('id', 'name', 'status', 'members', 'created', 'modified', 'last_active') and class LeagueRoomSerializer(serializers.ModelSerializer): location = LocationSerializer(read_only=True) league = LeagueSerializer(read_only=True) room = RoomSerializer(read_only=True) class Meta: model = LeagueRoom fields = ('id', 'name', 'location', 'status', 'league', 'logo_url', 'room', 'created', 'modified',) and class ClubRoomSerializer(serializers.ModelSerializer): location = LocationSerializer(read_only=True) club = ClubSerializer(read_only=True) room = RoomSerializer(read_only=True) class Meta: model = ClubRoom fields = ('id', 'name', 'location', 'club', 'logo_url', 'status', 'room', 'created', 'modified',) My problem is that I have fetched all rooms for an user in the following manner. rooms = user.room_set.order_by('-last_activity') Now I want to Serialize this data based on the room type. Thus instead of using the RoomSerializer I want to traverse the list of rooms and if the room is ClubRoom, then use ClubRoomSerializer or … -
DRF (django-rest-framework) action decorator not working
I have this class view, that works perfectly for creating and listing objects of SiteGroup: But I need a method to perform several operations on a single SiteGroup object, and objects associated with them. Therefore, I have tried to create a method, decorated with @action (as suggested by the docs). According to the docs, this will autogenerate the intermediate url. Nevertheless, it doesn't work. When I try to access (given that 423 is an existing SiteGroup Object): http://127.0.0.1:8000/api/site-groups/423/replace_product_id/?product_id=0x345 the url is not found. I also tried generating myself the URL in the urls.py, with no luck. Can someone tell me where the problem is? I've browsed through all the docs, and found no clue. Thanks a lot. class SiteGroupDetail(generics.ListCreateAPIView): queryset = SiteGroup.objects.all() parser_classes = (MultiPartParser, FormParser, JSONParser) serializer_class = SiteGroupSerializer authentication_classes = (authentication.TokenAuthentication,) @action(detail=True, methods=['post'], url_path='replace_product_id', permission_classes=[IsSuperUser], url_name='replace_product_id') def replace_product_id(self, request, pk=None, device_type=None): serializer = SiteGroupSerializer(data=request.data) product_id = self.request.query_params.get('product_id', None) print("replace_product", product_id, device_type, pk, flush=True) return Response({"hello":product_id}) My urls.py from django.conf.urls import url, include from api import views, routers router = routers.OptionalSlashRouter() router.register(r'users', views.UserViewSet) router.register(r'groups', views.GroupViewSet) urlpatterns = [ url(r'^', include(router.urls)), url(r'^site-groups/$', views.SiteGroupList.as_view()), url(r'^site-groups/(?P<pk>[0-9]+)/$', views.SiteGroupDetail.as_view()), ] And OptionalSlashRouter: from rest_framework.routers import SimpleRouter class OptionalSlashRouter(SimpleRouter): def __init__(self): self.trailing_slash = '/?' super(SimpleRouter, … -
How to clone a git repository based on the git+ssh entry in requirements.txt?
I have a requirements.txt file with the following entry: git+https://github.com/venmo/responses.git@0.13.0-dev.0#egg=responses==0.13.0-dev.0 I would like to clone this specific version, with branch 0.13.0-dev.0. However, if I go to https://github.com/venmo/responses and browse the branches, I don't see any such branch. How can I clone this version of the code? -
Securely Storing Token for SPA
I've recently been learning about single-page applications (SPA) and how to use these with a backend web API. Currently I've been using Django/Django REST Framework (DRF) for the backend web API and that is going well. But I'm currently stuck on the practical side of how to securely communicate between a front end (React) and a backend web API (Django/DRF). There is a tutorial program that I've been looking at recently which functionally (on the surface) does what I'm hoping to do (if I'm understanding the process correctly): User logs in via frontend SPA login form User credentials are POSTed to backend web API Backend web API checks credentials Backend web API sends back a user-based token, if credentials are valid SPA saves user-based token for future backend web API calls I'm concerned about that last step, however, because of articles such as this and this. From what I understand, it's not safe to store token information in either localStorage or sessionStorage, which is evidently what the tutorial I've been going through uses. The safest approach I've found so far in avoiding XSS and CSRF-related issues is discussed near the end of this article. I cannot seem to find an … -
Django and Gunicorn logging to multiple locations
I am running a django 2.0 app via Gunicorn 19.9.0 which is started via systemd. Gunicorn is started as follows: ExecStart=/home/xxx/venv/prd/bin/gunicorn --pid /run/gunicorn/pid_prd --access-logfile /var/log/gunicorn/prd/access.log --log-file /var/log/gunicorn/prd/gunicorn.log --error-logfile /var/log/gunicorn/prd/error.log --config gunicorn_config.py --bind=127.0.0.1:9000 myapp.wsgi:application For my gunicorn logs I can see access.log and error.log, but no gunicorn.log. access.log contains incoming url requests and the error.log contains standard gunicorn startup messages. For django the logs are configured to be output to a separate location (~/logs/...) however sometimes the log messages are not there and they appear in /var/log/messages as follows: Nov 8 21:16:23 xxx gunicorn: 2018-11-08T21:16:23,509 INFO ...my message... My django app logging config looks like this: { "version": 1, "disable_existing_loggers": false, }, "handlers": { "console": { "class": "logging.StreamHandler", "level": "DEBUG", "formatter": "simple", "stream": "ext://sys.stdout" }, "info_file_handler": { "class": "logging.handlers.TimedRotatingFileHandler", "when": "MIDNIGHT", "interval": 1, "utc": true, "level": "INFO", "formatter": "simple", "filename": "$HOME/logs/info.log", "backupCount": 0, "encoding": "utf8" }, } "root": { "level": "INFO", "handlers": [ "console", "info_file_handler", ] } } Can anyone help to explain why sometimes my logs goto /var/log/messages instead of $HOME/logs/info.log ? Thanks in advance -
matterllo - uWSGI/django & nginx 400 Bad Request
I'm trying to set-up matterllo on Ubuntu 16.04.5 LTS When I run the server manually via python manage.py runserver, without nginx, the hooks are creating with success. But, when I try to put the things up via uWSGI behind nginx delete trello hook :: result=[] create trello hook :: callback=http://matterllo.x.com:8080/callback/1/ :: board=amazon-argila :: result=False create trello hook :: callback=http://matterllo.x.com:com:8080/callback/2/ :: board=apiscrm :: result=False create trello hook :: callback=http://matterllo.x.com:8080/callback/2/ :: board=apiscrm :: result=False nginx config: server { listen 8080; server_name matterllo.x.com; location / { include uwsgi_params; uwsgi_ignore_client_abort on; uwsgi_pass unix:/home/silviu/uwsgi/trello.sock; } } uwsgi ini config: home = /home/silviu/matterllo/venv chdir = /home/silviu/matterllo wsgi-file = /home/silviu/matterllo/matterllo/wsgi.py logger = file:/home/silviu/uwsgi/sites/trello.log socket = /home/silviu/uwsgi/trello.sock vacuum = true master=true chown-socket = silviu:www-data chmod-socket = 666 uid = silviu gid = www-data die-on-term = true module=run:app /etc/systemd/system/uwsgi.service [Unit] Description=uWSGI Emperor service [Service] ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown silviu:www-data /run/uwsgi' ExecStart=/usr/local/bin/uwsgi --emperor /home/silviu/uwsgi/sites Restart=always KillSignal=SIGQUIT Type=notify NotifyAccess=all [Install] WantedBy=multi-user.target And this is the create hook method, but I don't think the source of problem is it: def create_hook(self, callback_url, id_model, desc=None, token=None): """ Creates a new webhook. Returns the WebHook object created. There seems to be some sort of bug that makes you unable to create a … -
No module named 'django_cas_ng'
I am trying to run a webpage using PyCharm, but when I run the server, I see an error saying: ModuleNotFoundError: No module named 'django_cas_ng'. I looked up for solutions on sources like this, this, and this. I believed I needed to install specific modules but none of them worked -
angular RXjs unsubscribe in subscribe callback function?
I've been looking around for a simple way to avoid the memory leaks I've read about caused by failing to unsubscribe. Everything is too much work, and I'm allergic to boilerplate, so... The silly thing, to my way of thinking, is that most of the time I'm just wanting the ONE response from my backend. And then I'll want to unsubscribe. So why not call it in the callback? onSubmit(){ var killme = this.puzzleService.login(this.nameoremail, this.password).subscribe( success =>{ if(success){ this.router.navigate(['/puzzles']); } else{ this.message="Login failed. Please try again."; } this.loading=false; killme.unsubscribe(); }); this.loading=true; } Note the assignment of the subscription to a local variable. This local variable is then locked inside a closure and told to kill itself when it's work is done. No class variables, no takeUntil, nothing else. This code seems to work and seppuku is, if nothing else, and honorable solution. Ok, fine. It compiles and runs without error. I'm not familiar enough with the debugger to determine if the observable object is actually destroyed and subsequently garbage collected. Is there something I'm missing? Can someone more familiar with the debugger correct me? 'Cause if this works I'm gonna be doing this everywhere. Except in my pollWords() function... This … -
why JSON.parse() is not working in my code?
Here is some codes: var act = '{{ activities_json }}'.toString(); var lat = 43.767760; var lng = -79.502970; var latLng = {lat: lat, lng: lng}; document.getElementById("json").innerHTML = act[0]; var obj = JSON.parse(act); document.getElementById("demo").innerHTML = 1; The problem is the JSON.parse() line. If I comment that line, I can see [ and 1 in my HTML page. But if I uncomment the JSON.parse() line, I cannot see 1 anymore, indicating the JSON.parse() code has some error. But I did not find anything wrong. Could someone help me on that? The act is a string which is : [{"model": "CS_Activities.activities", "pk": 1, "fields": {"act_name": "gun shot", "location": "York Universitty", "loc_lat": 43.76776, "loc_long": -79.50297, "time": "2018-11-05T20:25:08Z", "description": "a people dead"}}, {"model": "CS_Activities.activities", "pk": 2, "fields": {"act_name": "another gun shot", "location": "York Village", "loc_lat": 43.76, "loc_long": -79.5, "time": "2018-11-05T22:35:06Z", "description": "A person shot dead while walking"}}] -
Can't access order page for my online shop from the cart page-django url error
Am doing online shop example in Django 2.0.5 and i have run into url error when trying to checkout the cart to the order page.it brings the error below Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/cart/%25%20url Using the URLconf defined in myshop.urls, Django tried these URL patterns, in this order: admin/ orders/ cart/ [name='cart_detail'] cart/ add/<int:product_id>/ [name='cart_add'] cart/ remove/<int:product_id>/ [name='cart_remove'] [name='product_list'] <slug:category_slug>/ [name='product_list_by_category'] <int:id>/<slug:slug>/ [name='product_detail'] ^media\/(?P<path>.*)$ The current path, cart/% url, didn't match any of these. myshop/orders/urls.py from django.urls import path from . import views app_name = 'orders' urlpatterns = [ path('create/', views.order_create, name='order_create'), ] myshop/orders/views.py from .models import Order from django.conf import settings from django.http import HttpResponse def order_create(request): cart = Cart(request) if request.method == 'POST': form = OrderCreateForm(request.POST) if form.is_valid(): order = form.save() for item in cart: OrderItem.objects.create(order=order, product=item['product'], price=item['price'], quantity=item['quantity']) # clear the cart cart.clear() return render(request, 'orders/order/created.html', {'order': order}) else: form = OrderCreateForm() return render(request, 'orders/order/create.html', {'cart': cart, 'form': form}) myshop/orders/admin.py from django.contrib import admin from django.http import HttpResponse from .models import Order, OrderItem class OrderItemInline(admin.TabularInline): model = OrderItem raw_id_fields = ['product'] @admin.register(Order) class OrderAdmin(admin.ModelAdmin): list_display = ['id', 'first_name', 'last_name', 'email', 'address', 'postal_code', 'city', 'paid', 'created', 'updated'] list_filter = ['paid', 'created', 'updated'] inlines … -
Django adding to database with foreign key while still showing the informations from the other model
I want to add elements to my database (for model Student) while having stuff from another model (School) be displayed alongside the form for the Student.\ This is the models.py class School(models.Model): name = models.CharField(max_length=256) principal = models.CharField(max_length=256) location = models.CharField(max_length=256) def get_absolute_url(self): return reverse('basiccbv:detail', kwargs={'pk':self.pk}) def __str__(self): return self.name class Student(models.Model): name = models.CharField(max_length=256) age = models.PositiveIntegerField(validators= [validators.MinValueValidator(1),validators.MaxValueValidator(20)],default=1) school = models.ForeignKey(School, related_name='students') def __str__(self): return self.name In my views.py I have this: class SchoolDetailedView(DetailView): context_object_name = 'school_detail' model = models.School template_name = 'basiccbv/school_detail.html' # What i want is when I visit the link in the description I want to # to see the school stuff and the form to add the student in this new # view class StudentCreateView(CreateView): model = models.School # I tried using the Student but that I don't know how to display the # school information, I tried with related_name = 'students' but it # didn't work(I don't know if that can be done the way that intended it # or I just don't have the knowledge ) fields = ['name', 'age'] # If I use School I could get the name of the school in the title and # its primary key, but than … -
Django filter from multiple models
I get a list (QuerySet) of objects from which I would like to filter like that: books = Book.objects.filter(author="Someone") Paragraph.objects.filter(book=books) I expect to get a QuerySet of paragraphs that are related to the books I got earlier, the problem is that the QuerySet of paragraphs come only from the first book in the QuerySet -
Gruntfile.jsThe "path" argument must be of type string
I am creating a Django website and I am trying to get the following gruntfile.js file to run correctly and run a SASS compiler along with Django-Compressor. I'm stuck on this error, but i'm assuming it has something to do with the var PathsConfig function. My app is called Mysite Any help is greatly appreciated. Gruntfile.js module.exports = function (grunt) { var appConfig = grunt.file.readJSON('package.json'); // Load grunt tasks automatically // see: https://github.com/sindresorhus/load-grunt-tasks require('load-grunt-tasks')(grunt); // Time how long tasks take. Can help when optimizing build times // see: https://npmjs.org/package/time-grunt require('time-grunt')(grunt); var pathsConfig = function (appName) { this.app = appName || appConfig.name; return { app: this.app, templates: this.app + 'mysite/templates', css: this.app + 'mysite/static/css', sass: this.app + 'mysite/static/sass', fonts: this.app + 'mysite/static/fonts', images: this.app + 'mysite/static/images', js: this.app + 'mysite/static/js', manageScript: 'local.py', } }; grunt.initConfig({ paths: pathsConfig(), pkg: appConfig, // see: https://github.com/gruntjs/grunt-contrib-watch watch: { gruntfile: { files: ['Gruntfile.js'] }, sass: { files: ['<%= paths.sass %>/**/*.{scss,sass}'], tasks: ['sass:dev'], options: { atBegin: true } }, livereload: { files: [ '<%= paths.js %>/**/*.js', '<%= paths.sass %>/**/*.{scss,sass}', '<%= paths.app %>/**/*.html' ], options: { spawn: false, livereload: true, }, }, }, // see: https://github.com/sindresorhus/grunt-sass sass: { dev: { options: { outputStyle: 'nested', sourceMap: false, precision: 10 …