0

I am trying to create my own Learning Management System (LMS) as a project to learn a range of programming languages. So far users can login/logout and register.

However what i want the system to do is to return a post to the user specific to the group I have assigned to them in the admin page.

EXAMPLE user:'Steve' is assigned to group:'Maths' When 'Steve' logs in, if there are any posts assigned to 'Maths' then i want only those posts to be shown on their homepage. Further to this, if 'steve' is in other groups, I want posts from those groups to also be displayed.

Below is html of the homepage which i have created. with this i can only show all posts to a user if they are in a very specific group.

I understand that somewhere i will need to do some python programming to get this to work. If you need to see any more of my code I will be more than happy to provide. Thank You :)

<div class="row">
      {% for group_for in request.user.groups.all %}
      {% if group_for.name == "Science" %}
        {% for work in homework %}
      <div class="row">
        <div class="col s12 m6 14">
          <div class="card blue-grey darken-1">
            <div class="card-content white-text">
              <span class="card-title">{{work.homework_title}}</span>
              <p>{{work.homework_description | safe}}</p>
                <p>{{work.homework_deadline}}</p>
                <p>{{work.homework_issued_by}}</p>
            </div>
            <div class="card-action">
              <a href="#">This is a link</a>
              <a href="#">This is a link</a>
            </div>
          </div>
        </div>
      </div>
        {% endfor %}

      {% endif %}
    {% endfor %}
  • 1
    You should code in your view, from there you can get the user logged in, the group assigned to them, and get the posts in the group, according to the group. You can then pass this in context to the html, then arrange the posts by the group. – srv236 Sep 11 '20 at 08:11
  • Hi, thank you for your reponse. After doing some nore research i think i may need to use foreign keys and work with the in-built django permissions. I may have thrown myself in the deep end here – CodingJ Sep 13 '20 at 10:58

0 Answers0