Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
JSON field on elasticsearch
I am trying to create an index in elasticsearch. my sample code goes like this, @cjsta.doc_type class Books(DocType): class Meta: model = Book fields = ['name','author','price','additional_info'] here additional_info is a JSON field when I try to rebuild index I am getting, django_elasticsearch_dsl.exceptions.ModelFieldNotMappedError: Cannot convert model field additional_info to an Elasticsearch field! I have also tried initializing additional_info as NestedField. But didn't worked. What is the correct way to initialize a JSONField in fields? -
how to allow the user to filter objects in a database allowing multiple choices for a parameter
In Django I have a form that allow the user to filter objects in a database, this works great when the user chooses one value for parameter but I would like to allow multiple choices. I've tried using checkbox or select multiple, both don't work. I've tried writing a view function with multiple if statement for every possible combination of choices, it works but it's definetely a bad practice. I'm reading the Django tutorial but still haven't found a solution for what I think it's a simple problem. #my models.py class Game(models.Model): name = models.CharField(max_lenght=100) platform = models.CharField(max_lenght=100) is_free = models.BooleanField(default=True) genre = models.CharField(max_lenght=100) #my views.py def index(request): platform = request.GET.get('platform') is_free = request.GET.get('is_free') genre = request.GET.get('genre') if platform is not None: games = games.filter(platform=platform, is_free=is_free, genre=genre) return render(request, 'index_games.html', {'games': games}) /*this is index_games*/ {% extends 'base.html' %} {% block content %} <h1>Games</h1> <form method="get" action="/games/"> <h5>Choose platform</h5> /*only one choice is allowed here*/ <select name="platform"> <option value='PS4'>PS4</option> <option value="XBOX">XBOX</option> <option value='Switch'>Switch</option> </select> /*here's the problem, multiple choices should be allowed for is_free and genre but are not*/ <h5>Free to Play?</h5><br/> <input type="checkbox" name="is_free" value="True" checked>Free<br/> <input type="checkbox" name="is_free" value="False">For sale<br/> <h5>Genre</h5> <input type="checkbox" name="genre" value="Shooter">Shooter<br/> <input type="checkbox" name="genre" … -
Error in date an time parsing in jango ["'Tue, 02 Jul 2019 08:11:45 +0530' value has an invalid format. in YYYY-MM-DD HH:MM[:ss[.uuu]][TZ] format."]
hi i am getting the rss feed as xml and i am parsing , but date an time zone throwing error my model field models.DateTimeField(blank=True, null=True) my xml date and time format <pubDate>Tue, 02 Jul 2019 16:43:41 +0530</pubDate> error is ["'Tue, 02 Jul 2019 08:11:45 +0530' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format."] so how save this date and time with +0530 or with out +0530 ? -
mod_wsgi error: ModuleNotFoundError: No module named 'django'
I am trying to deploy very basic Django application with Apache 2.4 on Ubuntu 18.04 without using a virtual environment. When wsgi.py executes, it cannot find django module. I have tried setting sys.path in wsgi, various solutions that define different configuration settings for 000-default.conf. Changing ownership of site-packages folder to www-data for Apache, but nothing seems to work. I could make it work using virtualenv but for production server, I do not want to use virtualenv. I can import django in Python's command line without an issue. Following is my sample.tst.conf, if have already activated it using a2ensite command. ServerName sample.tst ServerAdmin webmaster@sample.tst DocumentRoot /var/www/html <Directory /home/raza/projects/sample/sample> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess sample python-path=/home/raza/projects/sample WSGIProcessGroup sample WSGIScriptAlias / /home/raza/projects/sample/sample/wsgi.py <Location /> WSGIProcessGroup sample </Location> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined How can I fix this problem? I am struggling with this issue for more than a week. I am a very experienced programmer but very new to Linux, python, and Apache platform, so I may be making some obvious mistake. I get following error in Apache log file: [Tue Jul 02 18:05:22.458785 2019] [wsgi:error] [pid 12490] [remote 10.10.10.99:51170] mod_wsgi (pid=12490): Target WSGI script '/home/raza/projects/sample/sample/wsgi.py' cannot be loaded as … -
I tried to update image in my app but in database its storing only file name and the file is not getting uploaded?
In my app i have a details where user can view and update their details.I tried to update image in my app but in database its storing only file name and the file is not getting uploaded? If i create a user and upload profile pic its uploading to respective folder.But if i update its not uploading that pic to respective folder rather its storing only file name in database. def accountdetails(request,pk): user=User.objects.get(pk=pk) initial_values= {'Firstname':user.first_name,'Lastname':user.last_name, 'Username':user.username,'Email':user.email} if request.method == "POST": form = Accountdetails(request.POST,request.FILES) if form.is_valid(): email = form.cleaned_data['Email'] Username=form.cleaned_data['Username'] firstname=form.cleaned_data['Firstname'] lastname=form.cleaned_data['Lastname'] user=User.objects.filter(pk=pk).update (first_name=firstname,last_name=lastname, username=Username,email=email) Profile.objects.filter(user_id=pk).update(image = request.FILES['picture']) messages.success(request,'Updated Successfully!') return redirect('accountdetails', pk=pk) -
os.listdir showing deleted files
Using os.listdir to get files of a folder and os.remove to remove files from it and files are still listed after being removed until Django server is restarted. Is it any way to avoid having to restart the server to get the "correct" file list? -
How can I access two models connected by a foreignkey for a DetailView and a CreateView?
I am building a wiki and need to save every revision made for each wikipage. This means that i need a new revision tabel for every wikipage created. I then need to access that information for the template. models.py class Wikipage(models.Model): title = models.CharField(max_length=100) date_created = models.DateTimeField('Created', auto_now_add=True) def __str__(self): return self.title class Meta: verbose_name_plural = "Wikipages" class Revison(models.Model): wikipage = models.ForeignKey(Wikipage, null=True, on_delete=models.CASCADE, related_name='revison') content = models.TextField('Content') author = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) last_edit = models.DateTimeField('Last edit', auto_now=True) comment = models.TextField('Comment', blank=True) class Meta: verbose_name = 'Revison' verbose_name_plural = 'Revisons' ordering = ['-last_edit'] get_latest_by = ['last_edit'] def __str__(self): return self.content I wanted to use the DetailView and CreateView that comes with django, but I have not succeeded in accessing specific data from both tables. I have gotten the ListView to work correctly, but that only needs the title from Wikipage, and nothing from Revision. -
How can i search by tag name and if post published
i have 2 problems; the first one; How can i search by tag name tag model is manytomanyfield. the last one; if post published, show posts by tag name. i take published posts using this code " post_list=Post.objects.published()". However, i don't know how can i use filter and published Models.py class PostQuerySet(models.QuerySet): def active(self): return self.filter(status__in=[Post.STATUS_PUBLISHED]) def published(self): return self.filter(status=Post.STATUS_PUBLISHED) class Post(models.Model): STATUS_DRAFT = 1 STATUS_PUBLISHED = 2 STATUSES = ( (STATUS_DRAFT, 'Draft'), (STATUS_PUBLISHED, 'Published'), ) category=models.ManyToManyField(Category) tag=models.ManyToManyField(Tag) user=models.ForeignKey(User,on_delete=models.CASCADE,verbose_name="Yazar",related_name='posts') title=models.CharField(max_length=120,verbose_name="Başlık") content=RichTextField(verbose_name="İçerik") created_date=models.DateTimeField(auto_now_add=True,verbose_name="Oluşturulma Tarihi") updated_date=models.DateTimeField(auto_now=True,verbose_name="Güncellenme Tarihi") image=models.ImageField(null=True,blank=True) slug=models.SlugField(max_length=130,unique=True) status = models.SmallIntegerField(choices=STATUSES) objects = PostQuerySet.as_manager() views.py def post_index(request): #post_list=Post.objects.published().order_by('-created_date') post_list=Post.objects.published() query=request.GET.get('q') if query: post_list=post_list.filter( Q(content__icontains=query)| Q(title__icontains=query) | Q(tag_name__icontains=query)| # doesn't work Q(user__first_name__icontains=query)).distinct()... -
How to process data from one model field to another
I have models of Exercise, Training and Workout. Training contains some exercises (Exercise) Workout contains trainings (Training). Snippet of my models.py: class Exercise(models.Model): user = models.ForeignKey(User, related_name='exercises', on_delete=models.CASCADE) name = models.CharField(max_length=80) description = models.TextField(max_length=300) details = models.ManyToManyField(ExerciseDetail, blank=True) ... class Training(models.Model): user = models.ForeignKey(User, related_name='trainings', on_delete=models.CASCADE) name = models.CharField(max_length=80) description = models.CharField(max_length=250) exercises = models.ManyToManyField(Exercise, related_name='trainings', blank=True) ... class Workout(models.Model): user = models.ForeignKey(User, related_name='workouts', on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now=True) name = models.CharField(max_length=200) description = models.TextField(max_length=400, blank=True) trainings = models.ManyToManyField(Training, related_name='workouts', blank=True) ... I would like to have possibility to use something like Workout.objects.get(name='workout').exercises.objects.all() to get a list/set of all exercises included in trainings of chosen Workout. Can someone give a hint how can I do that? -
How to make a form field readonly with the HTML attribute readonly instead of disabled
I want to make my field in a form to be readonly. I have already used disabled in forms but it doesn't send my data to the database when POST request is triggered by the Form. site_location = forms.CharField(disabled=True) So, I inspected the element and manually added readonly attribute to its HTML code to check if readonly is working or not. And readonly has no issues in submitting the form. But disabled tells me that my form is invalid. Readonly and Disabled have some differences according to this answer: What's the difference between disabled="disabled" and readonly="readonly" for HTML form input fields? How can I use the readonly in forms instead of disabled?? -
invalid character in identifier in django
I am writing a simple code in django Code: status = self.get_object() owner = status.owner_id print("status.status ", status.status) if (status.status == "Active"): subject = 'Yantraksh-RFQ Status' message = 'You have succesfully raised RFQ' # shipper_email reci = Teacher.objects.filter(user_id=owner).values_list("shipper_email", flat=True) email_from = settings_bak.EMAIL_HOST_USER send_mail(subject, message, email_from, reci, fail_silently=False) But it is saying > SyntaxError: invalid character in identifier I am not able to find any error in the syntax, please help! error log: File "D:\Downloads-HDD\My work -- agg\django_school\classroom\views\teachers.py", line 220 reci = Teacher.objects.filter(user_id=owner).values_list("shipper_email", flat=True) ^ SyntaxError: invalid character in identifier -
How To Initialize A Value in ForeignKey Dropdown from View in Django
I need to set the value of my ForeignKey dropdown = to a url parameter when the form is rendered. I am able to successfully set other form fields to this value, but not the ForeignKey. I am trying to initialize the 'reference' form field which is a foreign key using the reference_id value which is passed via the url. I can successfully assign this value to the three other fields in the form, but not to 'reference'. Models.py class Manifests(models.Model): reference = models.ForeignKey(Orders) cases = models.IntegerField() description = models.CharField(max_length=1000) count = models.IntegerField() def __str__(self): return self.description Forms.py class CreateManifestForm(forms.ModelForm): class Meta: model = Manifests fields = ('reference', 'cases', 'description', 'count') Views.py def add_manifest(request, reference_id): if request.method == "POST": form = CreateManifestForm(request.POST) if form.is_valid(): instance = form.save(commit=False) try: order = Orders.objects.get(id=reference_id) except Orders.DoesNotExist: pass instance.reference = order instance.save() return redirect('add_manifest', reference_id=reference_id) #this is where my problem is form = CreateManifestForm(initial={'reference': reference_id}) reference = request.POST.get('reference') manifests = Manifests.objects.all().filter(reference=reference) context = { 'form': form, 'reference_id': reference_id, 'manifests' : manifests, } return render(request, 'add_manifest.html', context) And just in case it's needed: urls.py url(r'^add_manifest/(?P<reference_id>\d+)/$', add_manifest, name='add_manifest'), There are no errors, but the field does not set to the value passed through the URL. Like … -
Django SingleTableView object has no attribute 'filter'
When I am rendering a table from a legacy MySQL database using the class-based (SingleTableView) view I recieve the following message: "...object has no attribute 'filter'" I am trying to visualize the table by following the solution from Nicolas Kuttler (https://kuttler.eu/en/post/using-django-tables2-filters-crispy-forms-together/?c=208349) and the solution from this ticket: How do I filter tables with Django generic views?. When I deployed the solution initially it worked well, meaning that I saw the filter, and the table, but at some point the error message appeared. As I am being a beginner in web-developing I have no idea on what am I doing wrong, therefore I would greatly appreciate an advise of the wise community =) #tables.py import django_tables2 as tables from .models import ValuesModel class ValuesModelTable(tables.Table): export_formats = ['csv', 'xls'] col1 = tables.Column(accessor='pk_t.pk_type.type1', verbose_name='Column One') .... class Meta: model = ValuesModel template_name = 'django_tables2/bootstrap.html' .... +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #filters.py import django_filters class ValuesModelFilter(django_filters.FilterSet): col1 = django_filters.CharFilter(field_name='pk_t__pk_type__type1', lookup_expr='icontains', label='Column One') .... +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #forms.py from .models import ValuesModel from crispy_forms.helper import FormHelper class ValuesModelListFormHelper(FormHelper): form_method = 'GET' model = ValuesModel form_tag = False +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #utils.py from django_tables2 import SingleTableView class PagedFilteredTableView(SingleTableView): filter_class = None formhelper_class = None context_filter_name = 'filter' def get_quryset(self, **kwargs): qs = super(PagedFilteredTableView, self).get_queryset() … -
Django how to get file path defined in the custom field
I'm using Django 2.2 and Django REST Framework. I'm writing a custom DRF serializer field, extending the JSONField to perform validation using jsonschema. I have defined the path of the scheme in the myapp.serializers like class MySerializer(serializers.Serializer): j_data = JSONSchemaField(schema='json_schema/validate.json') The file is saved in the myapp/json_schema/validate.json and the JSONSchemaField is defined in a file outside the application. json_validate.py class JSONSchemaField(JSONField): def to_internal_value(self, data): // Get file path here. return super().to_internal_value(data) How can I get the path to the schema in the JSONSchemaField class? -
Django get certain object from paginated object. Like `after` in Apollo
I am trying to implement Ariadne to my django app. I got problem with pagination. Well i am using django's default pagination. Thing is i want to select after certain objects in paginated queryset. Here is my resolver. So there is an after argument which would be optional but when provided i have to fetch from paginated queryset right after it's value. In this case after="some-UUID" def resolve_artist_releases(artist, *_, single=None, first=10, skip=1, after=None, last=None): albums = artist.album_set.all() if single is None else artist.album_set.filter(single=single) p = Paginator(albums.order_by("-created_dt"), first) if last: p = Paginator(albums.order_by("created_dt"), last) return p.page(skip).object_list Can you guys help me on this? -
Model instances saved only partially
I have a fairly complex view with several subforms and formsets with both many-to-many and one-to-one relationships. When getting a form from context object, I'm hitting a weird issue that some of the data is not saved. Correct model instance is created with form.save(), I can see all the fields I filled out in form, but all that's added to the database is pk, all the fields are empty. The same happens when I'm saving with commit=False and then saving again, when I'm updating fields manually and then saving or when I'm using force_insert=True. Creating new instances in the same code block however are saved without an issue. This doesn't end here, when saving many-to-many relationships, child models are saved without a hitch, but most of the time, m2m through models are not created. I said most of the time, because every once in a while they are. But even if they're not, the id descriptor in database is incremented so what I'm seeing in the through table is few lines, much less than there should be with non-sequential id-s. What am I dealing with here, does anybody have a clue? I'm out of ideas what to try next. I … -
Django allauth Automatically set mail address as confirmed
I am using django-allauth together with an LDAP-backend. So whenever a users logs in, the mail address is set to the mail address stored in our directory server. I was able to disable email confirmation by setting ACCOUNT_EMAIL_VERIFICATION = "none" But now those users have an unconfirmed mail address attached to their account. More specifically: I am trying to set up a mailman 3 including webUI and connect that to LDAP. Users having the mail address unconfirmed, causes them to not be able to use this address to subscribe to mailing lists. Can I maybe somehow modify the AccountAdapter to automatically confirm mail addresses when a user logs in? -
websocket connection in new_web.js not triggering consumers in django
the new.js file which contains the websocket connection and which actually connects/activates the django channels isn't connecting i don't understand where exactly the issue i have tried connecting another socket connection for different consumer in different html page that is working perfectly fine WebSocket HANDSHAKING /new/ [127.0.0.1:61934] WebSocket CONNECT /new/ [127.0.0.1:61934] Add specific.bYAxHTPf!sBbGasUiKdHR channel to post's group connected one websocket is connecting perfectly fine where as when i fireup localhost:8000/w which is supposed to connect the other websocket its not connecting that to consumers HTTP GET /static/js/channels/new_web.js 304 [0.01, 127.0.0.1:62085] i can access the websocket connection within the template but this websocket is triggering my path in routing which in turn triggers my consumers new_web.js $(function(){ endpoint = 'ws://127.0.0.1:8000/like/' // 1 var socket = new ReconnectingWebSocket(endpoint) // 2 socket.onopen = function(e){ console.log("open",e); } socket.onmessage = function(e){ console.log("message",e) var userData = JSON.parse(e.data) $('#new_user').html(userData.html_users) } socket.onerror = function(e){ console.log("error",e) } socket.onclose = function(e){ console.log("close",e) } }); socket.onclose = function(e){ console.log("close",e) } }); routing.py from channels.routing import ProtocolTypeRouter, URLRouter from channels.auth import AuthMiddlewareStack from django.urls import path from posts.consumers import PostConsumer,LikeConsumer application = ProtocolTypeRouter({ 'websocket': AuthMiddlewareStack( URLRouter( [ path("new/", PostConsumer), path("like/", LikeConsumer), ] ) ) }) consumers.py class LikeConsumer(AsyncJsonWebsocketConsumer): async def connect(self): self.user … -
Cannot Solve "ValueError: attempted relative import beyond top-level package"
I am running the project and shows this error. I have googled and tried some of the solutions but doesn't seem to work. File "/home/bs-094/Dev/backend/busgroup-backend/src/bus_portal_backend/apps/inquiry/forms/inquiry_details.py", line 2, in <module> from ..models.inquiry import Inquiry ValueError: attempted relative import beyond top-level package My folder structure is busgroup-backend src bus_portal_backend apps inquiry models _init_.py inquiry.py forms inquiry_details.py It would be great help is anyone helps me solve the problem. I am fairly new to django. Thanks -
Django REST Framework custom serializer mixin not working
I'm using Django 2.2 and Django REST framework. In the serializer, I want to have few fields only for creating an instance and not for updating. Means, the user won't be able to change the value of that field once created. Since Django does not provide any default way to do it. I am writing a mixin which when used will use the create_only_fields from the serializer Meta to remove the fields from the request data with PUT/PATCH request. serializer_mixin.py class CreateOnlyFieldsMixin(object): def to_internal_value(self, data): data = super().to_internal_value(data) print(data) if self.instance: # Update request print(data) for x in self.Meta.create_only_fields: if x in data: data.pop(x) return data and using in the serializer like class MySerializer(CreateOnlyFieldsMixin, serializers.ModelSerializer): class Meta: model = MyModel fields = [ 'id', 'name', 'value' ] create_only_fields = ['name'] But now calling any endpoint, it gives an error Cannot call `.is_valid()` as no `data=` keyword argument was passed when instantiating the serializer instance. Putting CreateOnlyFieldsMixin after serializers.ModelSerializer gives no error but has no effect of the mixin. Appending to_internal_value directly in the serializer is working as expected. -
How to use a field value instead of pk in the url?
I want to show the username or name of the person I want to update details for, in the url of update view. The only method I know is to display pk in the url. Is there a method to replace pk with a field value? Thanks in advance. -
in update form when went to update profile picture getting MultiValueDictKeyError at /42/accountdetails 'picture'
In my app i have a details where user can view and update their details.I went to update profile pic and when i choose profile pic and click on update it returns MultiValueDictKeyError at /42/accountdetails 'picture' models.py class Profile(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE) image = models.ImageField(upload_to='media',default="None") views.py def accountdetails(request,pk): user=User.objects.get(pk=pk) initial_values= {'Firstname':user.first_name,'Lastname':user.last_name, 'Username':user.username,'Email':user.email} if request.method == "POST": form = Accountdetails(request.POST,request.FILES) if form.is_valid(): email = form.cleaned_data['Email'] Username=form.cleaned_data['Username'] firstname=form.cleaned_data['Firstname'] lastname=form.cleaned_data['Lastname'] user=User.objects.filter(pk=pk).update(first_name=firstname, last_name=lastname,username=Username,email=email) pro=Profile.objects.filter(user_id=pk).update(image= request.FILES['picture']) messages.success(request,'Updated Successfully!') return redirect('accountdetails', pk=pk) else: form = Accountdetails(initial=initial_values) return render(request,'accountdetails.html',{'user': user,'form':form}) forms.py class Accountdetails(forms.Form): picture = forms.ImageField(required=False) #i am posting only for imagefield -
Django shorten query on save to ForeignKeyField
I have 2 models Owners, Relationships Owners class Owner(models.Model): id = models.BigAutoField(primary_key=True) nickname = models.CharField(max_length=20, unique=True) Relationships class Relationships(models.Model): id = models.BigAutoField(primary_key=True) owner = models.ForeignKey(Owner, on_delete=models.CASCADE, related_name='relationship_owner') target_owner = models.ForeignKey(Owner, on_delete=models.CASCADE, related_name='relationship_target_owner') To add rows to Relationships, I used below query. owner1 = Owner.objects.filter(nickname='hide').first() owner2 = Owner.objects.filter(nickname='john').first() Relationships.objects.create(owner=owner1, target_owner=owner2) It is pretty clear. But when I inspect on django-debug-toolbar, it queried to database 3 times. Get nickname=hide from owners table. Get nickname=john from owners table. Insert into hide and john into relationship table. I wonder that, is it a general way? Or, Is there any clear way to performing above query? Thanks! -
How to make a login and signup page using an existing model in Django==2.1
I am a making a student management system with django. I have a Student model which should be modified only by the registrar when a student takes admission. The registrar will use the inbuilt django admin page to add students. class Student(models.Model): first_name = models.CharField(max_length=100, null=False, blank=False) last_name = models.CharField(max_length=100, null=False, blank=False) roll = models.CharField(unique=True, max_length=200, null=False, blank=False) email = models.EmailField(unique=True, null=False, blank=False) age = models.PositiveIntegerField(blank=True) gender = models.CharField(choices=GENDER, default='O', max_length=1) dob = models.DateField(null=False, help_text='YYYY-MM-DD', blank=False) admission_type = models.CharField(choices=ADMISSION_TYPES, default='B', max_length=1) Now I want to be able to use this model to make a login and signup page for students. In the signup page, the student enters his valid roll number and a password. In the login page he must enter this roll and password to go to his dashboard. How can I do this efficiently? I have tried extending AbstractUser but I am unable to make it work. -
How to display relationship with back reference at django template through User?
I have such models class Employee(models.Model): """Employee information.""" user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='employee', unique=True) position = models.CharField("current position in a company", max_length=64, blank=True) birth_date = models.DateField("date of birth", null=True) skills = models.ManyToManyField( Technology, through="Skill", verbose_name="skills", blank=True) class Technology(models.Model): """Technologies.""" name = models.CharField('technology name', max_length=32, unique=True) class Skill(models.Model): """Information about an employee's skills.""" LEVELS = ( ('basic', 'Basic'), ('intermediate', 'Intermediate'), ('advanced', 'Advanced'), ('expert', 'Expert'), ) employee = models.ForeignKey( Employee, on_delete=models.CASCADE, related_name="employee_skills") technology = models.ForeignKey(Technology, on_delete=models.CASCADE) start_date = models.DateField( verbose_name='Works with since:') level = models.CharField("level", max_length=64, choices=LEVELS) And I can't understand why my template code doesn't work template.html {{ user.employee.position }} {{ user.employee.birth_date }} {{ user.employee.summary }} {% for i in user.employee.skills.all %} {{ i.technology.name }} {{ i.level }} {% endfor %} I can't see absolutely nothing. All models possible to see at adminpanel. And else then I using TemplateView such as class AccountView(TemplateView): template_name = "profile.html" def get_context_data(self, **kwargs): context = super(AccountView, self).get_context_data(**kwargs) context['skills'] = Skill.objects.filter(employee__user=self.request.user) return context then everything works fine.