Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Problem with django-jet and Google Analytics widgets
I followed the entire documentation (https://github.com/assem-ch/django-jet-reboot) for installing the dashboard. Everything works as it should except for the Google Analytics widgets. After the command "pip install google-api-python-client==1.4.1" the Google Analytics widgets are not there inside the panel: Can anyone help me? -
Django celery redis, recieved task, but not success not fail message, how to fix?
When i run celery task i got this. Windows 10, redis celery 5. video try [2021-10-29 19:08:18,216: INFO/MainProcess] Task update_orders[55790152-41c0-4d83-8874-4bd02754cb77] received [2021-10-29 19:08:19,674: INFO/SpawnPoolWorker-8] child process 7196 calling self.run() / My celery.py from __future__ import absolute_import, unicode_literals import os from celery import Celery from celery.schedules import crontab os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings.local') BASE_REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379') app = Celery('src') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() app.conf.broker_url = BASE_REDIS_URL @app.task(bind=True) def debug_task(self): print("Request: {0!r}".format(self.request)) app.conf.beat_scheduler = 'django_celery_beat.schedulers.DatabaseScheduler' app.conf.worker_cancel_long_running_tasks_on_connection_loss = True my tasks.py import random from celery import shared_task from django.shortcuts import get_object_or_404 import datetime from config.models import Config @shared_task(name="update_orders") def update_orders(): print('Delayed') obj = Config.objects.all().order_by("-id").last() obj.orders_last_time_updated = datetime.datetime.now() obj.save() return True My settings # CELERY STUFF CELERY_BROKER_URL = 'redis://127.0.0.1:6379' CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379' CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_TIMEZONE = TIME_ZONE DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' CELERY_RESULT_BACKEND = "django-db" It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details. -
ModuleNotFoundError: No module named 'rest_framework' python3 django
I copied code from blog and i got this error. Actually i am newbie in django and stackoverflow too. i copied code from github blog so easly i can reach to my aim. line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'rest_framework' Copied code is from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager from phonenumber_field.modelfields import PhoneNumberField ) class Address(models.Model): address_line = models.CharField( _("Address"), max_length=255, blank=True, null=True ) street = models.CharField( _("Street"), max_length=55, blank=True, null=True) city = models.CharField(_("City"), max_length=255, blank=True, null=True) state = models.CharField(_("State"), max_length=255, blank=True, null=True) postcode = models.CharField( _("Post/Zip-code"), max_length=64, blank=True, null=True ) country = models.CharField( max_length=3, choices=COUNTRIES, blank=True, null=True) return address -
How to have a Seperate REST API that only handles authentication for multiple app
I have developed multiple Django REST APIs, each with their own user authentication system, using tokens for authentication. I want to have all the APIs only use a single authentication database such that I can have a single front end where a user can log in, and then access multiple apps, each using their own API. Is there a way whereby an API can make an API call to a central API with a user database for authentication? Or What would be industry/best practice to achieve this? -
Is there any solution for the {"detail":"Method \"POST\" not allowed."}
views.py code: @api_view(['POST']) @permission_classes([IsAdminUser]) def createProduct(request): user = request.user product = Product.objects.create( user = user, name = 'sample name', price =4, countInStock = 12, category = 'Sample category', brand = 'Sample Brand', description = 'Sample Description', ) serializer = ProductSerializer(product, many=False) return Response( serializer.data ) urls.py path('products/create/',views.createProduct , name='product-create' ), Error that i got : {"detail":"Method "POST" not allowed."} -
Django - create a file for FileField inside media
I want to store log files (that change over time) that users can explore. As I want to serve these files but also change them programmatically whenever I need, I want to use FileField and store the files inside the media folder. First, when the object is created, I want to create an empty file <UUID>.log so I can access/update it then. How to create a default empty log file? class MyModel(..): log_file = FileField(upload_to='user_logs') def _create_log_file(self): content = '' filename = str(uuid4())+'.log' ... # what to do here? -
(Django) Admin datatable does not show data in the select field
below is the issue I'm having: The drug type column, which is a select field with specified options drug_types_list = ( ('pills','PILLS'), ('pellets','PELLETS'), ('lozenges','LOZENGES'), ) somehow did not show any data. Even though inside my Jquery Datatable everything displayed. So I went to my drugs/admin.py and modified the code as followed: from django.contrib import admin from import_export.admin import ImportExportModelAdmin # local from .models import Drug from .forms import DrugForm class DrugAdmin(ImportExportModelAdmin): fields = ('drug_type',) # added list_display = ['drug_id', 'name', 'drug_type', 'amount'] form = DrugForm # added list_per_page = 20 search_fields = ['drug_id', 'name', 'drug_type', 'brand', 'description'] admin.site.register(Drug, DrugAdmin) I aslo changed the drug_type line inside my drugs/forms.py as followed: from django import forms # local from drugs.models import Drug from .drug_types import drug_types_list class DrugForm(forms.ModelForm): class Meta: model = Drug fields = [ 'drug_id', 'name', 'drug_type', 'amount', ] widgets = { 'drug_id': forms.TextInput(attrs={ 'class': 'form-control', 'data-val': 'true', 'data-val-required': 'Please enter drug id', }), 'name': forms.TextInput(attrs={ 'class': 'form-control' }), 'drug_type': forms.Select(attrs={'class': 'form-control'}, choices=drug_types_list), # modified 'amount': forms.TextInput(attrs={ 'class': 'form-control' }), } but nothing worked so far. drugs/models.py Below is my drug model: from django.db import models from .drug_types import drug_types_list class Drug(models.Model): drug_id = models.CharField(max_length=20, unique=True, error_messages={'unique':"This drug id has … -
Django Redis Connection reset
Iam trying to use django_redis for redis cache backend for Django. The app is working fine in development stage on the localhost. But after deployment on Heroku and using django_redis for redis cache The connection is getting reset and the page crashes with 500 internal server error 2021-10-29T12:10:20.450924+00:00 heroku[router]: at=info method=GET path="/" host=www.humaurtum-matrimony.com request_id=37a90921- 9d8d-46c6-9d6a-888d34fb1d01 fwd="42.106.161.10" dyno=web.1 connect=0ms service=2701ms status=500 bytes=5280 protocol=https 2021-10-29T12:10:20.447599+00:00 app[web.1]: 2021-10-29 17:40:18,010 ERROR Internal Server Error: / 2021-10-29T12:10:20.447606+00:00 app[web.1]: Traceback (most recent call last): 2021-10-29T12:10:20.447607+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django_redis/cache.py", line 27 , in _decorator 2021-10-29T12:10:20.447608+00:00 app[web.1]: return method(self, *args, **kwargs) 2021-10-29T12:10:20.447608+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django_redis/cache.py", line 94 , in _get 2021-10-29T12:10:20.447609+00:00 app[web.1]: return self.client.get(key, default=default, version=version, client=client) 2021-10-29T12:10:20.447609+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django_redis/client/default.py" , line 222, in get 2021-10-29T12:10:20.447609+00:00 app[web.1]: raise ConnectionInterrupted(connection=client) from e 2021-10-29T12:10:20.447610+00:00 app[web.1]: django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error while rea ding from socket: (104, 'Connection reset by peer') 2021-10-29T12:10:20.447610+00:00 app[web.1]: 2021-10-29T12:10:20.447611+00:00 app[web.1]: During handling of the above exception, another exception occurred: 2021-10-29T12:10:20.447611+00:00 app[web.1]: 2021-10-29T12:10:20.447612+00:00 app[web.1]: Traceback (most recent call last): 2021-10-29T12:10:20.447612+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/exception. py", line 34, in inner 2021-10-29T12:10:20.447613+00:00 app[web.1]: response = get_response(request) 2021-10-29T12:10:20.447614+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response 2021-10-29T12:10:20.447614+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request) 2021-10-29T12:10:20.447614+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response 2021-10-29T12:10:20.447615+00:00 app[web.1]: … -
Django broken pipe occurs with CORS setting
I want to connect flutter app with my Django API, but broken pipe keeps occuring. settings.py """ Django settings for crawler project. Generated by 'django-admin startproject' using Django 3.2.6. For more information on this file, see https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-)4%#q5&d3^5=0!bauz62wxmc9csk*_c09k!jl2g1a-0rxsa--j' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'crawling_data', 'rest_framework', 'corsheaders', ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'crawler.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'crawler.wsgi.application' # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { … -
Write the o/p into a new text file with table format below for each iteration appends in python
Write the o/p into a new text file with table format below for each iteration appends. ( i,e in for loop, 5th iteration coms number 5 which is divisible by 5 so this one should write into file) ----------------------------------------------------------- Iteration | Value 5 5 10 10 15 15 -
Unable to configure formatter 'json': Cannot resolve 'app_name.utils.logging.JSONFormatter': cannot import name 'Celery'
I am trying to include celery into our Django app and am struggling with the setup. So far all my searching of stackoverflow/google tells me I have a circular dependency, but I can't see it. The docs, https://docs.celeryproject.org/en/stable/getting-started/first-steps-with-celery.html, clearly use from celery import Celery I have defined: app_name/app_name_celery.py with from celery import signals, Celery import os from django.conf import settings # disable celery logging so that it inherits from the configured root logger @signals.setup_logging.connect def setup_celery_logging(**kwargs): pass os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") # Create default Celery app app = Celery('app_name') # namespace='CELERY' means all celery-related configuration keys # should be uppercased and have a `CELERY_` prefix in Django settings. # https://docs.celeryproject.org/en/stable/userguide/configuration.html app.config_from_object("django.conf:settings", namespace="CELERY") # When we use the following in Django, it loads all the <appname>.tasks # files and registers any tasks it finds in them. We can import the # tasks files some other way if we prefer. app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) Additionally, I have defined app_name/my_app_config.py with from django.apps import AppConfig class MyAppConfig(AppConfig): # ... def ready(self): # Import celery app now that Django is mostly ready. # This initializes Celery and autodiscovers tasks import app_name.app_name_celery Lastly, I have added to my __init__.py: # This will make sure the app is always imported … -
Python package: should I transform my code?
3 things you need to know for context: I have never done this before, so try to keep everything low level, or in simple steps. I have pretty good knowledge of Python and HTML (and JS) but I don't have ton of experience. I am doing this on a Chromebook, without access to Linux. (I do have access to JSLinux though) I have a Python project that is organized something like this / -- QaikeAI_1.py # This is what is actually run to use the program -- QHelper.py # Has helper functions, imported into QaikeAI_1.py -- Qepicenter.py # "The meat of the AI" imported into QHelper.py -- Qlog.py # A logfile -- Various other files (.gitignore, .replit, .gitpod.yml) Should I transform my code into a package? I want to use a Python web framework on gh-pages. Remember, I am on a Chromebook. The actual code is hosted on Github.com -
DRF post to a flask server using pytest
I am writing a test suite in Django wherein post requires flask server to be running in order to successfully return a 201 response. How can I mock that in my test? Here's a snippet of what I've tried: def test_something(self, data): response = self.client.post(reverse('myurl'), data) assert response.status_code == 201 The error here is that the flask server is not running that's why the status code is not as expected. -
Why different id values in the admin panel's list and object details views?
The custom ModelAdmin class is class ContactAdmin(admin.ModelAdmin): list_display = ('first_name', 'phone_number', 'id') readonly_fields = (id,) But the values in the id column list differ from those of the corresponding objects: List with an object; Object's detail view Why so? -
Print out forms on dashboard
I'm writing Quiz app on Dajngo. I have a model.py: class Quiz(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='quizzes') name = models.CharField(max_length=200, verbose_name=_('Quiz name')) description = models.CharField(max_length=100, verbose_name=_('Description')) slug = models.SlugField(blank=True) roll_out = models.BooleanField(default=False) timestamp = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['timestamp'] verbose_name = _('Quiz') verbose_name_plural = _('Quizzes') def __str__(self): return self.name class Question(models.Model): quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='questions') label = models.CharField(max_length=255, verbose_name=_('Question text')) order = models.IntegerField(default=0, verbose_name=_('Order')) class Meta: verbose_name = _('Question') verbose_name_plural = _('Questions') def __str__(self): return self.label class Answer(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='answers') label = models.TextField(max_length=600, verbose_name=_('Answer text')) is_correct = models.BooleanField(default=False, verbose_name=_('Correct answer')) class Meta: verbose_name = _('Answer') verbose_name_plural = _('Answers') def __str__(self): return self.label And I get confused about how to output forms to create quiz with quiestions. This is my forms.py: class QuizAddForm(forms.ModelForm): class Meta: model = Answer exclude = ('question',) def __init__(self, *args, **kwargs): quiz = kwargs.pop('quiz', '') super(QuizAddForm, self).__init__(*args, **kwargs) self.fields['question'] = forms.ModelChoiceField(queryset=Quiz.objects.filter(name='category')) I want view in my template like: Category Quiz Question Answer 1 Answer 2 Answer 3 etc. -
Insert records into two tables using single view in Django rest framework
I have three models as follows. class Quiz(models.Model): name = models.CharField(max_length=50) desc = models.CharField(max_length=500) number_of_questions = models.IntegerField(default=1) time = models.IntegerField(help_text="Duration of the quiz in seconds", default="1") def __str__(self): return self.name def get_questions(self): return self.question_set.all() class Question(models.Model): ques = models.CharField(max_length=200) quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE) def __str__(self): return self.ques class Answer(models.Model): content = models.CharField(max_length=200) correct = models.BooleanField(default=False) question = models.ForeignKey(Question, on_delete=models.CASCADE) def __str__(self): return f"question: {self.question.ques }, answer: {self.content}, correct: {self.correct}" I have to create api for create question. for this I have to use model Question and Answer same time e.g. its admin page but I want to create same api which accept above parameters and store it into database. how to write view.py for this api ? -
Django constraint on Foreign Key field 'startswith'
I have got problem with Django constraint. I want to create constraint on foreign key field to check if it starts with user_id but Django think "__startswith" is a lookup option. Am i wrong with constraint syntax or it is Django problem? Probably i have tried to do this constraint with raw SQL and it works. Have got this error: django.core.exceptions.FieldError: Related Field got invalid lookup: startswith I have this Models: class PrivateModel(models.Model): id = models.CharField(primary_key=True, max_length=255, default="", editable=False) _owner = models.ForeignKey(User, on_delete=models.CASCADE) class Meta: abstract = True class Genre(PrivateModel): genre = models.CharField(max_length=255) class Book(PrivateModel): caption = models.CharField(max_length=255) genre = models.ForeignKey(Genre, on_delete=models.CASCADE) class Meta: constraints = [ models.CheckConstraint( name="book_genre_owner_constraint", check=Q(genre_id__startswith=F("_owner_id")) ), ] -
python 3 ModuleNotFoundError: No module named 'phonenumber_field'
line 53, in from phonenumber_field.modelfields import PhoneNumberField ModuleNotFoundError: No module named 'phonenumber_field' -
Sharing Cookies
My Django website is running on hello.com and react application on abc.hello.com and I want to share cookies between them. The nginx configuration given below isn't working for me.Can anyone help me for this. Configuration : Django-nginx config: server { listen 80; server_name abc.com; location /static/{ root /home/ubuntu/static/; } location / { proxy_cookie_domain ~^(.+)(Domain=abc.hello.com)(.+)$ "$1 Domain=.hello.com> proxy_pass http://xx.xx.xx.xxxx:8000; } } React nginx config: server { listen 80; server_name abc.hello.com; location / { proxy_cookie_domain ~^(.+)(Domain=abc.hello.com)(.+)$ "$1 Domain=.hello.com> proxy_pass http://xxx.xxx.xxx.xxx:3000; } } -
Matching < select > values based on Django-Model entries
I have one Django- Model that has a Name and Number of Units field. An example of the entries is: Name1: 12 Name2: 18 Name3: 25 I would like to add these 2 fields on a form where the user will use a < select > dropdown to select a name e.g. Name1 And then another dropdown for the user to select their unit from 1 to the total number of units e.g. 1 - 12 However, the way that my code is currently set up, it shows the unit name - and the user can select it, but for the unit number it shows all the NumberOfUnits fields in the model Please see my current code: template.html: <form> <select name="Complex"> {% for x in model %} <option value="{{ x }}">{{ x.ComplexName }}</option> {% endfor %} </select>> Complex <select> {% for x in model %} <option value="{{ x.NumberOfUnits }}">{{ x.NumberOfUnits }}</option> {% endfor %} </select> Views.py: def customerDetails(request): model = ComplexListClass.objects.all().order_by('ComplexName') content = {'model': model} return render(request, 'main/customerDetails.html', content) Models.py: class ComplexListClass(models.Model): ComplexName = models.CharField(choices=complex_list , max_length = 50 ,default='1' , unique=True) NumberOfUnits = models.IntegerField(max_length=2 , blank=False , default=1 ) def __str__(self): return (self.ComplexName) -
Download YouTube Video using Python
I'm using the Python library Pytube to download youtube videos. Here is the main issue: While I configure the project on the server and access it through my domain name, it saves video on the server while I want to save it to my computer. Do you have any idea how can I do that? Thanks -
Django Q object not chaining correctly
I'm querying a ManyToMany field (tags). The values come from a list: tag_q = Q() tag_list = ["work", "friends"] for tag in tag_list: tag_q &= Q(tags__tag=tag) Post.objects.filter(tag_q) When I have only one value, it works flawlessly, but when more objects are stacked it always return an empty queryset. I didn't used tags__tag__in=tag_list because it returned any post that contained any of the tags in the tag list (an OR filter), and I need an AND filter here. This is my models: class Tag(models.Model): tag = models.CharField(max_length=19, choices=TagChoices.choices()) class Post(models.Model): tags = models.ManyToManyField(Tag, related_name='posts', blank=True) This is the Q object that is being passed in the filter query: (AND: ('tags__tag', 'work'), ('tags__tag', 'friends') -
measure the height and width of the image in django and store the value in models
I have a model for image url in django. I want to calculate the image_height and iamge_width of image which is stored in s3 bucket.Below is my model.py from django.db import models from .project_model import Project class Image(models.Model): image = models.TextField(blank=False) image_width = models.IntegerField(default=0) image_height = models.IntegerField(default=0) project_id = models.ForeignKey(Project, on_delete=models.CASCADE) is_thumpnail = models.BooleanField(blank=False) upload_on = models.DateTimeField("created on", auto_now_add=True) updated_on = models.DateTimeField("updated on", auto_now=True) def __str__(self): return self.file_name After getting the value of height and width, I want to store the value in the model.py. I am looking for below type of response example { "id": "cJ9cm", "title": null, "description": null, "datetime": 1357856330, "type": "image/jpeg", "animated": false, "width": 2592, "height": 1944, "size": 544702, "views": 31829, "bandwidth": 17337319958, "link": "https://i.imgur.com/cJ9cm.jpg" } -
I've a issue with my favourite app in django
I am designing a blog site and there will be a favorites module on my blog site. However, the problem is that I developed a custom user model using JWT, but then when I try to access the favorites section with these users, I get the following error. When I delete the perform_create function, everything works fine, but I have to use it to make users' favorite posts appear unique to each of them, but I couldn't find an alternative code that I can write instead. Can you help? this error TypeError at /api/favourites/list-create Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x000001E01402CA00>. this is my favorite/api/views.py code from favourite.api.seralizers import FavouriteListCreateSerializer from favourite.models import Favourite from rest_framework.generics import ListCreateAPIView from rest_framework.permissions import IsAuthenticated class FavouriteListCreateAPIView(ListCreateAPIView): queryset = Favourite.objects.all() serializer_class = FavouriteListCreateSerializer permissions_classes = [IsAuthenticated] def get_queryset(self): return Favourite.objects.filter(user=self.request.user) def perform_create(self, serializer): serializer.save(user=self.request.user) favoruites/api/serializers.py file from favourite.models import Favourite from rest_framework.serializers import ModelSerializer class FavouriteListCreateSerializer(ModelSerializer): class Meta: model = Favourite fields = "__all__" and finally this is my custom account model from django.db import models from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager from django.utils.text import slugify class CustomAccountManager(BaseUserManager): def … -
Python test succeed on Linux but fail on windows
I'm currently working on a project where my python tests are actually succeeding when they are running on a Linux environment, but they fail when they are running in a Windows environment. And what is really weird is that the tests are failing randomly on Windows(sometimes, 4 tests are failing, sometimes it's 6...). I have the feeling that maybe the setUp method doesn't execute the same way in Linux and in Windows. Does anyone know if there is a difference between python test run on windows or on linux. Thank you.