Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Validate "sensible" characters in string
I need to validate that a string (in a Django form) contains "sensible" characters before sending this to an API that won't allow chars like emoticons. It's somewhat unclear what chars this API won't allow, but I figured that it will allow all "sensible" chars that's available to type on a normal keyboard. That includes !"#€%&/() etc. etc. and i.e. swedish chars like åäö, but I want to raise a validation error when chars like emoticons etc. are in the string. Thanks for any help solving this. -
django.contrib.auth.models.User.DoesNotExist : User matching query does not exist
Doing quite a simple thing. Trying to get an object from the User model using id and it returns me the following traceback: User.objects.get(id=1) Traceback (most recent call last): File "", line 1, in File "/home/anna/Desktop/Josefin/djang_shop_api/env/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/anna/Desktop/Josefin/djang_shop_api/env/lib/python3.6/site-packages/django/db/models/query.py", line 408, in get self.model._meta.object_name django.contrib.auth.models.User.DoesNotExist: User matching query does not exist. -
How means this regex?
Hello I have a regex in my django code but I don't know what it means actually. Here is my regex : r'^email/(?P<email>[^@\s]+@[^@\s]+\.[^@\s]+)/$', Could you give me some examples which match with this regex ? Thank you very much ! -
How to bind more than one model to a template
I'm trying to feed a select tag with options recovered from a database. The problem is, I'm totally beginner with Django and don't even know how to search for this. I'm using generic view and as far as I know, the template is fed by a model bound to a context_object, default named as object_list, but you can change it in the context_object_name variable. But my companies_object is not feeding the template. <tbody> {% for project in projects %} <tr> <td> {{ project.title }} </td> [...] <select> {% for company in companies %} <option value="{{company.id}}">{{company.name}}</option> {% endfor %} </select> class ProjectsView(LoginRequiredMixin, ListView): model = Project context_object_name = 'projects' template_name = 'projects/projects.html' def select_company(self): companies = Company.objects.all() return 1 #return selected company def get_projects(self): seek_in_database() return projects I expect to know how to show two different objects in the same template, the projects, which is already working, and the companies object. I didn't figure it out yet how the template is getting the project's data, I suspect of model = Projects and context_object_name. I know that it is begginer level, and I don't expect someone to write a complete guide, I'll be very happy with some instruction of what subject to … -
How to show an excel file in Django webpage
I am new to Django and I have a Django application where once you upload few excel files, it does a background calculation and saves the results in an excel file. I need to show those excel files with minimal processing in the Django home page as datatable. I tried django-excel package with Iframe to do so. I am not not able to get the page. Please suggest if the code below needs to be modified. Is there any other ways to solve this problem? In views.py: import django_excel as excel import pyexcel as p def show_result_files(request,foldername,outputfilenames): file_path = path + '/Data/' + foldername if os.path.isfile(file_path + 'Final_Results.xlsx'): for afile in request.FILES.getlist(outputfilenames): combined_sheet = p.get_sheet(file_path + '2020MY EWPR Combined Parts List Final.xlsx') combined_sheet.save_as(afile.sortable.html) from IPython.display import IFrame IFrame("afile.sortable.html", width=600, height=500) In home.html: <div class="inline col-md-9" id="showFinalResults"> <form method="POST" name="showCombined" action="">{% csrf_token %} <button name="showCombined" type="submit" class="btn btn-primary">Combined Parts List</button> </form> </div> <div class="inline col-md-9" id="showFinalResults"> <form method="POST" name="showCombined" enctype="multipart/form-data" action=''>{% csrf_token %} <div class="col"> <div class="row"> <span class="btn btn-primary btn-file"> Combined Parts List <input name="SparrowFiles" id="Sparrow" type="file" multiple=""> </span> <button name='upload_Sparrow' type="submit" class="btn btn-secondary js-upload-files" data-toggle="modal" data-target="#modal-progress_sp"">Go</button> </div> </div> </form> </div> What I want the resulting excel file displayed in … -
Django: Pagination ListView and return json
I have this ListView that paginates the context, but i want to add also car types in my context, for that i need to built it in json which i don't know how, or is any other way around this, any help would be very much appreciated. class CarListView(ListView): model = Car template_name = 'listings.html' context_object_name = 'cars' ordering = ['-created'] paginate_by = 5 def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) print(context) paginator = context['paginator'] page_numbers_range = 10 # Display 5 page numbers max_index = len(paginator.page_range) page = self.request.GET.get('page') print(self.request) current_page = int(page) if page else 1 start_index = int((current_page - 1) / page_numbers_range) * page_numbers_range end_index = start_index + page_numbers_range if end_index >= max_index: end_index = max_index page_range = paginator.page_range[start_index:end_index] # context['page_range'] = page_range # return context cars = Apartment.objects.all()[:10] car_types = CarType.objects.all() context = {'cars': cars, 'car_types': car_types} return context -
Django. ''The `actions` argument must be provided when calling `.as_view()` '' when I try to allow DELETE, PUT, ETC
I have to allow delete and update requests from front for my objects of some model. I wish to delete instance and accordinary row in DB. I tryed to use info from DRF tutorials (https://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/) , some other examples. I understand if I using ViewSet I have to allow some actions and using rows. I use decorator like in DRF tutorial. There is my view.py class DualFcaPlanUseViewSet(viewsets.ModelViewSet): authentication_classes = (CsrfExemptSessionAuthentication,) def get_queryset(self): user = self.request.user return FcaPlanUse.objects.filter(id_fca__num_of_agree__renters_id__user_key = user) def get_serializer_class(self): if self.request.method == 'GET': return FcaPlanUseSerializer if self.request.method == 'POST': return FcaPlanUsePOSTSerializer @action(detail=True, renderer_classes=[renderers.StaticHTMLRenderer]) def highlight(self, request, *args, **kwargs): fcaplanuse = self.get_object() return Response(fcaplanuse.highlighted) def perform_create(self, serializer): serializer.save(owner=self.request.user) my actions in app urls.py from django.conf.urls import url from rest_framework import renderers from . import views from cutarea.views import DualFcaPlanUseViewSet fcaplanuse_list = DualFcaPlanUseViewSet.as_view({ 'get': 'list', 'post': 'create' }) fcaplanuse_detail = DualFcaPlanUseViewSet.as_view({ 'get': 'retrieve', 'put': 'update', 'patch': 'partial_update', 'delete': 'destroy' }) fcaplanuse_highlight = DualFcaPlanUseViewSet.as_view({ 'get': 'highlight' }, renderer_classes=[renderers.StaticHTMLRenderer]) so a part of my project urls.py from cutarea.views import * #... from rest_framework import routers router = routers.DefaultRouter() router.register(r'cutarea', DualFcaPlanUseViewSet.as_view(), base_name='cutareadel') #... urlpatterns = [ #... url(r'^api/', include(router.urls)), ] So result: TypeError: The `actions` argument must be provided when calling `.as_view()` on … -
bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6. Django. Bootstrap 3
I use Bootstrap 3 in my project, but I still see the error: bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6 My template looks like this: {# Load the tag library #} {% load bootstrap3 %} {# Load CSS and JavaScript #} {% bootstrap_css %} {% bootstrap_javascript %} {% block bootstrap3_content %} <div class="container"> <!-- navbar --> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">Password Manager</a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> <li><a href="{% url 'app:login' %}">Login</a></li> <li><a href="{% url 'app:signup' %}">Registration</a></li> </ul> </div> </div> </nav> {% block content %}(no content){% endblock %} </div> {% endblock %} It seems to me that I added everything in accordance with the documentation. I also tried to add {% bootstrap_jquery_url %} before javascripts, but it did not change anything. How to remove the error, any help will be appreciated. -
Django queryset filter for most recent in the past and all in the future
Context I have the models ContentBuild & ContentBuildDeviceGroupLink like this: # models.py class ContentBuild(models.Model): content_build_uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, db_index=True) class ContentBuildDeviceGroupLink(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, db_index=True) content_build_uuid = models.ForeignKey(ContentBuild, on_delete=models.CASCADE, related_name='content_build_deploy') group_uuid = models.ForeignKey(DeviceGroup, on_delete=models.CASCADE) preload_date = UnixDateTimeField() release_date = UnixDateTimeField() Goal I want to return the most recent ContentBuildDeviceGroupLinkobject with the release_date in the past, along with all ContentBuildDeviceGroupLink objects with the release_date in the future. What I tried I tried to use the Q object like this: in_future = Q(release_date__gte=timezone.now()) recent_past = Q(release_date__lt=timezone.now()).order_by('-release_date')[0] ContentBuildDeviceGroupLink.objects .filter(in_future & recent_past) This does not work and throws the error: 'datetime.datetime' object has no attribute 'order_by' How do I filter for the object with release_date in the most recent past AND all objects with release_date in the future? -
How to render and save Model using FilteredSelectMultiple on Django (non-admin)
I'm trying to use FilteredSelectMultiple in a user form (not in Django admin). The form renders fine but the ManyToMany relationships aren't saved. This is my models.py class Playlist(models.Model): name = models.CharField(max_length=20) owner = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete = models.CASCADE ) projects = models.ManyToManyField(Project, blank=True) def __str__(self): return '%s %s' % (self.name, self.owner.username) def get_absolute_url(self): return reverse("view-playlist", args=[self.pk]) This is my views.py class CreatePlaylistView (LoginRequiredMixin, CreateView): model = Playlist form_class = PlaylistForm def get_initial(self): initial = super().get_initial() initial['owner'] = self.request.user return initial And this is the html {% extends 'base.html' %} {% load static %} {% block css %} {% endblock %} {% block content %} <section> <div class="container"> <div class="row"> <h3>Create Playlist</h3> <div class="col-xs-12"> <form method="post"> {% csrf_token %} {{ form }} <button type="submit" class="btn btn-primary">Create Playlist</button> </form> </div> </div> </div> </section> {% endblock %} {% block scripts %} <script type="text/javascript" src="{% static 'admin/js/vendor/jquery/jquery.min.js' %}"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script> <script type="text/javascript" src="{% static 'admin/js/jquery.init.js' %}"></script> <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script> {{ form.media }} {% endblock %} What I have got wrong? -
I printed {{comment.text}} in the text area. But there is a space in front. How do I remove blanks?
I have a question I printed {{comment.text}} in the text area. <tr> <td>code</td> <td colspan="3" id="my_code_{{comment.id}}"> <textarea name="name" rows="10" cols="80"> {{comment.text}} </textarea> </td> </tr> But there is a space in front. How do I remove blanks? ex) output of django templates -
How to Properly Short-Circuit Middleware in Django?
CONTEXT: I am working on a Django 1.10/Python2.7 app with legacy stuff, and I am preparing part of it to pay some tech debt in near future. For that I need to put some logic on the chain of middleware used in the app to by-pass a whole set of layers underneath the Django ones if the URL being requested is to hit the API new app (/api routes). My idea was to introduce a new middleware in between the Django ones and the custom ones of the project (commented as "Custom middlewares" below as an example of what the proj has - in total about 8 middlewares, some of which make dozens of calls to DB and I don't know yet the implications of removing them or turning them into decorators for requests/views that need them). That intermediary middleware would short-circuit all the ones below it on MIDDLEWARE if the url starts with /api. I tried short-circuiting the Middleware chain in Django as they say in documentation but it is not working for me. HOW I GOT IT WORKING (but not ideal): The way I got it working was by doing this (which is not what they say in … -
I have install a Nadine project from github while runing server it's only showing html and text it's not showing UI or images on the browser
I have install Nadine from github but while running it on the browser i am only getting html and text. I am not getting images or UI.I don't know if it is browser problem. Site › example.com administration Welcome, nitish2. View site / Documentation / Change password / Log out Site administration Arpwatch Arp logs Add Change Import logs Add Change User devices Add Change User remote addrs Add Change Authentication and Authorization Users Add Change -
Django_auth_ldap: User from LDAP post_save signal 'created' flag always false
I am trying to allow LDAP users to login to my Django application. Each user needs some additional attributes which I want to store in a User Profile model. I have implemented the 'post_save' signal to create the userprofile on initial login, however, I found that with LDAP users the created flag is always False even if they have never logged in before. The only time created = True is when I create a new superuser using manage.py My post_save looks like this: @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): print(sender) print("USERPROFILE1: {0} with id {1}".format(instance, instance.pk)) print("CREATION: {0}".format(created)) if created: print("USERPROFILE3") UserProfile.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_profile(sender, instance, **kwargs): print("USERPROFILE2") instance.userprofile.save() Upon first login, the profile is never created as 'created' is always 'False' <class 'django.contrib.auth.models.User'> USERPROFILE1: lbird with id 1 CREATION: False User has no userprofile. while authenticating [...] django.contrib.auth.models.User.userprofile.RelatedObjectDoesNotExist: User has no userprofile. -
How to fix 'TypeError: argument of type 'function' is not iterable' in python
I was making a django app which would be able to send and receive emails. For the django app I was writing the code for views.py After I ran the file, I got stuck with this error. This is the views.py from my django app from django.shortcuts import render from django.contrib import messages from django.core.mail import send_mail #from demoapp.form import ContactForm # Create your views here. def index(request): return render(request,'index.html',{'page':'home'}) def contact(request): try: if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): send_mail(form.cleaned_data) messages.success(request,'Your message is successfully submitted') else: form = ContactForm() except: messages.error(request,'contact.html',{'page':'contact','form':form}) def clear(request): form = ContactForm() messages.error(request,'Fields Cleared') return render(request,'contact.html',{'page':'contact','form':form}) After I run python3 manage.py runserver I get the following error Watching for file changes with StatReloader Performing system checks... Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.6/dist-packages/django/utils/autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 377, in _run_checks return checks.run_checks(**kwargs) File "/usr/local/lib/python3.6/dist-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/usr/local/lib/python3.6/dist-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/usr/local/lib/python3.6/dist-packages/django/core/checks/urls.py", line 23, in check_resolver … -
Abstract ForeignKey without using GenericForeignKey
To create a generic versioning for my models I have created a model Version: class Version(models.Model): version_number = models.IntegerField() edited_ts = models.DateTimeField() edited_by = models.ForeignKey("app.User", on_delete=PROTECT, null=True, blank=True) and an abstract models VersionedModel class VersionedModel(models.Model): versioned_fields = None created_ts = models.DateTimeField(default=django_now) created_by = models.ForeignKey("app.User", on_delete=PROTECT, null=True, blank=True, related_name="%(app_label)s_%(class)s_created") edited_ts = models.DateTimeField(null=True, blank=True) edited_by = models.ForeignKey("app.User", on_delete=PROTECT, null=True, blank=True, related_name="%(app_label)s_%(class)s_edited") versions = models.ManyToManyField(Version, related_name="%(app_label)s_%(class)s") class Meta: abstract = True everything works but I would like to have the database check that each version is assigned to one and only one object. What I can think of is to modify the field versions and use through to create and intermediate table where I could then use a unique index on version_id, but I am just back to the initial problem of creating a ForeingKey field to an abstract model. I don't like using GenericForeignKey as they create all sort of headaches when working with graphene. I wondered if there is a way to model this in a different way, or to use some constraint I am not aware of, so that the database can provide completeness and uniqueness on its own. -
Django - Is it possible to transfer template tags to client asynchronously?
I am looking for a way to receive template tags, specifically a paypal form generated in views. I've been trying with jquery $.post and $.get to no avail. Also considered ajax bu it seems to receive only json views.py return render(request, 'pagamentos/payment.html', { 'morada':morada, 'telemovel':telemovel,'codigo_postal':codigo_postal, 'cidade':cidade, 'form': form }) template $.post( "/token/", { items: x.toString(), desconto: y.toString() , 'csrfmiddlewaretoken': '{{ csrf_token }}' }, function( data ) { console.log(data.morada) console.log(data.telemovel) console.log(data.cidade) console.log(data.codigo_postal) console.log(data.form) }); it doesn't work like that. Looking for a solution to load the template tags in the javascript ready function, without additional buttons. -
Django signals not sending on save() for models inheriting from a parent class?
I've just setup inheritance on my models, this makes much better sense for my project - everything inherits from Item class, with common elements. Then additional fields are added to child classes - Video, Podcast, Article etc... Previously, upon Item.save() I had some pre_save and post_save signals setup which parsed/performed various tasks on my Item model objects. @receiver(pre_save, sender=Item) def some_function(sender, instance, *args, **kwargs): print("I am working") However, now that my objects are all subclassing from Item, those signals don't seem to be firing. >Article.objects.get_or_create(title='some title') @receiver(pre_save, sender=Article) def some_function(sender, instance, *args, **kwargs): print("I am not doing anything") models.py class Item(models.Model, AdminVideoMixin): title = models.TextField(max_length=2000) slug = models.SlugField(max_length=500, default='') link = models.URLField(max_length=200) def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(get_random_string(length=5,allowed_chars='1234567890') + '-' + self.title) super().save(*args, **kwargs) def get_absolute_url(self): return reverse('curate:item_detail',args=[self.slug]) def __str__(self): return self.title class Video(Item): video_embed = EmbedVideoField(max_length=300) channel = models.TextField(max_length=500, blank=True def __str__(self): return self.title.upper() class Article(Item): authors = models.CharField(max_length=10000) movies = models.TextField(max_length=10000) def __str__(self): return self.title.upper() class Podcast(Item): authors = models.CharField(max_length=10000) itune_image = models.CharField(max_length=10000) owner_name = models.CharField(max_length=10000) def __str__(self): return self.title.upper() class Episode(Item): authors = models.CharField(max_length=10000) itune_image = models.CharField(max_length=10000) owner_name = models.CharField(max_length=10000) enclosure_url = models.URLField(max_length=2000) owner = models.ForeignKey(Podcast, on_delete=models.CASCADE,max_length=2000) class Meta: pass def __str__(self): return … -
Visualising relationships between view classes in Python / Django
I am working on a Django project which is starting to get quite large and uses a large amount of mixins within the views. Is there any tools out there that would help visualise relationships between different classes. I understand that some tools exist to show the structure of the models, but I haven't found anything specifically for view classes. -
Logging into SP when IDP is already logged in
I've been using https://pypi.org/project/djangosaml2idp/ to configure a IDP/SP for work. It's working but whenever I log in SP , it asks me to log in on IDP even if the IDP is logged in.How do I change this behavior so that SP directly detects that IDP is logged in? -
How to group several forms in one form?
I'm trying to create a match system for a Tournament Manager. I already generated my matches and I'm going to focus on the forms to update scores of those matches. I have "Match" model and "Set" model which contain a ForeignKey to "Match" because for exemple in Volleyball a match is played in 5 sets. What I did is that I created a formset (check forms.py) and I populated a list with formsets depending on the number of matches that I've got (check views.py). models.py class Set(models.Model): timeSet = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True) scoreTeam1 = models.IntegerField(null=True) scoreTeam2 = models.IntegerField(null=True) match = models.ForeignKey(Match, default=None, on_delete=models.CASCADE) class Match(models.Model): phase = models.ForeignKey(Phase, default=None, on_delete=models.CASCADE) teams = models.ManyToManyField(Team, default=None, blank=True) forms.py class SetUpdateForm(forms.ModelForm): class Meta: model = Set fields = [ 'scoreTeam1', 'scoreTeam2', ] MatchSetFormset = forms.inlineformset_factory(Match, Set, form=SetUpdateForm, min_num=1, extra=0, can_delete=False) views.py def matches_phase_view(request, id, id_phase, *args, **kwargs): tournaments = Tournament.objects.filter(user=request.user) tournament = Tournament.objects.get(pk=id) phase = Phase.objects.get(pk=id_phase) pools = Pool.objects.filter(phase=phase) teams = Team.objects.filter(pool__in=pools) matches = Match.objects.filter(phase=phase) sport = tournament.sport if phase.matchesGenerated == False: if pools: for pool in pools: teams_combinations = combinations(Team.objects.filter(pool=pool), 2) list_teams_combinations = list(teams_combinations) for combination in list_teams_combinations: match = Match.objects.create(phase=phase) match.teams.add(combination[0]) match.teams.add(combination[1]) match.save() for x in range(sport.nbSet): set_match = Set.objects.create(match=match) … -
AttributeError at /admin/ 'tuple' object has no attribute 'regex' while upgrading django version from 1.5 to 1.8
im upgrading django version 1.5 to 1.8 urls.py from django.conf.urls import include, url from django.contrib import admin admin.autodiscover() urlpatterns =[ url(r'^admin/' , include(admin.site.urls)), ] -
ModuleNotFoundError: No module named 'hotshot'
I am trying to port python 2.7 code to python 3.7 code I am seeing an "import hotshots" in a file but getting a ModuleNotFoundError: No module named 'hotshot' I can't seem to find that module anywhere online. Is this a python 2.7 specific package replaced with something else ? I had that case with cStringIO Additional info : this is implemented in a Django project. Maybe an older Django lib ? I am trying to port this code from Django 1.8 to 2.2 What I tried to do : - pip install --upgrade hotshot No matching distribution found for hotshot Looking for hotshot on The Python Package Index No library with that name What it is used for ? The only line where it is used is prof = hotshot.Profile(final_log_file) The whole project code is available here : https://github.com/EbookFoundation/fef-questionnaire, the file using "hotshots" is "profiler.py". Additionnally, there are no "hotshots.py" file in the whole project. -
How to draw Google Charts (Combo Chart) with django template?
I create a dictionary in a list in django: myList = [{'time':'week1','val':'0'},{'time':'week2','val':'1'}] I wanted to show on html page using google Combo Chart,but it not show: var data = google.visualization.arrayToDataTable([['Week', 'val']]); {% for i in myList%} data.addRows([['{{i.time}}','{{i.val}}']]); {% endfor %} and than, I add an empty row behind ,it can finally show the chart. var data = google.visualization.arrayToDataTable([['Week', 'val'],['', 0]]); {% for i in myList%} data.addRows([['{{i.time}}','{{i.val}}']]); {% endfor %} my question is : 1.why "arrayToDataTable" need 2 row when create? 2.and how can I create Combo Chart use django template, without insert an empty row? very thanks! -
Is there a way to get graphene to work with django GenericRelation field?
I have some django model generic relation fields that I want to appear in graphql queries. Does graphene support Generic types? class Attachment(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey('content_type', 'object_id') file = models.FileField(upload_to=user_directory_path) class Aparto(models.Model): agency = models.CharField(max_length=100, default='Default') features = models.TextField() attachments = GenericRelation(Attachment) I expect the attachments field to appear in the graphql queries results. Only agency and features are showing.