Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How would I use a boolean field in a template?
So I am trying to create some moderation in my app. A users post should be false when the create it and a moderator must come in and set it to true for it to go live. I have added the field into my models. But I am struggling to get the true ones to display on my template. MODELS: class Post(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) title = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True) category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True) image = models.ImageField(blank=True, null=True) live = models.BooleanField(default=False) VIEWS: class IndexView(ListView): model = Post template_name = "public/index.html" I know I need to use an if statement but I am not sure how to implement it. Thanks. -
Dynamically added forms not saving to inlineformset_factory Django
I have been following a variety of tutorials for a while and trying to understand/put them all together to achieve the ability for my user to dynamically add instances to a child within an inlineformset_factory. My project is a simple employee/shifts set up. My parent model is a ManagerChecklist model that the manager would complete at the end of the day. The child model is an EmployeeShift model that contains information of each of the employees that worked on that shift and what hours they did. I would like my manager to be able to dynamically add employees to his "manager checklist" form. views.py def update_manager_checklist(request, date): template_name = 'shifts/checklists/manager_checklist_update.html' instance = get_object_or_404(ManagerChecklist, shift__shift_date=date) checklist = inlineformset_factory(ManagerChecklist, EmployeeShift, fields=('employee', 'start_time', 'end_time', 'total_hours_worked', ), extra=0, max_num=None) if request.method == 'POST': formset = checklist(request.POST, instance=instance) if formset.is_valid(): formset.save() return redirect('shifts:shift_list') formset = checklist(instance=instance) return render(request, template_name, { 'formset': formset, }) html: {{ formset.management_form }} <div id="form_set"> {% for form in formset %} <table class='no_error'> {{ form.as_table }} </table> {% endfor %} </div> <input type="button" value="Add More" id="add_more"> <div id="empty_form" style="display:none"> <table class='no_error'> {{ formset.empty_form.as_table }} </table> </div> javascript: <script> $('#add_more').click(function() { var form_idx = $('#id_form-TOTAL_FORMS').val(); $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, form_idx)); $('#id_form-TOTAL_FORMS').val(parseInt(form_idx) + 1); });</script> The … -
Conflict bewteen MySql and Postgres with Heroku and Django
First of all : I run migrate and makemigrations I run migrate on heroku as well On my local machine I use Mysql, everything work On Heroku I use postgres, it does not work The problem : It first occur when I tried to add some table to my model "Dashboard". I added them and migrate on mysql then push it to heroku and migrate again and I got this message : Then I add a new table to my Dashboard and I got this error : ProgrammingError at /admin/dashboard/adressbook/ relation "dashboard_adressbook" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "dashboard_adressbook" **Traceback:** File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute 85. return self.cursor.execute(sql, params) The above exception (relation "dashboard_adressbook" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "dashboard_adressbook" ^ ) was the direct cause of the following exception: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 126. response = self.process_exception_by_middleware(e, request) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 124. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/options.py" in wrapper 604. return self.admin_site.admin_view(view)(*args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view 142. response = view_func(request, *args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/sites.py" in inner 223. return view(request, … -
Serve blog as subdirectory in heroku for an app deployed in Django
I am using heroku as my platform for a website. I want to serve my blog from a subdirectory to make more of SEO.I tried looking for ways elsewhere but couldn't find anything. really!. I am trying to solve the problem which helps me to serve Blog from a subdirectory of a django based website hosted in heroku while also giving me abilities of maintaining my blog using a cms. Please help me understand what should be the approach that I should be following for achieving this. -
Django ORM inside model label - speed
Using Django 1.11 and python 2.7, I have a heavy Django admin App with the code below: # same as __str__ in python 3 def __unicode__(self): redirected = "REDIRECTED-" if self.is_redirected else "" return u'[{}{}] {}'.format(redirected, self.typecode, self.headline) @property def is_redirected(self): return OtherModel.objects.filter(old_path=self.url).exists() The problem is since the model label (the name that defaults as an output when printing the object) is used in a lot of places in the admin template this calls the ORM each time which drains ~200ms each time and it totals 8 times to ~2 seconds per page and I would like to speed that up and reduce calls. The obvious answer is cache but calling our cache also takes time since its on a different server so instead of getting 8 SQL calls I'll get 8 outside requests which is another thing I want to avoid. I will not elaborate but I need everything to stay inside the unicode function. -
Nested view in django giving TypeError because of additional argument passed to __init__()
I have a view in which I am attempting to do all of the following: Extend an existing form to have additional fields that do not correspond to a model Check if form data is valid Generate a stripe token and process a charge If that charge is successful, save non cc fields in the form to my local db I believe my logic is all correct here, and that a charge is created, then form fields that correspond to my model will be saved to my db, and the user will be shown a success page, or an error page otherwise. However, when attempting to test, I get the error: TypeError at /url/linked/to/view __init__() takes 1 positional argument but 2 were given In attempting to solve this problem on my own, I came across this question. Based on answers to that question, the short answer seems to be that adding self as first argument to the relevant method should resolve the issue, although it doesn't appear to in this case. My view: class payment_order(View): def post(self, request): card_num = request.POST['card_num'] exp_month = request.POST['exp_month'] exp_year = request.POST['exp_year'] cvc = request.POST['cvc'] email = request.POST['email'] cart = Cart(request) if request.method == 'POST': … -
How to call a specific python script/program from a HTML button using DJango
I have a face detection program (built on python) and I'm struggling to call such program from inside a web site (built on DJango). In my personal computer, the face detection program can be started with python eye_tracker. I have tried the suggested solutions on the web all day long, without any success. What I'm trying to do is pretty simple: create a button on the web site that calls the face detection program (the program is designed to open the personal computer cam in a new window). Could some one help me? -
nested django view to handle stripe payment and then save form giving syntax error
I have a view in which I am attempting to do all of the following: Extend an existing form to have additional fields that do not correspond to a model Check if form data is valid Generate a stripe token and process a charge If that charge is successful, save non cc fields in the form to my local db I had thought my logic, and levels of branching are all correct, however when attempting to test I am getting a very vague syntax error, on the 3rd line from the bottom, which is simply an else: clause. I know sometimes in such cases the line number given may not correspond to the actual error, however in this case I can't see any obvious problems with my branching or syntax, and I don't see any other difference from views that are known to work that use similar if/else logic. My view: class payment_order(View): def post(self, request, *args, **kwargs): card_num = request.POST['card_num'] exp_month = request.POST['exp_month'] exp_year = request.POST['exp_year'] cvc = request.POST['cvc'] email = request.POST['email'] cart = Cart(request) if request.method == 'POST': form = OrderPayForm(request.POST) if form.is_valid(): token = stripe.Token.create( card={ "number": card_num, "exp_month": int(exp_month), "exp_year": int(exp_year), "cvc": cvc }, ) charge … -
Having issues connecting to PostgreSQL Database in Django
I am getting the error django.db.utils.OperationError: FATAL:database "/path/to/current/project/projectname/databasename" does not exist. I have accessed the database both manually through psql, as well as through pgadmin4, and have verified in both instances that the database does exist, and I have verified that the port is correct. Im not sure why I cant access the database, or why it would say the database cannot be found. According to pgAdmin4, the database is healthy, and it is receiving at least 1 I/O per second, so it can be read and written to by...something? I have installed both the psycopg2 and the psycopg2-binary just to be safe. -
Validate dates from DateTimeField are the same
I have a form that I am trying to add a clean method to make sure that the dates entered are the same. The form happens to be passing, even when the dates are not the same. I believe the problem is in my clean method, but as it is not passing an error, I am unsure what is causing the issue. I would appreciate any help with this. class LessonForm(forms.ModelForm): lesson_instrument = forms.ChoiceField(choices=instrument_list, widget=forms.Select(attrs={'class' : 'form-control', 'required' : 'True'})) lesson_datetime_start = forms.DateTimeField(input_formats=['%Y-%m-%d %I:%M %p'], widget=forms.DateTimeInput(attrs={'class': 'form-control', 'placeholder':'YYYY-MM-DD Hour:Minute am/pm'}), validators=[validate_date1]) lesson_datetime_end = forms.DateTimeField(input_formats=['%Y-%m-%d %I:%M %p'], required=False, widget=forms.DateTimeInput(attrs={'class': 'form-control', 'placeholder':'YYYY-MM-DD Hour:Minute am/pm'}), validators=[validate_date2]) lesson_weekly = forms.BooleanField(required=False) class Meta: model = Lesson fields = ('lesson_instrument', 'lesson_datetime_start', 'lesson_datetime_end', 'lesson_weekly') def clean(self): cleaned_data = super().clean() if self.cleaned_data.get('lesson_datetime_start') \ and self.cleaned_data.get('lesson_datetime_end') \ and self.cleaned_data['lesson_datetime_start'] >= self.cleaned_data['lesson_datetime_end']: raise ValidationError({'lesson_datetime_end': "End time must be later than start time."}) return cleaned_data def clean2(self): cleaned_data = super().clean() lesson_datetime_start = self.cleaned_data.get("lesson_datetime_start") lesson_datetime_end = self.cleaned_data.get("lesson_datetime_end") start = datetime.strptime(lesson_datetime_start, '%Y-%m-%d').date() end = datetime.strptime(lesson_datetime_end, '%Y-%m-%d').date() if start != end: raise ValidationError('Dates have to be the same') return cleaned_data -
Django rest framework get json instead of count
i have a Community app with a field of subscriber related to the accounts app but in the response it return counts instead of using account serializer CommunitySerializer: class CommunitySerializer(serializers.ModelSerializer): class Meta: model = Community fields = ('name', 'about', 'subscribers', 'moderators') AccountsSerializer: class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('username',) It Return: { "name": "pcmasterrace", "about": "Welcome to the official subreddit of the PC Master Race. In this subreddit, we celebrate and promote the ultimate gaming and working platform. Ascend to a level that respects your eyes, your wallet, your mind, and your heart. Ascend to... the PC Master Race.", "community_rules": [ { "rule": "Rule 1 - Off Topic", "description": "DOnt fuck" }, { "rule": "Rule 2 - No tech support", "description": "community_rulescommunity_rulescommunity_rulescommunity_rulescommunity_rules" } ], "subscribers": [ 1 ], "moderators": [ 1 ] } -
Heroku: Running a Node module in a Django/Python app
I have a fairly classic Python/Django app deployed to Heroku. There's a pip package I want to use, django-mjml that itself relies on a node-module named mjml. My question is how to combine the two? Doing npm init and npm install mjml created a node_modules directory in my root folder, and also the files: package.json and package-lock.json. I guess that's not really what I want..? Not sure how to proceed from here and any directions are appreciated! -
What are the differences between these two ways of saving form information?
I am learning how to use django forms and I was presented two ways to save information from a form. I tested the two and both work with validations, but I did not understand the difference between one and the other. The first uses functions inherited from the models.Model class, using the function "objects.create(** form.cleaned_data)" and passing the form fields as a parameter. In the example below, I instantiate the ProductForm class that inherits from 'forms.ModelForm' and use the 'cleaned_data' function to pass as a parameter. def product_create_view(request): form = ProductForm() if request.method == 'POST': form = ProductForm(request.POST or None) if form.is_valid(): **Product.objects.create(**form.cleaned_data)** form = ProductForm() data = {} data['form'] = form return render(request, 'products/product_create.html', data) The second way instead of using the function 'objects.create(** dict)' uses form.save() directly. def product_create_view(request): form = ProductForm() if request.method == 'POST': form = ProductForm(request.POST or None) if form.is_valid(): **form.save()** form = ProductForm() data = {} data['form'] = form return render(request, 'products/product_create.html', data) I'd like to know there are differences between using form.save() and using Product.objects.create(** dict) -
Override default route method in Django
I've got a small app with DefaultRouter used to handle basic operations at certain models. The problem is, that I need to override the create and update method for standard DefaultRouter, to handle problem without using Django Admin. Models, etc. are nothing special, but important thing is that I want to override method for all models using specific abstract model as a parent. If I've created save() and update() methods in model, DefaultRouter crashes. Thanks for help! -
Django Rest Framework CORS blocking XMLHttpRequest
I have set up my CORS policy using Django-cors-headers with the following settings: APPEND_SLASH=False CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True CORS_ORIGIN_WHITELIST = ( 'localhost:8000', 'localhost:3000', 'localhost' ) I have also added it to installed_apps and middleware. Now I am making a React app for the front end and using AXIOS for my API requests. When I make an API request to log in to my app the CORS policy allows it. But, if I make an API request that requires a Token, I get: Access to XMLHttpRequest at 'localhost:8000/api/TestConnection/' from origin 'http://localhost:3000' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. It seems that I need to allow XMLHttpRequest for supported protocol schemes but I cannot find anything in the pypi documentation about this. Thank you! -
i am getting an error saying category matching query does not exist
The voting proceess is working fine with this code. The problem is only when redirecting after voting the options. Exception Type:DoesNotExist Exception Value: Category matching query does not exist. category = Category.objects.get(slug=slug) urls.py path('<slug>/',views.options,name='options'), path('<slug>/vote/', views.vote, name='vote'), views.py def home(request): categories = Category.objects.filter(active=True) return render(request,'rank/base.html',{'categories': categories,'title':'TheRanker'}) def options(request,slug): category = Category.objects.get(slug=slug) options = Option.objects.filter(category=category) return render(request,'rank/options.html',{'options':options,'title':'options'}) def vote(request,slug): option = Option.objects.get(slug=slug) if Vote.objects.filter(slug=slug,voter_id=request.user.id).exists(): messages.error(request,'You Already Voted!') return redirect('rank:options',slug) else: option.votes += 1 option.save() voter = Vote(voter=request.user,option=option) voter.save() messages.success(request,'Voted!') return redirect('rank:options',slug) options.html {% extends "rank/base.html" %} <title>{% block title %}{{title}}{% endblock title%}</title> {% load bootstrap4 %} {% block content %} <center><br> <center>{% bootstrap_messages %}</center> <ol type="1"> {% for option in options %} <div class="col-lg-6 col-md-6 mb-6"> <div class="card h-100"> <div class="card-body"> <b><li> <img src="/media/{{option.image}}" width="200" height="100"> <h4>{{option.name}} </h4> <h5 class="card-text">{{ option.details}}</h5> <h5>{{ option.votes }} votes</h5> <form action="{% url 'rank:vote' option.slug %}" method="post"> {% csrf_token %} <input type="submit" class="btn btn-success" value="Vote" > </form> </li></b> </div> <div class="card-footer"> <small class="text-muted"></small> </div> </div> </div> {% endfor %} </ol> </center> {% endblock content%} -
Moving PyCharm .idea directory
I am trying to move the PyCharm .idea directory out of the project folder (a django project in this case). I followed the instructions from JetBrains to move the .idea.properties file, which involves creating a custom .idea.properties file. I figured this might also provide a means to move the .idea folder, but having done this, it does not appear to have addressed the issue and if I create a new Django project the .idea directory is still in the Django project folder. I have looked at the contents of the custom .idea.properties file and although there is an entry relating to where it looks for .idea files to flag them as such, it doesn't appear to actually have a specific setting for the location of the .idea directory it creates for new projects. As is often the case with JetBrains, I feel like I am missing the point somewhere and in this case searching on StackExchange or more general googling has not shed any light on the problem. There is a workaround that I found that is in a nine-year old thread on the JetBrains 'YouTrack' bug tracking system (https://youtrack.jetbrains.com/issue/IDEA-170102?p=WI-343) but it refers to changing the Settings|Directories option in PyCharm, … -
How to validate that at least one of two fields are present during serialization/deserialization
I am using Django Rest Framework and defining my Serializer class. The input that the Serializer class is validating contains two fields like so: "absolute_date_range":{ "start":..., "end":..., } "relative_date_range"="last_7" The user can choose to pass one or both of these in. But at least one of them has to be present. If not then it should result in a validation error. The required=True condition works only on a single field. If I do this using custom logic, which is the best place to put this logic in - the Serializer or in a Custom Field or Field level validation? How do I enforce this in my Serializer? -
Django REST framework image upload not working
I have a register API that works but I want to be able to upload an optional image when registering a user. Currently I get an error: "TypeError: 'photo' is an invalid keyword argument for this function". Here is my code: # serializers.py class RegisterSerializer(serializers.ModelSerializer): first_name = serializers.CharField(required=True) last_name = serializers.CharField(required=True) email = serializers.EmailField(required=True) photo = serializers.ImageField() # doesn't work currently class Meta: model = User fields = ('id', 'username', 'first_name', 'last_name', 'email', 'photo', 'password') extra_kwargs = {'password': {'write_only': True, 'min_length': 5}} def create(self, validated_data): user = super(RegisterSerializer, self).create(validated_data) user.set_password(validated_data['password']) user.save() return user api.py class RegisterAPIView(CreateAPIView): serializer_class = RegisterSerializer permission_classes = [AllowAny] parser_class = (FileUploadParser,) # not sure if this is needed def post(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) self.perform_create(serializer) token = Token.objects.create(user=serializer.instance) token_data = {"token": token.key} return Response({**serializer.data, **token_data}) -
Connecting SQL Tables in Django w/ React frontend
I am trying to reference different tables in my SQL database to each other (named Workout and Circuit). They both show, until I try to reference the other table (for example in Workout -- list the circuits in its relational table'.) But it always throws me this error: Could not resolve URL for hyperlinked relationship using view name "CircuitListView". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field. Code Snippet In Serializers.py class WorkoutSerializer(serializers.HyperlinkedModelSerializer): circuits = serializers.HyperlinkedRelatedField( # name of view view_name="Circuit", many=True, read_only=True ) class Meta: model = Workout fields = ('id', 'name', 'description', 'circuits') class CircuitSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Circuit fields = ('id', 'exercise', 'minutes', 'seconds') In Views.py from rest_framework.generics import ListAPIView, RetrieveAPIView from circuit.models import Workout, Circuit from .serializers import WorkoutSerializer, CircuitSerializer class WorkoutListView(ListAPIView): queryset = Workout.objects.all() serializer_class = WorkoutSerializer class WorkoutDetailView(RetrieveAPIView): queryset = Workout.objects.all() serializer_class = WorkoutSerializer class CircuitListView(ListAPIView): queryset = Circuit.objects.all() serializer_class = CircuitSerializer class CircuitDetailView(RetrieveAPIView): queryset = Circuit.objects.all() serializer_class = CircuitSerializer I have seen people use functions in their views, such as: def workout_list(request): workout = Workout.objects.all() return render(request, 'workout_list.html', {'workout': workout}) However, I don't have a template in my django … -
Django Rest Framework - Choose serializer database
I have recently been having a lot of difficulty with getting information to appear in my viewset as the fields have always been empty. It turns out that it has been using data from the default database instead of the one I want (so obviously the fields are empty as there is nothing in them!) I believe it occurs when I'm trying to get fields from another table (one not in the main query itself) via the serializer (this information comes from the default db). Is there a way to specify the database for the serializer? Or any other fix to this? I'm very new to Django but I haven't been able to find anything regarding this. My View class MessagingViewSet(viewsets.ModelViewSet): def list(self, request): db_to_use = get_db_name_by_request(request) if db_to_use is None: return Response() conversations = models.Conversation.objects.using(db_to_use).filter(checkunread__user_id=request.user.id) conv_ids = list(conversations.values_list('id', flat=True).order_by('id')) comments = models.Comments.objects.filter(conversation_id__in=conv_ids) serialized_conversations = serializers.ConversationSerializer(conversations, many=True).data serialized_comments = serializers.CommentSerializer(comments, many=True).data #parsing the data into a JSON obect for conversation in serialized_conversations: conv_id = conversation['id'] for comment in serialized_comments: if comment['conversation_id'] == conv_id: conversation['comments'].append(comment) return Response(serialized_conversations) So the View here works, how I get comments was a hack to circumvent this (getting comments from the correct db) but if I … -
Custom LoginView django extra_context
I did a custom loginView and I can't reach the extra_context dictionary in my template. (authentification works fine) my view file: from django.contrib.auth import login class LoginViewCustom(LoginView): template_name = 'users/login_register.html' extra_context = {'test42': EsportUser} my template file (login_register.html): <a href="#">{% trans "Account" %} {{ test42.id }}</a> my urls file: path('login/', views.LoginViewCustom.as_view(), name='login', ), Thanks, Stéphane -
login in django using email or username (custom user model)
i am new to the django. i want that user is able to login using username or email. i am using custom user model. register page is working properly but in login while submiting login data i am getting errors. my code is not working. i do not know how to get it working properly. please if anyone can help to get in working properly.thanks //views.py from django.shortcuts import render from .forms import UserCreationForm,UserLoginForm from django.http import HttpResponseRedirect from django.contrib.auth import login,get_user_model, logout,authenticate # Create your views here. def base(request): return render(request, 'articles/base.html') def login(request,*args,**kwargs): form=UserLoginForm(request.POST or None) if form.is_valid(): user_obj=form.cleaned_data.get('user_obj') print(user_obj) username = user_obj['query'] password = user_obj['password'] user = authenticate(username=username, password=password) if user is not None: print("in login") login(request, user) return HttpResponseRedirect('/') else: return render(request, 'login1.html', {'form': form}) return render(request, 'articles/login1.html',{'form':form}) //forms.py from django import forms from django.contrib.auth import get_user_model from django.db.models import Q from django.contrib.auth import get_user_model User=get_user_model() class UserCreationForm(forms.ModelForm): password1 = forms.CharField(label='Password', widget=forms.PasswordInput) password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput) class Meta: model=User fields=['username','email'] def clean_password(self): # Check that the two password entries match password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1 and password2 and password1 != password2: raise forms.ValidationError("Passwords don't match") return password2 def save(self, commit=True): # Save … -
Download a FILE from GoogleDrive using Django
I was able to upload a FILE to Google drive using Drive API from django UI. Could you help me to DOWNLOAD the FILE from Google drive by DJANGO (same a web page download) PS. file id and file name , etc are available I have NOT asking how to DOWNLOAD by only Python code but PYTHON + DJANGO Apologies for bad English. -
Installing mod_wsgi to compile with python3.6 and configure with httpd
I am deploying a django app on Centos 7 and was running into problems getting the server up and running. It seemed to be because my mod_wsgi was compiled with python2.7 as opposed to python3.6 which is what i'm using. I uninstalled mod_wsgi and then ran sudo pip3.6 install mod_wsgi but was unable to get that installed with this errormissing Apache httpd server packages. So now i am stuck trying to get mod_wsgi to install with python3.6 and configure that for httpd to start up the service. I am completely lost and it looks as though i already have the python3.6 packages there for mod_wsgi shown below $ yum list | grep mod_wsgi mod_wsgi.x86_64 3.4-18.el7 @base rh-python36-mod_wsgi.x86_64 4.5.18-1.el7 @centos-sclo-rh python27-mod_wsgi.x86_64 4.5.13-2.el7 centos-sclo-rh python33-mod_wsgi.x86_64 3.4-13.el7 centos-sclo-rh python35u-mod_wsgi.x86_64 4.6.2-1.ius.centos7 ius python35u-mod_wsgi-debuginfo.x86_64 4.6.2-1.ius.centos7 ius python36u-mod_wsgi.x86_64 4.6.2-1.ius.centos7 ius python36u-mod_wsgi-debuginfo.x86_64 4.6.2-1.ius.centos7 ius rh-python34-mod_wsgi.x86_64 4.4.3-2.el7 centos-sclo-rh rh-python35-mod_wsgi.x86_64 4.4.21-1.el7 centos-sclo-rh I followed this tutorial to start: https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-centos-7 And i removed wsgi with sudo yum remove mod_wsgi How do i reinstall mod_wsgi to compile with pyton3.6 and configure that with my httpd service?