Help!... urgent help on simple file upload with payment or is_free

:open_mouth: Am building a music score sheet store but at first it was free but now my client demands that some should be made free while some scores with the original composers should be able to sell their composition at the site i have tried this at my model…

how do i implement this idea in my app…
here is my code and what i have done so far…

# My model

from django.db import models
from django.core.validators import FileExtensionValidator


def upload_dir(self, filename):
    return "{}/{}/{}".format(self.uploaded_by, filename)

class Category(models.Model):
    name = models.CharField(max_length=100)

    class Meta:
        verbose_name_plural = "Categories"

    def __str__(self):
        return self.name
    
    def get_absolute_url(self):
        return reverse("articles_by_category", args=[self.name])


class MusicScore(models.Model):
    title = models.CharField(max_length=100)
    description = models.CharField(max_length=255, blank=True)
    slug = models.SlugField(max_length=255)
    document = models.FileField(upload_to=upload_dir, validators=[FileExtensionValidator(['pdf'])])
    cover_picture = models.ImageField(upload_to=upload_dir, height_field=50, width_field=30, blank=True, null=True)
    composer = models.CharField(max_length=100)
    price = models.CharField(default='500.00', blank=True, max_length=100)
    free = models.BooleanField(default=True)
    category = models.ForeignKey(Category, on_delete=None)
    # uploaded_by = models.ForeignKey()
    uploaded_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        ordering = ("composer",)
        unique_together = ["composer", "title"]
        verbose_name = 'MusicScore'
        verbose_name_plural = 'MusicScores'

    def __str__(self):
        return self.title
    
    @property
    def image_url(self):
        if self.cover_picture:
            return self.image_url
        else:
            return "default cloudinary image url here"

    def get_absolute_url(self):
        return reverse("musicscores:detail", kwargs={"slug": self.slug})

# My View

from django.shortcuts import render
from django.views.generic import ListView, CreateView, DeleteView
from django.urls import reverse_lazy
from .models import MusicScore
from .forms import MusicScoreForm

# Create your views here.

class MusicScoreListView(ListView):
    model = MusicScore
    template_name = 'scores/scores.html'
    context_object_name = 'musicscores'


class UploadMusicScoreView(CreateView):
    model = MusicScore
    form_class = MusicScoreForm
    success_url = reverse_lazy('musicscores:music_score_list')
    template_name = 'upload_score.html'

    def get_initial(self):
        uploader = super().get_initial()
        uploader[uploaded_by] = self.request.user.pk
        return uploader


class MusicScoreDeleteView(DeleteView):
    model = MusicScore
    success_url = reverse_lazy('musicscores:music_score_list')

    def get_queryset(self):
        if not self.request.user.is_super:
            return self.model.objects.filter(uploaded_by=self.request.user)
        return self.model.objects.all()


#  Forms.py


from django import forms
from .models import MusicScore


class MusicScoreForm(forms.ModelForm):
    class Meta:
        model = MusicScore
        fields = ("title", "description", "document", "cover_picture", "composer", "price")`

#  Urls.py


from django.urls import include, path
from . import views

app_name = "scores"

urlpatterns = [
    path('scores', views.MusicScoreListView.as_view(), name="music_score_list"),
    path('upload', views.UploadMusicScoreView.as_view(), name="upload_music_score"),
    path('delete/<slug:title>/', views.MusicScoreDeleteView.as_view(), name='delete_music_score'),
]