Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
pass django HTML template variables to javascript file
First of all, I have read almost all the posts about passing Django HTML template variables to JS but I couldn't find any answer fitting my question. I am having a forloop generating forms, so I use django HTML template variables to make an ID for each new form, and i would like to use the ID of that form in a separate JS file. I can't figure out the best way to get these form IDs into my js file. Here is a piece of my HTML code..: {% if trains.count > 1 %} <h2><b>You have worked on {{ trains.count }} trains today. Affect the cars you have worked on today to the trains:</b></h2> {% for train in trains %} <h3><b>{{ train }}</b></h3> <form method="POST" id="affect_car_{{train}}" action="{{'AffectedCar'}}" class="form-style-5"> {% csrf_token %} <select class="limitedNumbSelect2" id="car-list" multiple="true" required style="width: 400px;"> {% for car in cars %} <option value="{{car.id}}" name="{{car.id}}" id={{car.id}}>{{car.name}}</option> {% endfor %} </select> </form> {% endfor %} {% endif %} I saw some people doing it by declaring a var in a script inside the html template, but how would I know how many of them are existing when in the JS part? Thanks for your help! -
Heroku: installing Postgres without local db | Django
I've already pushed my Django files to Heroku via Git and now I'd like to configure at Heroku server the Postgres database. After that, I need to transfer my local sqlite database to Heroku Postgres. All of this issue is because I don't have admin rights on my local PC (corporate unit) to install Postgres. So basically: 1. Configure remotely Postegres at Heroku; 2. Migrate local database (sqlite) to Heroku (Postgres). I don't know if there is another path to go on... Thank you! -
Django Models - One to Many or Many o Many
In Django there are no One-to-Many relationships, there are just Many-to-One. In cases where defining Foreign Key on the child table is odd, should we go for Many-to-Many? For example: Book has many pages. If we define foreign key on the Page model, then the page has one book which is not an intuitive thing to do (or say). OPTION 1: class Book(models.Model): name = models.CharField(max_length=100) date_published = models.DateTimeField(default=timezone.now) class Page(models.Model): page_number = models.IntegerField() page_text = RichTextField() book = models.ForeignKey(Book, on_delete=models.CASCADE) OPTION 2 class Book(models.Model): name = models.CharField(max_length=100) date_published = models.DateTimeField(default=timezone.now) pages = models.ManytoMany(Page) class Page(models.Model): page_number = models.IntegerField() page_text = RichTextField() In option2 I can access the pages of the book by book.pages. In option 1 I don't know how to access the pages, maybe book.pages_set.objects.all() which is not pretty. I asked a fellow programmer and he said just use Many-to-Many. I understand what each approach means and I also understand the difference between the two as to what's happening in the database. My question is what is a better/standard approach. -
How to use the django-rest-captcha in client and server?
The django-rest-captcha docs provide the simple usage of it, but I still have questions, how to use it in detail. in client, there is the example: curl -X POST http:localhost:8000/api/captcha/ | python -m json.tool { 'image_type': 'image/png', 'image_decode': 'base64', 'captcha_key': 'de67e7f3-72d9-42d8-9677-ea381610363d', 'captcha_value': '... image encoded in base64' } we know we can use the captcha_value to generate the image, and send the { username, password, captcha_key, captcha_value (the text of generated image shows) } to server. but the docs do not have a RegisterView example, I do not understand how to use it. At present, my code is like this: serialisers.py: UserModel = get_user_model() class UserSerializer(serializers.ModelSerializer): password = serializers.CharField(write_only=True) def create(self, validated_data): user = UserModel.objects.create( username=validated_data['username'] ) user.set_password(validated_data['password']) user.save() return user class Meta: model = UserModel # Tuple of serialized model fields (see link [2]) fields = ( "id", "username", "password", ) views.py from django.contrib.auth import get_user_model # If used custom user model from .serializers import UserSerializer class CreateUserView(CreateAPIView): model = get_user_model() permission_classes = [ permissions.AllowAny # Or anon users can't register ] serializer_class = UserSerializer how to change my view? -
Django: For each loop with counter that loads queryset in small sets
I am building an online store that displays cards containing products passed into the template as a queryset. The list of products will get large so I want to implement an incremental load that starts with 10 products and there is a button to load 10 more... and that would continue until eventually all the products are displayed. I currently have a for each loop in the template and I was wondering what the best approach would be to add some sort of counting mechanism into the loop so that I am able to achieve the incremental load. Any idea how I can do this? views.py def products_page_all(request): resetDefaultFilters() products = Product.objects.order_by('?') args = { 'products': products, } return render(request, 'store/products-page.html', args) products-page.html ... {% for product in products %} <-- I want this to only iterate for 10 products at a time <a href="{% url 'store-view-item' product.product_id %}"> <div class="col-lg-3 col-md-4 col-sm-6 col-xs-4 my-auto"> <div class="card h-100 rounded-0 border-0"> <div class="img-wrapper"> <div class="image"> <img src="{{ product.product_image.url }}"> </div> </div> <div class="card-body text-center"> <h4 class="card-title"> <a id="product-name">{{ product.product_name }}</a> </h4> <p id="seller-name">// {{product.seller.seller_listing_name }} //</p> <p class="card-text" id="product-description">{{ product.description_short }}</p> <h5 id="product-price">${{ product.price | floatformat:2 }}</h5> </div> </div> </div> </a> … -
Django - Bizarre behavior of reverse() in tests
I've been stuck on the following bug for about an hour and I can't figure out what is happening. Consider the following: class BoardViewTests(TestCase): def setUp(self): self.user = User.objects.create_user( username='testuser', email='test@test.com', password='very_secret', ) self.user.refresh_from_db() self.test_board = Board.objects.create(name='test board', description='board test description') self.test_topic = Topic.objects.create(name='test topic', board=self.test_board, starter=self.user.profile) def test_board_view_shows(self): response = self.client.get(reverse('boards:board', args=('testboard',))) # Slug value here is 'test-board' # (Tested with print statement) self.assertEquals(response.status_code, 200) self.assertContains(response, 'test board') self.assertContains(response, 'board test description') ... and the following url conf: app_name = 'boards' urlpatterns = [ path('', views.index, name='index'), path('boards', lambda request: redirect(reverse('boards:index'), permanent=True)), path('boards/<slug:board_slug>', views.board, name='board'), path('boards/<slug:board_slug>/<int:topic_id>', views.topic, name='topic'), ] When I run the test, it gives me the following exception: django.urls.exceptions.NoReverseMatch: Reverse for 'topic' with arguments '('test board', 1)' not found. 1 pattern(s) tried: ['boards/(?P<board_slug>[-a-zA-Z0-9_]+)/(?P<topic_id>[0-9]+)$'] What happens to the hyphen, and why is there a 1 in the arguments it shows? Since there are now supposedly 2 arguments, it tries matching against the next path ('topic'). I've tried replacing the argument by 'test-board' and I get the same output. When I use any string without hyphens, the problem doesn't occur: the url is correctly matched and the assert fails because it is a 404. Also worth noting that everything … -
why codecanyon just have 1 django project?
I search a lot of places to buy djnago project same like php which is sold in codecanyon but i am surprised there is only 1 project in codecanynon . I also tried to look a site who sells djnago proejct but i do not see any website . I want to know why is that or there is legal issue behind it. -
Create-react-app: unhandled error event: Events.js.187
'm trying to create a new react app with yarn. after using the command create-react-app i keep getting an error unhandled events error. There's also a reference to django-admin.py in the error log for some reason and I can't make out the connection.Can i get some assistance. the log of the error is shown below Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts... events.js:187 throw er; // Unhandled 'error' event ^ Error: spawn C:\Windows\system32\cmd.exe;C:\Users\HP\AppData\Local\Programs\Python\Python36\Scripts\django-admin.py ENOENT [90m at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)[39m [90m at onErrorNT (internal/child_process.js:456:16)[39m [90m at processTicksAndRejections (internal/process/task_queues.js:80:21)[39m Emitted 'error' event on ChildProcess instance at: at ChildProcess.cp.emit (C:\Users\HP\AppData\Local\Yarn\Data\global\node_modules\[4mcross-spawn[24m\lib\enoent.js:34:29) [90m at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)[39m [90m at onErrorNT (internal/child_process.js:456:16)[39m [90m at processTicksAndRejections (internal/process/task_queues.js:80:21)[39m { errno: [32m'ENOENT'[39m, code: [32m'ENOENT'[39m, syscall: [32m'spawn C:\\Windows\\system32\\cmd.exe;C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\django-admin.py'[39m, path: [32m'C:\\Windows\\system32\\cmd.exe;C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\django-admin.py'[39m, spawnargs: [ [32m'/d'[39m, [32m'/s'[39m, [32m'/c'[39m, [32m'"npm ^"install^" ^"--save^" ^"--save-exact^" ^"--loglevel^" ^"error^" ^"react^" ^"react-dom^" ^"react-scripts@0.9.x^""'[39m ] } C:\Users\HP\Documents\web dev\Angular 2>cd C:\Users\HP\Documents\web dev\Angular 2create-react-app my-app -
Django best why to Implement Memcached in blog site
I am using python/Django in my project with Memcache. I just want to know what is best why to Memcache Implement Memcache in the Django blog site. -
Django Default Css missing
I've reading the old posts about the CSS missing in Django projects but I didn't find the answer to my problem. I didn't make any change in any static file from the beginning of the building of the API and suddenly the HTML stopped to get the CSS properties. What can happen for this behavior? I also tried with python manage.py collectstatic after setting the STATIC_URL, STATIC_ROOT like it is mentioned in other post. If you need a code let me know please, I didn't find any possible clue. -
“I/O operation on closed file” error when trying to open uploaded file django 2.2.12
Unable to open uploaded image when using Django2.2.12, I am facing an error "ValueError: I/O operation on closed file". Type of image is InMemoryUploadedFile Here my code: default_storage.save(uploaded_image.name, uploaded_image) -
How replace an old image for another new image in django models?
I want to replace old image from django models by new image. This is my models.py: class ProfileImage(models.Model): image_id = models.IntegerField(null=True, blank=True) profile_image = models.ImageField(upload_to='images/', null=True, blank=True) -
Django Forms Setting field max_length attribute in __init__() not working
I asked a similar question before regarding this and I currently have a working version that does it another way. However it seems like a lot more code then I need to and I am suppose to be able to set this attribute at init. Here is forms.py def get_automation_form(content, data=None, files=None, initial=None): class AutomationForm(forms.ModelForm): if 'text_field01' in content[1].keys(): text_field01 = forms.CharField(max_length=content[2]['text_field01'], label=content[1]['text_field01']) if 'text_field02' in content[1].keys(): text_field02 = forms.CharField(max_length=content[2]['text_field02'], label=content[1]['text_field02']) if 'text_field03' in content[1].keys(): text_field03 = forms.CharField(max_length=content[2]['text_field03'], label=content[1]['text_field03']) if 'text_field04' in content[1].keys(): text_field04 = forms.CharField(max_length=content[2]['text_field04'], label=content[1]['text_field04']) if 'text_field05' in content[1].keys(): text_field05 = forms.CharField(max_length=content[2]['text_field05'], label=content[1]['text_field05']) if 'text_field06' in content[1].keys(): text_field06 = forms.CharField(max_length=content[2]['text_field06'], label=content[1]['text_field06']) if 'text_field07' in content[1].keys(): text_field07 = forms.CharField(max_length=content[2]['text_field07'], label=content[1]['text_field07']) if 'text_field08' in content[1].keys(): text_field08 = forms.CharField(max_length=content[2]['text_field08'], label=content[1]['text_field08']) if 'text_field09' in content[1].keys(): text_field09 = forms.CharField(max_length=content[2]['text_field09'], label=content[1]['text_field09']) if 'text_field10' in content[1].keys(): text_field10 = forms.CharField(max_length=content[2]['text_field10'], label=content[1]['text_field10']) class Meta: model = Automation fields = content[0] labels = content[1] widgets = { 'color1': ColorWidget, 'color2': ColorWidget, 'color3': ColorWidget, 'color4': ColorWidget, 'color5': ColorWidget, } def __init__(self, *args, **kwargs): super(AutomationForm, self).__init__(data=data, files=files, initial=initial, *args, **kwargs) for key, value in content[3].items(): self.fields[key].required = value # for key, value in content[2].items(): # print(key) # print(type(value)) # self.fields[key].max_length = value # print(self.fields[key]) # print(self.fields[key].max_length) return AutomationForm() At the … -
Django Blog Not all Data being imported
I am currently working on my first django project "not following a tutorial". I'm creating a blog and trying to get all my pictures & post data to import into post. I am getting some info to import, but not all. Specifically, my images and date are not getting populated into post. views.py -------------------------------- def home(request): context= { 'posts' : Post.objects.all(), 'comment': Comment.objects.all(), } return render(request, 'blog/home.html', context) def base(request): return render(request, 'blog/test.html') class ArticleDetailView(DetailView): model = Post template_name = 'blog/standard.html' ------ my html page {% extends 'blog/base.html' %} {% load static %} {% block content %} <section class="main-content"> <div class="padding"> <div class="container"> <div class="row"> <div class="col-sm-8"> <div class="single-post"> <div class="type-standard"> <article class="post type-post"> <div class="top-content text-center"> <span class="category"><a href="categories.html">{{ post.category }}</a></span><!-- /.category --> <h2 class="entry-title"><a href="standard.html">{{ post.title }}</a></h2><!-- /.entry-title --> <span class="time"><time>{{ post.date_posted|date:"F d, Y" }</time></span><!-- /.time --> </div><!-- /.top-content --> <div class="entry-thumbnail"><img src="{post.image.url }"></div><!-- /.entry-thumbnail --> <div class="entry-content"> {{ post.content }} <div class="post-meta"> <span class="comments pull-left"><i class="icon_comment_alt"></i> <a href="#">4 Comments</a></span><!-- /.comments --> <span class="post-social pull-right"> <a href="#"><i class="fa fa-instagram"></i></a> <a href="#"><i class="fa fa-facebook"></i></a> <a href="#"><i class="fa fa-twitter"></i></a> <a href="#"><i class="fa fa-pinterest-p"></i></a> </span><!-- /.post-social --> </div><!-- /.post-meta --> </div><!-- /.entry-content --> </article><!-- /.post --> </div><!-- /.type-standard --> <div class="author-bio … -
how to set a string value as a default value of a float field in django models
i couldn't set a string value as default in a float field here is my code class Product(models.Model): Name = models.CharField(max_length=700, null=True) Price = models.FloatField(null=True) Screen_size = models.FloatField(max_length=300, blank=True ,default="Not mentioned by the seller" , null=True) Focus_type = models.CharField(max_length=300, blank=True ,default="Not mentioned by the seller" , null=True) and when i try to run the code it says ValueError: Field 'Screen_size' expected a number but got 'Not mentioned by the seller'. -
Token Authentication IsAuthenticatedOrReadOnly in Django api
I'm using token to authenticate but I want that people not authenticated can see the content, which means have the GET METHOD. class EstacionViewSet(viewsets.ModelViewSet): queryset = Estacion.objects.all() serializer_class = EstacionSerializer permission_classes = [permissions.IsAuthenticatedOrReadOnly,] filter_backends = (filters.DjangoFilterBackend,) I'm using this kind of views but using this permissions I cant get access to read when I do a GET request. It says that the credentials where not provided which is true but it should be able to read the content of the urls in the api. Do you know a way to implement the ReadOnly if it not authenticated with the token? -
How to create table of forms in Django
Is there a way to create a table of forms in Django? For example. If I had a model: class Decisions(models.Model): meeting = models.ForeignKey(Meeting, on_delete=models.CASCADE) decision = models.TextField(max_length=1000,) decisionDate = models.DateTimeField(default = timezone.now, editable = False complete = models.BooleanField(default = False) I have created a form so that I can edit each individual record of Decisions, but this is time consuming each time I want to edit multiple records. How can I create an html table of forms so that I can edit these records in one view. Something like: <form method="post" enctype="multipart/form-data"> {% csrf_token %} <table> <tr> <th>decision</th> <th>complete?</th> </tr> {% for item in form %} <tr> <td>{{ item.decision }}</td> <td>{{ item.complete }}</td> </tr> {% endfor %} </table> <button type="submit">Update</button> </form> I just don't know where to start with the view creation. Is it best to use a function based view for this? I attempted to use the Class based generic UpdateView but it requires a pk to know what record it is editing, and in my case it is many. Any guidance is appreciated! Thanks -
Django change default hash algrithm to sha256
I wanna authme minecraft plugin integration with django app and my question is "how to change django hash algorithm to pure sha256" -
How do I override the results from an django API query
I'm very new to Django, so this might seem basic. I have 2 models: class Brand(models.Model): brand_name = models.CharField() class Foo(models.Model): brand = models.ForeignKey(Brand, null=True) foo_name = models.CharField() Foo.brand can be null. Now when an API query is made on Foo, I want to include results where the brand's name matches but also where Foo.brand is null If Foo looks like this: Foo.brand, Foo.foo_name 1, "apple" 3, "orange" 1, "mango" null, "grape" /api/foo?brand=1 should return apple, mango and grape. How can I get this? I tried reading similar questions, it sounds like I need to override the viewset, but wasn't sure. Thanks. -
Exception when running Django 2.2 runserver using python 3.7.4
Exception happened during processing of request from ('127.0.0.1', 65512) Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in init self.handle() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle self.handle_one_request() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 54] Connection reset by peer -
Django To remove quotation marks
I made a simple web page using the Django. I get the data from mysql, and mysql db. There are always quotation marks ' at the beginning and at the end. I want to remove quotation marks and display the values. Do I need to modify views.py? Or should I modify html? Please tell me how to get rid of the quotation marks Thank you for your reply in advance. my views from django.shortcuts import render from django.http import HttpResponse from .models import Macro # Create your views here. def cmacroMacro(request): macro_data = Macro.objects.get(pk=request.GET.get('pk',1)) context = {'macro_data':macro_data} return render(request, 'macrof/registerMacro.html', context) my html <div>contents</div> <textarea cols="70" id="contents" placeholder="본문내용">{{ macro_data.contents }}</textarea> <div>review</div> <textarea cols="70" id="review" placeholder="상품평">{{ macro_data.review }}</textarea> <div>link</div> <textarea cols="70" id="link" placeholder="쿠팡링크">{{ macro_data.link }}</textarea> my models.py contents = models.CharField(max_length=500) product_i = models.CharField(max_length=1000) review = models.CharField(max_length=10000) link = models.CharField(max_length=500) -
Django allauth: Remove form label from inherited form field?
Problem I'm building a registration page using Django with allauth. I am trying to remove the 'E-mail' label from the email field. What I've tried I've removed the labels from First Name and Last Name by adding label='' to their fields (as was recommended in similar questions). For some reason, this is not working for the email field. My forms.py: class CustomSignupForm(SignupForm): first_name = forms.CharField(max_length=30, label="", widget=forms.TextInput(attrs={'placeholder': 'First Name'})) last_name = forms.CharField(max_length=30, label="", widget=forms.TextInput(attrs={'placeholder': 'Last Name'})) email = forms.EmailField(label='', widget=forms.TextInput(attrs={'placeholder': 'Email'})) def signup(self, request, user): user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] user.email = self.cleaned_data['email'] user.save() return user I've also tried: email = forms.EmailField(label='', widget=forms.TextInput(attrs={'type': 'email', 'placeholder': 'E-mail address'})) Below is the allauth forms.py that the form is inheriting from: class BaseSignupForm(_base_signup_form_class()): username = forms.CharField(label=_("Username"), min_length=app_settings.USERNAME_MIN_LENGTH, widget=forms.TextInput( attrs={'placeholder': _('Username'), 'autofocus': 'autofocus'})) email = forms.EmailField(widget=forms.TextInput( attrs={'type': 'email', 'placeholder': _('E-mail address')})) def __init__(self, *args, **kwargs): email_required = kwargs.pop('email_required', app_settings.EMAIL_REQUIRED) self.username_required = kwargs.pop('username_required', app_settings.USERNAME_REQUIRED) super(BaseSignupForm, self).__init__(*args, **kwargs) username_field = self.fields['username'] username_field.max_length = get_username_max_length() username_field.validators.append( validators.MaxLengthValidator(username_field.max_length)) username_field.widget.attrs['maxlength'] = str( username_field.max_length) default_field_order = [ 'email', 'email2', # ignored when not present 'username', 'password1', 'password2' # ignored when not present ] if app_settings.SIGNUP_EMAIL_ENTER_TWICE: self.fields["email2"] = forms.EmailField( label=_("E-mail (again)"), widget=forms.TextInput( attrs={ 'type': 'email', 'placeholder': _('E-mail address confirmation') } … -
Changing from int:pk to Slug
After finalizing my blog project I found out a way a switch from writing the id of the blog to writing a function to add the post title to become a slug. So I am currently trying to switch all my post detail to slug but after I finished everything I am getting a page error 404 which doesn't indicate exactly where I have something wrong with my code. My question is when I move from changing the urls from int:id to slug what should I be looking for to change as well to avoid page error 404? In the URL for every page detail I am getting the int:id not the title of the post and the error 404 I have commented the addition of the slug function: Here is the models.py : class Post(models.Model): designer = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=100) likes = models.ManyToManyField( User, related_name='liked') slug = models.SlugField(blank=True, null=True, max_length=120) def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(self.title) super(Post, self).save(*args, **kwargs) Here is the views.py class PostDetailView(DetailView): model = Post template_name = "post_detail.html" def get_context_data(self, *args, **kwargs): context = super(PostDetailView, self).get_context_data() stuff = get_object_or_404(Post, id=self.kwargs['slug']) total_likes = stuff.total_likes() liked = False if stuff.likes.filter(id=self.request.user.id).exists(): liked = … -
Target WSGI scriptcannot be loaded as Python module
I am looking for some help in migrating a web app from local machine to apache server. -Python 3.7 -Django 2.1 -Apache 2.4 I also have a virtualenvironment created for the FleetManagRApp. My httpd.conf looks like this. LoadFile "c:/python36/python36.dll" LoadModule wsgi_module "c:/python36/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd" WSGIPythonHome "c:/python36" Listen 9981 <VirtualHost *:9981> WSGIScriptAlias / "E:/DjangoSite/WebApps/WebApps/wsgi.py" Alias /static "E:/DjangoSite/WebApps/FCApp/static" <Directory "E:/DjangoSite/WebApps/FCApp/static"> Require all granted </Directory> <Directory "E:/DjangoSite/WebApps/WebApps"> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> Listen 3456 <VirtualHost *:3456> path="E:/FleetManagRDjango/FleetManagRApp/" WSGIScriptAlias / "E:/FleetManagRDjango/FleetManagRApp/FleetManagRApp/wsgi.py" Alias /static "E:/FleetManagRDjango/FleetManagRApp/PMApproval/static" <Directory "E:/FleetManagRDjango/FleetManagRApp/PMApproval/static"> Require all granted </Directory> <Directory "E:/FleetManagRDjango/FleetManagRApp/FleetManagRApp"> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> wsgi.py looks like below import os import sys path = 'E:/FleetManagRDjango/FleetManagRApp' # use your own username here if path not in sys.path: sys.path.append(path) from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'FleetManagRApp.settings') application = get_wsgi_application() Error Log mod_wsgi (pid=21464): Target WSGI script 'E:/FleetManagRDjango/FleetManagRApp/FleetManagRApp/wsgi.py' cannot be loaded as Python module. mod_wsgi (pid=21464): Exception occurred processing WSGI script 'E:/FleetManagRDjango/FleetManagRApp/FleetManagRApp/wsgi.py'. Traceback (most recent call last):\r File "c:\\python36\\lib\\site-packages\\django\\db\\utils.py", line 115, in load_backend\r return import_module('%s.base' % backend_name)\r File "c:\\python36\\lib\\importlib\\__init__.py", line 126, in import_module\r return _bootstrap._gcd_import(name[level:], package, level)\r File "<frozen importlib._bootstrap>", line 994, in _gcd_import\r File "<frozen importlib._bootstrap>", line 971, in _find_and_load\r File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked\r File "<frozen importlib._bootstrap>", … -
when I use http://dev.example.com with django-sites framework, do I need to create all subdomains inside site?
I was Testing django-sites framework, do I need to create a site for the full address? I have tried inserting only example.com in sites then if I try dev.example.com is not working. is It right?