Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
outputting a pdf file using docx module in python
I am trying to output a pdf using the docx python module. I am using docx because I can format it very nicely. I want my file output to be .pdf instead of .docx. When i set the file output to .docx it works perfectly, generating a word document file. However, when i set it to .pdf it generates a corrupt pdf file. def making_a_doc_function(request): doc = docx.Document() doc.add_heading('hello') doc.save('thisisdoc.pdf') generated_doc = open('thisisdoc.pdf', 'rb') response = {"generated_doc": FileResponse(generated_doc)} return render(request, 'doc.html', response) -
Changing the password doesnt log out the user
To my understanding Django at one point logged out the user after a password was changed but after I change a password to a test user it keeps them logged in. Is there I am missing or is there context I need to add to make this possible? -
Django translations is not working on production in Ubuntu 18.04
On my development machine my translations work perfectly, but on my production server they don't. I follow all the suggestion showed here but my site continue without show the translations I follow django translation settings but nothing. I don't know if anything I'm doing is wrong or if I'm missing any settings. Settings.py TIME_ZONE = "America/Bogota" LANGUAGE_CODE = "es-co" USE_I18N = True USE_L10N = True USE_TZ = True LOCALE_PATHS = [BASE_DIR.path("locale")] # If I print this variable the location its ok -> project_root/locale Creating the translation files for every locale that the site will support: python manage.py makemessages -l es-CO the result is: project_root βββlocale βββ README.md βββ es_CO βββ LC_MESSAGES βββ django.po Compiles .po files: python manage.py compilemessages the result is: project_root βββlocale βββ README.md βββ es_CO βββ LC_MESSAGES βββ django.mo βββ django.po Production Environment Ubuntu 18.04 python 3.8 django 3.0.8 nginx 1.14.0 Aditional notes Every time that I change something in my locale settings I reload the server. I fill all translations in django.po file. My browser language settings have spanish as primary language. -
Django: Query Product Type and/or Category
I am trying to create a product list page where the user can perform two types of filters to sort through the products. The filters are for the product category and product type. Whats the best way to do this? My code below shows what I tried but it only allows me to query the categories. When I try to select between product types, I get a: "Page not found (404), No Category matches the given query." Any help would be appreciated! I'm still a bit new. models.py class Type(models.Model): name = models.CharField(max_length=50, db_index=True) slug = models.SlugField(max_length=200, unique=True) class Meta: ordering = ('name',) def __str__(self): return self.name def get_absolute_url(self): return reverse('product_list_by_type', args=[self.slug]) class Category(models.Model): name = models.CharField(max_length=100, db_index=True) slug = models.SlugField(max_length=200, unique=True) class Meta: ordering = ('name',) verbose_name = 'category' verbose_name_plural = 'categories' def __str__(self): return self.name def get_absolute_url(self): return reverse('product_list_by_category', args=[self.slug]) class Product(models.Model): name = models.CharField(max_length=200, db_index=True) description = models.TextField(blank=True) price = models.FloatField() image = sorl.thumbnail.ImageField(upload_to='thumbnails', null=True, default='default.jpg') type = models.ForeignKey(Type, on_delete=models.SET_NULL, null=True) category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True, related_name='products') manufacturer = models.ForeignKey(Manufacturer, on_delete=models.CASCADE) slug = models.SlugField(db_index=True, max_length=200) available = models.BooleanField(default=True) created = models.DateTimeField(auto_now_add=True, blank=True, null=True) updated = models.DateTimeField(auto_now=True) class Meta: ordering = ('name',) index_together = (('id', 'slug'),) def __str__(self): β¦ -
No such file or directory when trying to upload images in Django
I have an ImageField on a Profile model so users can upload images. However, when I try to upload an image I get this error: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\name\\Documents\\Projects\\project\\media\\image.png'. When I look in the database, the profile_image field gets popuated as "image.png" but the file doesn't appear in any folders in the project. settings.py STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' # Extra places for collectstatic to find static files. STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) DEBUG_PROPAGATE_EXCEPTIONS = True STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' urls.py urlpatterns = [ ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) models.py def validate_image(image): file_size = image.file.size limit_kb = 1000 if file_size > limit_kb * 1024: raise ValidationError("Max size of file is %s KB" % limit_kb) class Profile(models.Model): ... profile_image = models.ImageField(upload_to='profile_images/', blank=True, null=True, validators=[validate_image]) views.py profile_form = ProfileForm(request.POST, request.FILES, instance=profile) updatedProfile = profile_form.save(commit=False) updatedProfile.save() currentuser.email = request.POST['email'] currentuser.save() messages.success(request, 'Profile successfully updated!') return redirect('viewprofile', slug=profile) forms.py class ProfileForm(ModelForm): class Meta: model = Profile fields = ['profile_image', ...] template <label for="profile_image">Profile Image (size cannot exceed 1 MB)</label></p> <input id="profile_image" type="file" class="" name="profile_image"> -
how do i use django signals with views and models
i am trying to create a booking page, my models works correctly. i can create appointments from the admin page. i want to create appointments from my html template, how do i do it. i have written signals.py file but i do not know what should be in the view or template file. i'm thinking the book button will be a form signals.py from django.contrib.auth.models import User from django.dispatch import receiver from django.db.models.signals import post_save from .models import Profile, Appointment @receiver(post_save, patient=Appointment) def post_save_add_to_appointment_with(patient, created, instance, **kwargs): patient_ = instance.patient hospital_ = instance.hospital if instance.status == 'approved': patient_.appointment_with.add(patient_.User) hospital_.appointment_with.add(hospital_.User) patient_.save() hospital_.save() models.py from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from django.conf import settings class Profile(models.Model): username = models.CharField(max_length=50, blank=True) user = models.OneToOneField(User, on_delete=models.CASCADE) last_name = models.CharField(max_length=100, blank=True) first_name = models.CharField(max_length=100, blank=True) last_name = models.CharField(max_length=100, blank=True) email = models.EmailField(max_length=150) appointment_with = models.ManyToManyField(User, related_name='appointment_with', blank=True) def __str__(self): return self.user.username def get_hospitals(self): return self.hospitals.all() STATUS_CHOICES = ( ('book', 'book'), ('approved', 'approved'), ) @receiver(post_save, sender=User) def update_profile_signal(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) instance.profile.save() class Appointment(models.Model): patient = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='patient') hospital = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='hospital') created = models.DateTimeField(auto_now_add=True) status = models.CharField(max_length=50, choices=STATUS_CHOICES, default='none') def β¦ -
Django Form and multiple users
I am currently trying to implement a way of sending surveys to the users on my site. The classes that I have right now are as follows: A survey class, representing survey objects with name and URL to external surveying site. A "survey invite" class that has: 1) a many-to-one relationship with survey object (that is, each invite references only one survey but we can send out multiple invites for the same survey). Ideally would want a second field representing a list of Users that we want to send the survey to. Notification objects associated with particular users. User objects for each user on the site. The "survey invite" class is hooked up to a post_save function that will end up creating notifications objects specific to the user, for all users. I want to facilitate the creation of survey invites by creating survey invites through a Django Form. Furthermore, what I'm currently trying to accomplish is to be able to send out surveys to MULTIPLE users. I'm come up with the following idea, but unsure of how to proceed: I want something like a list of users in the "survey invite" class that represents the users to send the survey β¦ -
err trying to extending user model in django restframework
sup guys, i want to extend django user model using oneToOneField in my django api project, but i'm getting a wired error, hoping anyone can help out, below is my code and the err msg ##models.py class Profile(models.Model): yearOfExperience = models.PositiveIntegerField(default=1) profession = models.CharField(max_length=250, blank=True, null=True) dp = models.URLField(blank=True, null=True) qualification = models.CharField(max_length=255, blank=True, null=True) phoneNumber = models.CharField(max_length=255, blank=True, null=True) @receiver(post_save, sender=CustomUser) def create_user_profile(sender, instance=None, created=False, **kwargs): if created: Profile.objects.create(user=instance) instance.profile.save() ##serializer class ProfileSerializer(serializers.ModelSerializer): id = serializers.IntegerField(source = 'pk', read_only = True) username = serializers.CharField(source = 'user.username', read_only = True) email = serializers.CharField(source = 'user.email', read_only=True) class Meta: model = Profile fields = ('id', 'email', 'username', 'yearOfExperience', 'qualification', 'profession', 'phoneNumber' ) def create(self, validated_data, instance=None): if 'user' in validated_data: user_data = validated_data.pop('user') user = CustomUser.objects.create(**validated_data) profile = Profile.objects.update_or_create(user=user, **validated_data) return user ##apiView class ProfileListView(generics.ListCreateAPIView): permission_classes = (IsAuthenticatedOrReadOnly,) queryset = Profile.objects.all() serializer_class = ProfileSerializer def perform_create(self, serializer): serializer.save(user=self.request.user) ##err msg File "/home/olaneat/Desktop/filez/project/django/funzone/lib/python3.7/site-packages/django/db/models/base.py", line 500, in __init__ raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.__name__, kwarg)) TypeError: CustomUser() got an unexpected keyword argument 'yearOfExperience' -
How to check if a user has at least one Permission in Django
I'm trying to display to end user that they have no permission assigned. How can I do that with Django templates? -
How do you migrate models in Django?
I made an abstract parent and a child model in Django. Now, I want the parent to have its own database table but since it was an abstract model, simply removing the abstract = True from the class Meta forces me to assign all child instances a pointer. I was advised here to create new Base/ Child classes and migrate the old ones to these new ones, but I'm having a lot of trouble figuring out exactly how to do that. I wrote a migration file to attempt to do this, but it has had no effect: def migrate_classes(apps, schema_editor): OldBase = apps.get_model('appname', 'OldBase').__dict__.items() NewBase= apps.get_model('appname', 'NewBase').__dict__.items() OldChild = apps.get_model('appname', 'OldChild').__dict__.items() NewChild = apps.get_model('appname', 'NewChild').__dict__.items() for attr, val in OldBase: NewBase= attr, val for attr, val in OldChild: NewChild= attr, val class Migration(migrations.Migration): dependencies = [ ('appname', '0015_auto_20200803_1409'), ] operations = [ migrations.RunPython(migrate_classes), ] When only the code to migrate the Child classes is run, it migrates without error but does not actually instantiate any models of NewChild (which should be copies of OldChild). Also, when the code is run including the Base classes, I get a LookupError stating that my app does not have an OldBase model (presumably since β¦ -
How to update multiple rows at once using Django forms.ModelForm in views.py
I am trying to update many rows of a model based on user input but I'm having trouble updating them in views.py. I create the modelForm class MyForm(forms.ModelForm): class Meta: model = MyModel fields = ["book_title", "book_title_2"] In my views def my_view(request): query = MyModel.objects.filter(foo=foo) forms = [MyForm(instance=q) for q in query] context["forms"] = forms In templates I iterate over forms and input data for some rows. I know normally on form submission I can use form = MyForm(request.POST) and use the is_valid() and save() attributes to save new data to my model. But when I am using a list of forms like above to update many instances, how can I actually save the forms in views.py? When I call MyForm(request.POST) after submitting all of the queried forms at once I get this error 'WSGIRequest' object has no attribute 'FORM' . When I look at the post data I see a list values for book_title and book_title_2. It seems that because I'm submitting more than one form it doesn't work. Is there a workaround for this? Thanks -
Django: TemplateSyntaxError Could not parse the remainder:
I dont know what is the error with my code: msgerChat.append(` <div class="${side_append}" class="msg"> <div class="msg-img" style="background-image: url({% if ${chatDataMsg.username} != object.first %}{{ object.first.profile.avatar.url }}{% else %}{{ object.second.profile.avatar.url }}{% endif %})"></div> <div class="msg-bubble"> <div class="msg-info"> <div class="msg-info-name">${chatDataMsg.username}</div> <div class="msg-info-time">${formatDate(new Date())}</div> </div> <div class="msg-text">${chatDataMsg.message}</div> </div> </div> `) it is giving me this error: TemplateSyntaxError at /messages/Marcela Could not parse the remainder: '${chatDataMsg.username}' from '${chatDataMsg.username}' -
'ProductListView' object has no attribute 'object_list'
I am getting an error and I think it may be for the same reasons Viktor had a problem ('ProductList' object has no attribute 'object_list') On Viktors post AKS wrote - You might be getting the error on following line in get_context_data() of the super class: queryset = kwargs.pop('object_list', self.object_list) The get method of BaseListView sets the object_list on the view by calling the get_queryset method: self.object_list = self.get_queryset() But, in your case, you are calling get_context_data() in get_queryset method itself and at that time object_list is not set on the view. I reviewed my trace back and saw code that AKS had mentioned. File "C:\Users\HP\Django Projects\EcommerceProject\products\views.py", line 48, in get_context_data context = super(ProductListView, self).get_context_data(*args, **kwargs) File "c:\Users\HP\DJANGO~1\ECOMME~1\lib\site-packages\django\views\generic\list.py", line 131, in get_context_data queryset = kwargs.pop('object_list', self.object_list) AttributeError: 'ProductListView' object has no attribute 'object_list' [03/Aug/2020 18:20:21] "GET /products/ HTTP/1.1" 500 90906 Here is my code class ProductListView(ListView): model = Product template_name = "products/list.html" # added for pagination context_object_name='object_list' #Default: object_list # print(context_object_name) # paginate_by = 3 def get_context_data(self, *args, **kwargs): context = super(ProductListView, self).get_context_data(*args, **kwargs) cart_obj, new_obj = Cart.objects.new_or_get(self.request) print("get context data") # context = {} context['cart'] = cart_obj return context def get_queryset(self, *args, **kwargs): request = self.request return Product.objects.all() def β¦ -
can i use django if statment to run javascript
I want to show the image only if the output of the data comes out here is the code .. the function on JS is to hide and show the image but I need to show the image only if the data output comes out {% load static %} <html> <head> <title> Python button script </title> </head> <body> {% if data %} {{data | safe}} {% endif %} <form action="/external/" method="post"> {% csrf_token %} Input Text: <input type="text" name="param" required><br><br> <p id="demo" style="color:red">{{data_external}} {{data1}} </p> <img id="pic" src="{% static 'images/graph.png' %}" style="display:none;" /> <input type="submit" onclick="reloadimg();" value="Execute External Python Script"> </form> </body> </html> <script> function reloadimg(){ var src = "{% static 'images/graph.png' %}"; imageObject = document.getElementById("pic"); imageObject.style.display = 'inline-block'; imageObject.src = src; } </script> if you have any questions please let know -
Dynamic MultipleChoiceField breaks POST request in Django
I have a django form that has a multiple choice field. The field should be dynamic, that is, only the records associated with the user who is currently logged in should be displayed. I've managed to put this together so far; forms.py class myForm(forms.ModelForm): def __init__(self, someUser, *args, **kwargs): super(myForm, self).__init__(*args, **kwargs) someRecords = models.SomeModel.objects.filter(someUser = someUser) #The line above gets records associated with a specific user displayNames = [] for i in someRecords: displayNames.append((i.someField, i.someOtherField + ' ' + i.someOtherField2)) #I am basically making a list of tuples, containing a field and a concatnation of two other fields. The latter will be what is displayed in the select box self.fields['theSelectField'] = forms.ChoiceField(choices = displayNames) class Meta: #I defined model, fields and labels here views.py def myFormPage(request): someUser = request.user.someextensionofuser.someUser form = forms.myForm(someUser) context = {'form': form} if request.method == 'POST': form = forms.myForm(request.POST) if form.is_valid(): #Do Stuff if form is valid. However,this stuff doesn't get done, the page refreshes instead So I've managed to make the select options dynamic. However, now I can't submit data, the page just refreshes. My development server records a POST event, but no data is really sent to the database. [03/Aug/2020 17:59:25] "POST /transactionsform β¦ -
Django: How to pass string name instead of foreign id when creating an object
I have two table, ShippingAddress and Invoice table linked via ForeignKey. I have created a signals file that automatically creates Invoice instance whenever a new ShippingAddress instance is created. My problem is, I can't directly add a new Invoice instance by using the string name rather than the ForeignKey id without getting an error "shipping_address": [ "Incorrect type. Expected pk value, received str." ] How do i go about using string name of the field shipping_address found in Invoice table while maintaining the relationship between the two tables. ShippingAddress model class ShippingAddress(models.Model): customer = models.ForeignKey(Customer, on_delete=models.CASCADE, related_name="customer_ship_address") address = models.CharField(max_length=50, blank=True) zip_code = models.CharField(max_length=12, blank=True) def __str__(self): return self.customer.name Invoice model class Invoice(models.Model): shipping_address = models.ForeignKey(ShippingAddress, on_delete=models.CASCADE, related_name="ship_address_name") invoice_id = models.CharField(max_length=50, unique=True, default=increment_invoice_number) product = models.CharField(max_length=50, blank=True) date = models.DateField(default=datetime.date.today) def __str__(self): return self.shipping_address.name signal file @receiver(post_save, sender=ShippingAddress) def create_invoice(sender, instance, created, **kwargs): if created: Invoice.objects.create(shipping_address=instance) views.py file class InvoiceListCreateView(ListCreateAPIView): serializer_class = InvoiceSerializer queryset = Invoice.objects.all().order_by('-date') -
starting Django shell but python interpreter kicks off
I started the Django's shell using: python3 manage.py shell but weirdly the python interpreter is kicking off instead (I see >>> instead of [n]:, and the initializing text contains no Django information, besides the main imports for the shell aren't executed) considering that: I'm in ubuntu 20.04, It was running with no problem with python instead of python3, now python isn't recognized but it's linked to python3 so no difference "isn't it??!". -
What is the best way to generate Ethereum address with django
What is the best way to allow users/customers in Django to create only one Ethereum Address and save this address to the user -
How to run jupyter notebook from django?
I have a task and I need hint where to start. I have Django application with .ipynb files in it, and now I can see them, download them and run them on localhost, using jupyter notebook. I would like to skip second step and be able to run jupyter notebook on server, so I could click on them, and jupyter hub would open with file loaded in it. I saw some topics where people loaded django models into jupyter notebook, but none, where people ran jupyter notebook from django. Do you have some hints where to start to get such functionality? -
I'm having an error that says NoReverseMatch at /app1/add_post/
Every time I try to update or create a post in the blog I'm creating, this error always pops up, it saves the information, but it doesn't redirect the page to the url I'm sending it to. Here's the code so you guys can check it out. Models.py from django.db import models from django.contrib.auth.models import User from django.urls import reverse from datetime import datetime, date # Create your models here. class Category(models.Model): name = models.CharField(max_length= 255) def __str__(self): return self.name class Post(models.Model): title = models.CharField(max_length= 255) author = models.ForeignKey(User, on_delete=models.CASCADE) body = models.TextField() post_date = models.DateField(auto_now_add=True) category = models.CharField(max_length=255, default = 'coding') def __str__(self): return self.title + ' | ' + str(self.author) def get_absolute_url(self): return reverse('app1:article-detail', args =(str(self.id))) views.py from django.shortcuts import render from django.contrib.auth import authenticate, login, logout from django.urls import reverse, reverse_lazy from .forms import PostForm, PostUpdateForm from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView from .models import Post, Category # Create your views here. def index(request): return render(request, 'app1/index.html') class PostView(ListView): model = Post template_name = 'app1/post.html' ordering = ['post_date'] class ArticleDetailView(DetailView): model = Post template_name = 'app1/article_details.html' class AddPostView(CreateView): model = Post form_class = PostForm template_name = 'app1/createpost.html' success_url = reverse_lazy('app1:article-detail') #fields = '__all__' class UpdatePostView(UpdateView): β¦ -
Best practice way of adding querystrings in django rest framework
I need to add querystrings to django rest framework but so far all the information I've read either doesn't work for me or just doesn't make sense for something simple. So I'm wondering, what's the "official" way or best practice of doing things? The endpoint I'm using is /account?user_id=1. My urls.py is set up as follows: router = routers.SimpleRouter(trailing_slash=False) router.register(r'account', view.AccountViewSet) urlpatterns = [ path('', include(router.urls)), ] These are the options I've explored: Using search filters: In AccountViewSet, I've set the following: from rest_framework.filters import SearchFilter . . . class AccountViewSet(mixins.CreateModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, viewsets.GenericViewSet): filter_backends = (SearchFilter, ) search_fields = ['user_id'] . . . With this I get a 405, Method \"GET\" not allowed. Add router.register(r'', view.AccountViewSet, basename='account) to urls.py then override either get_queryset or retrieve() which then means I have to add logic to handle two use cases, getting an account using path parameters and getting an account with a user_id in the query string. Add a custom action with regex pattern. With this, I'd still have router.register(r'', view.AccountViewSet, basename='account). Then in my viewset I have: @action(detail=False, url_path='(?P<user_id>[^/.]+)') def get_user_id(self, request, user_id=None): . . This would also work, but the problem I'm getting (which doesn't seem right) is that β¦ -
How to use Django under Jupiter Notebook triggered from Anaconda
I am not very found of the Django environment but I've tried to use it under a Jupiter Notebook that I triggered from Anaconda Desktop. The issue is that I want to load data I have in a parser application I've developed under Jupiter Notebook, and I read it is much easier to use Django database commands than using straight SQLLite. The problem is that after running next comand: from django.conf import settings settings.configure() and then trying to create a Class with the following: from django.db import models class books(models.Model) Name = models.CharField(max_length=64) I get an error: AppRegistryNotReady: Apps aren't loaded yet. Do you have a clue what I'm missing? -
How to return an initial value when validating a custom form field?
I have a custom form field that accepts multiple emails. It subclasses the MultipleChoiceField and overrides the validate method: class MultiEmailField(forms.MultipleChoiceField): """ A choice field that validates a list of emails """ def validate(self, value): validation_errors = [] if self.required and not value: raise ValidationError(self.error_messages['required'], code='required') # Validate that each value in the value list is a valid email for val in value: try: validate_email(val) except ValidationError: validation_errors.append(f'<strong>{val}</strong> is not a ' 'valid email address.') if validation_errors: raise ValidationError( mark_safe('<br>'.join(validation_errors)), 'invalid_email' ) I am using it with Select2, so users are able to input a choice or create their own. This validation works well as it displays a list of all the invalid emails. However, if a valid email is also included it is not returned as an initial value, and the user has to type it in again. This can be problematic UI if there are 10 valid emails and 1 invalid one, as the input will be blank. How can I return valid emails? -
How to save model to another database in Django?
I have two databases: default and db_2. I want to save my models only to db_2. Here is my DATABASES: DATABASES = { 'default': { 'ENGINE': "django.db.backends.postgresql_psycopg2", 'NAME': "default", "USER": "postgres", "HOST": "localhost", "PASSWORD": "password", "PORT": "" }, 'db_2': { 'ENGINE': "django.db.backends.postgresql_psycopg2", 'NAME': "db_2", "USER": "postgres", "HOST": "localhost", "PASSWORD": "password", "PORT": "" } } What I need to do if I don't want to save Django's service tables (like auth_group, auth_user etc.) in db_2? Here is my router, but it doesn't work correctly. class DBRouter: def __init__(self): self.allowed_models = [Book, Author, Genre, ] def db_for_read(self, model, **hints): if type(model) in self.allowed_models: return "db_2" return None def db_for_write(self, model, **hints): if type(model) in self.allowed_models: return "db_2" return None def allow_relation(self, obj1, obj2, **hints): if type(obj1) in self.allowed_models and type(obj2) in self.allowed_models: return True return False Thanks. -
django webpack-loader does not load css
I have a Vue MPA for use in Django, with a very simple setting. Although when I try to load css part of it it does not work. Specifically {% render_bundle 'main' 'css' %} {% render_bundle 'chunk-vendors' 'css' %} Doesn't do anything. the js part works fine. My vue.config.js: const pages = { 'main': { entry: './src/main.js', chunks: ['chunk-vendors'] }, 'vignette': { entry: './src/vignette.js', chunks: ['chunk-vendors'] }, }; module.exports = { pages: pages, ... } and a head of the app looks like: import Vue from 'vue' import App from './App.vue' import Vuetify from 'vuetify' // index.js or main.js import 'vuetify/dist/vuetify.min.css' // Ensure you are using css-loader I suspect I don't 'use css-loader' but how to add it?