Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
field level permission in django
In django, I can use django-guardian for object level permission for user and groups. But what if I want to set field level permission? Lets say I have a model as below: class Attribute(models.Model): name = models.CharField() reg = models.CharField() location = models.CharField() and I have three users in my system and these are user1, user2, and user3 Now I want user1 will get a permission for all three fields of model Attribute. But user2 will get permission to only name and geg and user3 will get permission for only the name field. In my system there are a lot of users and groups. Is there any way like django-guardian to set field level permissions in django. -
Django/React Dev Servers Choices
I'm new to React. I'm building a project that uses Django to make a REST API and React to access the api. I have my backend running on http://localhost:8000/ & my frontend running on http://localhost:3000/. My frontend makes api requests to http://localhost:8000/api/v1/. I found this tutorial to get my frontend running on the index of http://localhost:8000/ for dev purposes. I would still have to have my React dev server and my Django dev server, but I also had to run 'npm run eject'. Is there any advantage to either of these setups? I don't know too much about 'npm run eject' but since I can't go back from it, is it better off to wait on ejecting until I'm closer to deployment? -
How to get paginated answer's response?
I am using django as backend for website There will be 10 qwestions i want to paginate them (one qwestion's ans is given then go to next so on ) and atlast give marks calculated based on all the answers given Any hints on how to do it? -
Create orders in Shopify API
I'm trying to create an order using the Shopify Storefront REST API. From the docs it looks like this should work, but no joy: I'm trying to make a Django Python app to process orders. I am using the requests library to post requests to the API. I have the following code: def create(request): url = 'https://my_shop.myshopify.com/admin/inventory_items.json' order = { "order": { "line_items": [ { "variant_id": my_var_id, "quantity": 1 } ] } } data = (requests.post(url, json=order)) print(data) return render(request, 'Stock/create.html', { 'create': data }) -
Remove MEDIA_URL prefix from serialized model
i have a django-restframwork project where i have set MEDIA_URL in settings.py file. the problen is when serialize a model i get the file name with media prefixed. Here the response i am getting { "employees": [ { "id": 1, "name": "neki", "doc": "/media/simple-nature-wallpapers-free-download-for-desktop-45.jpg" } ] } But i want the response without media prefixed like this { "employees": [ { "id": 1, "name": "neki", "doc": "simple-nature-wallpapers-free-download-for-desktop-45.jpg" } ] } I have two solutions. Both of them have some problems I can remove MEDIA_URL from setting.py file (Problem is i cant access the file from storage) Or i can save the file name as models.CharField(). (Problem is i cant save file from ModelSerializer automatically) So my Question is how to solve these problem. -
How to make a get model request through another model?
I've been writing unit tests for a Django app and ran into. With this problem, many test classes are associated with, say, a single App class. How to take a single class model through this App. app = App.objects.create(name='App1', title='App Test Title', app_type='F', abstract='This is a test App', description='**This is bold text test**', active=True, stars=4, votes=45, downloads=200, has_releases=True) class DevelopmentTestCase(TestCase): def setUp(self): Development.objects.create(app=app, notes='**This is bold text test**') def test_development_created(self): development = Development.objects.get(app=app) self.assertTrue(isinstance(development, Development)) self.assertEqual(development.notes, 'Some test notes') -
How can i fix the following: 'ValueError: Cannot assign "2": "Actie.actie_gebruiker_id" must be a "Gebruiker" instance.'?
Here are the imports: from django.db import models from datetime import datetime, timedelta This is the first class i did define. It is the status of the action (Actie) and it has a status-id and a status-name with a max_length attribute of 5 (todo, doing, done) class Status(models.Model): id = models.IntegerField(primary_key=True) status_naam = models.CharField(max_length=5, default='todo') def __str__(self): return str(self.id) + " - " + self.status_naam This class Gebruiker (what means user) just has an id and a username class Gebruiker(models.Model): id = models.IntegerField(primary_key=True) gebruiker_naam = models.CharField(max_length=5, default='Naamloze gebruiker') def __str__(self): return str(self.id) + " - " + self.gebruiker_naam This is the class Actie (Action or the action the user determines) wich has an id, an action-name, a action-status wich refers to the table Status here above, an action-publish-date, an ending-date (the deadline) and a user-id wich refers to the table Gebruikers. class Actie(models.Model): id = models.IntegerField(primary_key=True) actie_naam = models.CharField(max_length=150, default='-') actie_status_id = models.ForeignKey(Status, default=1) actie_aanmaakdatum = models.DateTimeField(default=datetime.now()) actie_einddatum = models.DateTimeField(default=datetime.now() + timedelta(days=1)) actie_gebruiker_id = models.ForeignKey(Gebruiker, default=1) def __str__(self): return str(self.id) + " - " + self.actie_naam When i code the following in the Python-shell after importing the class: a = Actie(actie_naam='Bake a cake', actie_gebruiker_id=2) I get the following error: ValueError: … -
Docker compose could not open directory permisson denied
I am totally a newbie when it comes to Docker. And I am trying to understand it with a dummy project. I have a django project and my Dockerfile is inside the Django project's root folder. And my docker-compose.yml file is under the top root folder which contains django project folder and other config files. my docker-compose.yml version: '3' services: db: image: postgres container_name: dummy_project_postgres volumes: - ./data/db:/var/lib/postgresql/data event_planner: build: ./dumy_project container_name: dummy_project volumes: - .:/web ports: - "8000:8000" depends_on: - db links: - db:postgres and my Dockerfile FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /web WORKDIR /web ADD requirements.txt /web/ RUN pip install -r requirements.txt ADD . /web/ I am trying to run the following commands # stop and remove the existing containers docker-compose stop docker-compose rm -f # up and run the container docker-compose build docker-compose up -d docker-compose exec account_administration bash When I do docker-compose up -d, I see this error. docker-compose up -d dummy_project_postgres is up-to-date Starting dummy_project ... done warning: could not open directory 'data/db/': Permission denied I know this question asked before, but I didn't quite get the solution I need and I am stuck for hours now. EDIT: I have all the permissions … -
django channels Connection Errors only when tried with User_login
Running channels with daphne. django version: 2.0.4 asgiref==2.2.0 asgi-redis==1.4.3 channels==2.1.5 channels-redis==2.3.1 I'm trying to connect websoket. When I tried to connect with Anonymous user(without user login), it works well. But, when there is user, it doesn't work well. The one point that I get by using pdb.set_trace() is that there is self.scope['cookies']['sessionid'] when I tried with user login. But there is no result in self.scope['cookies']['sessionid'] when there is no user(Anonymous user) I thought that it might be related to AuthMiddlewareStack and I looked into the source code. But, I cannot find the source of the problem. Can you help me? Below are my codes. settings.py ASGI_APPLICATION = 'businessproject.routing.application' CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { "hosts": [('127.0.0.1', 6379)], }, }, } models.py class MyUser(AbstractUser): galaxy_num=models.IntegerField(default=1) onoff=models.IntegerField(default=1, null=True) def __str__(self): return self.username consumers.py from channels.generic.websocket import WebsocketConsumer, AsyncWebsocketConsumer import json, pdb from asgiref.sync import async_to_sync class TestConsumer(AsyncWebsocketConsumer): async def connect(self): # Join room group self.group_name="likes" await self.channel_layer.group_add( self.group_name, self.channel_name ) await self.accept() async def disconnect(self, close_code): await self.channel_layer.group_discard( self.group_name, self.channel_name ) async def receive(self, text_data): text_data_json = json.loads(text_data) message = text_data_json['message'] await self.channel_layer.group_send( self.group_name, { 'type': 'like_message', 'message': message } ) # Receive message from room group async def … -
How would I use a MultiSelectField with a Foreign key so a user can select a multiple items instead of one
I would love to use a MultiSelectField on the admin panel so for one of my classes 'Race' I can pick multiple 'Racers' instead of just one. This is my Race model, and the foreign key grabs the racers, but I can only select one. class Race(models.Model): race_name = models.CharField(max_length=50, help_text='50 Characters max', default='') country = models.CharField(max_length=32, help_text='32 Characters max', default='') team = models.ForeignKey('Team', on_delete=models.CASCADE, null=True) miles = models.FloatField(default='') image = models.ImageField(upload_to='images', default='') race_date = models.DateTimeField('Race Day') Just in case you need it here is the racer class class Racer(models.Model): first_name = models.CharField(max_length=24, help_text='24 Characters max', default='') last_name = models.CharField(max_length=24, help_text='24 Characters max', default='') age = models.PositiveIntegerField(default='') avatar = models.ImageField(upload_to='images', default='') team = models.ForeignKey('Team', on_delete=models.CASCADE, null=True) Hopefully my question makes sense... Thanks everyone :) -
Django imporlery loading while restarting it
I have a website that is in VPS hosting. I was supposed to restart it with the following code source .venv/bin/activate uwsgi --ini agros.ini But I am receiving the following error django.db.utils.OperationalError: (2006, 'MySQL server has gone away') here is the database configuration in the settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'CONN_MAX_AGE': 3600, 'NAME': 'agros_new', 'USER': 'root', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': 3309, } } this website uses Django version = 1.9 and the operating system is the Centos OS -
Django Admin Search via Tag
How do I search in django admin-panel using tag? It will search using tag which known as django-taggit package. -
Problem with django and sorl.thumbnail model field
What i want: when user download photo in the admin's panel, I want create preview(thumbnail) and save it into other field of this model, using sorl.thumbnail. What i do: from sorl.thumbnail import ImageField, get_thumbnail class sitePhotos(models.Model): photo = ImageField(verbose_name=u'Фотография для галереи', upload_to=upload_galery_photos, null=True) preview = ImageField(upload_to=upload_galery_previews, editable=False, null=True) Migrations are doing. I was trying overrite save method from class sitePhotos: def save(self, *args, **kwargs): self.preview = get_thumbnail(self.photo, '250x250', crop='center', quality=99) super(sitePhotos, self).save(*args, **kwargs) Problems: Documentation sorl.thumbnail: https://sorl-thumbnail.readthedocs.io/en/latest/examples.html#low-level-api-examples im = get_thumbnail(my_file, '100x100', crop='center', quality=99) What's type of my_file? It is a url, ImageField or what? When start has error 'ImageField' object has no attribute '_committed' Google: override save method - 'ImageFile' object has no attribute '_committed' After that i have magic with urls and other. My finish function: self.preview = get_thumbnail('../'+self.photo.url, '250x250', crop='center', quality=99).url May be somebody has working example of this or where can I read about this? Thank you for your answers! -
View all data in limit offset pagination
I am using limit offset pagination in an API which is being used in two scenarios. Where the pagination is needed. So as to show limited data in each page. The API is being used in another place where I have to show all the datas. Is there any way in Django limit offset pagination to view all the datas? -
django serializers tries to reference variable before assigning inside try-except block
This is my view for getting 3 objects and returning to template using ajax def getText(request): l=request.POST.get('lid','') n=request.POST.get('cid','') o=request.POST.get('pid','') # print(l) try: lb=books.objects.get(id=l) con=contacts.objects.get(id=n) mo=movies.objects.get(id=o) except books.DoesNotExist: lb=None except contacts.DoesNotExist: con=None except movies.DoesNotExist: mo=None serialized_obj = serializers.serialize('json', [ lb,con,mo ]) return HttpResponse(serialized_obj,content_type='application/json') I am getting the following error UnboundLocalError: local variable 'mo' referenced before assignment -
Getting NoReverseMatch at /blog/ at the book django by example
The ERROR : django.urls.exceptions.NoReverseMatch: Reverse for 'post_detail' with arguments '(2018, 11, 6, 'another post')' not found. 1 pattern(s) tried: ['blog\/(?P[0-9]+)\/(?P[0-9]+)\/(?P[0-9]+)\/(?P[-a-zA-Z0-9_]+)\/$'] Here is my templates/blog/base.html file: {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{% block title %}{% endblock %}</title> <link href="{% static "css/blog.css" %}" rel="stylesheet"> </head> <body> <div id="content"> {% block content %} {% endblock %} </div> <div id="sidebar"> <h2>My blog</h2> <p>This is my blog</p> </div> </body> </html> Here is my templates/blog/post/list.html file: {% extends "blog/base.html" %} {% block title %}My Blog{% endblock %} {% block content %} <h1>My Blog</h1> {% for post in posts%} <h2> <a href="{{ post.get_absolute_url }}"> {{ post.title }} </a> </h2> <p class="date"> Published {{ post.publish }} by {{ post.author }} </p> {{ post.body|truncatewords:30|linebreaks }} {% endfor %} {% endblock %} And the blog/urls file: from django.urls import path from . import views app_name = 'blog' urlpatterns = [ #post views path('',views.post_list,name='post_list'), path('<int:year>/<int:month>/<int:day>/<slug:post>/', views.post_detail, name='post_detail'), ] The blog/views file: from django.shortcuts import render,get_object_or_404 from .models import Post def post_list(request): posts = Post.published.all() return render(request,'blog/post/list.html',{'posts':posts}) def post_detail(request,year,month,day,post): post = get_object_or_404(Post,slug=post, status='published', published__year=year, published__month=month, published__day = day) return render(request,'blog/post/detail.html',{'post':post}) Please help me solve the problem, i would be very happy because i been stuck in … -
Am I able to keep db between test cases?
I have ordered tests in one of my projects. First test is inserting a row into a table. I need to get that row in the second test. Here is what I found in pytest-django documentation. However pytest-django also caters for transaction test cases and allows you to keep the test databases configured across different test runs. import pytest from django.apps import apps from api.factories import UserFactory @pytest.mark.django_db @pytest.mark.dependency(name='001') def test_demo_first(): UserFactory() assert True @pytest.mark.django_db @pytest.mark.dependency(name='002', depends=['001']) def test_demo_second(): assert apps.get_model('api', 'User').objects.all().count() == 1 Any ideas how can I do that ? -
WebSocket failed: Error during WebSocket handshake
I am trying to create a web socket for a django application using django-channels. I have changed django to use a ASGI server interface instead of the default WSGI and I have defined the following channel layers: settings.py CHANNEL_LAYERS = { 'default': { 'BACKEND': 'asgi_redis.RedisChannelLayer', 'CONFIG': { 'hosts': [('localhost', 6379)], }, 'ROUTING': 'rest.routing.application', } } ASGI_APPLICATION = 'rest.routing.application' asgi.py import os import django from channels.routing import get_default_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest.settings") django.setup() application = get_default_application() routing.py application = ProtocolTypeRouter({ "websocket": URLRouter([ url(r"^receive/$", websocket_receive), url(r"^connect/$", websocket_connect), ]) }) consumers.py def websocket_connect(self, event): self.send({ "type": "websocket.accept", }) The problem is that when I try to test it socket = new WebSocket("ws://" + window.location.host + "/connect/"); socket.onopen = function() { socket.send("hello world"); } I keep getting WebSocket connection to 'ws://localhost:8000/connect/' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET [Failure instance: Traceback: <class 'AttributeError'>: 'dict' object has no attribute 'send' C:\Python37\lib\site-packages\autobahn\websocket\protocol.py:2800:processHandshake C:\Python37\lib\site-packages\txaio\tx.py:429:as_future C:\Python37\lib\site-packages\twisted\internet\defer.py:151:maybeDeferred C:\Python37\lib\site-packages\daphne\ws_protocol.py:77:onConnect --- <exception caught here> --- C:\Python37\lib\site-packages\twisted\internet\defer.py:151:maybeDeferred C:\Python37\lib\site-packages\daphne\server.py:186:create_application C:\Python37\lib\site-packages\channels\staticfiles.py:41:__call__ C:\Python37\lib\site-packages\channels\routing.py:58:__call__ C:\Python37\lib\site-packages\channels\routing.py:144:__call__ C:.......\consumers.py:28:websocket_connect Any idea what might be going wrong here? -
Django file structure w/ venv
I'm fairly new to Django and a bit confused about venvs and the file structure. I'm using VSCode to create all of this. projectname?/ .vs/ .... .vsode/ .... myproject/ #1 myprojectapps?/ manage.py myvenv/ #2 myproject/ Include/ Lib/ Scripts/ myprojectapps?/ manage.py I create a top folder and point VSCode to it. I then create a new venv in this folder (#2). Where exactly do I then create a new project? Inside my venv or inside my "root" folder? If I create it in the root folder, will that use my OS Python installation instead of the venv, or is VSCode smart enough to use the venv that I created, if I select it from the dropdown? Do I create new "apps" in the 'myproject' folders, or in the 'myprojectapps?' folders? -
Confusing Django Models for sql lookups to preset a form with queries
So here's the relevant parts of models.py class Word_Source(models.Model): the_word_itself = models.CharField(max_length=200, default='') class SpaceSource(models.Model): the_space_itself = models.ForeignKey(Word_Source, on_delete=models.CASCADE, default=None) class Votes(models.Model): the_vote_style = models.ManyToManyField(SpaceSource, default=None, related_name='votestyle') class Anon(models.Model): username = models.OneToOneField(User, on_delete=models.CASCADE) excluded_votestyles = models.ManyToManyField(Votes, default=None, related_name='excluded_votestyles') And here's the forms.py class True_TranslationForm(forms.ModelForm): class Meta: model = True_Translation fields = ('the_translation_before', 'the_translation_after') def clean(self): cleaned_data = super(True_TranslationForm, self).clean() body = cleaned_data.get('the_translation_before') body2 = cleaned_data.get('the_translation_after') if not body or body2: raise forms.ValidationError('You need a both translations') def __init__(self, request, *args, **kwargs): super(True_TranslationForm, self).__init__(*args, **kwargs) if Author.objects.get(username=request.user.username): if Anon.objects.get(username__username=request.user.username): if Anon.objects.get(username__username=request.user.username).excluded_votestyles: self.fields['the_translation_before'] = forms.MultipleChoiceField(choices=[(e, e) for e in Word_Source.objects.filter(spacesource__votes__anon=Anon.objects.get(username__username=request.user.username).excluded_votestyles.all()).order_by('the_word_itself').values_list('the_word_itself', flat=True)]) self.fields['the_translation_after'] = forms.MultipleChoiceField(choices=[(e, e) for e in Word.objects.filter(author=Author.objects.get(username=request.user.username)).order_by('the_word_itself').values_list('the_word_itself', flat=True)]) else: self.fields['the_translation_before'] = None self.fields['the_translation_after'] = None else: self.fields['the_translation_before'] = None self.fields['the_translation_after'] = None else: self.fields['the_translation_before'] = None self.fields['the_translation_after'] = None I've tried so many cominations of .filter vs .get, .all() and working forwards and backwards, maybe I'm just spent for today, but what I'm after is for multiple choices to be selected from in the 'translation_before' that are found in the Anon's 'excluded votestyles', ordered alphabetically and showing up as what's contained in the charfield. I have no problem going down from anon.excluded_votestyles etc. normally, but working backwards through the models … -
access model field in serializer
key and data are dictionary how I can access data of specific key in serializer class Setting(models.Model): key = models.CharField(max_length=255, primary_key=True) data = JSONField(null=True, blank=True) -
Changing Django/Postgres db_table name
I followed the instruction here: Change table name in Django to move my django models to a different app. It worked, but now my models are referencing the old table name in class Meta: db_table = 'api_currency' What is the appropriate way to migrate the name of this table back to the default, countries_currency, as it is in the countries_currency app? -
Django and AJAX Form Submissions handling form inputs
i try to create one DJANGO demo app to learn more about Django and AJAX Form Submissions and i try to follow this example. in this task i want to handling inputs from html page using AJAX to server and django views.py to calculate some new numbers from inputs. but i cant to take data from html form in views.py propably maybe i have some wrong in functionality DJANGO with AJAX/HTML anyway in pycharm editor i take correct message get [06/Nov/2018 09:24:43] "GET /ajax/validate_username/?csrfmiddlewaretoken=QM6R0uHPbzPCPCjm3Bm4NPF3G2RHGNO7u69KaLiTLfKLdb1MN2VcRVMqwu75hd1C&CC=2&PP=3&FF=&type10=annual HTTP/1.1" 500 21897 but i cant take in views.py to calculate the numbers print data is none.Any idea how to handle data from AJAX in views.py ? here the code : urls.py : url(r'^details/(?P<slug>[^\.]+)/$', views.main_page, name='main_page'), url(r'^ajax/validate_username/$', views.validate_username, name='validate_username'), views.py def main_page(request): apps = MyModel.objects.all() return render(request, 'index.html',{'apps':apps}) def validate_username(request): data = request.GET.get('data', None) print data return JsonResponse(data) html form : <form id="form" action='' data-validate-username-url="{% url 'validate_username' %}" method="POST" enctype="multipart/form-data">{% csrf_token %} <div class="form-group col-md-6"> Select the C Raster Dataset:<br> <select name="CC" class="form-control" id="CC"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> <br> <br> Select the P:<br> <select name="PP" class="form-control" id="PP"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> <br> <br> Select the F:<br> <select name="FF" class="form-control" id="FF"> … -
IntegrityError at /likes/9/ FOREIGN KEY constraint failed
I wanted to create "Like button" features, however, it only works while 0 < post_id < 7, and if post_id increases over 8, Django pops error like this: IntegrityError at /likes/8/ FOREIGN KEY constraint failed During handling of the above exception (Like matching query does not exist.), another exception occurred: File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py" in _commit 239. return self.connection.commit() The above exception (FOREIGN KEY constraint failed) was the direct cause of the following exception: File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 126. response = self.process_exception_by_middleware(e, request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 124. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/mingselene/Documents/GitHub/network/feedback/views.py" in likes 42. new_like, created = Like.objects.get_or_create(user=request.user, post_id=post_id) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method 82. return getattr(self.get_queryset(), name)(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/query.py" in get_or_create 488. return self._create_object_from_params(lookup, params) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/query.py" in _create_object_from_params 530. raise e File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/query.py" in _create_object_from_params 522. obj = self.create(**params) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/transaction.py" in exit 212. connection.commit() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py" in commit 261. self._commit() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py" in _commit 239. return self.connection.commit() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/utils.py" in exit 89. raise dj_exc_value.with_traceback(traceback) from exc_value File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py" in _commit 239. return self.connection.commit() Exception Type: IntegrityError at /likes/8/ Exception Value: FOREIGN KEY constraint failed I cannot understand why it occurs, and stackoverflow posts were not effective. views.py: … -
Approach to unlock content in Django after a successful payment
I have something like ‚Requests to Offers‘ model in my homepage. A user can create a request, and other users can offer content to this specific request. After the requesting user has accepted a offer and the payment was done, the content should be unlocked / downloadable. I thought about creating a transaction model with ‚Requests, Offers, State‘ After the payment was done, the State should change to „Active“ which results in an active „Download“ Button. Is this an approach you would recommend (fairly new to Django) or are there other ways to implement it?