Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django: Save Form Data to Database
I'm using a form in my Django project to get people's name and number for later contact. Followed several guides including the Django docs but it doesn't seem to work. My test POST doesn't appear in admin and it can't be accessed via the manage.py shell either. I left in the multi-line comment in my code to show another method I was trying just in case. Form: from django import forms class SubscribeForm(forms.Form): name = forms.CharField(label='Your Name', max_length=100) phone_number = forms.CharField(label='Phone Number', max_length=12, min_length=10) Template: <form action="/success/" method="post"> {% csrf_token %} {{ form }} <input type="submit" value="Submit" /> </form> View: from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render from datetime import datetime from .models import Person from .forms import SubscribeForm def home(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = SubscribeForm(request.POST) # check whether it's valid: if form.is_valid(): # process the data in form.cleaned_data as required p = form.save() ''' name = form.cleaned_data['name'] number = form.cleaned_date['phone_number'] p = Person(name=name, phone_number=number, date_subscribed=datetime.now(), messages_recieved=0) p.save() ''' # redirect to a new URL: return HttpResponseRedirect('/success/') # if … -
Django can't see models on deployment server
i'm trying deploy my Django project on my vps server, but when i'm trying to do make migrations it can't see models, but it works completely fine on local server. File "/home/construct-ge/www/env/wsaleweb/Core/admin.py", line 2, in <module> from models import * ImportError: No module named 'models' -
Use pre_save signal in unit test
I'm setting a pre-save signal to change a flag on my UserProfile model (one to one with Django User). It works in practice not in my tests; it seems the pre-save signal is not getting called in the test at all. Is there something special I have to do when unittesting? Seems similar to this question but my signal and tests are in the same app, although the model it's in is django.contrib.auth.User, which I import at the top of my test file. I've also tried directly importing the signal method, but that didn't do anything either. app.models: @receiver(pre_save, sender=User) def password_change_signal(sender, instance, **kwargs): try: user = User.objects.get(username=instance.username) if not user.password == instance.password: user.profile.password_change_needed = False user.profile.save() except User.DoesNotExist: pass app.tests: from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.test import TestCase, Client class UserChangePassword(TestCase): def setUp(self): self.client = Client() self.new_user = User.objects.create_superuser( username="garnet", email="garnet@savestheworld.com", password="rubysapphire") self.new_user.save() self.old_user = User.objects.create_superuser( username="pearl", email="pearl@savestheworld.com", password="rosequartz") self.old_user.save() def test_change_password_flag_false_after_change(self): self.client.login(username="garnet", password="rubysapphire") new_password = "sapphireruby" self.new_user.set_password(new_password) self.new_user.save() self.assertFalse(self.new_user.profile.password_change_needed) -
Django, 1.9.10 Language matching query does not exist
I am a struggling beginner and I will appreciate your help. I have cloned a Django site to edit and learn from it but I can not runserver. On running server I get the error Language matching query does not exist. Request Method: GET Request URL: http://127.0.0.1:8000/en/software/features Django Version: 1.9.10 Exception Type: DoesNotExist Exception Value: Language matching query does not exist. Exception Location: /home/steve/Documents/wger/venv-django/lib/python3.5/site-packages/django/db/models/query.py in get, line 387 Python Executable: /home/steve/Documents/wger/venv-django/bin/python Python Version: 3.5.2 Python Path: ['/home/steve/Documents/wger/wger-croners', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/steve/Documents/wger/venv-django/lib/python3.5/site-packages', '/home/steve/.config/wger'] Server time: Mon, 24 Oct 2016 19:48:24 +0300 /home/steve/Documents/wger/wger-croners/wger/utils/language.py in load_language language = Language.objects.get(short_name=used_language) What could be wrong? I have followed all instructions on the Git readme. -
Django query, find latest version of self excluding unpublished versions
Abbreviating my code, I have two tables: Article: title = ... ArticleVersion: article = ForeignKey(Article) version = IntegerField datetime_published = DatetimeField(null=True) An ArticleVersion is unpublished if it's datetime_published field is null. I need to find the max published version for all ArticleVersion objects. What I have so far that works for ArticleVersion objects in any published state is: ArticleVersion.objects \ .select_related('article') \ .annotate(max_version=Max('article__articleversion__version')) \ .filter(version=F('max_version')) But I'm having difficulty filtering that relation article__articleversion__version to only ArticleVersion objects with a non-null datetime_published value. .exclude(datetime_published=None) doesn't work and neither does .exclude(article__articleversion__datetime_published=None) anywhere within the query. I'd prefer to not use raw SQL and keep it within a single query if at all possible. Any help? -
Nginx Why does my server serve correct content on localhost but not 0.0.0.0
I am trying to get data from my server but if I try from 0.0.0.0/my/api it gives a 400, but if I try from localhost/my/api it gives the content I need. I am using nginx and here is the config file for the server server { listen 80; server_name localhost 54.149.242.144; access_log /var/log/nginx/myapp.log; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/myapp; } location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } Also if I do a netstat I get this for the server tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8080/nginx Why would it only give me the correct content from localhost, and give me 400's from the 0.0.0.0 address? Also this is making it so I can not access the api from an outside machine. Finally I am using gunicorn as a backend server and using nginx to reverse proxy gunicorn. -
Django migrate db column width
In Django 1.10, username max length was increased from 30 to 150 characters. I have a django 1.9 app I'd like to migrate to take advantage of this. I have upgraded the Django installation to 1.10. When I python manage.py makemigrations, I get no changes detected. If I try to just edit an existing username to be more than 30 characters, I get django.db.utils.DataError: value too long for type character varying(30) in the logs. I would prefer to use Django's built-in migrations to handle this without hacking around in postgres. How can I trigger a migration to modify the DB column width? I had the idea to add a throwaway field to a model, migrate, and remove it again, but that seems hacky, and it seems like there should be a way to handle it better than that. The Django docs seem silent on this. -
Django REST list-only (no details) ViewSet
There is a router: router.register('users', UsersViewSet, base_name='users') And a ViewSet: class UserViewSet(viewsets.ReadOnlyModelViewSet): def get_queryset(self): return self.get_object_list() def get_object(self): for input in self.get_object_list(): if input.id == self.kwargs['pk']: self.check_object_permissions(self.request, input) return input raise MyCustomNotFound() When I go to "/rest/users/" it shows users list. When I go go "rest/users/1" - it shows details of some user. Now I would like to create an /employees read-only resource, which extends User, but only shows list (typing something like "/employees/1" shows Django 404). Solutions tried: 1) Override get_object() and return Http404 - doesn't work it shows REST page with data instead of 404 page. 2) Using something described at http://www.django-rest-framework.org/api-guide/viewsets/#readonlymodelviewset - user_list = UserViewSet.as_view({'get': 'list'}) in the router file - doesn't work. -
Django Generic Views and Customizability
Referring to CreateView, UpdateView, & DeleteView, as I get further in to my testing, I am finding these - however convienient - to be to restrictive to customization. I did a quick workthrough of using ModelForm last night (off of the Django docs), but wasn't successful. Does anyone know of a good detailed guide for using ModelForm views and customizing forms with Django? -
PyCharm not detecting unresolved references [Django]
So I'm having a problem with PyCharm and can't find a solution for it. It fails to recognize unresolved references: example. The image also shows that it fails to auto-complete request.session. It only happens with .session, it works with every other attribute. Also, this image shows that it does detect unresolved references for other stuff. I'm running it on a virtualenv, the interpreter is configured correctly and I have Django Support enabled. Oh, and I'm using Python3 and Django 1.10.2 -
Django-Docker dev environment
I am working to create a docker setup that will allow me to do active development on a set of containers using docker-compose that are exactly identical to how they will run in production. I am using docker, nginx, and uwsgi to serve the app. Everything works right now when I build the containers without sharing volumes. They only problem is that when I try to create a volume and mount the code on my machine into the container instead of copying it straight in I am getting an Internal Service Error. I checked all of the logs and it looks like nginx is running fine, but uwsgi is unable to start the application because of a missing Django module. Here is the traceback I am seeing in the uwsgi.log: File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist- packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist- packages/django/core/management/__init__.py", line 341, in execute django.setup() File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup from django.urls import set_script_prefix File "/usr/local/lib/python2.7/dist-packages/django/urls/__init__.py", line 1, in <module> from .base import ( File "/usr/local/lib/python2.7/dist-packages/django/urls/base.py", line 11, in <module> from .exceptions import NoReverseMatch, Resolver404 File "/usr/local/lib/python2.7/dist- packages/django/urls/exceptions.py", line 3, in <module> from django.http import Http404 File "/usr/local/lib/python2.7/dist-packages/django/http/__init__.py", line 1, in … -
Django FileField upload_to assistance
I'm new to python and trying to adapt to the OOP of Python. Could someone explain why the following is saving in a folder called 'None'? I want to upload an audio file in the admin page. This file gets stored in its own folder with the 'Vocab name' class Vocab(models.Model): module = models.ForeignKey(Modules, on_delete=models.CASCADE) number = models.CharField(max_length = 250) name = models.CharField(max_length = 250) class VocabContent(models.Model): vocab = models.ForeignKey(Vocab, on_delete=models.CASCADE) audio = models.FileField(upload_to=vocab.name) Running the following on shell. >>> from module.models import Modules, Vocab, VocabContent >>> vocab = VocabContent.objects.get(pk=1) >>> vocab.vocab.name 'Numbers' Numbers is the value i am looking for. -
Mezzanine Gallery thumbnail image loading slow
I use Mezzanine Gallery and I was wondering if is possible to speed up the loading of a list of thumbnail images without reducing quality. I'm using "thumbnail image.file 0 0" because if I reduce the size the quality gets really bad. The list is displayed with the below for loop. {% with page.gallery.images.all as images %} {% for image in images %} <a href="{{ image.file.url }}"> <img src="{{ MEDIA_URL }}{% thumbnail image.file 0 0 image.quality 100 %}"> </a> {% endfor %} {% endwith %} it takes about 4 seconds to load 8 images.. if I load the same images manually without the for loop query it loads in less than 1 sec. -
Finding the Latest Related Object in Django Queryset
I'm trying to set up a django queryset Purchase.objects.filter( date__lte=doc_date ).exclude( fifolink__sold_out=True ).aggregate( total=Sum(F("price") * F("fifolink__amt_remaining"), output_field=IntegerField()) ) For this line "fifolink__amt_remaining", there might be more than one fifolink object, in which case I want the latest one. Is this possible? -
django returns blank /empty string as None
Django app was running with DB oracle. When I switched the Db to Postgres , empty or blank strings are displaying "None" , however i want it to be blank as it was the case with oracle. Datatype of the column in oracle was nclob and in postgres it is text. Any idea, how could i fix this? any help would be much appreciated -
multiple Django projects apache virtual hosts
I'm a newbie to apache. So I'm trying to run at least two different django projects on one Ubuntu Server with a single IP address. IP: 123.456.789 Domain 1: www.example.de for Project1 Domain 2: www.test.de for Proejct2 The DNS for both domains is pointing on the same IP Address. I'm using apache2 with mod_wsgi in Daemon mode. Each Project has its own directory in ~/. I've also installed a virtaulenv with python inside the Project directorys The problem is that no matter how I configurate the apache2.conf, both domains point to Project1. What is weird is that they even do when it when I comment all the custom settings in apache2.conf. Can someone please explain this? here is my apache2.conf Listen 80 <VirtualHost *:80> ServerName www.example.de WSGIScriptAlias / /home/user/example/example-project/wsgi.py Alias /static/ /home/user/example/static/ WSGIPythonPath /home/user/example <Directory /home/user/example/static> Require all granted </Directory> <Directory /home/user/example/example> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess example.de python-path=/home/user/example:/home/user/example/exampleenv/lib/python2.7/site-packages WSGIProcessGroup example.de </VirtualHost> Listen 8080 <VirtualHost *:80> Servername www.test.de WSGIScriptAlias / /home/user/test/test-project/wsgi.py Alias /static/ /home/user/test/static/ <Directory /home/user/test/static> Require all granted </Directory> <Directory /home/user/test/test-project> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess test.de python-path=/home/user/test:/home/user/test/testenv/lib/python2.7/site-packages WSGIProcessGroup test.de </VirtualHost> Even if there is something wrong with my config, why does it … -
ValueError in Django when running the "python manage.py migrate" command
I needed to add more fields to Django's User model, so I created a custom model class (named Accounts in an app named accounts) that extends Django's AbstractUser class. After that, I updated my settings.py file, defining the AUTH_USER_MODEL property: AUTH_USER_MODEL = 'accounts.Accounts' I then created a migration file for the custom model using the python manage.py makemigrations command. After that, I ran the python manage.py migrate command and I got this error message: ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'accounts.accounts', but app 'accounts' isn't installed. What's the cause of the error and how can I fix it? -
Django FullCalendar next/prev working locally but not on Heroku
As per title. I've called python manage.py collectstatic before pushing onto Heroku. The events will load for the current month but when I click next or previous it won't load any data. It works fine on my local computer and I only have this issue on Heroku. -
Upload picture to Django from Python script
I am having a bad time trying to upload an image to Django from a python script. I tried some solutions I found around but none works. This is my simplified model: class ExampleModel(models.Model): address = models.CharField( _('address'), max_length=200, blank=True, ) photo = models.ImageField( verbose_name='photo', upload_to=path_for_photo, null=True, blank=True, validators=[FileValidator(max_size=settings.MAX_PHOTO_SIZE, allowed_mimetypes=settings.ALLOWED_CONTENT_TYPES, allowed_extensions=settings.ALLOWED_EXTENSIONS),] ) Now, my view is like this: def update(self, request, *args, **kwargs): instance = self.get_object() serializer = self.get_serializer(instance, data=request.data, partial=partial) serializer.is_valid(raise_exception=True) self.perform_update(serializer) return Response(serializer.data) This is the script I have in Python: with open('test.jpg', 'rb') as payload: headers = {'content-type': 'application/x-www-form-urlencoded'} files = { 'file': payload, 'Content-Type': 'image/jpeg' } r = requests.put('http://localhost:8000/v1/myendpoint', auth=('example@example.com', 'example'), verify=False, files=files, headers=headers) But I don't know how to modify my update method to update images. I've tried a few approaches: send it as json (changing the 'content-type' and sending the info in 'data' parameter of requests.put), send it as InMemoryUploadedFile, and some other solutions that I've found googleing around. I never thought that upload a simple image from Python would be that hard! I could do the same easily in a html form, but I need to put it from a python script. -
How do I retrieve the row data from my Django database as a list?
I would like to retrieve the data in my Django database table rows as a list so I can iterate over it and write each value of the list to an Excel spreadsheet. I tried doing this using dictionaries but dictionaries are not ordered in Python so my columns were getting all out of order. I need my Excel spreadsheet to look the same as my database table, not scrambled around in random order. How can I achieve this? Current code: def dump_attorneys_to_xlsx(request): if request.GET.get('export'): output = BytesIO() workbook = xlsxwriter.Workbook(output, {'in_memory': True}) worksheet = workbook.add_worksheet('Summary') attorneys = Attorney.objects.all().values() # Write header worksheet.write_row(0, 0, attorneys[0].keys()) # Write data for row_index, row_dict in enumerate(attorneys, start=1): worksheet.write_row(row_index, 0, row_dict.values()) workbook.close() output.seek(0) response = HttpResponse(output.read(), content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') response['Content-Disposition'] = 'attachment; filename=summary.xlsx' -
How do I query if the DB already has an object identical to the one I'm about to save?
Suppose I have: from django.db import models class MyContentClass(models.Model): content = models.TextField() another_field = models.TextField() x = MyContentClass(content="Hello, world!", another_field="More Info") Is there a more concise way to perform the following logic? existing = MyContentClass.objects.filter(content=x.content, another_field=x.another_field) if existing: x = existing[0] else: x.save() # x now points to an object which is saved to the DB, # either one we've just saved there or one that already existed # with the same field values we're interested in. Specifically: Is there a way to query for both (all) fields without specifying each one separately? Is there a better idiom for either getting the old object or saving the new one? Something like get_or_create, but which accepts an object as a parameter? -
Loading Django all-auth templates and completing registration in same modal pop up of bootstrap
I am using the Django All-Auth app in my Django website with bootstrap 3 navbar template where in the Log In button is in the navbar on the top-right. The navigation is in a different file navbar.html which in turn in called by base.html Now I could load the bootstrap modal popup in Login button in the nav bar. But I am unable to load the login view in the modal popup. The regular URL accounts/login works fine i.e. the non-Ajax template taking the whole website without any Ajax display. {% load staticfiles %} <!-- Static navbar --> <nav class="navbar navbar-default navbar-static-top"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="{% url 'home' %}"><img src="{% static 'img/THM_300.png' %}" class='img-responsive' style='width:200px'/></a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> <li> <a href="#">Log In</a></li> <!-- Button trigger modal --> <li> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> Log In </button> </li> <!-- <a href="#">Register</a></li> --> </ul> </div><!--/.nav-collapse --> </div> </nav> <!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" … -
Inline not displaying in Django Admin, Produces ManagementForm error when saving
I have a simple app for managing book clubs and meetings for my entity's website, and have an issue that's popped up where the meeting inline is not showing up in all associated club objects in the Django admin. If the meeting inline is actually enabled in the admin, it produces a ['ManagementForm data is missing or has been tampered with'] error when the club is saved. I've seen this ascribed to an encoding error, but I've checked the encoding on all saved objects in the database, and the Meeting objects render correctly when done in a separate admin, and save correctly as well. On the front end, the templates are able to access the data and render it correctly for public viewing. Here's the code for the models: class BookClub(models.Model): name = models.CharField(max_length=48) slug = models.SlugField(max_length=48) location = models.CharField(max_length=48) host_branch = models.ForeignKey(Branch,on_delete=models.CASCADE,blank=True,null=True) host_department = models.ForeignKey(Department,on_delete=models.CASCADE,blank=True,null=True,related_name="book_clubs") phone = models.CharField(max_length=14,validators=[RegexValidator(regex="^\(\d{3}\)\s\d{3}-\d{4}$", message="Please enter the phone number in the format (555) 555-5555")]) description = models.TextField(blank=True,null=True) flyer = ProcessedImageField(upload_to="book-club-flyers/",processors=[ResizeToFit(width=1024, upscale=False)],format='PNG',blank=True,null=True) def __str__(self): return self.name def get_absolute_url(self): return reverse('book_clubs:club', kwargs={'club_slug':self.slug},) class Meta(): verbose_name = "Book Club" def save(self,*args,**kwargs): if not self.pk: self.slug = slugify(self.name) super(BookClub,self).save(*args,**kwargs) class Meeting(models.Model): club = models.ForeignKey(BookClub,on_delete=models.CASCADE,unique_for_date="new_date") new_date = models.DateField() title = … -
django-session-security expire time not working
I'm somehow new to django and completely new to django-session-security package. I want my site to log the user out after 30 minutes of inactivity. using this package, I wrote my settings.py as it's shown below, but still I have some strange problems: settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'interpay', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'session_security', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'session_security.middleware.SessionSecurityMiddleware', ] SESSION_COOKIE_AGE = 50 SESSION_SAVE_EVERY_REQUEST = True SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_ENGINE = "django.contrib.sessions.backends.cached_db" SESSION_SECURITY_WARN_AFTER = 25*60 SESSION_SECURITY_EXPIRE_AFTER = 30*60 the problem is that the warning shows up if and only if the SESSION_SECURITY_WARN_AFTER is less than 10, else, the page suddenly turns to the login page and the user is logged out after SESSION_SECURITY_WARN_AFTER seconds. in addition, regardless to the SESSION_SECURITY_EXPIRE_AFTER amount, the session expires after about 10s, and THIS is not noticeable until you click on a link, button, etc. , and then the page is redirected to the login page!! I've gone completely crazy. any help would be really appreciated. BTW: I'm using the last version of the package for django 1.10 (which has been released 4 days ago) -
Configuration apache 2.4 wordpress and django wsgi on debian
I want to add a wordpress app at blog.mydomain.com but I already have a Django app at mydomain.com running with wsgi in deamon mode. I work on a Linux server (debian) with apache2.4.10 and PHP 5.6 Here is my apache conf for mydomain.com (django.conf): <VirtualHost 000.000.000.000:443> (my server ip) ServerName mydomain.com ServerAlias mydomain.com ServerAlias www.mydomain.com SSLEngine On SSLCertificateFile /pathToSsl/ssl.crt SSLCertificateKeyFile /pathToSsl/ssl.key SSLCertificateChainFile /pathToSsl/ssl.pem SSLVerifyClient None WSGIDaemonProcess mydomain.com threads=4 WSGIProcessGroup mydomain.com WSGIScriptAlias /path/to/settings/wsgi.py # Aliases toward static data Alias /media /pathToMedia/media/ Alias /static /pathToStatic/static/ Alias /log /var/www/html/ <Directory /path/to/settings> <Files wsgi.py> Require all granted </Files> </Directory> LogLevel warn CustomLog ${APACHE_LOG_DIR}/access-mydomain.com.log combined ErrorLog ${APACHE_LOG_DIR}/error-mydomain.com.log ErrorDocument 500 "Oups something goes wrong." </VirtualHost> <VirtualHost *:80> ServerName mydomain.com ServerAlias mydomain.com ServerAlias www.mydomain.com Redirect / https:// mydomain.com/ </VirtualHost> This one is working perfectly. And now I add a new configuration for my wordpress blog (wordpress.conf): <VirtualHost *:80> ServerName blog.mydomain.com DocumentRoot "/var/www/html/wordpress" <Directory /var/www/html/wordpress> AllowOverride all Options Indexes FollowSymLinks Require all granted </Directory> LogLevel warn CustomLog ${APACHE_LOG_DIR}/access-blog.fr.log combined ErrorLog ${APACHE_LOG_DIR}/error-blog.fr.log </VirtualHost> The problem is when i try to access to blog.mydomain.com, I am redirected to mydomain.com after few seconds. At the beginning, I thought that was because my conf wordpress was not found but if I put …