Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I am getting an error : rest_framework.request.WrappedAttributeError: 'CSRFCheck' object has no attribute 'process_request'
from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from .views import home from posts.views import PostListView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', PostListView.as_view(), name='home'), url(r'^post/', include('posts.urls', namespace='post')), url(r'^api/post/', include('posts.api.urls', namespace='post-api')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) api/views.py from rest_framework import generics from posts.models import Post from .serializers import PostModelSerializer class PostListAPIView(generics.ListAPIView): serializer_class = PostModelSerializer def get_queryset(self): return Post.objects.all() api/serializers.py from rest_framework import serializers from posts.models import Post class PostModelSerializer(serializers.ModelSerializer): class Meta: model = Post field = [ 'user', 'content' ] api/urls.py from django.conf.urls import url # from django.contrib import admin # from django.conf import settings # from django.conf.urls.static import static # from .views import home from .views import PostListAPIView from django.views.generic.base import RedirectView urlpatterns = [ # url(r'^(?P<pk>\d+)/update/$', PostUpdateView.as_view(), name='update'), # url(r'^(?P<pk>\d+)/delete/$', PostDeleteView.as_view(), name='delete'), # url(r'^(?P<pk>\d+)/$', PostDetailView.as_view(), name='detail'), url(r'^$', PostListAPIView.as_view(), name='list'), #/api/tweet # url(r'^$', RedirectView.as_view(url='/')), # url(r'^create/$', PostCreateView.as_view(), name='create'), ] views.py from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from .views import home from posts.views import PostListView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', PostListView.as_view(), name='home'), url(r'^post/', include('posts.urls', namespace='post')), url(r'^api/post/', include('posts.api.urls', namespace='post-api')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) enter image description here -
Django Throws 500 Internal Server Error instead of 404 on ElasticBeanstalk
I'm running a Django 2.1+ app and having an issue getting the 404 page to show up correctly on in my Elasticbeanstalk Environment. I'm able to get the 404 page to show correctly on my local environment and I believe I'm setting the ALLOWED_HOSTS file correctly according to everything else I've read. But for some reason I continue to get a 500 internal error page. I also have the app setup to email when an internal error occurs that is not caught. The errors that come back don't contain any kind of trace. It more or less just lists out my configuration file and tells me there was a server error. I've read through as many of the other stackoverflow issues related to this, but they all seem to be either missing ALLOWED_HOSTS or missing a 404.html template, but from what I've read I don't need that in Django 2.1+. Also, like I said above I'm able to get this to work locally just fine with Debug=True and Debug=False. Any suggestions would be greatly appreciated. Thank you. -
Django collectstatic does not work on nested directories of assets
I have an HTML template for my website, which has its own directory structure for JavaScript, CSS and images. My directory structure is like this: ِDirectory Structure My_Project/ |-Include/ |-Lib/ |-Scripts/ |-src/ | | | |--static_my_proj/ | | | ---assets/ | | | |----app/ | | | |----demo/ | | | |----snippets/ | | | |----vendors/ | |--templates/ | |--My_Projects/ |-static_cdn/ | |--static_root/ There are some static files under the "app," "demo," "snippets" and "vendors" directories and their sub-directories. My configurations on the "settings.py" are as below: STATICFILES_DIR = [ os.path.join(BASE_DIR, "static_my_proj") ] STATIC_URL = '/static/' STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn", "static_root") The problem is that when I use "python manage.py collectstatic" command, static files under the sub-directories of "static_my_proj" directory, will not be copied to "static_cdn/static_root/" path. The output on the "static_cdn/static_root" path, only contains "admin" directory and its subsequent "css," "fonts," "img," and "js" directories; there is not any sign that which shows the command ports the statics from the "assets" directory to defined destination. Any idea? -
django-elasticsearch-dsl unable to filter with mulitiple model fields
models.py class PostJob(models.Model): job_title = models.CharField(max_length=256) job_description = models.TextField() key_skills = models.TextField() def __str__(self): return self.job_title documents.py from django_elasticsearch_dsl import DocType, Index from .models import PostJob jobs = Index('jobs') @jobs.doc_type class JobsDocument(DocType): class Meta: model = PostJob fields = [ 'job_title', 'job_description', 'key_skills', ] views.py from .documents import JobsDocument def search_jobs(request): q = request.GET.get('q') if q is None: return JsonResponse({"code":500,"msg":"query sting not found"}) if q: Q = JobsDocument.search().query jobs = Q("match", key_skills=q) or Q("match", job_title=q) lst=[] dict ={} for i in jobs: dict["job_title"] = i.job_title dict["description"] = i.job_description dict["key_skills"] = i.key_skills lst.append(dict.copy()) return JsonResponse(lst,safe=False) in django using 'django-elasticsearch-dsl' i am trying to search with multiple model fields. here i wants to filter with multiple fields with key_skills and job_title but it is coming with only key_skills but doesn't matches with job_description for job_title if my job_title job python developer it is not coming if i am searching only developer. it is coming when i am searching python developer completely with white space Please have a look into it.. -
Change Passwod API using Django Custom user model and serializer
I have a Django application hwere I have extended the User model and created a custom user model for registration/login, now I want to implement a Change Password API which will be used in Android/IOS app development. I would get parameters as: user_id, old_password, new_password Using these paramters and custom user model and serializer is there any way I could achieve this. I have tried a sample example for this, but it failed. Custom Model: class User(AbstractBaseUser, PermissionsMixin): objects = UserManager() name = models.CharField(max_length=100, blank=True, null=True) email = models.EmailField(unique=True) created_at = models.DateField(blank=True, null=True, auto_now=True) phone_no = models.CharField(max_length=14, blank=True, null=True) user_android_id = models.CharField(max_length=255, blank=True, null=True) user_fcm_token = models.CharField(max_length=255, blank=True, null=True) user_social_flag = models.IntegerField(blank=True, null=True) user_fb_id = models.CharField(max_length=255, blank=True, null=True) user_android_app_version = models.CharField(max_length=25, blank=True, null=True) is_admin = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_active = models.BooleanField(default=True) USERNAME_FIELD = 'email' def __str__(self): return self.email User Manager: class UserManager(BaseUserManager): use_in_migrations = True def create_user(self, email, name, phone_no, created_at, user_android_id, user_fcm_token, user_social_flag, user_fb_id, user_android_app_version, password=None): cache.clear() user = self.model( email=self.normalize_email(email), phone_no=phone_no, created_at=created_at, user_android_id=user_android_id, user_fcm_token=user_fcm_token, user_social_flag=user_social_flag, user_fb_id=user_fb_id, user_android_app_version=user_android_app_version, name=name, ) user.is_admin = False user.is_staff = True user.is_superuser = False user.set_password(password) user.save(using=self._db) return user def create_staffuser(self, email, name, created_at, phone_no, user_android_id, user_fcm_token, user_social_flag, user_fb_id, user_android_app_version, password): … -
Real Time Notifications in django
I have a few types of notifications in my django project and as of now they are worked out using signals and the notifications are displaying correctly but it is not made real time. What is the best way to implement real time notifications in django?I have done a messaging app with django channels.Is django channels the best way to proceed? -
Default children plugins on custom plugin
I have a custom plugin called MultiColumnResponsive that receives the number of columns as parameter and accepts ColumnResponsive plugin only as children. I want to create the ColumnResponsive plugins nested as children by default, but I am not able to do it. Here my current code: cms_plugins.py class MultiColumnResponsivePlugin(CMSPluginBase): name = "Multi Column Responsive" module = _("Containers") model = MultiColumn render_template = "plugin/multi-column-responsive/multi-column-responsive.html" allow_children = True child_classes = ["ColumnResponsivePlugin"] def render(self, context, instance, placeholder): context = super(MultiColumnResponsivePlugin, self).render(context, instance, placeholder) return context class ColumnResponsivePlugin(CMSPluginBase): name = "Column Responsive" module = _("Containers") render_template = "plugin/column-responsive/column-responsive.html" allow_children = True parent_classes = ["MultiColumnResponsivePlugin"] def render(self, context, instance, placeholder): context = super(ColumnResponsivePlugin, self).render(context, instance, placeholder) return context models.py class MultiColumn(CMSPlugin): NUM_OF_COLUMNS = ( (1, '1'), (2, '2'), ) num_of_columns = models.IntegerField(default=1, choices=NUM_OF_COLUMNS) This is the desire result when I add a MultiColumnResponsive plugin with 2 columns: -
How to stop browser caching in Django?
The site i am building is being cached by browser.So when i make any changed in back-end or front-end i need to hard refresh the respective page to see the changes. In order to stop it i used @never_cache as described in django documentation but seems like its not preventing browser to cache page. Then i tried ajax cache false! $.ajax({ url: "/getData", method:"GET", cache: false }).done(function (res) { alert("Success"); }); Still not effective! Can any body help me in solving this problem? -
Django POST request from Postman
I am currently stuck with POST requests in Django. I am trying to send a POST request from an external applications such as smartphones or Postman (not forms) to the rest framework. Get requests work just fine. I went through many posts but couldn't resolve my issue. I tried to use request.body but always get an empty response. I used print(response.body) to print the output to the console and only get b'' back. class anyClass(APIView): def post(self, request): print(request.body) return Response({"id": 'anyClass', "data": '1234', }) How would I get the data from my request? My post request sent with Postman: http://127.0.0.1:8000/test/v2/Api/anyClass?qrcode=100023&date=2018-11-27&time=08:00:00&value_1=17 -
what is the difference between API and Website?
I know this is a very dumb question but i couldn't find any satisfactory answer on this . Let me elaborate to you my problem. I made a simple blogging website with Django. so , should i call this website a web app or API or just a website? Does API's and websites are same ? Is Django app and Django website and Django API same thing ? -
LinkedIn OAuth API version 2 updated in social_core but not working
I am using python-social-auth to let users log in with LinkedIn OAuth2 and updated the url as follows. linkedin.py AUTHORIZATION_URL = 'https://www.linkedin.com/oauth/v2/authorization' And set the redirect url to http://localhost:8000/oauth/complete/linkedin-oauth2/ In settings.py INSTALLED_APPS = [ ... 'social.apps.django_app.default', ...] EMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ ... 'social.apps.django_app.context_processors.backends', 'social.apps.django_app.context_processors.login_redirect', ], }, }, ] Finally, set the redirect urls to http://localhost:8000/oauth/complete/linkedin-oauth2/ What's missing here? -
Displaying all entries of a model that is linked to another model by a foreign key in Django
I'm learning Django and am trying to work through an exercise in making a small app. The requirements are are making an HR app that is supposed to display links on a login landing page to users based on a user's role within the company. My main question is if there is a way in Django to set up the logic in my template to display all the entries that are related between my models. To clarify a little, right now my current thinking is to set up my models like this: class Role(models.Model): title = models.CharField(max_length=200) def __str__(self): return self.title class CustomUser(AbstractUser): role = models.ForeignKey(Role, on_delete=models.DO_NOTHING, null=True) def __str__(self): return self.username class RoleLink(models.Model): role = models.ForeignKey(Role, on_delete=models.CASCADE) title = models.CharField(max_length=200) link = models.URLField() def __str__(self): return self.title Basically, one Role can have many Users, and also one Role can have many different RoleLinks and they can all be edited in the Django admin page. So for example, if I have a user 'PaulAllen1' with a role of 'sys-admin', when PaulAllen1 logs in, the landing page template should display all the links that are related to the 'sys-admin' role that I have set up like this. RoleLink model in the … -
how to implement views for chained dropdown list using djangorestframework
I have three models 1) Programme class Programme(models.Model): name = models.CharField(max_length=50 , unique=True) 2) Branch class Branch(models.Model): name = models.CharField(max_length=50, unique=True) programme = models.ForeignKey( 'Programme', related_name='branches', on_delete=models.CASCADE) 3)Scheme class Scheme(models.Model): name = models.CharField(max_length=50, unique=True) programme = models.ForeignKey('Programme', on_delete=models.CASCADE, related_name='schemes') branch = models.ForeignKey( 'Branch', on_delete=models.CASCADE, related_name='schemes') I want to create a serializer and a viewset for chained drop downlist selection of scheme will depend on filtered selection 1) selection of programme 2) selection of branch 3) selection of scheme anyone know how to do this using Djangorestframework -
Why can I access gdal in my python 3.6 shell but not my django shell
I have a django project that I want to use gdal in. I have installed all the dependencies and it works fine if I do: $ python3.6 Python 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from osgeo import gdal >>> gdal <module 'osgeo.gdal' from '/usr/lib/python3/dist-packages/osgeo/gdal.py'> but when I do: $python manage.py shell Python 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from osgeo import gdal Traceback (most recent call last): File "<console>", line 1, in <module> ModuleNotFoundError: No module named 'osgeo' It appears both are using the same python so I am not sure what the problem is. Could it be a path problem? -
Django models.py OneToOneField --- help creating a relationship between two models
I am having trouble testing a relationship between two models (CustomUser and Profile) located in different apps. I'm hoping someone can identify where I am going wrong here: Here is my profiles/models.py --- you can see my user field attempting to create a OneToOne with with my users/models.py: from django.db import models from core.models import TimeStampedModel class Profile(TimeStampedModel): user = models.OneToOneField('users.CustomUser', on_delete=models.CASCADE) first_name = models.CharField(max_length=30, blank=True) last_name = models.CharField(max_length=30, blank=True) bio = models.TextField(blank=True) image = models.URLField(blank=True) def __str__(self): return self.user.username Here is my users/models.py: class CustomUser(AbstractBaseUser, PermissionsMixin, TimeStampedModel): username = models.CharField(db_index=True, max_length=255, unique=True) email = models.EmailField(db_index=True, unique=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_provider = models.BooleanField(default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username'] objects = CustomUserManager() def __str__(self): return self.email @property def token(self): return self._generate_jwt_token() def get_short_name(self): return self.username def _generate_jwt_token(self): dt = datetime.now() + timedelta(days=60) token = jwt.encode({ 'id': self.pk, 'exp': int(dt.strftime('%s')) }, settings.SECRET_KEY, algorithm='HS256') return token.decode('utf-8') So the idea is that when I create a new user, a profile is automatically created as well. To do this, I am using a post_save signal in my users app: users/signals.py: from django.db.models.signals import post_save from django.dispatch import receiver from conduit.apps.profiles.models import Profile from .models import User @receiver(post_save, sender=User) def create_related_profile(sender, instance, … -
Tensorflow error while deploying Django app to Heroku
I am trying to deploy my application developed in Django to Heroku and getting the following errors: > File > "/app/.heroku/python/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", > line 58, in <module> > from tensorflow.python.pywrap_tensorflow_internal import * File "/app/.heroku/python/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/app/.heroku/python/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/app/.heroku/python/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/app/.heroku/python/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory During handling of the above exception, another exception occurred: Traceback (most recent call last): File "chatbot_website/manage.py", line 22, in execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/init.py", line 367, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/init.py", line 341, in execute django.setup() File "/app/.heroku/python/lib/python3.6/site-packages/django/init.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 116, in create mod = import_module(mod_path) File "/app/.heroku/python/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/app/chatbot_website/chatbot_interface/chatbotmanager.py", line 15, in from chatbot import chatbot File "/app/chatbot/chatbot.py", line 26, in … -
django : create table form when selecting multiple rows
I need to create a pretty straight forward form with Django but seems to be unable to find the proper tool for it, maybe because of the lack of vocabulary on what I want : I have a table of n rows, each row represents a database object. I want to put a checkbox in front left of each row to be able to select multiple rows and apply an action placed in a multiplechoice widget at the top. I thought about "serialize" a deleteview with formset but anyway I don't know how to add extra actions (apart from delete). Any valuable information on direction to take would be welcome, thanks. -
django updating model issues
I have a babysitter app I am working on. I can add and update the parent to the parent model with no problem. I can create and delete a kid but when I try to update a kid I get the following error. What am I doing wrong? I have been looking through examples and similar queries on this site but I still cant get it to work. urls.py from django.conf.urls import url from .views import register, profile, logout, login, update_profile, update_profile_kid, create_profile_kid, delete_profile_kid urlpatterns = [ url(r'^register/$', register, name='register'), url(r'^profile/$', profile, name='profile'), url(r'^profile/update/$', update_profile, name='update_profile'), url(r'^profile/kids/update/(?P<id>\d+)$', update_profile_kid, name='update_profile_kid'), url(r'^profile/kids/delete/(?P<id>\d+)$', delete_profile_kid, name='delete_profile_kid'), url(r'^profile/kids/create/$', create_profile_kid, name='create_profile_kid'), url(r'^logout/$', logout, name='logout'), url(r'^login', login, name='login'), ] profile.html {% extends "base.html" %} {% load static %} {% load gravatar %} {% block content %} <section class="container-fluid"> <div class="page-header text-center"> <h1>Client Dashboard</h1> </div> <div class="container-fluid"> <div class="row"> <div class="col-md-12 col-lg-4 text-center"> <p class="lead">Welcome <b>{{user.first_name}}</b></p> <img class="rounded-circle profile-image my-2 img-fluid" src="{{ MEDIA_URL }}{{user.profile.image}}" alt="{{user.username}}"> <br> <div class="text-center"> <a href="" class="btn btn-default btn-rounded mb-4" data-toggle="modal" data-target="#modalRegisterForm">Edit Profile</a> <ul class="list-group"> <li class="list-group-item d-flex justify-content-between align-items-center"> <span><i class="fas fa-user-alt fa-lg"></i> Name:</span> {{ user.first_name }} {{user.last_name}} </li> <li class="list-group-item d-flex justify-content-between align-items-center"> <span><i class="fas fa-map-marker-alt fa-lg"></i> Address</span> {{ user.profile.address1 }}, {{ … -
Django FormView to redirect to a URL generated from the form input
I've been trying to write a view in Django for this purpose but nothing has worked yet, so I'm not sure what the right approach is. Basically i want to have one page /request with the fields string1 and string2 and a button 'submit' And after submitting it redirects to another page results/{string1}/{string2} And i can use the two strings as variables on that page. Im running out of ideas what to try and i would be really happy if someone could help me out! -
Using Django admin interface with enumchoicefield
I'm attempting to use the Django (2.1.3) admin interface with the enumchoicefield package. All goes well with creating and executing the migration and starting Django, but when I try to add an instance to the model containing the EnumChoiceField I get: Exception Type: TypeError Exception Value: render() got an unexpected keyword argument 'renderer' Exception Location: /home/django/Env/rosella/lib/python3.5/site-packages/django/forms/boundfield.py in as_widget, line 93 Python Executable: /usr/local/bin/uwsgi Python Version: 3.5.2 Model code: from enumchoicefield import ChoiceEnum, EnumChoiceField ... class SystemStatus(ChoiceEnum): UNKNOWN = 'Unknown' OK = 'Ok' DOWN = 'Down' class Monitor(models.Model): ... status = EnumChoiceField(SystemStatus, default=SystemStatus.UNKNOWN) Question: Does enumchoicefield support the admin interface? Note: I tried doing enums using django_enumfield, but also ran into problems with the admin interface. -
Prevent html5 "required" attribute on Django required form fields
I've got a Django form with required fields, but I don't want them to render with the html required attribute because I want to control this from Javascript. How can I make the form render without the required attribute? -
Django - how to import fake data
I am looking to populate my Django database with fake data for testing. What is the best method to do this? -
How do you craete a django rest framework ListCreateAPIView?
I'm trying to implement functionality to upload a batch of records into a database using drf. This is my class in my api view. class BatchRecordModelViewSet(ListCreateAPIView): """ This is an API view to insert a batch of item counts. """ serializer_class = serializers.BatchRecordSerializer queryset = models.Record.objects.all() def create(self, request, *args, **kwargs): data = request.data some_data = request.user.profile.profile_id for rec in data: rec.update(some_data=some_data) serializer = self.get_serializer(data=data, many=True) if serializer.is_valid(): serializer.save() headers = self.get_success_headers(serializer.data) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) else: return Response(status=status.HTTP_400_BAD_REQUEST) This is my serializer that I am importing: class BatchRecordSerializer(serializers.ModelSerializer): item = RecordSerializer(many=True) class Meta: model = models.Record fields = ('field1', 'field2', 'field3', etc...) -
Post and save Django variable, doesn´t work
Hi, could someone please check how should I write correctly the views.py part? if I code: from django.shortcuts import render, redirect def shifts_table(request): print(request.POST['value']) return render(request, 'shifts_table.html', {}) ...at least the page runs, but if I code like below it doesn't, any idea why? Thank you. from django.shortcuts import render, redirect from django.contrib import messages def shifts_table(request): if request.method == 'POST': number = request.POST['value'] if number.is_valid(): number.save() return redirect('shifts_table.html') else: messages.success(request, ('Seems Like There Was An Error...')) return render(request, 'home.html', {}) else: return render(request, 'shifts_table.html', {}) home.html: <form action="{% url 'shifts_table' %}" method='POST'> {% csrf_token %} <label for='number'>Number:</label> <input type="number" name="value" placeholder="2020" required><br/> <button type="submit">submit</button> </form> urls.py: urlpatterns = [ path('', views.home, name='home'), path('shifts_table', views.shifts_table, name='shifts_table'), ] -
SSL not being recognized when accessing website without www
I'm deploying the website http://www.therentalmoose.com on a VPS (digital ocean) using the stack Django 1.11 Apache mySQL I've followed certbot tutorials from digital ocean (https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04), however, I'm with the following problems. on GOOGLE CHROME, whenever I access my website WITHOUT .www (http://therentalmoose.com) it shows a unsecure display as if SSL is not configured. However, it was configured multiple times. When I reach http://www.therentalmoose.com is works normally with SSL. Also, If I use MOZILLA, it works both normally (with or without www.) I have no clue of what's going on. My apache .conf file <IfModule mod_ssl.c> <VirtualHost *:443> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, …