Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Docker Compose - https with Nginx/Gunicorn
I have the following Nginx config and docker-compose.yaml. Before I adding the following block, server { listen 443; server_name localhost; ssl on; ssl_certificate /etc/nginx/conf.d/privkey.pem; ssl_certificate_key /etc/nginx/conf.d/mynginx.key; location / { proxy_pass http://web/; } } everything thru HTTP works fine. After I added the above code block, everything stopped working, I can't access the site thru HTTP/HTTPS. mynginx.conf upstream web { ip_hash; server web:8000; } # portal server { location / { proxy_pass http://web/; } listen 8000; server_name localhost; } # portal (https) server { listen 443; server_name localhost; ssl on; ssl_certificate /etc/nginx/conf.d/privkey.pem; ssl_certificate_key /etc/nginx/conf.d/mynginx.key; location / { proxy_pass http://web/; } } docker-compose.yaml ubuntu@ip-172-31-9-162:~/django_docker$ cat docker-compose.yml version: '2' services: nginx: image: nginx:latest container_name: ng01 ports: - "80:8000" - "443:443" volumes: - ./src:/src - ./config/nginx:/etc/nginx/conf.d depends_on: - web web: build: . container_name: dg01 command: bash -c "python manage.py makemigrations && python manage.py migrate && gunicorn composeexample.wsgi -b 0.0.0.0:8000" depends_on: - db volumes: - ./src:/src expose: - "8000" db: image: postgres:latest container_name: ps01 Folder Structure . ├── config │ ├── nginx │ │ ├── mynginx.conf │ │ ├── mynginx.conf~ │ │ ├── mynginx.crt │ │ ├── mynginx.key │ │ └── privkey.pem │ └── requirements.pip ├── docker-compose.yml ├── docker-compose.yml~ ├── Dockerfile └── src ├── composeexample … -
Insert JSON data into database for python
I'm currently doing a system that scrap data from foursquare. Right now i have scrap the review from the website using python and beautiful soup and have a json file like below {"review": "From sunset too variety food u cant liked it.."}{"review": "Byk motor laju2"}{"review": "Good place to chill"}{"review": "If you wan to play bubble and take photo, here is the best place"}{"review": "Scenic view for weekend getaway... coconut shake not taste as original klebang coconut shake..."}{"review": "Getting dirtier"}{"review": "Weekend getaway!"}{"review": "Good for casual walk & watching sunset with loved ones since my last visit macam2 ade kat sini very packed during public holidays"}{"review": "Afternoon time quite dry..beach is normal. Maybe evening/night might be better. The coconut shake they add vanilla ice cream,hmmm"}{"review": "Pantai awesome beb"}{"review": "Nice place for picnic"}{"review": "Cannot mandi here. Good place for recreation.. Calm place for weekdays! Haha"}{"review": "Very bz place. Need to go there early if you want to lepak. If not, no parking for you"}{"review": "So many good attraction here, worth a visit"}{"review": "Beautiful place for sunset"}{"review": "New beach! Like all beaches, awesome view & windy. Some stretch got many small crabs."}{"review": "There is bustel \"hotel in a bus\" can get coconut shake or … -
Django multitenant: how to customize django setting "ACCOUNT_EMAIL_VERIFICATION" per tenant?
Django==1.11.7 django-tenant-schemas==1.8.0 django-allauth==0.34.0 Multi tenant site using django-tenant-schemas (postgres). On different tenants, different settings are required. More specifically, different setting is required for ACCOUNT_EMAIL_VERIFICATION 1 tenant needs ACCOUNT_EMAIL_VERIFICATION = "optional" while another one needs ACCOUNT_EMAIL_VERIFICATION ="mandatory" Looking in the source code, the setting looks not customisable, it is fixed for the whole django site. -> How can this be done? -
How to access an entire table row based on annotation with Max()
I have a model that stores the cover images for different magazines (publications). In a simplified version it looks like this class Publication(models.Model): name = models.CharField(max_length=100) website = models.CharField(max_length=100) class PublicationIssue(models.Model): publication = models.ForeignKey(Publication, null=False) issue_number = models.IntegerField(null=False) cover_image = models.CharField(max_length=100) In SQL I can execute something like this: select publication_id, max(issue_number) current_issue, cover_image from conditionalsum_publicationissue group by publication_id This looks for the max issue number for a publication and easily gives me the current issue number and the associated cover image. The output looks something like this: publication_id current_issue cover_image 1 12 ae43fb33.jpg 2 26 445fbb45.jpg 3 213 db8489e3.jpg I know I can use rawsql in a Django query, but I wanted to see if there are solutions that avoid this. It's easy enough to get the current issue: PublicationIssue.objects. \ values('publication_id'). \ annotate(current_issue=Max('issue_number')) This returns the publication_id with the current_issue. But this look like a dead end as far as adding the cover_image. Adding 'cover_image' to the values clause does not work and any further annotation will similarly expand the queryset in ways incorrect for my purposes. I have attempted going with a subquery, but that is getting fairly long and complicated for a relatively simple SQL statement. … -
Select related many-to-many field in Django in model
I have the following classes in my model: class Dish(models.Model): name = models.CharField(max_length=200) def get_ingredients(self): return #what to return? class DishIngredient(models.Model): dish = models.ForeignKey(Dish, on_delete=models.PROTECT) ingredient = models.ForeignKey(Ingredient, on_delete=models.PROTECT) number_of_units = models.IntegerField('number of units') class Ingredient(models.Model): name = models.CharField(max_length=100) unit = models.ForeignKey(Unit, on_delete=models.PROTECT) I want Dish.get_ingredients() to return DishIngredient.number_of_units, Ingredient.name, Ingredient.unit Anybody know how to do this? -
Populating a form field in a view
I am working on an imageboard application, which has two views. An index view and a thread view. Views.py def ThreadView(request, thread_id): template = loader.get_template('thread.html') form = MessageForm(request.POST) if request.method == 'POST': #form = MessageForm(initial={'thread': thread_id}) #form.fields['thread'].initial = thread_id if form.is_valid(): form.save() form = MessageForm() else: form = MessageForm() context = { 'message': Thread.objects.get(id=thread_id), 'replies': Message.objects.all().filter(thread=thread_id), 'form':form } return HttpResponse(template.render(context, request)) Models.py class Thread(models.Model): msg = models.TextField(max_length=9001) timestamp = models.DateTimeField(auto_now_add=True) class Message(models.Model): msg = models.TextField(max_length=9001) timestamp = models.DateTimeField(auto_now_add=True) thread = models.ForeignKey('Thread', on_delete=models.CASCADE) Forms.py class ThreadForm(forms.ModelForm): class Meta: model = Thread fields = [ 'msg' ] class MessageForm(forms.ModelForm): class Meta: model = Message fields = [ 'msg' ] The problem is this: Message model has a foreign key to Thread model, and when I am posting to a certain thread, I need to prepopulate the "thread"-field in Message model with thread_id in views.py (because a message has to belong to a certain thread). The two lines that I have commented out are my attempts of passing the field value to a form, both unsuccessful. Is this even possible in function-based views? (Python 3, Django 2.0) I'm sorry if I missed something, I'm really tired of coding all day. Feel free to … -
Django, Validation Error not showing up in template
I was creating a form to register users, I added the validation error to check if the email already exists in the database. However, when you feed in an email which is already in the database, the form doesn't show up the error, it just resets. forms.py: class SignUpForm(UserCreationForm): institute = forms.CharField(max_length=255) def __init__(self, *args, **kwargs): super(SignUpForm, self).__init__(*args, **kwargs) # Making name required self.fields['email'].required = True self.fields['first_name'].required = True self.fields['last_name'].required = True class Meta: model = User fields = ('first_name', 'last_name', 'username', 'email', 'password1', 'password2', 'institute' ) def clean_email(self): email = self.cleaned_data.get('email') try: match = User.objects.get(email=email) except User.DoesNotExist: return email raise forms.ValidationError("Cannot use this email. It's already registered") return email And this is my views.py: def register(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() # load the profile instance created by the signal user.profile.institute = form.cleaned_data.get('institute') print(user.profile.institute) user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return render(request,'home.html') form = SignUpForm() context = { 'form' : form, } return render(request,'register.html', context) I am using crispy forms -
Django Comments: How to update page based on model instance returned by successful post?
When a user posts a new comment, I want to display that comment immediately on the page with information derived from the new comment model instance. (For example, including a live 'favorite' button that requires the instance id) I know that when Django Comments successfully posts content to the {% comment_form_target %} url it performs the comment_was_posted signal. How do I capture this signal so that the I can insert html featuring information from this model instance into the page? If I was doing this with ajax, I would pass the model instance or its pk back as part of the success message. But I don't know how to do this with the django comments library. -
How to write a custom template for paginated data in Django Rest Framework?
With Django Rest Framework, I'm trying to write a custom template for paginated list of snippets. I understand that list function in my view must return paginated response. So I get the page first and send the paginated response. However how can I specify the template name? get_paginated_response does not have template_name argument. Code: def list(self, request): page = self.paginate_queryset(self.queryset) if page is not None: serializer = self.get_serializer(page, data=request.data) serializer.is_valid() # fct has no template_name argument! return self.get_paginated_response(serializer.data) -
Django: No Such Table
I'm running into an error while trying to extend my user model. I have a model created that takes in some more fields that I would like to be attached to the user as seen here: accounts/models.py class Customer(models.Model): US_STATES_OR_CAN_PROVINCES = ( ('AK', 'Alaska'), ('AL', 'Alabama'), ('AR', 'Arkansas'), ('AS', 'American Samoa'), ('AZ', 'Arizona'), ('CA', 'California'), ('CO', 'Colorado'), ('CT', 'Connecticut'), ('DC', 'District of Columbia'), ('DE', 'Delaware'), ('FL', 'Florida'), ('GA', 'Georgia'), ('GU', 'Guam'), ('HI', 'Hawaii'), ('IA', 'Iowa'), ('ID', 'Idaho'), ('IL', 'Illinois'), ('IN', 'Indiana'), ('KS', 'Kansas'), ('KY', 'Kentucky'), ('LA', 'Louisiana'), ('MA', 'Massachusetts'), ('MD', 'Maryland'), ('ME', 'Maine'), ('MI', 'Michigan'), ('MN', 'Minnesota'), ('MO', 'Missouri'), ('MP', 'Northern Mariana Islands'), ('MS', 'Mississippi'), ('MT', 'Montana'), ('NA', 'National'), ('NC', 'North Carolina'), ('ND', 'North Dakota'), ('NE', 'Nebraska'), ('NH', 'New Hampshire'), ('NJ', 'New Jersey'), ('NM', 'New Mexico'), ('NV', 'Nevada'), ('NY', 'New York'), ('OH', 'Ohio'), ('OK', 'Oklahoma'), ('OR', 'Oregon'), ('PA', 'Pennsylvania'), ('PR', 'Puerto Rico'), ('RI', 'Rhode Island'), ('SC', 'South Carolina'), ('SD', 'South Dakota'), ('TN', 'Tennessee'), ('TX', 'Texas'), ('UT', 'Utah'), ('VA', 'Virginia'), ('VI', 'Virgin Islands'), ('VT', 'Vermont'), ('WA', 'Washington'), ('WI', 'Wisconsin'), ('WV', 'West Virginia'), ('WY', 'Wyoming'), ('AB', 'Alberta'), ('BC','British Columbia'), ('MB', 'Manitoba'), ('NB', 'New Brunswick'), ('NL', 'Newfoundland and Labrador'), ('NT', 'Northwest Territories'), ('NS', 'Nova Scotia'), ('NU', 'Nunavut'), ('ON', 'Ontario'), ('PE', 'Prince Edward Island'), … -
Using PK2 in a context where pk2 is not available
I am having an issue I am not sure how to solve. I have a two page one which is a user list with a "detail" link that lead to the user detail view. In that user detail view I make some calculation in my views using the pk2 of the user in the url in the form http://127.0.0.1:8000/website/project/applicant/57/44 where pk1= 57 is the current project and pk2 = 44 which represent the user. Now in my list view I would like to show that score that was calculate in the detail page. my html look like this : <table class="table table-hover"> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Survey Date</th> <th>Score</th> <th>Team Score</th> <th>Details</th> </tr> </thead> <tbody> {% for i in app_with_resp %} <tr> <td>{{i.first_name}}</td> <td>{{i.last_name}}</td> <td>17/06/86</td> <td>{{applicant_score}}</td> <td>{{team_score}}</td> <td> <a href="{% url 'website:CandidateDetails' pk1=current_project_id pk2=i.id %}"> Details</a></td> </tr> {% endfor %} </tbody> </table> my view is the following: class RecruitmentPage(generic.ListView): #import pdb; pdb.set_trace() model = Project template_name = "recruitment_index.html" def get_object(self, queryset=None): return get_object_or_404(Project, id=self.kwargs['pk1']) def get_context_data(self, **kwargs): context = super(RecruitmentPage, self).get_context_data(**kwargs) current_project_id = self.kwargs['pk1'] applicant_list = Project.objects.get(id = current_project_id).applicant.all() team_score = get_team_cohesivenss_score(self)[0] # applicant_score =get_applicant_cohesivenss_score(self)[0][0] # diff_score = get_applicant_cohesivenss_score(self)[0][0] - get_team_cohesivenss_score(self)[0] app_with_resp = [] app_without_resp = [] for … -
Override form widget and/or Form for ManyToMany TabularInline
Suppose I had two models as follows (example from Django Docs) from django.db import models class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, related_name='groups') And the following admin panel: from django.contrib import admin class MembershipInline(admin.TabularInline): model = Group.members.through class PersonAdmin(admin.ModelAdmin): inlines = [ MembershipInline, ] class GroupAdmin(admin.ModelAdmin): inlines = [ MembershipInline, ] exclude = ('members',) Now, suppose that my database built up over the years, and I have lots and lots of Persons, but very little Groups. So for Groups, I can use the default widget, but I need a custom widget for Person inside GroupAdmin. My question is, inside MembershipInline, how do I modify it so that the Person's widget is overridden? I know this is possible with django-autocomplete-light for ForeignKey admin.TabularInlines, but how do I modify this to come up with something for ManyToMany admin.TabularInlines? In other words, how do I modify the form going one way but not the other? -
Get server URL in django docker
I am running Django project in docker. I have 3 docker container. For Django App For Postgres For Nginx My docker-compose.yml file is as follow version: "3" services: db: restart: always container_name: tts-db image: postgres:9.6 environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - POSTGRES_DB=tts expose: - "5432" nginx: image: nginx:latest container_name: tts-nginx ports: - "8000:8000" volumes: - ./nginx/site-enabled:/etc/nginx/conf.d depends_on: - web web: build: . container_name: tts-app environment: - DATABASE=db - DEBUG=False - STATICFILES_STORAGE=whitenoise.storage.CompressedManifestStaticFilesStorage depends_on: - db expose: - "8888" entrypoint: ./entry_point.sh command: gunicorn urdu_tts.wsgi:application -w 2 -b :8888 restart: always In my django app, I need to access host address. I used request.get_host() which works in localhost. When I run this in Docker, I get url like http://web/media/voice/voice.wav. My nginx configuration is as follow. upstream web { ip_hash; server web:8888; } server { location ^/static/ { autoindex on; alias /static/; } location ~ ^/media/?(.*)$ { try_files /media/$1 /mediafiles/$1 =404; } location / { proxy_pass http://web; client_max_body_size 20m; } listen 8000; server_name localhost; } How can I get server url in Docker? -
django website is giving 404 error for static files
Having problem with staticfiles in Django 2. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) TEMPLATE_DIR = os.path.join(BASE_DIR, "templates") STATIC_URL = '/static/' STATIC_ROOT = BASE_DIR + '/static/' STATICFILES_DIR = [ (BASE_DIR + "static/"), ] STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] And my static structure is like below I am getting 404 for statics. Tried different things but no success. btw collectstatic has been already performed. Another thing is when i make changes in the static folder, collectstatic is not collecting anything. it says "unmodified". i am newbie in Django. appreciate for your help. -
django 2.0 file(view) changes does not effect in frontend
In my django 2.0 application, when I change something in view, it does not effect in frontend even closing the server by ctrl+c or ctrl+z. I am using windows. It works when I manually close python process from task manager. It's not good process to code and restarting server each time in development. If I have a simple HttpResponse of string like return HttpResponse('test') and changes the string(test) to any thing, it does not show the updated string, instead it shows test. How to overcome this, any idea will be appreciated. Thanks -
Testing Uploaded File Django
I m working on an Upload file example in Django. The user uploads a file, and I need to run a test on that file (compiling..) and launch a python script using that file. But I don't knw how to keep track of the uploaded file to use it. Here is my views.py from django.shortcuts import render from django.template import RequestContext from django.http import HttpResponseRedirect from django.urls import reverse from myproject.myapp.models import Document from myproject.myapp.forms import DocumentForm def list(request): # Handle file upload if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile=request.FILES['docfile']) newdoc.save() # Redirect to the document list after POST return HttpResponseRedirect(reverse('list')) else: form = DocumentForm() # A empty, unbound form # Load documents for the list page documents = Document.objects.all() # Render list page with the documents and the form return render( request, 'list.html', {'documents': documents, 'form': form} ) -
fp.write writes extra newlines to file
So I have a form in Django, where user inputs some text. Then I write this text to a file. My views.py looks something like this: if request.method == "POST": code = request.POST.get('code', False) fp = open('mp/somefile.txt', 'w') fp.write(code) fp.close() However this causes extra newline characters. (I am using windows) for example aaaaaaaa bbbbbbbb cccccccc results in aaaaaaaa bbbbbbbb cccccccc Is there a way to prevent these extra newline characters? -
Django - forloop.counter numbers not resetting when using nested for loops
I have a need for counting the standings of a sport team based on the total points they have their division. Each team has a total points and division assigned to them. My django template code is as follows: {% for division in divisions %} <h4>{{ division }}</h4> <table class="table"> <tr> <td align="center">Place</td> <td>Team</td> <td align="center">Points</td> </tr> {% for stat in stats %} {% if stat.division == division %} <tr> <td width="10%" align="center">{{ forloop.counter}}</td> <td width="70%">{{ stat.team }}</td> <td width="20%" align="center">{{ stat.points }}</td> </tr> {% endif %} {% endfor %} </table> {% endfor %} The problem right now is that say i have 6 teams and 3 are in Division A and 3 are in Division B. Because it is separating the teams based on division it is showing the forloop.counter as 1 through 6 on the first forloop for divisions. What I want it to do is only do the forloop counter for the nested forloop ( the second one for stats ) so that it shows places 1 through 3 for Division A and 1 through 3 for Division B. The results I am getting are: Division A Place Team Points 1 Timberlea Beverage Room 1 7 3 … -
Require Email When Creating an Account with Django
I've got a Django project, which requires users to be able create accounts to access content. I'm using the UserCreationForm to do this. In views.py I have def register_user(request): if request.method == "POST": user_form = UserCreationForm(request.POST) if user_form.is_valid(): new_user = user_form.save(commit=False) new_user.set_password(user_form.cleaned_data["password1"]) new_user.save() template = "account/registration/registration_done.html" context = {"new_user": new_user} else: # TODO: Handle exception raise BaseException elif request.method == "GET": user_form = UserCreationForm() template = "account/registration/register.html" context = {"user_form": user_form} else: raise NotImplementedError return render(request, template, context=context) And then my template is: {% extends "base.html" %} {% block title %}Create an Account{% endblock %} {% block content %} <h1>Create an Account</h1> <form action="." method="post"> {{ user_form.as_p }} {% csrf_token %} <p><input type="submit" value="Create my account"></p> </form> {% endblock %} Which works okay. But when the create account form is displayed, it only has fields for the username, password, and password verification. There's no requirement that the user enter a valid email. What I'd like to do is have a have the user be required to enter an email address, and then send them an email to ensure that the address is valid, and that they have access to is etc. Surely this is a common enough pattern that there's … -
Django: hashlib keeps generating same hex digest
I have a model like this: class Book(models.Model): hash = models.CharField(max_length=56, unique=True, null=True, editable=False) created_at = models.DateTimeField('Created at', auto_now_add=True) # .. and other fields def save(self): if self.hash is None: string_seed = str(self.created_at).encode('utf-8') + str(self.pk).encode('utf-8') self.hash = hashlib.sha224(string_seed).hexdigest() super(Book, self).save() But I keep getting this error "Duplicate entry 'c19c...abb5' for key 'store_book_hash_4517c5ea_uniq'" after inputting second data (book, in this case). I don't know why my code keeps generating same value. I use django admin page for data entry, and I thought when inserting new book via "Add book" form in django admin, the self.hash should always be None, so new random value would be freshly generated (but in my case, it wouldn't and threw integrity error instead). I'm confused -
Upload image from Android to django server using Retrofit
I am trying to make an Android application that would post the taken photo to django server using Retrofit framework. My android part: private void uploadFile(Uri filePath) { String path = getRealPathFromURI(filePath); File originalFile = new File(String.valueOf(path)); RequestBody filePart = RequestBody.create(MediaType.parse("multipart/form-data"),originalFile); MultipartBody.Part file = MultipartBody.Part.createFormData("upload", path, filePart); ApiRequestsService.UploadFile(this, new OnApiResponseListener() { @Override public void onApiComplete(Object object) { RetrofitResponse response = (RetrofitResponse) object; Toast.makeText(context, response.success, Toast.LENGTH_LONG).show(); } @Override public void onApiError(Exception e) { } }, "Loading...", file); } @Multipart @POST("/uploadImage/") Call<ResponseBody> uploadFile(@Part("upload") MultipartBody.Part file); In the views.py file on the server side I have: def uploadImage(request): # check to see if this is a post request if request.method == "POST": print request.FILES if 'upload' in request.FILES: print "success!" upload = request.FILES['upload'] else: print "something's wrong" The response I get is: [14/Jan/2018 15:55:24] "POST /uploadImage/ HTTP/1.1" 200 47 MultiValueDict: {} something's wrong -
Django unique together validation with request user
In Django, I need to validate unique_together the (author, title) fields. The problem is that the author is the request.user so what is the best approach to validate the admin form? I have this admin: @admin.register(Document) class DocumentAdmin(admin.ModelAdmin): list_display = ("title",) exclude = ('author',) def save_model(self, request, obj, form, change): """Save ``author`` as request user.""" if getattr(obj, 'author', None) is None: obj.author = request.user super().save_model(request, obj, form, change) I can query inside the save_model() and filter both author and title but that doesn't really work well. I also tried with a forms.ModelForm but I can't manage to get the request.user inside the clean() method. -
Heroku does not look for the DJANGO_SETTINGS_MODULE I've set for it
I'm deploying my first site. I intend to use one settings file for production and one for development. Thus I have this structure: workout | |-\settings | |- production.py |- development.py In order to let heroku know where to find the settings file, I do this: $ heroku config:set DJANGO_SETTINGS_MODULE=workout.settings.production Setting DJANGO_SETTINGS_MODULE and restarting ⬢ workoutcalendar... done, v3 DJANGO_SETTINGS_MODULE: workout.settings.production And push again. Everything should be fine now, right? But no: remote: -----> $ python manage.py collectstatic --noinput remote: Traceback (most recent call last): remote: File "manage.py", line 22, in <module> remote: execute_from_command_line(sys.argv) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line remote: utility.execute() remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 317, in execute remote: settings.INSTALLED_APPS remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__ remote: self._setup(name) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup remote: self._wrapped = Settings(settings_module) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__ remote: mod = importlib.import_module(self.SETTINGS_MODULE) remote: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module remote: return _bootstrap._gcd_import(name[level:], package, level) remote: File "<frozen importlib._bootstrap>", line 994, in _gcd_import remote: File "<frozen importlib._bootstrap>", line 971, in _find_and_load remote: File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked remote: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed remote: File "<frozen importlib._bootstrap>", line 994, in _gcd_import remote: File "<frozen importlib._bootstrap>", line 971, … -
Getting a long error while migrating using cmd to 'XAMPP' for database connection
Getting an error while using ->python manage.py migrate firstline216:in ensure_connection self.connect() lastline-> access denied for user'root'@localhost, -
Updating a single object with Django Rest Framework ViewSets and Axios
By default, the DRF ViewSets don't have a patch method. Also, by default, Axios doesn't have an update method. It would seem that in order to update/patch an object using Axios and DRF ViewSets I have to write out specifically how to handle a patch method for every ViewSet. Is it possible to use ViewSets default methods without writing extra code just to handle the Axios patch?