Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django, pagination over multiple queryset
I'm trying to provide an api endpoint where it gives a paginated response over multiple queryset. a = Foo.objects.filter_a() b = Foo.objects.filter_b() paginator = Paginator(a + b, 10) # a + b is just symbolic, add two querysets page = 3 qs = paginator.page(page) suppose each page has 10 elements, # of a is 23 then page-3 would return 3 from a and 7 from b And we have to assume that a and b could be potentially large, and it's ideal to keep the queryset's lazyness -
Django RelatedObjectDoesNotExits - In Model init method - Setting Values works with one ForeignKey Object but not with another
My Model looks like this: class Change(models.Model): account = models.ForeignKey(Account, on_delete=models.CASCADE, related_name="changes") date = models.DateTimeField() category = models.ForeignKey(Category, related_name="changes", null=True, on_delete=models.SET_NULL) description = models.TextField(blank=True) change = models.DecimalField(decimal_places=2, max_digits=15) # query optimization balance = models.DecimalField(max_digits=15, decimal_places=2, null=True, blank=True) # for checks on save __account = None __category = None __date = None __change = None def __init__(self, *args, **kwargs): super(Change, self).__init__(*args, **kwargs) self.__date = self.date self.__category = self.category self.__account = self.account self.__change = self.change In the init method I get the following error when I try to add a new change via a form: File "/home/daniel/Data/Tortuga-Webdesign/Kunden_und_Projekte/0000/finance_project/finance/finance/banking/models.py", line 205, in __init__ self.__account = self.account File "/home/daniel/Data/Tortuga-Webdesign/Kunden_und_Projekte/0000/finance_project/venv/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 197, in __get__ "%s has no %s." % (self.field.model.__name__, self.field.name) finance.banking.models.Change.account.RelatedObjectDoesNotExist: Change has no account. The Form looks like this: class ChangeForm(forms.ModelForm): date = forms.DateTimeField(widget=forms.DateTimeInput(attrs={"type": "datetime-local"}, format="%Y-%m-%dT%H:%M"), input_formats=["%Y-%m-%dT%H:%M"], label="Date") class Meta: model = Change fields = ( "account", "date", "category", "description", "change" ) def __init__(self, depot, *args, **kwargs): super(ChangeForm, self).__init__(*args, **kwargs) self.fields["account"].queryset = depot.accounts.all() self.fields["category"].queryset = depot.categories.all() self.fields["date"].initial = datetime.now() The create view looks like this: class AddChangeIndexView(LoginRequiredMixin, CustomGetFormMixin, CustomAjaxFormMixin, generic.CreateView): model = Change form_class = ChangeForm template_name = "modules/form_snippet.njk" Why do I get this error with the account but not with the category? The … -
Django - how to implement totp_login custom decorator for 2FA?
In my django app, before redirecting user to 'dashboard' template, the user is first logged in, and then taken to an intermediate URL 'totp-login' for TOTP 2FA. However, I am still able to access '/dashboard' URL after logging in and is thereby able to bypass '/totp-login' URL. I need to create a custom totp_required decorator function for the same, but am unsure to be go about it. urls.py path('totp-login/', views.totp_login, name='totp-login'), path('dashboard/', views.dashboard, name='dashboard'), .... views.py @login_required def dashboard(self, request): ... Similarly for other functions/classes I need to have a similar totp_required decorator. Thanks. -
How to protect requests from Android or IOS app by using Corsheaders or others in Django without allowing all hosts?
I have created a web and mobile application using Ionic, Angular, Cordova. Server is made from Django which uses corsheaders middleware. Now for browser production, I can simply use CORS_ORIGIN_ALLOW_ALL = False and CORS_ORIGIN_WHITELIST = ('http://example.com') which will filter out untrusted request sources. However, any request coming from the mobile app version has origin 'http://localhost'. Now if I allow localhost in CORS_ORIGIN_WHITELIST, this will definitely weaken my server as any request coming from any http://localhost can access my server and this makes no sense in using corsheaders any more. How can I easily, effectively and selectively filter out non-verified request origins without compromising security? Also, could be platform-independent if possible, so same settings can serve both web, mobile and desktop apps. -
Django ORM query with exclude not working properly
I have below Django ORM query which excluding product having 0(zero) sale_price. selected_attr_values = ProductAttribValue.objects.filter(product__status_id = 1,product_id__in= product_attributes_values.values_list('product_id', flat=True).distinct()).exclude(product__sale_price = 0, field_value = '',field_value__isnull=False).distinct("field_value",'field_id').values('field_value','product_id','field__caption','field_id','id') Above query does not excluding products having 0 sale_price. But after updating query like below. selected_attr_values = ProductAttribValue.objects.filter(product__status_id = 1,product_id__in= product_attributes_values.values_list('product_id', flat=True).distinct()).exclude(field_value = '',field_value__isnull=False,).distinct("field_value",'field_id').exclude(product__sale_price = 0).values('field_value','product_id','field__caption','field_id','id') it working fine. So my question is why do I need to call exclude 2 times to get desired output. Thanks. -
Passing Form Data to View
I have the following view: views.py def PackingListView(request): if request.method == "POST": form = PackingListForm(request.POST) if form.is_valid(): if 'preview' in request.POST: request.session['data'] = form.cleaned_data return redirect('myview') .... I would like to take the data in form and pass it to this next view, and set the data variable equal to it. This was previously working, but once I added a foreign key into this form, the session no longer works as it is not serializable. What approach is the safest for me to take here? views.py class myview(View): def get(self, request, *args, **kwargs): data = request.session.pop('data', {})#this won't work now pdf = render_to_pdf('packlist_preview.html', data) return HttpResponse(pdf, content_type='application/pdf') Also in case it is needed - here is the URL for myview url(r'^myview/', views.myview.as_view(), name='myview'), -
Display error message on PasswordChangeForm
I am PasswordChangeForm form to change password. I am trying to display an error message when given password is either less than 8 or greater than 64 (in below code "form.data['new_password1']"). So when I enter password with less than 8 characters, then I am seeing error message "New password should have minimum 8 characters and maximum 64 characters" hit. But error message not displayed on UI page. This is because "return render(request, 'registration/change_password.html'" renders again. Could you please help me how can we display error message on PasswordChangeForm. @login_required(login_url='/login/') def change_password_view(request): global passwordValidationFailed passwordValidationFailed = False if (request.method == 'POST'): form = PasswordChangeForm(request.user, request.POST) if len(form.data['new_password1']) >= 8 and len(form.data['new_password1']) <= 64: if form.is_valid(): form.save() messages.success(request, 'Your password was successfully updated!') profile = request.user.get_profile() profile.force_password_change = False profile.save() return render(request, 'dau_gui_app/status_view.html', {'title': "System Status"}) else: passwordValidationFailed = False messages.error(request, 'Please correct the error below.') else: raise form.ValidationError("New password should have minimum 8 characters and maximum 64 characters") else: form = PasswordChangeForm(request.user) return render(request, 'registration/change_password.html', { 'form': form }) Here is my change_password.html {% load i18n %} {% load admin_static %}{% load firstof from future %}<!DOCTYPE html> <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}> <head> <meta charset="utf-8"> <meta … -
Create a Django REST API from a class diagram
From the knowledge I have, one has two approaches: code first or database first. There are frameworks where one defines the models and the relationships, and auto migrate creates the database in the mirror of what one has defined. Tried to find something reverse, but appears to me that Django does what I mentioned first - if one created the class models and migrated, then Django would create the entity database model for us. Considering I started with the database, I don't know anything automatic to do this or the best way to tackle it. -
Can't access python local server on docker
Can't access python local server on docker I have django project on docker At first I am trying to access django server asides nginx. Django server is docker-django-set_python container. for now please ignore other containers. my port is forwarded like this 0.0.0.0:8082->8082/tcp CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1382905adca0 nginx:1.13 "nginx -g 'daemon of…" 2 seconds ago Up 1 second 80/tcp, 0.0.0.0:8000->8000/tcp nginx 43eda3b920f8 phpmyadmin/phpmyadmin "/docker-entrypoint.…" 2 seconds ago Up 1 second 0.0.0.0:8081->80/tcp phpmyadmin c32fdf7fdbe9 docker-django-set_python "uwsgi --socket :800…" 2 seconds ago Up 1 second 8001/tcp, 0.0.0.0:8082->8082/tcp python 74bd1fe5e49c mysql:5.7 "docker-entrypoint.s…" 2 seconds ago Up 2 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp db then I start, django server correctly started but it doesn't connect http://127.0.0.1:8082/. Is there any points I need to check?? $docker exec python python3 manage.py runserver 8082` Watching for file changes with StatReloader Performing system checks... Using TensorFlow backend. System check identified no issues (0 silenced). March 20, 2020 - 20:52:03 Django version 3.0.1, using settings 'myapp.myconf.local' Starting development server at http://127.0.0.1:8082/ Quit the server with CONTROL-C. -
Django admin - filter in get_queryset not working
I have this two models class Invitacion(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) host = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) name = models.CharField(max_length=256, verbose_name="Nombre Invitacion") class Invitado(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) invitacion = models.ForeignKey(Invitacion, on_delete=models.CASCADE) name = models.CharField(max_length=50) ... And registered those in the admin with admin.site.register(Invitacion) @admin.register(Invitado) class InvitadoAdmin(admin.ModelAdmin): def get_queryset(self, request): if request.user.is_superuser: return Invitado.objects.all() return Invitado.objects.filter(invitacion__host=request.user) However this filter does not work: return Invitado.objects.filter(invitacion__host=request.user) If I filter on the shell it works but not on the admin. I have an admin group that only has permission to add/change/delete Invitados -
How to all the admin to maintain content on this model
I am using Django/Wagtail I have a form and would like to allow the admin to be able to edit field titles and help text models.py class FoodDiaryItem(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user_pk = models.SmallIntegerField(null=True, blank=True, default=0,) date = models.DateField(null=True, blank=True) time = models.TimeField(null=True, blank=True) level_of_hunger = models.SmallIntegerField(null=True, blank=True, default=0, validators=[ MaxValueValidator(5), MinValueValidator(0) ]) ... food_diary_item.html <form action="/food-diary/diary-updated/{{ food_diary_item.id }}" method="post"> {% csrf_token %} <table> <tr><td class="text-right">Food Diary item for:</td><td>{{ user.username }}</td></tr> <tr><td class="text-right">Date:</td><td>{{ food_diary_item_form.date }}</td></tr> <tr><td class="text-right">Time:</td><td>{{ food_diary_item_form.time }}</td></tr> <tr><td class="text-right">Level of hunger:</td><td>{{ food_diary_item_form.level_of_hunger }}</td></tr> <tr><td class="text-right"> </td><td>before eating (rate from 0-5, 0=no hunger, 5=starving)</td></tr> ... Is there any way that I can re-organise the model to make the text admin maintainable? -
Confused about API relevance and Django
Im new to web development and trying to learn APIs through Django Rest Framework. I am actually confused about why we actually need to build an API. For example, I've seen tutorials of creating blog APIs, where it returns the posts and its info. Why would we need an API for that? We can simply create regular Django views to do the same. I've heard that APIs only provide the 'data', but I can also obtain data from regular Django. So why would you install a totally new 'sub' framework to do these for you? -
Django: overriding templates from oTree package
I wish to change the layout of some of the oTree templates, but I'm not sure how to override them? I've read the docs about overriding, I added the templates in settings and make my own .html files with the same name, but they still show the oTree templates. What am I doing wrong here? Settings.py TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'day_trader/day_trader/templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] Templates structure templates --> day_trader --> DemoIndex.html (name of the template I've made and want to override) However, it just loads the template from the oTree package. Am I suppose to create a view and return it too? -
How do I change my profile image in django?
I'm Trying to develop a social website, and in my user profile page I want to display the user's selected image from the registration page. I provided a default.jpg in my media folder in case the user dosen't want to upload an image. But everytime I'm trying to register a new user, even if I'm selecting a different image, the default image is being displayed. Can anyone please help me out? my models.py from django.db import models from django.contrib.auth.models import User from PIL import Image class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) image = models.ImageField(default='default.jpg', upload_to='profile_pics') CHOICES = ( ('AB+', 'AB+'), ('AB-', 'AB-'), ('A+', 'A+'), ('A-', 'A-'), ('B+', 'B+'), ('B-', 'B-'), ('O+', 'O+'), ('O-', 'O-'), ) bloodgroup = models.CharField(max_length=100, choices= CHOICES) bio = models.TextField(max_length=300) def __str__(self): return f'{self.user.username} Profile' def save(self): super().save() img = Image.open(self.image.path) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path) my forms.py from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Profile class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] class ProfileForm(forms.ModelForm): class Meta: model = Profile fields = ('image', 'bloodgroup', 'bio') class UserUpdateForm(forms.ModelForm): email = forms.EmailField() class … -
Django: can't get the url for update action to work with ModelViewSet
I am using ModelViewSet and Modelserializer for a blog like project. It could be my difficulty in understanding the implementation; I can't get the update action to work via calling it through router, only the list action is working with the route I have defined. When I put the url : 127.0.0.1:8000/api/blogs/1, to return the blog with ID 1 to edit, it returns {"Detail": "Not Found."}. This is my view: class ArticleViewSet(viewsets.ModelViewSet): queryset = Article.objects.all() serializer_class = ArticleSerializer I have also overridden the save and update methods in the serializer class, don't know whether it was needed for ModelViewSet in ModelSerializer. class ArticleSerializer(serializers.ModelSerializer): def create(self, validated_data): article = Article.objects.create( article_title = self.validated_data['article_title'], article_content = self.validated_data['article_content'], ... ) return article def update(self, instance, validated_data): instance.article_title = validated_data.get('article_title', instance.article_title) instance.article_content = validated_data.get('article_content', instance.article_content) ... instance.save() return instance class Meta: model = Article fields = ... And the urls.py file: router = DefaultRouter() router.register(r'blogs', ArticleViewSet, basename='articles-list') urlpatterns = router.urls My question is: 1. How do I specify urls for the ModelViewSet actions (in my case the update action)? 2. Will defining only one url suffice all my needs with every ModelViewSet actions? if so how? What am I doing wrong? I'm new to … -
Django with apache in centos 8. don't have permission to access / on this server(newly deployed)
filesystem path '/var/www/mysite/mysite/wsgi.py') because search permissions are missing on a component of the path [Fri Mar 20 06:35:04.536515 2020] [core:error] [pid 8177:tid 140498932373248] (13)Permission denied: [client 192.168.1.4:54121] AH00035: access to /favicon.ico denied (filesystem path '/var/www/mysite/mysite/wsgi.py') because search permissions are missing on a component of the path, referer: http://192.168.1.2/ [Fri Mar 20 06:36:23.588628 2020] [core:error] [pid 8503:tid 140498958239488] (13)Permission denied: [client 127.0.0.1:53958] AH00035: access to / denied (filesystem path '/var/www/mysite/mysite/wsgi.py') because search permissions are missing on a component of the path -
Redis Flushall command in Heroku Scheduler (Python/Django Project)
For a Django application, I want Heroku Scheduler to perform the following commands: heroku redis:cli flushall exit (ctrl-c) I do this myself once a day now in terminal, but it would be a lot easier if I can schedule these commands. My question is, is it possible to put these commands in a Python script, or do I need to work in another way? Does anyone has experience with this? -
django computation in aggregate
I have this computation in my views that using filter and aggregate method first is i distinct the select the StudentSubjectGrade models and in the overall i filter the average and i use aggregate to compute the average and for every grading categories i have to multiply it by its PercentageWeight. this is the computation average = average * Grading_Categories__PercentageWeight / 100 students = StudentSubjectGrade.objects.filter( grading_Period=period).filter( Subjects=subject).order_by( 'Students_Enrollment_Records', 'Grading_Categories','id' ).values('id','Grading_Categories','Average', 'Grading_Categories__PercentageWeight') overall = StudentSubjectGrade.objects.filter( grading_Period=period).filter( Subjects=subject).aggregate(average_grade=Avg('Average') * students[ 'Grading_Categories__PercentageWeight'] / 100) this is their models class StudentSubjectGrade(models.Model): GradeLevel = models.ForeignKey(EducationLevel, related_name='+', on_delete=models.CASCADE, null=True, blank=True) Subjects = models.ForeignKey(Subject, related_name='+', on_delete=models.CASCADE, null=True) Students_Enrollment_Records = models.ForeignKey(StudentsEnrolledSubject, related_name='+', on_delete=models.CASCADE, null=True) Grading_Categories = models.ForeignKey(gradingCategories, related_name='+', on_delete=models.CASCADE, null=True, blank=True) grading_Period = models.ForeignKey(gradingPeriod, related_name='+', on_delete=models.CASCADE, null=True, blank=True) Gradedates = models.DateField(auto_now_add=True) Average = models.FloatField(null=True, blank=True) class gradingCategories(models.Model): CategoryName = models.CharField(max_length=500, null=True) PercentageWeight = models.FloatField() this is the error i get -
Has Django version 3 stoped the need to register new apps in settings.py installed apps list?
I am new to django and the apps i create are working with out any need for them to be registered in settings.py of the project. Has django version 3 started to do this or is this a bug in my side? -
Django change form page data change after each refresh
I currently have a Fake model which based on of a view on mysql: class Transaction(models.Model): id = models.BigIntegerField(primary_key=True) transaction_id = models.IntegerField(default=0) user = models.IntegerField(null=True) transaction_type = models.CharField(null=True, max_length=255) to_bank = models.IntegerField(null=True) to_address = models.CharField(null=True, max_length=255) to_account = models.IntegerField(null=True) to_card = models.IntegerField(null=True) method = models.PositiveIntegerField() currency = models.IntegerField() amount = models.DecimalField(max_digits=65, decimal_places=0, default=0) fee = models.DecimalField(max_digits=65, decimal_places=0, default=0) status = models.PositiveIntegerField() created = models.DateTimeField() confirmed = models.DateTimeField() class Meta: managed = False db_table = 'v_transactions' verbose_name = 'Transaction History' verbose_name_plural = 'Transactions History' And MySQL view has the following query : CREATE VIEW v_transactions AS SELECT row_number() OVER () as id, transaction_id, user, transaction_type, to_bank, to_address, to_account, to_card, method, currency, amount, fee, status, created, received FROM (SELECT id as transaction_id, user_id AS user, "top up" AS transaction_type, NULL AS to_bank, NULL AS to_address, user_id AS to_account, NULL AS to_card, method, currency_id AS currency, amount, fee, status, created, received AS confirmed FROM topups WHERE deleted IS NULL UNION ALL SELECT id as transaction_id, user_id AS user, "transfer" AS transaction_type, NULL AS to_bank, to_address, to_account, NULL AS to_card, method, currency_id AS currency, amount, fee, status, created, confirmed FROM transfers WHERE deleted IS NULL UNION ALL SELECT id as transaction_id, user_id AS user, … -
How to open an uploaded saved file in another template?
my django app acts as an emailing service, emails that are sent are view-able and it's possible to send html emails. How do I display the html emails on the view-mail page rather than just displaying the name of the file ? (the following is the mail-view for an html email): How would I display the actual html in the body of this page? This is my views.py: def outbox(request): #Mail_Item.objects.all().delete() if request.method == "POST" and request.POST.get('Username', False)!=False: username = request.POST.get('Username') password = request.POST.get('Password') user = authenticate(request, username=username, password=password) if user is not None: login(request, user, backend='django.contrib.auth.backends.ModelBackend') print(username + " has logged in") messages = Mail_Item.objects.filter(user=request.user.username) args = {'messages':messages} return render(request, 'outbox.html', args) else: return render(request, '404.html') elif request.POST.get('Username', False) == False and request.POST.get('mail_body_field', False) == False: pass elif request.method == "POST" and request.POST.get('mail_subject_field')!=False: subject = request.POST.get('mail_subject_field') body = request.POST['mail_body_field'] file = "" try: file = request.FILES['filename'] except: pass print("sending mail:") for i in range(1, len(Res)+1): y = Res['ID' + str(i)].email print("sent to " + y ) msg = EmailMessage(subject, body, 'email@example.com', [y]) msg.content_subtype = "html" if (str(file)) != "" and (str(file))[-4:] != 'html': msg.attach_file(str(file)) obj = Mail_Item(subject=subject, body=body, user=request.user.username, file_name=(str(file))) obj.save() print("email stored in database") elif (str(file)) != "" … -
How can i exit the python shell to the terminal in Pycharm?
For example, I wrote the code; SyntaxError: invalid syntax python manage.py command File "", line 1 python manage.py command* to get to the shell now I can't return back to the command line in Pucharm -
How to make a web app using both django and express? How would you interchange data between the two platforms?
I was trying to make a web app with a complicated idea and at some point realised that I couldn't do it alone. When, I started to look around for friends with a skill set with node in their bag, I found out that everyone had experience with pure php or django. I was thinking if I could make the web app by combining different backend technologies. But I can't really understand where and how to start. What would I need to learn? How would I exchange values or data between the two frameworks or programming languages? What things would I have to learn? Where would I start? -
django-allauth: how to avoid requesting friends list?
I have set user registration via Facebook with django-allauth. When I am trying to login with Facebook, Facebook notifies me that the app wants to get the list of my users. However, these data are not stored in my database after the login, nor are they included in my settings.py. How can I disable requiring the list of friends? Django-allauth settings from settings.py: SOCIALACCOUNT_PROVIDERS = \ { 'facebook': {'METHOD': 'oauth2', 'SCOPE': ['email','public_profile', 'user_friends'], 'AUTH_PARAMS': {'auth_type': 'reauthenticate'}, 'FIELDS': [ 'id', 'email', 'name', 'first_name', 'last_name', 'verified', 'locale', 'timezone', 'link', 'gender', 'updated_time'], 'EXCHANGE_TOKEN': True, 'LOCALE_FUNC': lambda request: 'path.to.callable', 'VERIFIED_EMAIL': False, 'VERSION': 'v2.4'}, 'google': { 'SCOPE': ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'], 'AUTH_PARAMS': {'access_type': 'online'}, } } -
Django HighChart with Api
I'm new at Django please help me, I read some articles vlogs seems I cannot find the right code here's my code in views.py and i want it to disply in in HTML index.html and the result is it wont display I dont know what is wrong with my code from django.shortcuts import render from django.http import JsonResponse,HttpResponse import requests import pandas as pd import json def home(request): response = requests.get('https://coronavirus-ph-api.now.sh/cases').text # li = list(response.split(",")) res = json.loads(response) maleCount = 0 femaleCount = 0 for i in res: if i['gender'] == 'M': maleCount += 1 else: femaleCount += 1 TotalCount =[ { "name": "MALE", "data": [maleCount]}, { "name": "FEMALE", "data": [femaleCount] } ] return render(request,'index.html',{'data':TotalCount}) and here my code in html in index.html tru views.py it wont display my data in html seems my code wont work what is the problem of my code? please help thank you <!doctype html> <html lang="en"> <body> <div class="container-fluid"> <div class="border" id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> </div> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <script src="https://code.highcharts.com/modules/export-data.js"></script> <script> Highcharts.chart('container', { chart: { type: 'column' }, title: { text: 'Total fruit consumtion, grouped by gender' }, xAxis: { categories: ['asd','asd'] }, yAxis: { allowDecimals: false, min: …