Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:11:00+00:00 2026-06-02T09:11:00+00:00

I am creating a very simple to-do list application. Each user should have an

  • 0

I am creating a very simple to-do list application. Each user should have an associated to-do list page with basic CRUD functionality. That means User A should have different data than User B.

As of right now there is no distinction about who owns the to-do list. Anyone who is logged in can add, remove, display, delete tasks.

I have a gut feeling that I might need an extra something in my model and my template. I should mention that I use Pinax 0.9a2. If it does what I need it to do, I would prefer to use that solution instead.

Here’s my models.py

class Task(models.Model):
    name = models.CharField(max_length=100)
    added_at = models.DateTimeField(auto_now_add=True)
    last_update = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.name

Here’s one of my forms in views.py

def task_create(request):
    return create_object(request,
        model=Task,
        template_name='task_create.html',
        post_save_redirect=reverse("todo_list")
    )

Here’s 2 of my templates:

To-Do Create

 <form action="" method="post">{% csrf_token %}
        {{ form.name }}
        <button type="submit" class="btn primary">Create &rarr;</button>
    </form>

To-Do List

{% if task_list %}
    <p><a href="{% url task_create %}">Create a task</a></p>
    <ul>
    {% for task in task_list %}
        <li><a href="{% url task_detail task.id %}">{{ task.name }}</a></li>
    {% endfor %}
    </ul>
    {% else %}
        <p>No tasks to display, click to <a href="{% url task_create %}">create new</a>.</p>
    {% endif %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:11:05+00:00Added an answer on June 2, 2026 at 9:11 am

    So you just want to add access control to it?

    1. Add ForeignKey to auth.User to your ToDos model
    2. Rewrite your list and create views to make their work manually (you can achieve your goal with new class based views but you need to understand how do they work first)
    3. Add filter for queryset in list view
    4. Provide commit=False to your form’s save(), set up user for retrieved object and save it manually

    Code:

    class Task(models.Model):
        user = models.ForeignKey('auth.User')
        name = models.CharField(max_length=100)
        added_at = models.DateTimeField(auto_now_add=True)
        last_update = models.DateTimeField(auto_now=True)
    
    class TaskForm(forms.ModelForm):
        class Meta:
            model = Task
            exclude = ['user', ]
    
    def task_create(request):
        form = TaskForm(data=request.POST or None)
        if request.method == 'POST' and form.is_valid():
            task = form.save(commit=False)
            task.user = request.user
            task.save()
            return reverse("todo_list")
        return render(request,
            'task_create.html',
            {'form': form}
        )
    

    Also, add filtering by request.user in list view and I’d recommend @login_required decorator to avoid adding tasks by non-authorized users.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a very simple django upload application but I want to make it
I am creating a very large PHP MVC-based site that will have a large
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
Its very simple but somehow not working (weird!!). I have a List of a
I am creating a simple aspnetmvc cart application and have defined classes similar to
I have an activity that has two tabs and a list view in each.
I'm creating a simple IP blacklist. Each request is evaluated against list of IPs
I have a simple form that has a list (dropdown list generated from a
I have a simple list of items that needs to be printed using Cocoa.
I'm creating some tests with JMeter, the situation is very simple, I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.