Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Models has change in Django but they are not reflected in celery
I have a Django project running inside a Docker container. Celery Worker, Celery Beat, Redis and Postgres are running inside it containers too. My problem is that i made some changes in a Django model then generate migration, applied it and everything works. When celery tries to save an instance of that model, i get the classic Django error: The col non exists. My question is: Do i have to do something like apply migrations in celery? Thanks for your help, Regards. -
Django Rest Framework and url shortcuts
I have a url: path('reservations/', views.ReservationViewSet.as_view(dict(get='list', post='create')), name='reservations'), so I will call it like: reservations?restaraunt=3 and I want to have a shortcut for it: path('restaurants/<int:restaurant_id>/reservations/', views.RestaurantReservationsForwardView.as_view(), name='restaurant-reservations'), which I gonna call like restaurants/3/reservations so, I have two views: class ReservationViewSet(viewsets.ModelViewSet): queryset = models.Reservation.objects.all() serializer_class = serializers.ReservationSerializer def get_queryset(self): queryset = super().get_queryset() restaurant_id = self.request.query_params.get('restaurant', None) if restaurant_id: queryset = queryset.filter(restaurant=restaurant_id) return queryset def create(self, request, *args, **kwargs): request.data['restaurant'] = request.query_params.get('restaurant') return super().create(request, *args, **kwargs) class RestaurantReservationsForwardView(View): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): request.GET = request.GET.copy() request.GET['restaurant'] = kwargs.get('restaurant_id') return ReservationViewSet.as_view(dict(get='list', post='create'))(request) It works but I fill like inventing the will. Also the I duplicate the dict which I puth inside as_view in dispatch -
Django - how to log error and display message
Currently, we use django logger to log errors and send emails to admin. # settings.py 'handlers': { 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler', }, 'applogfile': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', } }, 'loggers': { 'django': { 'handlers': ['applogfile', 'mail_admins'], 'level': 'ERROR', }, } We want to create custom user error page so we created a middleware to process exception: # exceptionMiddleware.py class ExceptionMiddleware: def process_exception(self, request, exception): message = str(exception) if isinstance(exception, BusinessLogicException) else "Sorry, we encountered an unexpected error" return HttpResponse( message ) The problem with this middleware is that the logging mechanism stop working. How do I get the loggers that are set up in settings.py to run from exceptionMiddleware.py? Thanks! -
Removing old permissions from a model in DJANGO
I changed the name of a model. It was called "Riesgo asociado", I changed it to "Reglas", then to "Regla" and applied the migrations, everything was ok. But now I have change, delete, view and add permissions for each name, even tho they are the same model. I need to change this because all this permissions are displayed in a custom admin view and those permissions for the old names are useless. -
How would I make a user who is verifed have a blue tick next to their name in Django
I would like to know how I would go about adding a system so that if a user if verified, a tick will appear next to their name. I think I will have to make a variable called verifed and make it a bool and only admins can change it. So how would I display an icon next to their name if verified == True? I haven't tried anything because whenever I Google it, tutorials on how to get verified on Instagram flood everything -
Logging out the current user in social user
I am overriding the social user in social core but how can I log out the current user? If I log out the request linked with the social auth, I am getting an error saying that 'AnonymousUser' object has no attribute 'social_auth'. def social_user(backend, uid, user=None, *args, **kwargs): provider = backend.name social = backend.strategy.storage.user.get_social_auth(provider, uid) if social: if user and social.user != user: logout(backend.strategy.request) Any ideas? -
Upload data from django to AWS S3
I learning django and AWS. I trying make 'dropbox' to my bucket. But i have wall ... I don't have a file selection button Is: https://zapodaj.net/62748ac082fb3.png.html should be: https://zapodaj.net/55638742043b5.png.html What am I doing wrong? I trying learn from this site https://simpleisbetterthancomplex.com I using Python v. 3.7.1, Django v 2.1.7 I looking resolve this problem for many website but i don't find storage_backends.py class MediaStorage(S3Boto3Storage): location = 'media' file_overwrite = False settings.py os.path.join(BASE_DIR, 'project/static'), ] AWS_ACCESS_KEY_ID = 'xxx' AWS_SECRET_ACCESS_KEY = 'xxx' AWS_STORAGE_BUCKET_NAME = 'xxx' AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_LOCATION = 'static' STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) DEFAULT_FILE_STORAGE = 'project.storage_backends.MediaStorage' models.py class Document(models.Model): uploaded_at = models.DateTimeField(auto_now_add=True) upload = models.FileField() views.py from django.views.generic.edit import CreateView from django.urls import reverse_lazy from .models import Document class DocumentCreateView(CreateView): model = Document fields = ['upload', ] success_url = reverse_lazy('home') def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) documents = Document.objects.all() context['documents'] = documents return context home.html {% csrf_token %} {{ form.as_p }} <button type="submit">Submit</button> </form> <table> <thead> <tr> <th>Name</th> <th>Uploaded at</th> <th>Size</th> </tr> </thead> <tbody> {% for document in documents %} <tr> <td><a href="{{ document.upload.url }}" target="_blank">{{ document.upload.name }}</a></td> <td>{{ document.uploaded_at }}</td> <td>{{ document.upload.size|filesizeformat }}</td> </tr> {% empty … -
Unable to display login user profile details on profile template?
Im new to django i unable to display current login user details on profile template from data base.when i will try with Maas.objects.all() it will get all existing userdata also.i need to diplsy only current login user data on tempalete.when i will try with Maas.objects.get(username=username) i will get error Type error:Maas.testapp.models dus't exist match quiry. views.py: ---------- def maas(request,username): context_dict = {} try: maas = Maas.objects.get(username=username) context_dict['maas_username'] = maas.username context_dict['maas_username_slug'] = maas_username_slug context_dict['maas_phone'] = maas.phone context_dict['maas_firstname'] = maas.firstname context_dict['maas_lastname'] = maas.lastname context_dict['maas_location'] = maas.location context_dict['date_of_birth'] = maas.date_of_birth context_dict['comments'] = maas.comments context_dict['maas_gender'] = maas.gender context_dict['photo'] = maas.photo context_dict['maas'] = maas except Maas.DoesNotExist: pass print(context_dict) return render(request, 'testapp/profile.html', context_dict) profile.html ------------ <!DOCTYPE html> {%extends 'testapp/base.html'%} {%block body_block%} <h1>Profile page</h1> <h1>{{ maas_username }}</h1> <li>Phone: {{ maas_phone }} </li> <li>firstname: {{ maas_firstname }} </li> <li>lastname: {{ maas_lastname }} </li> <li> gender: {{ maas_gender }} </li> <li> Comments: {{ comments }} </li> {%endblock%} models.py --------- from django.db import models from django.template.defaultfilters import slugify from django.contrib.auth.models import User class Maas(models.Model): username=models.CharField(max_length=25) password = models.CharField(max_length=50) phone = models.IntegerField(default=0) firstname = models.CharField(max_length=40, blank=True) lastname = models.CharField(max_length=40, blank=True) location = models.CharField(max_length=40, blank=True) email = models.EmailField(blank=True) date_of_birth = models.DateField(null=True, blank=True) gender = models.CharField(max_length=10, blank=True) comments = models.CharField(max_length=500, blank=True) photo = … -
Django - get ID using functional base view
I'm having a problem in getting the pk in my template. When I select a record it always returns the last pk ID. Btw, I'am using functional base view. Here's my collection.html: <form method="POST" action="{% url 'single_collection' %}"> {% csrf_token %} <table class="table" id="dataTables-example"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Status</th> <th>Download</th> </tr> </thead> <tbody> {% for collectionlist in collection %} <tr> <td>{{ collectionlist.id }}</td> <td>{{ collectionlist.sqa_name }}</td> <td>{{ collectionlist.status }}</td> <td class="center"><center><button type="button" class="btn btn-link" data-toggle="modal" data-target="#myModaldl{{ collectionlist.id }}" ><span class="glyphicon glyphicon-download-alt"></span></button></center></td> </tr> <div class="modal fade collectClass" id="myModaldl{{ collectionlist.id }}" role="dialog" tabindex="-1"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h3 class="modal-title">Single Collect</h3> </div> <div class="modal-body form-horizontal"> <div class="form-group"> <label for="inputSQAID" class="col-sm-3 control-label">SQA Name</label> <div class="col-sm-8"> <input type="hidden" name="pk_id" id="pk_id" value="{{ collectionlist.id }}"> <input type="text" class="form-control" name="singlecollect" value="{{ collectionlist.sqa_name }}" id="inputSQAID"> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button> <button type="submit" class="btn btn-success" name="single_dl">Download</button> </div> </div> </div> </div> {% endfor %} </tbody> </table> </form> Here's my views.py: def collection(request): context = { 'collection': DataCollection.objects.all(), 'title': 'Data Collection', } return render(request, 'data_collection/collection.html', context) def single_collect(request): if request.method == 'POST': pkid = request.POST.get('pk_id') print(pkid) all_data = DataCollection.objects.all() return render(request, 'data_collection/collection.html', {'title' : 'Data Collection', 'data': all_data}) In my … -
making the passed parameters provided in URL as optional [Non-Capturing] using " ?: "
I am tying to make the passed parameters in the URL as optional. I have a URL like this -> path('users/<optional_value>',views.users_list_or_detail, name='users_list_or_details'), I do not want to make 2 different URLS to give me the list or the detail. How can I make the second <optional_value> as optional so that if by any means, I am not providing the <optional_value> to the view, it gives me a list of users and user details if provided? one option I have looked over on Internet is http://localhost:8000/users/?from=user_id How can I make it optional using the ?: in the urls.py given in the Django's documentation? -
TemplateDoesNotExist at /sign up/
I'm trying to implementation email confirmation at the time of signup. I'm following this tutorial. https://medium.com/@frfahim/django-registration-with-confirmation-email-bb5da011e4ef Everything is correct except TemplateDoesNotExist at sign up acc_active_email.html It cannot find email confirmation htmt template sent during sign up -
"How to implement a feature of searching text inside the .pdf and .word documents in django application"
I am building a web app collection of documents in .pdf and .word format and want to implement search functionality to find words inside the documents. What would be the easiest way to implement it? I have searched and came across of integrating Elastic Search + Haystack into my app here https://www.youtube.com/watch?v=xr1b39XMtBQ&t=476s, but seems could not find exactly what I want to do. Any help appreciated. Thanks! -
ModuleNotFoundError: No module named 'app_manage'
I have encountered an issue related to running of django-cms I downloaded a zip package of djangoCMS sourcecode from https://www.django-cms.org/en/ I extracted zip file to a location on my hdd I set up my virtual env for my folder i've just extracted on hdd already When i run command "python manage.py runserver", i have encountered an error like the tile of this post. "ModuleNotFoundError: No module named 'app_manage'" Any helps will be much appreciated. Thanks in advanced. -
Django Connection Error(Oracle 11g Database)
When my django program connected to Oracle 11g DB, an error occured. When I input “python manage.py migrate” command, a below error occured. (When my django connected to sqlite3 DB, no problem.) Django 1.11.22 cx-Oracle 7.2.2 python 3.6 Oracle 11g (venv) PS D:\python\TEST\ijmes> python manage.py migrate Error Message. (venv) PS D:\python\TEST\ijmes> python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, db, sessions Running migrations: Applying contenttypes.0001_initial…Traceback (most recent call last): File “manage.py”, line 22, in execute_from_command_line(sys.argv) File “D:\python\TEST\venv\lib\site-packages\django\core\management_init_.py”, line 364, in execute_from_command_line utility.execute() File “D:\python\TEST\venv\lib\site-packages\django\core\management_init_.py”, line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File “D:\python\TEST\venv\lib\site-packages\django\core\management\base.py”, line 283, in run_from_argv self.execute(*args, **cmd_options) File “D:\python\TEST\venv\lib\site-packages\django\core\management\base.py”, line 330, in execute output = self.handle(*args, **options) File “D:\python\TEST\venv\lib\site-packages\django\core\management\commands\migrate.py”, line 204, in handle fake_initial=fake_initial, File “D:\python\TEST\venv\lib\site-packages\django\db\migrations\executor.py”, line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File “D:\python\TEST\venv\lib\site-packages\django\db\migrations\executor.py”, line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File “D:\python\TEST\venv\lib\site-packages\django\db\migrations\executor.py”, line 250, in apply_migration self.recorder.record_applied(migration.app_label, migration.name) File “D:\python\TEST\venv\lib\site-packages\django\db\migrations\recorder.py”, line 73, in record_applied self.migration_qs.create(app=app, name=name) File “D:\python\TEST\venv\lib\site-packages\django\db\models\query.py”, line 394, in create obj.save(force_insert=True, using=self.db) File “D:\python\TEST\venv\lib\site-packages\django\db\models\base.py”, line 808, in save force_update=force_update, update_fields=update_fields) File “D:\python\TEST\venv\lib\site-packages\django\db\models\base.py”, line 838, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File “D:\python\TEST\venv\lib\site-packages\django\db\models\base.py”, line 924, in _save_table result = self._do_insert(cls._base_manager, using, fields, … -
How to pre_populate model columns in admin using its foreign key?
how can I prepopulate model column in django admin using model's foreign key(any column of foreign key model), I have found that in official docs, they say prepopulated_fields doesn't work with a foreign key, any other do you know any other approaches? -
How do I link a comment to a post using a class based view
Using django version 2.2 I have created a blog app. I am trying to connect a comment to a post using a class based view (CreateView). However when i test the application I am getting an error which says: IntegrityError at /post/7/comment/ NOT NULL constraint failed: blog_comment.post_id I tried to reuse the CreatePostView but i am unse how in the view.py to link the comment to the post. My view is as follows: class CommentCreateView(LoginRequiredMixin, CreateView): model = Comment fields = ['text',] def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) My model is as follows: class Post(models.Model): title = models.CharField(max_length=100) content = models.TextField() date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.title def get_absolute_url(self): return reverse('post-detail', kwargs={'pk': self.pk}) class Comment(models.Model): post = models.ForeignKey('Post', on_delete=models.CASCADE) author = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) approved_comment = models.BooleanField(default=False) def approve(self): self.approved_comment = True self.save() def __str__(self): return self.text In my url I have: path('post/<int:pk>/comment/', CommentCreateView.as_view(), name='comment-create'), So what I am expecting is to some how resolve this error and have it being able to add a comment to post via the front end. I can add a comment to a post via the admin site seemingly with now issue so … -
django.db.utils.OperationalError: foreign key mismatch - "project_projectpage" referencing "auth_user"
what this question want to say first of all? And here below is my model.py class ProjectPage(Page): """ A Project Page We access the People object with an inline panel that references the ParentalKey's related_name in ProjectPeopleRelationship. More docs: http://docs.wagtail.io/en/latest/topics/pages.html#inline-models """ introduction = models.TextField( help_text='Text to describe the page', blank=True) image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text='Landscape mode only; horizontal width between 1000px and 3000px.' ) body = StreamField( BaseStreamBlock(), verbose_name="Page body", blank=True ) subtitle = models.CharField(blank=True, max_length=255) tags = ClusterTaggableManager(through=ProjectPageTag, blank=True) date_published = models.DateField( "Date article published", blank=True, null=True ) #email = models.CharField(max_length=255, blank=True, null=True) email = models.ForeignKey(User, on_delete=models.PROTECT, to_field='email', null=True) content_panels = Page.content_panels + [ FieldPanel('subtitle', classname="full"), FieldPanel('introduction', classname="full"), ImageChooserPanel('image'), StreamFieldPanel('body'), FieldPanel('date_published'), InlinePanel( 'project_person_relationship', label="Author(s)", panels=None, min_num=1), FieldPanel('email'), FieldPanel('tags'), FieldPanel('added_by', classname="full"), FieldPanel('updated_by', classname="full"), ] search_fields = Page.search_fields + [ index.SearchField('body'), ] added_by = models.ForeignKey(People,related_name="project_added_by", null=True, blank=True, on_delete=models.SET_NULL) updated_by = models.ForeignKey(People,related_name="project_updated_by", null=True, blank=True, on_delete=models.SET_NULL) created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True) updated_at = models.DateTimeField(auto_now=True, null=True, blank=True) What is solution for above problem let me know if you want more detail for this question!!!! I don't know but i think problem here in email id or somewhere else because i added email id after that this problem may arise. -
Join migration tables with Django
I would like to get a new table from two migrations tables: In migrations folder, I create these tables: migrations.CreateModel( name='GeneratedReport', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')), ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')), ('print_date', models.DateTimeField(blank=True, null=True)), ('s3_url', models.CharField(blank=True, max_length=200, null=True)), ('error', models.CharField(blank=True, max_length=600, null=True)), ('size', models.FloatField(blank=True, null=True)), ], options={ 'ordering': ('-modified', '-created'), 'get_latest_by': 'modified', 'abstract': False, }, ), migrations.CreateModel( name='Subscriber', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')), ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')), ('userid', models.IntegerField(unique=True)), ('name', models.CharField(blank=True, max_length=100, null=True)), ('email', models.EmailField(max_length=100)), ('contribution', models.IntegerField()), ('signupdate', models.DateTimeField()), ('user_lang', models.CharField(blank=True, choices=[('en', 'English'), ('fr', 'French'), ('es', 'Spanish'), ('jp', 'Japanese')], max_length=3, null=True)), ('subscribed', models.BooleanField(default=True)), ('_weather_unit', models.CharField(blank=True, choices=[('us', 'Imperial'), ('si', 'SI'), (None, 'Automatic')], max_length=3, null=True)), ], options={ 'ordering': ('-modified', '-created'), 'get_latest_by': 'modified', 'abstract': False, }, ), In models.py: class Subscriber(TimeStampedModel): userid = models.IntegerField(unique=True) name = models.CharField(max_length=100, null=True, blank=True) email = models.EmailField(max_length=100) contribution = models.IntegerField() signupdate = models.DateTimeField() user_lang = models.CharField(max_length=3, null=True, blank=True, choices=LANGUAGE_CHOICES) subscribed = models.BooleanField(default=True) _weather_unit = models.CharField(max_length=3, null=True, blank=True, choices=WEATHER_UNIT_CHOICES) class GeneratedReport(TimeStampedModel): report = models.ForeignKey(ReportType, on_delete=models.PROTECT) print_date = models.DateTimeField(null=True, blank=True) s3_url = models.CharField(max_length=200, null=True, blank=True) error = models.CharField(max_length=600, null=True, blank=True) size = models.FloatField(null=True, blank=True) Now, I would like to get a new table with these fields: user month year s3_link I'm not too sure about … -
How to create relationship in django model for postgresql database as per my design
How to create relationship in django model for postgresql database as per my design. I want to create multiple forignkey relationship between two table as per given image. from django.db import models from django.contrib.postgres.fields import ArrayField class Table1(models.Model): Emp_ID = models.IntegerField(primary_key=True) Emp_ID_Emp_Ext= models.IntegerField() Emp_ID= models.IntegerField(unique=True) Exp_Ext= models.IntegerField(unique=True) Date = models.DateTimeField() class Table2(models.Model): File_ID = models.IntegerField() Emp_ID= models.IntegerField() Exp_Ext= models.IntegerField() Contant= ArrayField(ArrayField(models.TextField())) Date = models.DateTimeField() I want to connect Emp_ID from table1 to Emp_ID table2 as well as Emp_Ext from table1 to Emp_Ext table2 as per the image diagram shows. I don't know whether I connect these two field with foreign key or composite key enter image description here -
AWS Elastic Beanstalk gives "could not translate host name "db" to address" error
I've been trying to deploy my docker consisted of Django, Postgresql and Nginx. It works fine when I do sudo docker-compose up However when deploy it on AWS EB, it gives me could not translate host name "db" to address: Name or service not known What I've done is I pushed my docker to docker hub using sudo docker build -t myname/dockername -f Dockerfile . and I simply do eb deploy File Structure myproject myproject settings.py urls.py ... Dockerfile Dockerrun.aws.json manage.py requirements.txt ... Dockerfile FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code COPY requirements.txt /code/ RUN pip install -r requirements.txt COPY . /code/ EXPOSE 8000 CMD ["sh", "on-container-start.sh"] Dockerrun.aws.json { "AWSEBDockerrunVersion": "1", "Image": { "Name": "myname/dockername:latest", "Update": "true" }, "Ports": [ { "ContainerPort": "8000" } ] } docker-compose.yml version: '3' services: db: image: postgres hostname: db networks: - some_network web: restart: always build: . volumes: - .:/code hostname: web expose: - "8000" depends_on: - db links: - db:db networks: - some_network nginx: image: nginx hostname: nginx ports: - "8000:8000" volumes: - ./config/nginx:/etc/nginx/conf.d depends_on: - web networks: - some_network networks: some_network: One thing I realize is that when I use docker-compose up on my machine, I get 3 different … -
Why the Simple tag in django is not working?
I have made a custom tag to set up a flag in my code (for logic). I have used link as a reference to set up flag. Here is the code of my custom tag: from django import template register = template.Library() @register.simple_tag def update_variable(value): data = value return str(data) My app directory: ├── admin.py ├── apps.py ├── database_consistency.py ├── forms.py ├── __init__.py ├── models.py ├── templatetags │ ├── __init__.py │ └── vars.py ├── tests.py ├── urls.py └── views.py Basiclly I am trying to set up a flag in template: <!--Diamonds:--> <!--Initialized diamond_flag--> {% with diamond_flag as False %} {% for diamond in item.diamonds.all reversed %} {% update_variable False as diamond_flag %} {% if forloop.first and diamond.rate != 0 %} ... <!--Trying to update the flag--> {% update_variable "True" as diamond_flag %} {% endif %} {% endfor %} {% if diamond_flag == "True" or diamond_flag == "1" or diamond_flag == 1 or diamond_flag == True %} <td>Working</td> <!--This line is not working, the code never runs--> <td>-</td> {% endif %} I want the flag value to be True between the code so the following 'if' conditions gets true and the code runs accordingly. -
Wagtail - use same slug multiple times
I would like to have a structure like this on a site: learn.com/math/lessons learn.com/english/lessons learn.com/science/lessons In wagtail, the "lessons" slug would get used three times. At least out of the box, that doesn't seem allowed. Is there a wagtail setting I can override to achieve this structure? Or is there a better method? The closest I've been able to get is creating three sites and then writing a filter that gets the leason page under a certain root page. But I really would like everything on one site. -
Push got rejected when push to heroku master, error happened when install python dependencies
I am deploying django-react project to heroku. Push got rejected when installing python dependencies using requirements.txt. Some say this is becuasue some libraries in requirements.txt are deprecated. But I am not sure which one causes the problem and how to fix it. Thank you. Heroku error : remote: -----> Build succeeded! remote: -----> Python app detected remote: ! Python has released a security update! Please consider upgrading to python-3.7.3 remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes remote: -----> Installing python-3.7.4 remote: -----> Installing pip remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: ! Push rejected, failed to compile Python app. remote: remote: ! Push failed My requirements.txt: certifi==2019.6.16 chardet==3.0.4 defusedxml==0.6.0 Django==2.2.4 django-allauth==0.39.1 django-cors-headers==3.1.0 django-countries==5.4 django-rest-auth==0.9.5 djangorestframework==3.10.2 gunicorn==19.9.0 idna==2.8 oauthlib==3.1.0 Pillow==6.1.0 python3-openid==3.1.0 pytz==2019.2 requests==2.22.0 requests-oauthlib==1.2.0 six==1.12.0 sqlparse==0.3.0 urllib3==1.25.3 whitenoise==4.1.3 -
Django When does cache expire?
Say you cache a view response with cache_page(60) for one minute. After the view is cached, after 20 seconds someone hit the page again, does the cache expire at time-60 or time-80 (60+20) from the origin (first hit) -
How does web (Django) cache works?
When server caches a page, I thought it worked like this, but apparently I'm wrong. server stores http response contents in a cache-store with a key (that's generated for the endpoint) one could create separate cache key for certain aspects of requests (such as user language) when there's a request for the same key, and it's stored in cache-store (such as redis), webserver returns the cached response instead of recreating the response I think the above understanding is flawed because,, when I hit the endpoint with axios, first request is hit on the server, but the second request doesn't even hit the endpoint, it seems axios is reusing the previous response it received. So, if I clear all cache store between two requests, the second request doesn't get to the request handler (view function in django) In django, I'm using from django.views.decorators.cache import cache_page But the question is more of general working of web response cache