Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
use of viewsets in django rest framework
Being new to django rest framework , I often get puzzled as what exactly is the use of viewset when we can overwrite crud methods in serializers too .Another thing is that how is overwriting crud methods in serializers different from overwriting crud methods in viewsets ? -
How to annotate on a single object and not a QuerySet in Django?
When annotating something to a model in Django one would write something like this: Post.objects.all().annotate(total_yes_votes=Count('vote', filter=Q(vote__vote_choice='yes'))) What if I want to annotate on a single object and not all() the objects: Post.objects.get(id=id).annotate(total_yes_votes=Count('vote', filter=Q(vote__vote_choice='yes'))) By the way, it doesn't work. Isn't it more efficient to annotate a single object rather than all()? -
Access to image at [Img Link] from origin [domain] has been blocked by CORS policy
I have a domain, domain.com where I have hosted my VueJs application and I have a domain api.domain.com where I have hosted my Django API. I have hosted both of these applications on the AWS (EC2 ubuntu instance). I am getting this Image CORS error while I am sending add_header 'Access-Control-Allow-Origin' '*' always; in the NGINX.conf Access to image at 'http://api.deshpardesh.in/media/newspapers/images_qseNU9o.jpeg' from origin 'http://deshpardesh.in' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Here is the actual error. -
How to create an instance of a pre-existing model in django?
I want to create a Task execution checklist app in django. Suppose I have a checklist with 3 tasks assigned to it. Now I want to have multiple instances of that same checklist so that at a time multiple user can cross off from their own instance of that checklist. -
Django problem with implementing a form within generic view
I am working on app that allows users to share prictures (instagram like) and I got stuck on implementing functionality of adding comments to pictures in DetailView. Namely: after entering the data into my comment form and clicking the submit button I get 404 error here are my views: @method_decorator(login_required, name='dispatch') class ItemInterest(SingleObjectMixin, FormView): template_name = 'content/item_detail.html' form_class = CommentForm model = Item def post(self, request, *args, **kwargs): self.object = self.get_object() return super().post(request, *args, **kwargs) def get_success_url(self): return reverse('item-detail', kwargs={'pk': self.object.pk}) @method_decorator(login_required, name='dispatch') class ItemDisplayView(DetailView): model = Item def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['form'] = CommentForm() return context @method_decorator(login_required, name='dispatch') class ItemDetailView(View): def get(self, request, *args, **kwargs): view = ItemDisplayView.as_view() return view(request, *args, **kwargs) def post(self, request, *args, **kwargs): view = ItemInterest.as_view() return view(request, *args, **kwargs) models: class Item(models.Model): description = models.CharField(max_length=255) photo = models.ImageField(upload_to='photos') date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) class Comment(models.Model): item = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='comments') author = models.CharField(max_length=255) body = models.TextField() create_date = models.DateTimeField(default=timezone.now) active = models.BooleanField(default=True) comment form: class CommentForm(forms.ModelForm): class Meta: model = Comment fields = ('author', 'body', 'item',) and url: path('item/<int:pk>/', ItemDetailView.as_view(), name='item-detail'), -
How to make table filter in Django
I am new to django framework, my project is data-mining for 'GPUs'; the database of "GPU" that I have has been collected from "Kaggle"; I want to filter the table rows based on the custom queries. I have done this in PHP7 in the last semester and back then I used the code in this website "https://www.webslesson.info/2018/08/how-to-make-product-filter-in-php-using-ajax.html" All I want is a step by step walk-through just like in that website if it exist, else if some proper documentation which could help me. Also one more question:- We can write php code{my emphasis is on rendering data from database with a custom query} in between HTML can we do the same in django using "jinja" pattern *The following code is a snippet from that website I mentioned earlier wherein the "Brand" has set of all the manufacturing company with a checkbox and once checked it filters out only those products * <h3>Brand</h3> <div style="height: 180px; overflow-y: auto; overflow-x: hidden;"> <?php $query = "SELECT DISTINCT(product_brand) FROM product WHERE product_status = '1' ORDER BY product_id DESC"; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector brand" value="<?php echo $row['product_brand']; ?>" > <?php echo … -
How do sites like Google and Aol prevent the user from accessing the login form after logging in?
I am trying to implement a log-in (Django) form which, ideally, should not be visible to the user after he/she has signed in. The problem occurs when i press the back button of the browser. Since the button acts like a stack, it immediately plops the previous page without making any requests (if i can't receive a request, i don't think i'll be able to redirect the user to the desired page). Not sure how, but both Google and Aol are able to prevent this. Any ideas? -
Django Endlesss pagination breaks buttons genereated by endlesss pagination
I have endless pagination working on my site for posts. Each post has a like and dislike button which works using ajax. The first set of posts have working buttons but all posts delivered with pagination don't have working buttons. When clicking the buttons they don't even run the ajax to send a query to my views.py file but the first set of posts have working ones. views.py file sort = request.GET.get("sort") if sort=="newest": posts = Post.objects.filter(deleted=False).order_by('-date_posted') sort_type = "newest" if sort=="oldest": posts = Post.objects.filter(deleted=False).order_by('date_posted') sort_type = "oldest" if sort=="top-alltime": posts = Post.objects.filter(deleted=False).annotate(like_count=(Count('like_post')-Count("dislike_post"))).order_by('-like_count') sort_type = "top-alltime" if sort==None or sort=="top-today": today = datetime.now().date() today_start = datetime.combine(today, time()) posts = Post.objects.filter(deleted=False, date_posted__gte=today_start).annotate(like_count=(Count('like_post')-Count("dislike_post"))).order_by('-like_count') sort_type = "top-today" if sort=="top-week": current_week = date.today().isocalendar()[1] posts = Post.objects.filter(deleted=False, date_posted__week=current_week).annotate(like_count=(Count('like_post')-Count("dislike_post"))).order_by('-like_count') sort_type = "top-week" page = request.GET.get('page', 1) paginator = Paginator(posts, 4) trending_tags = Post.tags.most_common()[:5] try: posts_given = paginator.page(page) except PageNotAnInteger: posts_given = paginator.page(1) except EmptyPage: posts_given = paginator.page(paginator.num_pages) context = { "trending_tags": trending_tags, "posts_given": posts_given, "sort": sort_type } return render(request, "users/index.html", context) template {% load static %} {% block content %} <h1>Homepage</h1> <div class="infinite-container" id="infinite-container" style="max-width:700px;width:100%;margin-left:auto;margin-right:auto;"> <form action="/action_page.php"> {% csrf_token %} <div style="display:inline-block;"> <h5 style="margin-left:10px;">Sort by</h5> <select name="sort" class="sort_by" id="sort_by" style="margin-left:10px;"> <option value="newest">Newest</option> <option value="top-today" selected="selected">Top Today</option> … -
Laravel / Django CMS for next project
How does Laravel CMSs compare with for example Django built-in CMS? How hard is it to implement a laravel CMS that enables you to add/edit posts and interact with users accounts compared to Django built in solution? I'm contemplating on my next project stack, and I'm split between laravel and django (other thoughts at the end of the post) because my last (small) project was with Laravel, but Django CMS seems like it can save me time. Next project will in general be a site with Stories section which contains a pool of stories. Users can sign in to view the stories section (they can also comment on stories or upload a story to the stories section (which will be reviewed/edited by the admin before appearing in the stories section). The stories section will only be available for paying users. Back to the discussion - I think a CMS is useful here, because content is regularly added to the pool of stories (content either by admin or by users uploads that go through admin review). Or should I just use wordpress in this case? What will be the benefits coding this in Laravel/Django rather than doing it on wordpress based … -
Various dynamically django formsets throws missing_management_form error
I have a problem validating django formsets when i build several formsets dynamically In this case the one client could be various brands and contact people. models.py class Client(ChangesMixin, models.Model): name = models.CharField(verbose_name="Nombre", max_length=100, unique=True) code = models.PositiveIntegerField(verbose_name="Código", blank=True) class Meta: verbose_name = "Cliente" verbose_name_plural = "Clientes" class Brand(ChangesMixin, models.Model): name = models.CharField(verbose_name="Marca", max_length=100, blank=True, null=True) client = models.ForeignKey('Client', verbose_name="Cliente", related_name='brand_client', on_delete=models.DO_NOTHING) class Meta: verbose_name = "Marca" verbose_name_plural = "Marcas" class Contact(ChangesMixin, models.Model): name = models.CharField(verbose_name="Contacto", max_length=100, blank=True, null=True) client = models.ForeignKey('Client', verbose_name="Cliente", related_name='contact_client', on_delete=models.DO_NOTHING) class Meta: verbose_name = "Contacto" verbose_name_plural = "Contactos" I have two method to create forms and formsets dynamically forms.py def get_custom_formset(entry_model=None, entry_fields=None, action=None): formset = None if action == 'create': extra = 1 else: extra = 0 formset = modelformset_factory( model = entry_model, extra = extra, form = get_custom_form(entry_model, entry_fields, action) return formset def get_custom_form(entry_model=None, entry_fields=None, action=None): class _CustomForm(forms.ModelForm): class Meta: model = entry_model fields = [field.name for field in entry_fields] def __init__(self, *args, **kwargs): """ """ super(_CustomForm, self).__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance and instance.pk: for field in entry_fields: if action == 'detail': self.fields[field.name].widget.attrs['readonly'] = True return _CustomForm I have a creation class view with get and post methods, depends on … -
I am unable to add category urls in my Post
Error Image When i am trying to add Url of candidate_slug i am getting error about: Unknown field(s) (category_slug) specified for Candidate. Check fields/fieldsets/exclude attributes of class CandidateAdmin on add a candidate button and when i remove urls from admin i cannot add categories over my series and i am ubable to go toseries after the category that shows on homepage urls.py from django.urls import path, include from . import views app_name = 'main' urlpatterns = [ path("", views.homepage, name="homepage"), path("signup/", views.signup, name="signup"), path("login/", views.login_request, name="login"), path("logout", views.logout_request, name="logout"), path("profile/", views.profile, name="profile"), path("account/", views.account, name="account"), path("<single_slug>", views.single_slug, name="single_slug"), ] views.py from django.shortcuts import render, redirect from django.http import HttpResponse from .models import Candidate, CandidateCategory, CandidateSeries from django.contrib.auth.forms import UserCreationForm, AuthenticationForm from django.contrib.auth import login, logout, authenticate from django.contrib import messages from .forms import NewUserForm # Code for Showing(rendering) Homepage def homepage(request): return render(request=request, template_name="main/categories.html", context={'categories': CandidateCategory.objects.all}) # Code for showing profiles section def profile(request): return render(request, "main/profile.html", ) def single_slug(request, single_slug): categories = [c.category_slug for c in CandidateCategory.objects.all()] if single_slug in categories: matching_series = CandidateSeries.objects.filter(candidate_category__category_slug=single_slug) series_urls = {} for m in matching_series.all(): part_one = Candidate.objects.filter(candidate_series__candidate_series=m.candidate_series).earliest("candidate_published") series_urls[m] = part_one.candidate_slug return render(request=request, template_name='main/category.html', context={"candidate_series": matching_series, "part_ones": series_urls}) categories = [ca.candidate_slug for ca … -
django order_by either columns (date whichever is recent)
I want to order my posts by either the most recent comment.created or post.published_date(in case there is no comment yet). posts_all =ForumPost.objects.all().filter(published_date__lte=timezone.now()).prefetch_related('comments') posts=posts_all.annotate(max_activity=Max('comments__created')).order_by('-max_activity','-published_date') With the above code, it shows all posts with comments first (ordered by most recent comment activity), then follows all posts that do not have any comment (ordered by recently published). What I really want is order posts by most recent comment OR recently published. Any idea? Thanks. -
Getting the path of an uploaded media file that uses "upload_to" in django
I am trying to replace the images that will be uploaded for a certain ImageField in my models. Now My models are like this: class Image(models.Model): image = models.ImageField(upload_to='images/') def save(self, *args, **kwargs): # some resizing here which works fine As you can see, my model saves the file to the 'images/' directory (because i have different image types that need to go in different sub-directories of /media) which will eventually become '/media/images/' due to this setting in my settings.py: MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') Now the problem is where I'm using the receiver method to delete the previously uploaded image. @receiver(pre_save, sender=Image) def file_update(sender, **kwargs): instance = kwargs['instance'] print(instance.image.path) ### HERE IS THE PROBLEM if instance.image: path = instance.image.path ### HERE IS THE PROBLEM os.remove(path) It's supposed to return this: /home/.../media/images/file.jpg But it returns this: /home/.../media/file.jpg Which obviously results in a No such file or directory error. What am I missing? -
How to calculate sum and also cumulative sun in django orm
I have table project, project has sub project and subproject has developers. Another table sprint, work distribute in sprint 1 2 ..n so on, Each sprint has different developers data. Now How can i calculate sum, current sprint value and percentage complete Using Django Orm. Project has sub project foreign key class project(models.Model): title = models.CharField(max_length=150) project = models.ForeignKey("self", on_delete=models.CASCADE, related_name="subproject", blank=True, null=True) Developers table class Developers(models.Model): quantity = models.FloatField(default=0.0) charge_rate = models.FloatField(default=0.0) project = models.ForeignKey("Project", on_delete=models.SET_NULL, related_name="developers", null=True) Table Sprint class Sprint(models.Model): sprint_name = models.CharField(max_length=150) percentage = models.FloatField(default=0.0) sprint data class SprintsData(models.Model): sprint = models.ForeignKey( "project", on_delete=models.CASCADE, related_name="d", blank=True) percentage = models.FloatField(default=0.0) This is sample data project id name project 1 development null Sub project id name project 1 Homepage 1 2 header 1 3 footer 1 Developers id name quantity rate project (sub project foreign key) 1 developers 5 200 1 2 designer 5 150 2 Sprint id name start_date end_date 1 sprint1 - - SprintsData id sprint project(subproject foreign key) percentage 1 1 1 5 2 1 2 80 Output looks like sprint project sub_project total_sum percentage_complete current_sprint_amount sprint1 development Homepage (quantity*charge_rate) 5 (total_sum)5% sprint1 development Header 5*150 80 (5*150)*80% -
django el-pagination list index out of range
Hi I'm following this tutorial to do pagination. I used pip to install the files. Then I added from django.conf.global_settings import TEMPLATES TEMPLATES[0]['OPTIONS']['context_processors'].insert(0, 'django.core.context_processors.request') to my settings.py file but I get this error TEMPLATES[0]['OPTIONS']['context_processors'].insert(0, 'django.core.context_processors.request') IndexError: list index out of range -
White spaces are not showing when fetched from MYSQL database using Django
I am creating a website for my blog using Django and MYSQL database. I have a page to add blog content. But when I split the content into paragraphs it stores them all in one line. What can I do to display the content split into paragraphs as typed. Thanks! :) -
How to declare settings in an app that later can be generally overriden?
I am coding a reusable django-app and I'd like to set some settings, say in a settings.py file inside the app folder, which later can be overriden by other developer on their settings.py file. Is there a particular way, python-zen-way to achieve this rather than the described above? For instance in my settings.py the pagiation elements would be... default_pagination_elements = 9 But I'd like the user of the app to be able to override that in their settings.py... Which is the best way to achieve this? Many thanks -
Django inner join on
First of all, I want to say that i've checked all the similar questions and none of them were the answer to my question. I have Friend and User models. Friend Model class Friend(models.Model): id = models.BigAutoField(primary_key=True) user = models.ForeignKey(User, on_delete=models.CASCADE, unique=False, related_name='%(class)s_requests_created') following = models.ForeignKey(User, on_delete=models.CASCADE, unique=False, null=True, blank=True) accepted = models.BooleanField(default=False) deleted_at = models.DateTimeField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) User Model class User(AbstractBaseUser): id = models.BigAutoField(primary_key=True) username = models.CharField(max_length=30, unique=True) email = models.EmailField(max_length=191, unique=True) first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30, blank=True) is_active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) Lets think of 3 users. User A, B, C. B is following A and C is following B. What i want to achieve is Get user A based on user B that is following user A. Pretty simple query but a little bit complicated with Django QuerySet. This is my query SELECT U2.username FROM `accounts_friend` INNER JOIN `accounts_user` U1 ON accounts_friend.following_id = U1.id AND U1.is_active = 1 INNER JOIN `accounts_friend` F1 ON accounts_friend.following_id = F1.user_id AND F1.accepted = 1 AND F1.deleted_at IS NULL AND F1.user_id != F1.following_id INNER JOIN `accounts_user` U2 ON F1.following_id = U2.id AND U2.is_active = 1 WHERE accounts_friend.accepted = 1 AND accounts_friend.deleted_at IS NULL AND accounts_friend.user_id != accounts_friend.following_id Here's … -
Not able to see form in Django-rest CreateAPIView
I am trying to view the CreateAPIView. I am referring to the following tutorial. So as you can see in the image below I am able to get a similar page as is expected, but I cant see the form where we enter data. Now, I think it might be because I am not logged in. But I have been trying to login to the django-rest framework, it doesnt work even thought in the django-admin I am logged in. The image of the terminal shows the response I get when I try logging in to django-rest. image of api/booking/create webpage i.e. CreateAPIView image of the terminal response This is my views.py from django.shortcuts import render # Create your views here. from pool.models import Booking, Register from pool.serializers import BookingSerializer, RegisterSerializer from rest_framework import viewsets from rest_framework.generics import ListCreateAPIView, RetrieveAPIView, CreateAPIView class BookingListView(ListCreateAPIView): queryset = Booking.objects.all() serializer_class = BookingSerializer class BookingDetailView(RetrieveAPIView): queryset = Booking.objects.all() serializer_class = BookingSerializer class BookingCreateView(CreateAPIView): queryset = Booking.objects.all() serializer_class = BookingSerializer class RegisterListView(ListCreateAPIView): queryset = Register.objects.all() serializer_class = RegisterSerializer class RegisterDetailView(RetrieveAPIView): queryset = Register.objects.all() serializer_class = RegisterSerializer class RegisterCreateView(CreateAPIView): queryset = Register.objects.all() serializer_class = RegisterSerializer This is my serializers.py from rest_framework import serializers from pool.models import Booking, … -
Display Django model data to table in HTML
I have two Django models that record time. Model one records time during the morning and Model two records time during the evening. I want to present both of these times along with the difference between the times within an HTML table but am confused about how to do it. I am new to Django and would really appreciate some advice. This is what I have so far: models.py: class Morning(models.Model): id= models.ForeignKey(User, on_delete = models.CASCADE) mtime = models.DateTimeField() class Evening(models.Model): id= models.ForeignKey(User, on_delete = models.CASCADE) etime = models.DateTimeField() views.py: def panel(request): time_data = User.objects.filter(pk__gt=1) #I need all data except for the default Super User account morning_time = Morning.objects.all() evening_time = Evening.objects.all() return render(request, 'users/interface.html', {'data': time_data, "morning_time": morning_time, "evening_time": evening_time}) panel.html: <form> {% csrf_token %} <table> <tr> <th>Name</th> <th>Morning timeE</th> <th>Evening time</th> <th>Difference in hours</th> </tr> {% for data in data %} <tr> <td>{{data.username}}</td> {% endfor %} {% if morning_time %} {% for m in morning_time %} <td>{{m.mtime}}</td> {% endfor %} {% else %} <td> Not available </td> {% endif %} {% if evening_time %} {% for e in evening_time %} <td>{{e.etime}}</td> {% endfor %} {% else %} <td> Not available </td> {% endif %} </tr> </table> </form> How … -
Django filter form not rendering
I'm using a FilterSet to perform a filtering over a set of product. Here is my code : models.py class Plat(models.Model): titre = models.CharField(max_length = 100) description = models.TextField(null = True) allergenes = models.TextField(null = True) prix = models.IntegerField(verbose_name = "Prix par portion") chef = models.ForeignKey('inscription.Chef', on_delete = models.CASCADE) date_prep = models.DateField(default=timezone.now, verbose_name="Date de préparation") nb_portions = models.IntegerField(verbose_name = "Nombre de portions disponibles") photo = models.ImageField(upload_to = "photos_plat/") filters.py class PlatFilter(django_filters.FilterSet): class Meta: model = Plat fields = { 'titre': ['icontains'], 'prix': ['lte', 'gte'], 'nb_portions': ['gte'], 'date_prep': ['exact'], } views.py def home(request): plats = Plat.objects.all() filter = PlatFilter(request.GET, queryset=plats) return render(request, 'actualites/home.html', locals()) home.html <form method="get"> {{ filter.form.as_p }} <button type="submit">Search</button> </form> Everything is working perfectly but I want to make the form prettier and being able to customize the label names and so on so I use this code (I found it in a tutorial) : {% load widget_tweaks %} <form method="get"> <div class="well"> <h4 style="margin-top: 0">Filtrer par</h4> <div class="row"> <div class="form-group col-sm-4 col-md-3"> {{ filter.form.titre.label_tag }} {% render_field filter.form.titre class="form-control" %} </div> </div> <button type="submit" class="btn btn-primary"> <span class="glyphicon glyphicon-search"></span> Search </button> </div> </form> And here nothing is displayed except the "Filtrer par" and the submit button. I've … -
Optmized way to use pymongo client in django
I am using pymongo as my DB for application data , and I kept my mongoclient in project init.py. And i am calling mongo client in my own wrapper . But I can see spike increase in no of mongoconnection at mongodb dashboard. Which is the best place to keep mongoclient and share with all aound my project. -
path is not reading unless it is in order
i added 2 primery keys to 2 paths A and B in one html page and added paths to url, each i gave {% url 'name' pk.id %} to move to defrent pages but when i click the url B it shows page not found so i put the path B to first then it works but the the Path A is not working path('<int:prgm_id>/', views.program, name='program'), path('<int:services_id>/', views.details, name='details') ]`` <a href="{% url 'program' prgm.id %}"> <div id="prgm" style="width:50%"> <a href="{% url 'details' services.id %}"> <div class="box wow "> <div class="col-xs-2" id= -
How to filter django x chart.js charts? Uncaught TypeError
Hello im attempting to filter chart.js charts. The way im inputting the data from my database is via the django rest framework API. Here is what i have done: <script type="text/javascript"> endpoint = 'api/chart/data' $.ajax({ type: "GET", url: endpoint, success: function(data){ sales_time = data.sales_time_axis sales_rev = data.sales_rev conversion_label = data.conversion_label conversion_data= data.conversion_data profit_data_per_project= data.profit_data_per_project var ctx = document.getElementById('myChart').getContext('2d'); var myChart = new Chart(ctx, { type: 'bar', data: { labels:sales_time, datasets: [{ label: sales_time, data: profit_data_per_project, backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] } } }); }, error: function(error_data){ console.log('error') console.log(error_data) } }) This is my template: <div class="card-body" id="card_body"> <select class="text_select" id="chart-select" onchange="applyFilter(value, myChart)" name="select"> <option value="All">All Time</option> <option value="3">Last 3 Months</option> <option value="6">Last 6 Months</option> <option value="12">Last Year</option> <option value="24">Last 2 Years</option> </select> <canvas id="myChart"></canvas> </div> this is the javascript call that im using to test … -
Creating an ordered list in Django with models
I want to create a way for users to add and change the order of a list. I have the list as a model, with rank as one of the fields, and title and info as the other 2 fields. Users have the ability to add items to the list. The page will then display the list ordered by rank. However, I have no idea how I'd add functionality for the user to re-order the list. I want the user to be able to click an item in the list and then move it up or down, and additionally be able to just type in a number they want to move the item to. I can handle the aspect of how to adjust the rank numbers, but I don't know the best way to actually access the information and update it.