Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Queryset for django-select2 widget being ignored
In my project I am using Django-Select2 heavily, particularly its ModelSelect2Widget as my users frequently need to select from lists of 2,000-6,000 items. In all my uses of it up 'til now, the queryset for the widget has always been called as ".all()" instances of a model, for the user to select from, and there's been no issues. Now, however, I have implementations in different parts of the project for which filtering the queryset of options for the widget is necessary. In all of these cases, however, any modification of the queryset seems to have no effect, and I'm wondering if there is a problem with the widget itself. In the primary case, the items in the database are boolean-flagged as active/inactive (about 65% inactive), and I need to only have active items available for the end-user to select. I'm able to filter the queries correctly via the shell. In the form definitiion, any filtering (".filter(flag_active=True)", or even setting the queryset to ".none()" has no effect – there is no apparent change in the options in the dropdown/autocomplete. Being that it is a select2 input, I can only view a small number of items at a time, but both the … -
Django filter objects based on list values
I have a listTextField in my modal called technology. I want to filter objects based on an array, if every array value is present in the technology field. tech = ['a','b',....] #dynamic list mentors_list = Mentor.objects.filter( **{"technology__contains" : value for value in tech}) #this doesn't work Mentor class has (among other fields) : class Mentor(Meta): technology = ListTextField( base_field=models.CharField(max_length=20), size=10, max_length=(10 * 11)) Basically i want all objects in mentor_list whose technology field must contain all the values from tech array ( but may contain some extra values ). -
Reverse for 'plan_edit' with keyword arguments '{'pk': ''}' not found. 1 pattern(s) tried: ['palan/edit$']
I am getting an error Reverse for 'plan_edit' with keyword arguments '{'pk': ''}' not found. 1 pattern(s) tried: ['palan/edit$'], please can you help me. my urls.py urlpatterns = [ url(r'^$', views.post_list, name='post_list'), url(r'^palan/(?P<pk>[0-9]+)/$', views.palan_detail, name='palan_detail'), url(r'^palan/new/$', views.plani_new, name='plani_new'), url(r'^nn1/new/$', views.plani_new1, name='plani_new1'), url(r'^palan/edit$', views.edit, name='plan_edit'),] my views.py def edit(request, pk): post = get_object_or_404(Planning, pk=pk) if request.method == "POST": form = PostFormP(request.POST, instance=post) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.published_date = timezone.now() post.save() return redirect('palan_detail', pk=post.pk) else: return render(request, 'pages/plan_edit.html') palan_detail.html <a href="{% url 'plan_edit' pk=post.pk %}"> <h1>{{ palan.parcours }}</h1> </a> <p>{{ palan.semestre|linebreaksbr }}</p> <p>{{ palan.jour.jour1}}</p> -
unable to find single user using django rest-auth
I have an application which I implemented django restframework and django reat-auth and jango framework jwt. I followed the instructions and every thing works fine in the browser and i can login and logout and view a user details. I tried calling the user details using Alamofire and swift but I got error saying Optional(Alamofire.AFError.responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(401))) so I decided to investigate it in my django project and I found out that there is no specific way to call a user's details like email and username with the generated authtoken. this is the error I am facing and it is a big challenge to because i cannot proceed. I followed the django rest-auth documentation and I am unble to get a call for a single user like `rest-auth/user/1 or by username. any help is appreciated and further codes would be supplied based on request -
Create Custom Page Sitemap formatted/html/css designed Page in Wagtail
We are having issues creating a sitemap in Wagtail. Im not talking about the standard sitemap.xml that is good for google etc... Im talking about creating a custom styled page with all the links for the site on one page. Almost like a glossary/index of the site (sitemap.html). Im just cant seem to work out how to do this. Not sure if im missing something here, I have no issues generating domain.com/sitemap.xml Could someone let me know how this should be done as its not obvious in the documentation -
Django - Model whit a foreign key field to a table name that is not in models file
I have the next models: class ModelA(models.Model): name = models.CharField(max_length=100) class ModelB(models.Model): name = models.CharField(max_length=100) model_a = models.ManyToManyField(ModelA) class ModelC(models.Model): name = models.CharField(max_length=100) intermediate_ab = models.ForeignKey("database_intermediate", on_delete=models.CASCADE) The ManyToMany relation create the intermediate table("database_intermediate") on the database. Is posible to refer that intermediate table without create the intermediate model, for use in the ModelC? -
publish_actions permission in facebook sdk for python
I am working on app in django 1.11 with facebook-sdk (v. 2.12 for facebook). I have problem with added permissions to publish content on wall. I got an error: (#200) Requires either publish_actions permission, or manage_pages and publish_pages as an admin with sufficient administrative permission Below is my code: settings.py SOCIAL_AUTH_FACEBOOK_KEY = '###########' SOCIAL_AUTH_FACEBOOK_SECRET = '############' SOCIAL_AUTH_FACEBOOK_API_VERSION = '2.12' code in view.py from social_django.models import UserSocialAuth import facebook facebook_login = UserSocialAuth.objects.get(provider='facebook') oauth_token = facebook_login.extra_data["access_token"] graph = facebook.GraphAPI(oauth_token, version="2.12") profile = graph.get_object(facebook_login.extra_data['id']) graph.put_object(parent_object='me', connection_name='feed', message='Hello, world - test :)') I got an error in last line: graph.put_object(parent_object='me', connection_name='feed', message='Hello, world - test :)') -
Cannot dump Django database using pg_dump due to permissions
I want to dump PostgreSQL database to an SQL file. Here is the pg_dump DB_NAME > dump.sql command result: pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation django_migrations pg_dump: [archiver (db)] query was: LOCK TABLE public.django_migrations IN ACCESS SHARE MODE When I want to list relations: postgres=# \d No relations found. List of schemas: List of schemas Name | Owner | Access privileges | Description --------+----------+----------------------+------------------------ public | postgres | postgres=UC/postgres+| standard public schema | | =UC/postgres +| | | root=U/postgres +| | | secretusr=U/postgres | (1 row) Database list: List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+------------------------ db_secret | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres + | | | | | postgres=CTc/postgres + | | | | | secretusr=CTc/postgres+ | | | | | root=CTc/postgres postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (4 rows) Where is the problem? -
Handling a many-to-many relationship in CreateAPIView - These fields already exist
I would like to handle a post request using CreateAPIView however since the object that I would like to create contains a many-to-many field. I am getting the error.I would not like to create this object instead I would simple like to add it to my current object. { "skills": [ { "skill_description": [ "model skill with this skill description already exists." ] }, { "skill_description": [ "model skill with this skill description already exists." ] } ] } These are my two model class modelJob(models.Model): employer = models.ForeignKey(modelEmployer,on_delete=models.CASCADE,null=True,default=None,blank=True) skills = models.ManyToManyField(modelSkill,blank=True) title = models.CharField(max_length=200, unique=False,blank=False,null=True) and this is the model that I would like to create when receiving a json object from my post request class modelSkill(models.Model): skill_description = models.CharField(max_length=20, unique=True) Now This is my serializer class Serializer_CreateJob(serializers.Serializer): skills = Serializer_SkillName_TX(many=True) class Meta: model = modelJob fields = [ 'title', 'skills', ] This is my view class CreateJob_CreateAPIView(CreateAPIView): serializer_class = Serializer_CreateJob permission_classes = (permissions.AllowAny,) # permissions.IsAuthenticated def post(self, request, format=None): emp = self.request.user serializer = self.serializer_class(data=request.data) if serializer.is_valid(): modjob = serializer.save() #Return the created instance modjob.employer = emp modjob.save() return Response(Serializer_Job_TX(modjob).data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) This is what I am sending { "title" : "Cleaning the lamp of my … -
Django rest framework serializer.errors outputs ["This field is required."] with a multipart/form-data post request
I've been looking at this for a while now, I'm sending out a post request with multipart/form-data, but get back the error ["This field is required."] for each field that I'm supposed to populate with the request. Here's the Serializer: class InvoiceUploadSerializer(serializers.Serializer): serial=serializers.CharField(max_length=256, required=True) amount=serializers.CharField(max_length=256, required=True) debtor=serializers.CharField(max_length=256, required=True) dateout=serializers.CharField(max_length=256, required=True) expiration=serializers.CharField(max_length=256, required=True) invoicefile=serializers.FileField() class Meta: fields=('serial', 'amount', 'debtor', 'dateout', 'expiration', 'invoicefile',) And the View: class InvoiceViewSet(viewsets.ModelViewSet): queryset=Invoices.objects.all() serializer_class=InvoiceSerializer parser_classes=(MultiPartParser, FormParser) def get_permissions(self): if self.request.method in permissions.SAFE_METHODS: return (permissions.AllowAny(),) if self.request.method == 'POST': return (permissions.IsAuthenticated(),) return (permissions.IsAuthenticated(), IsAccountOwner(),) def create(self, request): serializer=InvoiceUploadSerializer(data=request.data) if serializer.is_valid(): ... handle serializer return Response(serializer.validated_data, status=status.HTTP_201_CREATED) else: emessage=serializer.errors return Response({ 'status': 'Bad request', 'message': emessage, }, status=status.HTTP_400_BAD_REQUEST Here is a picture showing the browser console with the outgoing request: And lastly the error message from the browser console: I don't understand why it tells me all fields are missing, the header is set correctly and it looks fine to me. -
Django Query from Post
I am trying to pass into my DRF API a post that needs to be queried against the database. For now I have included only 2 fields that can be queried. I am having trouble getting the view to work. Here is what I have so far. POST { "city": "Denver", "state": "CO" } Serializer only lets city and state be accepted class EventQuerySerializer(serializers.ModelSerializer): class Meta: model = Events fields = ('city', 'state') View note that EventsSerializer is used in the return and I can confirm it works for a basic get request class QueryEvents(APIView): @staticmethod def post(request): serializer = EventQuerySerializer(data=request.data) if serializer.is_valid(): events = Events.objects.get(serializer) return Response(EventsSerializer(events).data) Error AttributeError: 'CharField' object has no attribute 'split' -
why django is so slow after install package pygraphviz?
3 weeks ago i´ve installed pygraphviz and since this moment django test server is slow, I've tried: i've tried uninstalling all but the problem still continues, whats the problem? some idea? -
get current object in django filter orm
It may be a basic question but please bear with me. How to get the current object in the ORM query. x = 'abc' sample = Sample.objects.filter( x__in = current_sample_obj.x_list ) Here Sample is a model having x_list: class Sample(models.Model): x_list = ListTextField( base_field=models.CharField(max_length=20), size=10, max_length=(10 * 11)) So basically i want to filter, if the list field in model has a particular value. -
How to serve media file using Nginx and django?
Good evening, I am currently facing an issue on my home project. I set up a django project, with gunicorn and nginx. Nginx seems to serve my statics normally but when it comes to media files it does not work and i have the following message displayed in my error log: failed (2: No such file or directory) I tried to use different users for nginx.conf but it is still the same. I am missing something somewhere but i can not find out. I attach my nginx file: upstream app_server { server unix:/home/project/saleor.sock fail_timeout=0; } server { listen 80; server_name mytest.com; access_log /home/project/logs/nginx-access.log; error_log /home/project/logs/nginx-error.log; location ~ ^/(images|javascript|js|css|flash|media|static)/ { root /home/project; expires 30d; } location / { try_files $uri @proxy_to_app; } location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } } Here is a sample of my settings.py: ALLOWED_HOST = 0.0.0.0 PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '..')) MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') MEDIA_URL = '/media/' Do you have any idea where it could come from? (I am quite sure it is something stupid =/) -
django multiple user permission decorator
I am working on a invoices applicatoin where I have 3 different roles. I've got an administrative employee, financial employee and a client. All the financial part views are protected by a custom financial employee permission decorator and the same goes for the administrative and client views. However I want to have the build in django super user to have permission to all the views but somehow this doesn't seem to work. See my example view below: @method_decorator(admin_required, name='dispatch') @method_decorator(financial_employee_required, name='dispatch') @method_decorator(login_required, name='dispatch') class InvoiceListView(generic.ListView): queryset = Invoice.objects.filter(complete=False) And these are the decorators: def admin_required(function=None,redirect_field_name=REDIRECT_FIELD_NAME,login_url='home'): actual_decorator = user_passes_test( lambda u: u.is_active and u.is_superuser, login_url=login_url, redirect_field_name=redirect_field_name, ) if function: return actual_decorator def financial_employee_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='home'): actual_decorator = user_passes_test( lambda u: u.is_active and u.is_financial_employee, login_url=login_url, redirect_field_name=redirect_field_name, ) if function: return actual_decorator(function) return actual_decorator This doesn't not work at all. I've only been able to let the superuser login or the financial employee. What am I doing wrong? How am I able to have a view acces by 2 different roles? Because I am trying to prevent to let the superuser work with the django admin panel. -
Django does not translate filter labels
I am using django-filters for filtering on my site and the filter labels are being translated correctly on every page except two. I have checked all the common problems like making sure il8n is loaded to both pages, testing the path to the locale folder, restarting the server, checking middleware & other settings, checking for fuzzy tags in translations file, etc. The only similarity I can think of between them is that they both use Django's built-in Paginator when none of the other pages on the site do. Would that be enough to break translation? I am including the code for one of the two pages in the hopes that someone can tell me what's going on. If anyone wants to see other pieces of the code the github is here models_FSJUser.py class FSJUser(models.Model): # List the languages a user may choose from in human readable format and also make them accessible in other files # via FSJUser.LANG_CHOICES, FSJUser.ENGLISH, etc. FRENCH = 'fr' ENGLISH = 'en' LANG_CHOICES = ( (FRENCH, "Fran"+u"\u00E7"+"ais"), (ENGLISH, 'English'), ) # Link FSJUser with a User model for authentication related business user = models.OneToOneField(User, on_delete = models.CASCADE, blank = True, null = True) # All FSJ … -
Django User Create Form dropdowns not displaying
I have a user class that is subclassed from abstract user: models.py: class CustomUser(AbstractUser): birth_year = models.PositiveIntegerField(choices=birth_year_choices) gender = models.CharField(max_length=1, choices=gender_choices) education = models.CharField(max_length=1, choices=education_choices) occupation = models.CharField(max_length=1, choices=occupation_choices) sector = models.CharField(max_length=1, choices=sector_choices) email = models.EmailField(max_length=254, null=True) REQUIRED_FIELDS = ['birth_year', 'gender', 'education', 'occupation', 'sector'] And a signup form to create such a user: forms.py: from .models import CustomUser class SignUpForm(UserCreationForm): username = forms.CharField() birth_year = forms.IntegerField() gender = forms.CharField() education = forms.CharField() occupation = forms.CharField() sector = forms.CharField() email = forms.EmailField() class Meta: model = CustomUser fields = ('username', 'birth_year', 'gender', 'education', 'occupation', 'sector','email') And a class based view to display this: views.py: class SignUpView(CreateView): form_class = SignUpForm success_url = reverse_lazy('login') template_name = 'signup.html' My understanding is that django should automatically provide a widget.Select for each model field that has choices, and render the form with dropdowns. Clearly one solution is to duplicate the choices in forms.py as well as models.py, but this seems to violate django's DRY principle. Is there a better solution? -
vuejs getelementbyid django
According to this , the way to get html element with Vue.js is by using $ref. In my Django Form html, I want to get <input type="hidden" name="form-TOTAL_FORMS" value="2" id="id_form-TOTAL_FORMS" /> with something like $('#id_form-TOTAL_FORMS').val(). Is there a solution with Vue.js ? In addition, console.log(this.$ref); in mounted of my View instance outputs undefined. -
AttributeError: 'User' object has no attribute 'get_descendant_count' | django-mptt
Can someone help me to fix next problem. I use django-mptt application in my Django project. I want to make tree of related users. For this task I decided to create Profile model with next code. from mptt.models import MPTTModel, TreeForeignKey class Profile(MPTTModel): user = models.OneToOneField( User, on_delete=models.CASCADE, ) referral = models.OneToOneField( Referral, null=True, on_delete=models.CASCADE, ) parent = TreeForeignKey( User, on_delete=models.CASCADE, null=True, blank=True, related_name='children' ) class MPTTMeta: order_insertion_by = ['user'] Problem: In views.py I want to change parent field value of Profile object but has next error. ERROR: File "C:\Users\PycharmProjects\Project\project_venv\lib\site-packages\mptt\models.py", line 209, in get_ordered_insertion_target if parent is None or parent.get_descendant_count() > 0: AttributeError: 'User' object has no attribute 'get_descendant_count' views.py: print(self.created_user) # return correct value profile = Profile.objects.get(id=5) profile.parent = self.created_user profile.save() -
filter a queryset dynamically after initial retrieval from database
I have the following django code. I want to grab a queryset, then apply additional filters to it if certain query parameters are satisfied in the incoming url. example. browsevenues/ gets all venues browsevenues/?city=Chicago?cuisine=American gets all chicago venues which serve American fare the code I have is so. def get(self, request, *args, **kwargs): city = kwargs.get('city', 0) venuelist = Venue.objects.filter(online=True) if city != 0 : cityobjectpk = get_object_or_404(SearchCity, city=city, online=True) cityobjectpk = cityobjectpk.id venuelist.objects.filter(searchcity=cityobjectpk) else: return Response(status=status.HTTP_400_BAD_REQUEST) neighborhood = self.request.query_params.getlist('neighborhood', 0) if neighborhood != 0: neighborhoodpklist = [] for n in neighborhood: neighborhoodobjectpk = get_object_or_404(SearchNeighborhood, neighborhood= n) neighborhoodobjectpk = neighborhoodobjectpk.id neighborhoodpklist.append(neighborhoodobjectpk) venuelist = venuelist.filter(searchneighborhood__in=neighborhoodpklist) but bro dogs (lulz) neither filtering by doing venuelist.filter(...) or enuelist.objects.filter(...) is working... why for this? What does a guy gotta do to get some filters up in here hugs and kisses. -
django: No Techpost matches the given query
I'm new Django and have been working on project. When I click on my techposts. it says No Techpost matches the given query. It was working fine and I didnt change anything. Not sure what could have happned. It has happened 2-3 times. Database flush used to fix this issue. But now nothing is working. Please suggest how do i fix this and possible reason behind this? PS: Found similar questions but their answers didnt help. CODE: models.py class PublishedManager(models.Manager): def get_queryset(self): return super(PublishedManager, self).get_queryset().filter(status='published') class Techpost(models.Model): STATUS_CHOICS=( ('draft', 'Draft'), ('published', 'Published') ) title = models.CharField(max_length=255, blank=False, null=False) slug = models.SlugField(max_length=255, unique_for_date='publish') author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='tech_posts') body = models.TextField() publish = models.DateTimeField(default=timezone.now) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) status = models.CharField(max_length=10, choices = STATUS_CHOICS, default='draft') tags = TaggableManager() class Meta: ordering = ('-publish',) def __str__(self): return self.title objects = models.Manager() # default manager published = PublishedManager() # Custom Manager. def get_absolute_url(self): return reverse('rincon:techpost_details', args=[ self.publish.year, self.publish.strftime('%m'), self.publish.strftime('%d'), self.slug ]) class Comment(models.Model): techpost = models.ForeignKey(Techpost, on_delete=models.CASCADE, related_name='comments') comment = models.TextField() created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now =True) active = models.BooleanField(default=True) class Meta: ordering = ('created',) def __str__(self): return "Comment on {}".format(self.techpost) views.py @login_required def techpost_details(request, year, month, day, techpost): techpost … -
Using Django to create a private blockchain
I've only recently found out about private blockchains, and wanted to have at it myself for personal experience. I have been looking all over for best practices, but haven't been very successful at finding resources on private blockchains while resources on public blockchains are plenty. Below are some questions I haven't been able to figure out to my satisfaction: 1) From what I gathered, using web frameworks such as Django and Flask are considered overkill for public blockchains, and Flask is recommended for being simpler to use if a web framework is to be used. I've decided to use Django as I am very familiar with it, and as I think that a web framework would be necessary for user authorisation. Is there a simpler way of doing this? 2) All example code snippets online show the blockchain being stored as a list, which means having to store the entire blockchain in memory. I've decided to use Django's built-in database to store the blockchain on the hard drive. Is this something I should avoid doing? 3) I am somewhat confused about orphaned blocks, and have been unable to find a good solution for avoiding them. The only solution I have … -
Slow API response time with Django Apache and Elastic Beanstalk
I am having a POST API in django and I've installed the django-silk profiler for the application. The time taken by django to process the request is around 250ms but the response time (measured from postman) is around 2.5 seconds. My architecture is set up on AWS Elastic Beanstalk. A load balancer (with SSL) is used as the web interface A linux instance is running Apache along with the Django app via WSGI The response time of consecutive requests vary from 2.5 secs to 600 ms. How can I identify the issue and bring down the response time to less than 500ms -
Enabling CORS on Django Web App
I'm working on a Django Web API that's supposed to serve a separate Angular 5 client. The Django app is running on localhost:49846 and the Angular one on localhost:50887, so I need to enable CORS. I tried using django-cors-headers. I have installed the package and added the following lines to my settings.py file: INSTALLED_APPS = [ ... 'corsheaders', ... ] MIDDLEWARE_CLASSES = [ 'corsheaders.middleware.CorsMiddleware', ... ] CORS_ORIGIN_ALLOW_ALL = True But when the client is making a request I still get the following error: Response to preflight request doesn't pass access control check: No 'Access->Control-Allow-Origin' header is present on the requested resource. Origin >'http://localhost:50887' is therefore not allowed access. For now I am using the Allow-Control-Allow-Origin: * Chrome extension and everything works fine, but I would like to find a way of handling the CORS issue from my API. -
Improperly configured django error
I have a simple django project and whenever i run it, it gives me an improperly configured error. Tells me my model is missing a query set: Improperly Configured Error Image Here's the code for my views.py. The functionality doesn't matter for now: import random from django.shortcuts import render from django.http import HttpResponse from django.views import View from django.views.generic import TemplateView from django.views.generic.list import ListView class RestaurantList(ListView): querySet = Restaurant.objects.all() template_name = 'restaurants/restaurants_list.html' class SpicyList(ListView): template_name = 'restaurants/restaurants_list.html' querySet = Restaurant.objects.filter(category__iexact='spicy') class AsianList(ListView): template_name = 'restaurants/restaurants_list.html' querySet = Restaurant.objects.filter(category__iexact='asian') Here's the code for my models.py from django.db import models class Restaurant(models.Model): name = models.CharField(max_length=120) loocation = models.CharField(max_length=120, null=True, blank=True) category = models.CharField(max_length=120, null=True, blank=False) timestamp = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name urls.py code: from django.contrib import admin from django.conf.urls import url from django.views.generic import TemplateView from restaurant.views import * urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', TemplateView.as_view(template_name='home.html')), url(r'^restaurants/$', RestaurantList.as_view()), url(r'^restaurants/asian/$', AsianList.as_view()), url(r'^restaurants/spicy/$', SpicyList.as_view()), url(r'^Contact/$', TemplateView.as_view(template_name='Contact.html')), url(r'^About/$', TemplateView.as_view(template_name='About.html')) ] It's only the urls containing 'restaurants' that give me this error. The rest are fine. Here's a picture of my file structure at the side File Structure