Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django issue with url receive from API
http://127.0.0.0:8000/test-pay-redirect?token=60257a578aedc20bd1a6892c&mode=popup&tap_id=chg_TS014820212148r1N41102850 this is redirect link from api i would like to render my urls.py re_path(r"^test-pay-redirect/",views.paytestredirect,name='test_pay_redirect'), path("test-pay-redirect/",views.paytestredirect,name='test_pay_redirect'), i try both but it couldnt connect with this urls -
Error on retrieving json data through django templates in javascript gives Uncaught SyntaxError: missing ) after argument list
I am rendering the json response data through apiview in django restframework, to html template list.html where i want to retrieve this data in a javascript code. However everytime it gives "missing ) after argument list error" even though they are not actually present in the data received (as seen in inspect tools of chrome) Getting the error on var list =JSON.parse("{{data|safe}}") The code apiview from views.py which is rendering the data is : @api_view(['GET','POST']) def memeList(request): if request.method=='GET': meme = Meme.objects.all().order_by('-meme_id')[:100] serializer = MemeSerializer(meme, many=True) elif request.method=='POST': serializer=MemeSerializer(data=request.data) if serializer.is_valid(): serializer.save() serJS = JsonResponse(serializer.data,safe=False) return render(request,'list.html',{'data':serJS.content}) Any solution for this as i have tried all available solutions on the internet still the problem isn't resolved. -
Custom Register Form with Django Rest Auth - Error: save() takes 1 positional argument but 2 were given
I want to create a custom Signup form with Django Rest Auth and Django Allauth but I'm getting an error save() takes 1 positional argument but 2 were given I know that this error is related to the function def save(self, request) provided by Django Rest Auth, but I have no clue how I can change it. What should I do to make it work? Bellow is the respective code for my user Model and Serializer: # Models.py class UserManager(BaseUserManager): def create_user(self, email, password=None, **extra_fields): """Creates and saves a new user""" if not email: raise ValueError('Users must have an email address') user = self.model(email=self.normalize_email(email), **extra_fields) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, password, **extra_fields): """Creates and saves a new super user""" user = self.create_user(email, password, **extra_fields) user.is_staff = True user.is_superuser = True user.save(using=self._db) return user class User(AbstractBaseUser, PermissionsMixin): """Custom user model that supports using email instead of username""" email = models.EmailField(max_length=255, unique=True) name = models.CharField(max_length=255) age = models.PositiveIntegerField(null=True, blank=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['name', 'age'] def __str__(self): return self.email # serializers.py class UserSerializer(serializers.ModelSerializer): """Serializer for the users object""" class Meta: model = get_user_model() fields = ('email', 'password', 'name', 'age') extra_kwargs … -
How to change UserCreationForm error messages in django
I'm trying to change error messages in UserCreationForm. I want to change password field error messages but i don't know how. I tried this: class CreateUserForm(UserCreationForm): error_messages = { 'password_mismatch': "my message", } class Meta: model = User fields = ['username', 'first_name', 'password1', 'password2'] and it works, but i can't figure out how to change other messages like "password is too similar to the username", "password is too short", "password is too common" and "password is entirely numeric". I tried adding to the error_messages 'min_length' key but this doesn't work -
Rendering objects by category in Django
I created a model, in which admin categorizes posts by being new or exclusive. Now I want to view posts, that are only new. here's the code: class Post(models.Model): class Category(models.TextChoices): NEW = 'NP', ('New Post') EXCLUSIVE = 'EP', ('Exclusive Post') post_category = models.CharField( max_length=2, choices=Category.choices, default=Category.NEW, ) title = models.CharField('Title of the post',max_length=50) content = models.TextField('Page content', max_length=500) posted = models.DateTimeField('last updated') def __str__(self): return self.title def is_new(self): return self.post_category in{ self.Category.NEW, self.Category.EXCLUSIVE, } views: def index(request): post_list = Post.objects.filter(post_category).order_by('-posted')[:2] context = { 'post_list': post_list, 'page_list': Pages.objects.all(), } return render(request, 'pages/extension.html', context) -
@unittest.skip doesn't print anything in Python <= 3.7
We are using Django with unittest. Some tests are skipped with the @unittest.skip decorator. But if I run the tests with Python 3.6 or 3.7, I get a number of tests passed (Ran 993 tests / OK), and if I run the same tests with Python 3.8, I get the same number of tests but with some tests skipped (Ran 993 tests / OK (skipped=4)). I would like to know if the same tests were also skipped with Python 3.6 and 3.7, or only with Python 3.8? And why do I get the skipped output only with Python 3.8? And is the number 993 including the skipped tests or not including them? Is one of the outputs incorrect? Because it doesn't make sense that the output is different for different versions of Python and I don't understand the reason for this difference. I didn't find it documented in the documentation. Our code is open source, and you can see for example a skipped test here. -
When using django-simple-history and DRF, how can I create an extra action to access the history of an object?
I'm new to Python, Django and DRF but I've gone through all the tutorials needed to set up a basic REST server and for this example, we'll pretend that it only serves one thing: a list of customers. Additionally, I have installed django-simple-history and registered my Customer model with it. This is the code that I've written so far and everything seems to work just fine. api/urls.py from django.urls import path, include from rest_framework import routers import api.views as views router = routers.DefaultRouter(trailing_slash=False) router.register('customers', views.CustomerView) router.register('customerhistory', views.CustomerHistoryView) urlpatterns = [ path('', include(router.urls)), ] api/views.py from rest_framework import viewsets from retail.models.customers import Customer class CustomerView(viewsets.ModelViewSet): queryset = Customer.objects.all() serializer_class = CustomerSerializer filterset_fields = '__all__' search_fields = ['name'] class CustomerHistoryView(viewsets.ModelViewSet): queryset = Customer.history.all() serializer_class = CustomerHistorySerializer filterset_fields = '__all__' api/serializers.py from rest_framework import serializers from retail.models.customers import Customer class CustomerSerializer(serializers.ModelSerializer): class Meta: model = Customer fields = '__all__' class CustomerHistorySerializer(serializers.ModelSerializer): class Meta: model = Customer.history.model fields = '__all__' As it is, when I go to api/customerhistory/1, it gives me a lovely list of all the history for customer 1. Question What I'd like to do is access the same list by going to api/customer/1/history. My Attempt So Far... To do this, I'm … -
passing django views into a separate highcharts js script file
I have a template that visualizes data from a django view using Highcharts js (as shown below) and it works IF the Content Security Policy is disabled. However, I don't want the CSP disabled and after some reading I come to the conclusion that the best way is to host the highcharts script into another (external) file which then would be allowed by the CSP 'self' directive (please correct me if I wrong). <script> document.addEventListener('DOMContentLoaded', function () { const chart = Highcharts.chart('container', { chart: { backgroundColor: '#eaeaea', type: 'bar' }, title: { text: 'Rezultatet sipas lëndëve' }, xAxis: { categories: [{% for cat, value in cat_scores.items %} '{{ cat }}' {% if not forloop.last %}, {% endif %}{% endfor %}] }, yAxis: { title: { text: 'Suksesi' } }, series: [{ name: 'Saktë', data: [{% for cat, value in cat_scores.items %} {{ value.2 }} {% if not forloop.last %}, {% endif %}{% endfor %}] }, { name: 'Pasaktë', data: [{% for cat, value in cat_scores.items %} {{ value.1 }} {% if not forloop.last %}, {% endif %}{% endfor %}] }, { name: 'Perqindje', data: [{% for cat, value in cat_scores.items %} {{ value.0 }} {% if not forloop.last %}, {% … -
Ajax and django routes with search form as-you-type
Im working on a search as-you-type with ajax form on a django web app (django oscar package), the problem is that the results only show on 1 specific route, and i need that in all apps, because is in the navbar, somebody saave meee smallville song working whit this tutorial https://openfolder.sh/django-tutorial-as-you-type-search-with-ajax apps/search/apps.py from django.urls import path from django.utils.translation import gettext_lazy as _ from oscar.core.application import OscarConfig from oscar.core.loading import get_class from django.urls import re_path class SearchConfig(OscarConfig): label = 'search' name = 'oscar.apps.search' verbose_name = _('Search') namespace = 'search' def ready(self): self.search_view = get_class('search.views', 'FacetedSearchView') self.productos_view = get_class('search.views', 'productos_view') self.search_form = get_class('search.forms', 'SearchForm') def get_urls(self): from haystack.views import search_view_factory # The form class has to be passed to the __init__ method as that is how # Haystack works. It's slightly different to normal CBVs. urlpatterns = [ path('', search_view_factory( view_class=self.search_view, form_class=self.search_form, searchqueryset=self.get_sqs()), name='search'), path('productos', self.productos_view, name="productos"), ] return self.post_process_urls(urlpatterns) def get_sqs(self): """ Return the SQS required by a the Haystack search view """ from oscar.apps.search import facets return facets.base_sqs() apps/search/views.py from haystack import views from oscar.apps.search.signals import user_search from oscar.core.loading import get_class, get_model Product = get_model('catalogue', 'Product') FacetMunger = get_class('search.facets', 'FacetMunger') from django.template.loader import render_to_string from django.http import JsonResponse from django.shortcuts … -
how to display user data in django?
here am looking for the particular data of logged in user to display in their profile i don't know how to do that. this is the error i get "'User' object is not iterable" please help me . views.py def users_homepage(request): merchant=Merchant.objects.filter(request.user) models.py class Merchant(models.Model): user=models.OneToOneField(User,on_delete=models.CASCADE, primary_key=True) shop_name=models.CharField(max_length=100) phone_number=models.IntegerField(null=True) dashboard.html {%for merchan in merchant%} <h1>{{merchan.shop_name}}</h1> {%endfor%} thanks in advance -
how to check the charfield choice instance
i need to check the charfield choice instance, representing a role for permissions, however i cannot obtain that here's models.py: class User(AbstractUser): ROLE_CHOICES = ( ('ADMIN', 'admin'), ('USER', 'user'), ('MODERATOR', 'moderator'), ) role = models.CharField(choices=ROLE_CHOICES, default=ROLE_CHOICES[1], max_length=500) bio = models.CharField(max_length=500, blank=True, null=True) password = models.CharField(max_length=128, blank=True, null=True) username = models.CharField(max_length=50, blank=True, null=True, unique=True) email = models.EmailField(unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['role'] view permission func: def get_permissions(self): print(self.request.user.role) print(self.request.user.role) print(self.request.user.role) print(self.request.user.role) print('vvvvvvvvvvvvvvvvvk') if self.request.user.role == 'user': print(self.request.user.role) if self.request.user.role == 'USER': print(self.request.user.role) if self.request.user.role == ('USER', 'user'): print(self.request.user.role) if self.request.user.role in ['USER', 'user']: print(self.request.user.role) print('aaaaaaaaaaaaaa') if self.action == 'create' or self.action == 'perform_create': permission_classes = [] elif self.action == 'list' or self.action == 'retrieve': permission_classes = [permissions.IsAuthenticated] # elif self.action == 'list': # permission_classes = [IsAboveUser] elif self.action == 'destroy' or self.action == 'update' or self.action == 'partial_update': permission_classes = [permissions.IsAuthenticated] else: permission_classes = [IsAdmin] return [permission() for permission in permission_classes] out: ('USER', 'user') ('USER', 'user') ('USER', 'user') ('USER', 'user') vvvvvvvvvvvvvvvvvk so noting passes the check -
How should I handle uploaded resumes in django
I have a form where users can upload their resumes as word or pdf. Where should I store these files during production? I also thought about directly emailing the uploaded resume to my email without storing it, and it works but I dont know the cons of using such a way in production so any help would be really appreciated. Thanks -
Variable changes its value for no reason
In this function variable called "assembly_required_quantity" should change its value in line 16 (if function definition is line 1. And it changes. For example, it changed the value from 3 to 2 (-1). I have some print statements to track its value and I see that until print([8]) (including) line it doesn't change its value and still have 2 but at print([9]) value changes to 3. Can somebody explain to me why is this happening, please? def create_production_list_func(nomenclature, sets_number, step=0): product = ProductStructureProduct.objects.filter(nomenclature=nomenclature).first() assembly_required_quantity = product.quantity * sets_number available_warehouse_quantity = None if step != 0: available_warehouse_products = filter( lambda p: p.locator.warehouse.id not in [2, 3], nomenclature.warehouse_product.all(), ) available_warehouse_quantity = 0 for product_ in available_warehouse_products: available_warehouse_quantity += product_.quantity if assembly_required_quantity <= available_warehouse_quantity: return else: assembly_required_quantity -= available_warehouse_quantity print(f'[1]{product=},{assembly_required_quantity=}', flush=True) print(f'[2]{product=},{assembly_required_quantity=}', flush=True) production_list = ProductionList.objects.create( code=nomenclature.code, name=nomenclature.name, sets_number=sets_number ) print(f'[3]{product=},{assembly_required_quantity=}', flush=True) if not product: raise NotExistentProduct if not nomenclature.type == Nomenclature.Type.ASSEMBLY: raise NotAssemblyProduct print(f'[4]{product=},{assembly_required_quantity=}', flush=True) products_from_structure = product.get_children().select_related("nomenclature") print(f'[5]{product=},{assembly_required_quantity=}', flush=True) products_to_be_created = list() print(f'[6]{product=},{assembly_required_quantity=}', flush=True) if step == 0: required_quantity = product.quantity else: required_quantity = sets_number print(f'[7]{product=},{assembly_required_quantity=}', flush=True) products_to_be_created.append( ProductionListProduct( list=production_list, nomenclature=product.nomenclature, required_quantity=required_quantity, ) ) print(f'[8]{product=},{assembly_required_quantity=}', flush=True) for _product in products_from_structure: if available_warehouse_quantity: if assembly_required_quantity <= available_warehouse_quantity: return else: assembly_required_quantity -= available_warehouse_quantity … -
How to decide whether to have one or many apps in Django project
What are the design decisions one should make when choosing to have just one large app versus several smaller apps in a Django project? I read 2 Scoops of Djangowhich strongly asserts that latter- that it should always be several small apps. However, others assert the opposite, that building production-level projects at scale are a nightmare if broken up into several apps. My project currently has 2 apps: animals and store where animals stores animal related data and store stores online shop related data. I was thinking about breaking store up into a cart app, a vendor app, and product app but have been advised that I should have it all in one app and that store should also be in the animal app, as there is a few FK rel between animal and store, so that I will just have one app. This is my first project and Ive already rebuilt it once and want to make the right design decisions now so that it is optimally functional and wont be a nightmare when moving it to production. I appreciate any advice about how to make these decisions from those who have more experience building production level Django apps. … -
What's the most convenient full softare stack to incorporate video chats among about 5-10 clients at the same time?
I'm thinking of building a website where a small group of people can video chat while playing simple games together on their computers (not mobile). (If such website already exists, please let me know, because I failed to find one after lots of search). I have never programmed video chats into a website before, is there a specific software web stack that is very convenient to incorporate video chats with? Many years ago I used Django on the backend and Angular.js was very popular at that time. I just found out Angular.js is no longer going to be maintained. So if there are specific software I should or should not use, please let me know, since web development changes rapidly and I might be missing something obvious, and Google searches would yield a lot of outdated resources. I plan to host it for free on github pages. -
How to add relation in a model instantiation before save/create the instance in database?
I had a problem adding bulk with m2m, so I created a script a little different from the examples I found. Post here This seems to work, until the part of adding the instance arrives. This does not work in the examples: - Add using ModelName(related_m2m_field=related_instance) not works, django says to use something like: ModelName(id=1).related_m2m_field=related_instance. - So, try using this way, but not works, I get the error: django.db.utils.IntegrityError: FOREIGN KEY constraint failed because the instance hasn't been created yet, I THINK, so I can't add a relation to an instance that hasn't been created, the problem is that I can't just create it, since I'm using bulk_create, everything should be ready before executing the bulk. You can see the complete code in the linked post. But here is the code that raise the error: # other imports.... from olympic.models import Game, Athlete # ... some code athlete_objs = [] game_objs = [] athlete_instance = Athlete( id=pk, name=name, sex=sex, age=age, height=height, weight=weight, team=team, noc=noc, ) athlete_objs.append(athlete_instance) game_objs.append( Game( id=register_row_number, name=game_name, year=year, season=season, city=city, sport=sport, event=event, medal=medal, ).athlete.add(athlete_instance) # I can't do this before save/creation!!!? ) # bulk code out of the instance scope Athlete.objects.bulk_create(athlete_objs, ignore_conflicts=True) Game.objects.bulk_create(game_objs, ignore_conflicts=True) -
TypeError: Field 'id' expected a number but got OrderedDict
I want to post request django rest but this error.I have two Serializer.I want to post a request for full data not via id Exception Value: Field 'id' expected a number but got OrderedDict([('title', 'id:2 Смартфон Samsung Galaxy Note 20 Ultra 256GB Black'), ('price', 2019)]). class ShopSerializer(serializers.ModelSerializer): img1 = serializers.SerializerMethodField('get_image_url') img2 = serializers.SerializerMethodField('get_image_url') img3 = serializers.SerializerMethodField('get_image_url') img4 = serializers.SerializerMethodField('get_image_url') img5 = serializers.SerializerMethodField('get_image_url') img6 = serializers.SerializerMethodField('get_image_url') class Meta: model = smartphone fields = ("id", "img1", "img2", "img3", "img4", "img5", "img6","title","price","slug") def get_image_url(self, obj): return obj.image.url class OrderCreateSerializer(serializers.ModelSerializer): smartphone=ShopSerializer(many=True) class Meta: model = order fields = '__all__' def create(self, validated_data): smartphone = validated_data.pop('smartphone') question = order.objects.create(**validated_data) question.smartphone.set(smartphone) return question how to solve this problem how to solve this problem how to solve this problem how to solve this problem -
Django model object as parameter for celery task raises EncodeError - 'object of type someModelName is not JSON serializable'
Im working with a django project(im pretty new to django) and running into an issue passing a model object between my view and a celery task. I am taking input from a form which contains several ModelChoiceField fields and using the selected object in a celery task. When I queue the task(from the post method in the view) using someTask.delay(x, y, z) where x, y and z are various objects from the form ModelChoiceFields I get the error object of type <someModelName> is not JSON serializable. That said, if I create a simple test function and pass any of the same objects from the form into the function I get the expected behavior and the name of the object selected in the form is logged. def test(object): logger.debug(object.name) I have done some poking based on the above error and found django serializers which allows for a workaround by serializing the object using serializers.serialize('json', [template]), in the view before passing it to the celery task. I can then access the object in the celery task by using template = json.loads(template)[0].get('fields') to access its required bits as a dictionary -- while this works, it does seem a bit inelegant and I wanted … -
Media files in Django
I think I'm doing everything correctly but the images won't show on the website although they get added successfully in the media folder... media/product_images inside media is the placeholder image + product_images folder Model Field image = models.ImageField(upload_to='product_images/', default='placeholder.png') Settings STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / 'static' ] MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' Urls urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -
chained drop down using django html jquery
in below code in need to chained dropdown using jquery. if i select county i need to get list of the states in state dropdown. county sate is working if i select state then related city need to be listed i dont know how to do ? please help using django i am passing country sate city info to the html page. in select1 value field county_id has been passed from country table in select2 value field county_id(fk) has been passed from state table. here i need to get state_id using that i need ger city list I dont know how to do ? in select3 value field, state_id(fk) has been passed from city table. this should refer select2 state_id I don't know how to do this one? <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function() { var $select1=$('#select1'), $select2=$('#select2'), $options=$select2.find('option'); $select1.on('change',function() { $select2.html($options.filter('[value="'+this.value+'"]')); }).trigger('change'); } ); </script> <title>Page Title</title> </head> <body> <tr> <td><label for="appt">Work County1:</label></td> <td><select id="select1"> <option selected disabled="true" value="">------</option> <option value="1">INDIA </option> <option value="2">USA </option> </select><br></td> <td><label for="appt">Work State1:</label></td> <td><select id="select2"> <option selected disabled="true" value="">------</option> <option value=1>CHN</option> <option value=1>tn</option> <option value=2>TX</option> </select><br></td> <td><label for="appt">Work city 1:</label></td> <td><select id="select3"> <option selected disabled="true" value="">------</option> <option value=1>CHN</option> <option value=1>CHN1</option> <option … -
How to not escape characters in Django Rest Framework
I have a blog model. I have text field where I want to write in HTML, for example including an a tag. The permission class used on unsafe methods is isAdminUser. I don't necessarily have to escape the characters. Is there way where I could not escape the characters. -
How to implement a conditional formset with multiple updates in one and the same sessionwizard step (Django 2.2)
I'm using a formwizard, SessionWizard, and I want to be able do to multiple choices in one step before proceeding to the next wizard step. In the below image there's a MultipleChoiceField 'choices' where the content should change, or update based on the selected features + feature 1-3 with Boolean buttons. The 'submit features' button is meant for updating the MultipleChoiceField 'choices' based on the choices of features and the Next button is meant for proceeding to the next wizard step. I've read some documentation and followed some tutorials on formsets but it doesn't work in the form wizard. In the first wizard step in get_form_kwargs(), step 0, in the view a dynamic list is filtered by the chosen features 1-3 and used for the MultipleChoiceField. Both the form Form1 and the step 0 in get_form_kwargs() should be updated, or reiterated as long as there are more filtered options in the list dynamic_ls in the MultipleChoiceField prior to proceeding to the next wizard step. How can I do this ? I found a django-multipleformwizard on Pypi that seems to be an extension for doing this type of task but I'm not sure how to use it or if it can … -
Display all of a single user's content on a profile page in django
I want to create a public-facing user profile page that displays these three things: 1-the user's Profile (model-singular-) data (image, name, email, etc..) 2-The Blog (model -list of posts-) posts the user has published. 3-The Art (model -list of art pieces-) pieces the user has published. All three of these models have fields that tie them to their User. So far I have been able to display all of these models on one page, but I cannot figure out how to sort them down to only display the content of the user who's profile page is being visited. I am trying to display all of this data on a ListView view, not sure if that is the correct move. I have been searching around for hours trying to find how to adjust the get_queryset and get_context_data but I can't figure out how to grab the <pk> from the url (i.e. artist/44). I also tried putting <username> in the url but I wasn't able to grab that either. The two views below are the views I have been working on. One uses (username) and the other uses (id) in the url: views.py class UserPostListView(ListView): model = Post template_name = 'blog/user_posts.html' context_object_name … -
Extra alias thumbnail generated
I am using easy-thumbnails the image-cropping app and aliases in this model (simplified): from image_cropping import ImageRatioField from easy_thumbnails.fields import ThumbnailerImageField class Image(SlugMixin, models.Model): slug_from_field = 'title' slug_length = 110 image = ThumbnailerImageField('path', upload_to=get_file_name, resize_source=dict( size=(1600, 0), quality=95), width_field='width', height_field='height', blank=True, null=True) crop_thumb = ImageRatioField( 'image', '120x90', help_text='Drag the handles and crop area to crop the image thumbnail.', verbose_name="crop thumbnail") .... The alias definition in settings.py: THUMBNAIL_ALIASES = { '': { 'small': { 'size': (120, 90), 'detail': True, 'crop': True, 'upscale': True, 'ALIAS': 'small', 'ratio_field': 'crop_thumb', }, 'medium': { 'size': (240, 180), 'detail': True, 'crop': True, 'upscale': True, 'ALIAS': 'medium', 'ratio_field': 'crop_thumb', }, 'large': { 'size': (0, 400), 'quality': 90, 'detail': True, 'upscale': True, 'ALIAS': 'large', 'ratio_field': 'crop_image', }, }, } THUMBNAIL_NAMER = 'easy_thumbnails.namers.alias' I am expecting to get 3 thumbnails per image uploaded, but I am getting 4. The 3 expected are named my_image.jpg.small.jpg + medium and large and the additional one is my_image.jpg..jpg and is 300px wide. It is like it generates an extra thumbnail for an empty alias, but I cannot find anything in my code that would do this. Any idea? -
Postgresql unable to alter role to superuser
I am failing at postgresql 101... I simply want to change my current user catmaid to have superuser privileges. (catmaid) [catmaid@sonic ~]$ psql postgres psql (10.10) Type "help" for help. postgres=> \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- catmaid | | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} postgres=> alter role catmaid superuser; ERROR: must be superuser to alter superusers I want to do this because I'm otherwise unable to do django migrations (catmaid) [catmaid@sonic django]$ ./projects/manage.py migrate INFO 2021-02-11 18:12:40,155 CATMAID version 2018.11.09-1660-gce1dee4 WARNING 2021-02-11 18:12:40,806 NeuroML module could not be loaded. WARNING 2021-02-11 18:12:41,068 CATMAID was unable to load the Rpy2 library, which is an optional dependency. Nblast support is therefore disabled. WARNING 2021-02-11 18:12:41,068 CATMAID was unable to load the Pandas lirary, which is an optional dependency. Nblast support is therefore disabled. INFO 2021-02-11 18:12:41,125 Spatial update events disabled INFO 2021-02-11 18:12:41,271 History tracking enabled System check identified some issues: WARNINGS: ?: Couldn't check spatial update notification setup, missing database functions HINT: Migrate CATMAID ?: The output folder is not writable HINT: Make sure the user running CATMAID can write to the output directory or change …