Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to do math operations in django template?
I want to substract a variable from another variable of the same object in django template {% for object in object_list %} {{ object.var1 - object.var2 }} {% endfor %} But this results in a TemplateSyntaxError. How to do that operation? -
My tests dont want to run, only shows window for very short time
I'm currently learning how write tests, and when I'm trying to run test in PowerShell by using command "py manage.py test" then nothing happend, except showing window in whom something is written, but this window last for so short amount of time that is impossible to read anything from this window This is my test.py from django .test import TestCase from ..models import Category class CategoryModelTest(TestCase): @classmethod def setUpTestData(cls): Category.objects.create(name='Armors', slug='Armors', description='') def test_name_label(self): category = Category.object.get(id=1) field_label = category._meta.get_field('name').verbose_name self.assertEqual(field_label, 'name') def test_slug_label(self): category = Category.object.get(id=1) field_label = category._method.get_field('slug').verbose_name self.assertEqual(field_label, 'slug') def test_description_label(self): category = Category.object.get(id=1) field_label = category._method_get_field('description').verbose_name self.assertEqual(field_label, 'description') def test_name_max_length(self): category = Category.object.get(id=1) max_length = category._method.get_field('name').max_length self.assertEqual(max_length, '25') def test_slug_max_length(self): category = Category.object.get(id=1) max_length = category._method_get_field('slug').max_length self.assertEqual(max_length, '25') Localization of my test files: encyclopedy(application in my project) model.py tests __init__.py test_models.py -
Django with datebase on sqlserver
I have a project working with sqlite3 (default datebase) and i am trying to use now the microsft sqlserver and trying to do all the same with the new datebase. I was following this setps: https://docs.microsoft.com/en-us/sql/connect/python/pymssql/python-sql-driver-pymssql?view=sql-server-2017 and i have already install the pymssql , but right now i dont know what i need to do to connect my django to the sql server. -
Python Django error ModuleNotFoundError: No module named 'corsheaders'
Hey guys i am getting the below error when i have corsheaders installed, any idea why im getting the below error message as im out of ideas. installed: Python 3.7.2 certifi==2018.11.29 chardet==3.0.4 Django==2.1.7 django-cors-headers==2.4.0 django-mssql==1.8 django-oauth-toolkit==1.2.0 djangorestframework==3.9.1 idna==2.8 oauthlib==3.0.1 pytz==2018.9 requests==2.21.0 urllib3==1.24.1 (Oauth) C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth>Scripts\python.exe mysite\manage.py runserver Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03AC8C48> Traceback (most recent call last): File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception raise _exception[1] File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\core\management\__init__.py", line 337, in execute autoreload.check_errors(django.setup)() File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\apps\registry.py", line 89, in populate app_config = AppConfig.create(entry) File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\apps\config.py", line 90, in create module = import_module(entry) File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'corsheaders' -
Django AWS Zappa deployement satic files error
I've manage to deploy my site to AWS Lambda using Zappa which was complicated but i got there in the end. However i'm running into an issue where some of my icons are not loading. Please see the consol log below. Blocked loading mixed active content "http://localhost:8000/static/scss/icons/simple-line-icons//fonts/Simple-Line-Icons.ttf?-i3a2kk"[Learn More] login Blocked loading mixed active content "http://localhost:8000/static/scss/icons/themify-icons/fonts/themify.woff"[Learn More] login Blocked loading mixed active content "http://localhost:8000/static/scss/icons/material-design-iconic-font//fonts/materialdesignicons-webfont.woff2?v=1.8.36"[Learn More] login Blocked loading mixed active content "http://localhost:8000/static/scss/icons/font-awesome/webfonts/fa-solid-900.woff2"[Learn More] login Blocked loading mixed active content "http://localhost:8000/static/scss/icons/font-awesome/webfonts/fa-regular-400.woff2"[Learn More] The site is hosted at https://h28ijhkwy3.execute-api.eu-west-2.amazonaws.com/Demo/account/login So, i believe this files are being called from my style.css file using: @import url(../scss/icons/material-design-iconic-font/css/materialdesignicons.min.css); I have tried putting the full AWS S3 path instead but it still doesn't work and i still get the same errors in the console. -
How to display a HTML file in django framework which is an output of my python code?
I am writing a python code and the output is writing into an html file. When I was running this code on my laptop, I was able to use webbrowser.open to open the html file on local browser but when I have installed my django project on Linux server and accessing it remotely, it is not working. I have been reading question on how to return a "HTML" page in django but most of them are talking about template. I try that but every time my html file name is changing and I am not keeping it under default template location. It is kind of urgent. Please help. -
In Django Rest Framework Serializer, how to get the full path of image?
In my project, I want to get the full path of image using Serializer class. When I use ViewSet class, it seems to get correct result. But when using APIView class, it doesn't get what I need. # the model class UserAccount(models.Model): ... icon = models.ImageField(upload_to='icon/user') # the serializer class UserSerializer(serialziers.ModelSerializer): class Meta: model = UserAccount fields = (..., 'icon') Use ViewSet # viewset class UserViewSet(viewsets.ModelViewSet): ... serializer_class = UserSerializer # result # {..., 'icon': 'http://127.0.0.1:8000/media/icon/user/filename'} Use APIView class UserView(APIView): ... def get(self, request): ... userAccount = user.userAccount serializer = UserSerializer(userAccount) return Response(serializer.data) # result # {..., 'icon': '/media/icon/user/filename'} What should I do to get full path of the image in APIView? -
django ckeditor image upload
I'm using Django-ckeditor in my website. I'm especially using RichTextUploadingField() in my model. and other option just works fine, except image upload. 1. Error Message I'm getting an error message of "Incorrect Server Response" and especially, chrome devtools indicates that ckeditor.js:21 [CKEDITOR] Error code: filetools-response-error. ckeditor.js:21 [CKEDITOR] For more information about this error go to https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_errors-section-filetools-response-error 2. Guess I have tried uploading images using ckeditor in my admin page, authorized as superuser in django, it works. However, logged in as the normal user account, I've tried the same thing, but it does not work. So my guess is it has some kind of authorization problem. But I can't figure out where to start debugging in my django-ckeditor. What things should I be checking? Thanks in advance. -
how to used nesteded serilizer i am getting attribute error
I am getting attribute error accounts app name models.py class AddressUser(models.Model): customer = models.OneToOneField(Customer_create, related_name='customer_address', on_delete=models.CASCADE, blank = True,null=True) user = models.OneToOneField(User, on_delete=models.CASCADE, blank = True,null=True) house_number = models.CharField(max_length=250) builiding_name = models.CharField(max_length=250) block_no = models.CharField(max_length=250) street = models.CharField(max_length=250) area = models.CharField(max_length=250) city = models.CharField(max_length=250) pincode = models.CharField(max_length=250) state_choices = ( ("Andhra Pradesh", "Andhra Pradesh"), ("Arunachal Pradesh ", "Arunachal Pradesh "), ("Assam", "Assam"), ("Bihar", "Bihar"), ("Chhattisgarh", "Chhattisgarh"), ("Goa", "Goa"), ("Gujarat", "Gujarat"), ("Haryana", "Haryana"), ("Himachal Pradesh", "Himachal Pradesh"), ("Jammu and Kashmir ", "Jammu and Kashmir "), ("Jharkhand", "Jharkhand"), ("Karnataka", "Karnataka"), ("Kerala", "Kerala"), ("Madhya Pradesh", "Madhya Pradesh"), ("Maharashtra", "Maharashtra"), ("Manipur", "Manipur"), ("Meghalaya", "Meghalaya"), ("Mizoram", "Mizoram"), ("Nagaland", "Nagaland"), ("Odisha", "Odisha"), ("Punjab", "Punjab"), ("Rajasthan", "Rajasthan"), ("Sikkim", "Sikkim"), ("Tamil Nadu", "Tamil Nadu"), ("Telangana", "Telangana"), ("Tripura", "Tripura"), ("Uttar Pradesh", "Uttar Pradesh"), ("Uttarakhand", "Uttarakhand"), ("West Bengal", "West Bengal"), ("Andaman and Nicobar Islands", "Andaman and Nicobar Islands"), ("Chandigarh", "Chandigarh"), ("Dadra and Nagar Haveli", "Dadra and Nagar Haveli"), ("Daman and Diu", "Daman and Diu"), ("Lakshadweep", "Lakshadweep"), ("National Capital Territory of Delhi", "National Capital Territory of Delhi"), ("Puducherry", "Puducherry")) state = models.CharField(choices=state_choices, max_length=255) country = models.CharField(max_length=10, default='India') Simple app model.py class Customer_create(models.Model): #address = models.ForeignKey(AddressUser, on_delete= models.CASCADE) customer_name=models.CharField(max_length=250) mobile_number=models.CharField(max_length=10) email=models.CharField(max_length=50) serializers.py class AddressSerlizer(serializers.ModelSerializer): class Meta: model = AddressUser fields = ('id','house_number','builiding_name','block_no', … -
Getting default logs of celery
I am not able to get access to default logs of celery without using terminal and using python code. Able to get it with terminal though using -f . want to get logs in a file using python script and that too the default logs which are generated by celery in stderr. -
Django Application
I have finished coding a Django App. In that app I have created two models in order to record some project information. Also I am showing project locations with markers on a map (OpenStreetMap) by using leaflet.js. I will use this app only by starting an offline server like "python manage.py runserver". I am using "Firefox" to display the django app. I really wonder if somehow the information that I keep in my django models or the markers on the OpenStreetMap is somehow reachable by others via on Firefox or leaflet. Thank you very much in advance. -
How to display plots in django templates,using bokeh?
I want to display a simple plot django templates,but it was showing the blank page instead here is my code: views.py from bokeh.io import output_file,show,output_notebook,push_notebook from bokeh.plotting import figure from bokeh.models import ColumnDataSource,HoverTool,CategoricalColorMapper from bokeh.layouts import row,column,gridplot from bokeh.models.widgets import Tabs,Panel from bokeh.embed import components from bokeh.resources import CDN def MainPage(request): p = figure(plot_width=800, plot_height=250, x_axis_type="datetime") p.line([1,2,3,4,5], [4,1,3,5,2], color='navy', alpha=0.5) script, div = components(p) return render(request,'mainpage.html',{'script':script,'div':div}) my mainpage.html: <!DOCTYPE html> <html lang="en-US"> <link href="http://cdn.pydata.org/bokeh/dev/bokeh-1.0.4.min.css" rel="stylesheet" type="text/css"> <script src="http://cdn.pydata.org/bokeh/dev/bokeh-1.0.4.min.js"></script> <body> <h1>Hello Bokeh!</h1> <p> Below is a simple plot of stock closing prices </p> {{ script|safe }} {{ div|safe }} </body> </html> When i'm executing it,my html page does not displaying any plot -
Dango: form rendering empty fields when calling with POST and an instance of the model
I want to add an edit option to a template that just retrieves data from a model and displays it. When the edit button is clicked, the form that has been previously filled and saved, should show up being populated with saved data. But in my case, the form is rendering with empty fields and showing "This field is required" above each field. How do i render the form in editable mode with fields pre-populated? This is the view for first time data saving: @login_required def addprofileView(request): if request.method == "POST": form = UserProfileForm(request.POST, request.FILES) if form.is_valid(): new_user_profile = form.save(commit=False) new_user_profile.user = request.user new_user_profile.save() return redirect('add_license') else: form = UserProfileForm() return render(request, 'addprofile.html', {'form': form}) And this is the view for editing and which should return pre-populated form: @login_required def editprofileView(request, pk): ac = get_object_or_404(Account, pk=pk) if request.method == "POST": form = UserProfileForm(request.POST, instance=ac) if form.is_valid(): ac = form.save(commit=False) ac.user = request.user ac.save() return redirect('view_profile', ac.pk) else: form=UserProfileForm(instance=ac) return render(request, 'addprofile.html', {'form': form}) What am I doing wrong? -
PostgreSQL saving date in 'Local time zone' while i set it to 'UTC' with Django
I m trying to save date in UTC format, but it being save in my localtimezone It is okay till Django view but after .save() it stores in database as 'localtimezone' my setting.py LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_TZ = True model.py class Career(models.Model): """ model for storing all leads from career section of front apps """ name = models.CharField(max_length=200) email = models.CharField(max_length=200) phone = models.CharField(max_length=20, blank=True, null=True) status = models.BooleanField(default=1) created_on = models.DateTimeField(null=True, blank=True) updated_on = models.DateTimeField(null=True, blank=True) class Meta: db_table = 'career_leads' my views file class CareerFormApi(APIView): def post(self, request): career_serializer = CareerPostSerializer(data=request.data) career_data = request.data if career_serializer.is_valid(): career_serializer.validated_data['created_on'] = timezone.datetime.now() career_serializer.validated_data['updated_on'] = timezone.datetime.now() # I am geeting correct time zone here. print(timezone.datetime.now()) career_serializer.validated_data['status'] = True #after save i check my Database where it saved as my localtime zone career_serializer.save() return Response({ 'status': status_code.HTTP_201_CREATED, 'message': 'Detail has been saved successfully.' }, status=status.HTTP_201_CREATED) return Response(career_serializer.errors, status=status.HTTP_400_BAD_REQUEST) P.S. I have change my postgres timezone as well in to UTC like this set timezone='UTC'; But it didn't work. -
Django Admin list_per_page for a multichoicefield m2m
I have a m2m relationship setup and it works on the admin side. however it lists all 60,000 records (as it should), to make this work more efficiently when loading how do I limit the number of returned records. I have looked into the list_per_page option to add to the admin.py but this seems to work for the object list, I need to have this in the multiselectfield. Any ideas? # models.py class Sample(models.Model): sample_id = models.AutoField(primary_key=True) area_easting = models.IntegerField(choices = EASTING_CHOICES) area_northing = models.IntegerField(choices = NORTHING_CHOICES) context_number = models.IntegerField() sample_number = models.IntegerField() sample_type = models.CharField(max_length=200, default='', blank=True, null=True, choices = MATERIALS) weight = models.DecimalField(max_digits=6, decimal_places=2) description = models.CharField(max_length=500, default='', blank=True, null=True) recovery_method = models.CharField(max_length=200, default='', blank=True, null=True, choices = RECOVERY_METHODS) taken_by = models.ForeignKey(settings.AUTH_USER_MODEL, db_column='taken_by', on_delete = models.PROTECT, related_name='depotsample_taken_by') comments = models.CharField(max_length=1000, default='', blank=True, null=True) def __str__(self): return str(self.sample_number) class Meta: db_table = 'kap\".\"sample' #ordering = ["sample_id"] managed = True #verbose_name_plural = "samples" class Container(models.Model): container_id = models.AutoField(primary_key=True) container_name = models.CharField(max_length=50, blank=True, null=True) container_type = models.CharField(max_length=50, blank=True, null=True) location_id = models.ForeignKey(Location, db_column='location_id', on_delete = models.PROTECT) samples = models.ManyToManyField('Sample') icon_desc = models.ForeignKey(Icon, db_column='icon_desc', null=True, blank=True, default='Box',on_delete = models.PROTECT) def __str__(self): return self.container_name The admin side: # admin.py class ContainerAdmin(admin.ModelAdmin): list_display = … -
Django Multistage FilterSet
Is there a way to use the django FilterSet from the django_filters library dynamically so that the second dropdown is dependant on the first one, the third on the the first and second and so on. Lets say I have the following models.py : class CSV4(models.Model): var1 = models.CharField(max_length=100) var2 = models.CharField(max_length=100) var3 = models.CharField(max_length=100) var4 = models.CharField(max_length=100) var5 = models.CharField(max_length=100) var6 = models.CharField(max_length=100) var7 = models.CharField(max_length=100) var8 = models.CharField(max_length=100) var9 = models.CharField(max_length=100) class CSVFilter(django_filters.FilterSet): entries = CSV5.objects.values_list('val1', flat = True).distinct() val1_choice = [(e, e) for e in entries] #print("e" , val1_choice) val1 = django_filters.ChoiceFilter(choices = val1_choice) entries = CSV5.objects.values_list('val2', flat=True).distinct() val2_choice= [(e, e) for e in entries] val2= django_filters.ChoiceFilter(choices=val2_choice) entries = CSV5.objects.values_list('val3', flat=True).distinct() val3_choice= [(e, e) for e in entries] val3= django_filters.ChoiceFilter(choices=val3_choice) entries = CSV5.objects.values_list('val4', flat=True).distinct() val4_choice = [(e, e) for e in entries] val4 = django_filters.ChoiceFilter(choices=val4_choice) my views.py def filter_port(request): instance = CSV5.objects.values() user_filter = CSVFilter(request.POST or None, queryset=instance) template: {% if user.is_authenticated %} <form method="POST" id = "form1"> {% csrf_token %} {{ filter.form }} <button name="filter_port" type="submit">Search</button> </form> <ul> {% for excel5 in filter.qs %} <li> {{ excel5.val5 }} - {{ excel5.val6 }} - {{ excel5.val7 }} - {{ excel5.val8 }} - {{ excel5.val9 }} <a href … -
Django: optimizing a query with spread data
I have Order objects and OrderOperation objects that represent an action on a Order (creation, modification, cancellation). Conceptually, an order has 1 to many order operations. Each time there is an operation on the order, the total is computed in this operation. Which means when I need to find the total of an order, I just get the last order operation total. The simplified code class OrderOperation(models.Model): order = models.ForeignKey(Order) total = DecimalField(max_digits=9, decimal_places=2) class Order(models.Model): @property def last_operation(self) -> Optional['OrderOperation']: try: qs = self.orderoperation_set.all() return qs[len(qs) - 1] except AssertionError: # when there is a negative indexing (no operation) # IndexError can not happen return None @property def total(self) -> Optional[Decimal]: last_operation = self.last_operation return last_operation.total if last_operation else None The issue Since I get lots of orders, each time I want to make a simple filtering like "orders that have a total lower than 5€", it takes a long time, because I need to browse all orders, using the following, obviously bad query: all_objects = Order.objects.all() Order.objects.prefetch_related('orderoperation_set').filter( pk__in=[o.pk for o in all_objects if o.total <= some_value]) My current ideas / why I tried Data denormalization? I could simply create a total attribute on Order, and copy the operation … -
combine django-filter DateTimeFromToRangeFilter and DateTimeInput(datepicker)
Using django_filter and datetimeinput as a datepicker, I am trying to add a date and time input, a FROM, and TO fields. I have only been able to use a dateinput with just one field from django forms or from django filter DateTimeFromToRangeFilter without the date picker showing (just manual text entry). Here is my filter_model.py for the one field with a date picker. from app.models.api_status import ApiStatus import django_filters from django import forms class DateTimeInput(forms.DateTimeInput): input_type = 'date' # working solution for just 1 date field class ApiStatusFilter(django_filters.FilterSet): date_time = django_filters.DateFilter( label=('With start date'), lookup_expr=('icontains'), # use contains, widget=DateTimeInput() ) class Meta: model = ApiStatus fields = ['id', 'date_time'] Picture shows a clickable date picker popup. Here is my filter_model.py for the two fields, FROM and TO without a date picker. from app.models.api_status import ApiStatus import django_filters from django import forms class DateTimeInput(forms.DateTimeInput): input_type = 'date' class ApiStatusFilter(django_filters.FilterSet): date_time =django_filters.DateTimeFromToRangeFilter() class Meta: model = ApiStatus fields = ['id', 'date_time'] widgets = { 'date_time': forms.DateTimeInput(attrs={'placeholder':'Select a date'}) } Picture below shows a manual text input without a datepicker popup. Here is my template file although I didn't alter it much when trying the two approaches above. status_template.html {% load static … -
django urls.py changes not reflecting
I have an API running at the endpoint: sitename.net/sitename-api/myapi. It was working perfectly fine until I decided to change the url to sitename.net/sitename-api/myapi1. This is what my myapi/urls.py file looks like: from django.conf.urls import url from .views import myapi_view urlpatterns = [ url(r'^myapi1$', myapi_view.as_view()) ] But I still get 404 when I try to reach myapi1. I tried deleting pycache and restarting the development server but it did not help. Can anyone here suggest a possible solution? INFO: This is what my sitename-api/urls.py file looks like : from django.conf.urls import url from django.conf.urls import include urlpatterns = [ url(r'^sitename-api/', include('myapi.urls')), url(r'^sitename-api/', include('anotherapi.urls')) ] -
Add current user id in a django model
I am developing a web app for online quiz .For that i want to save the current userid(logged in user) in a model .I am using model form in django and i dont know how to add current user(logged in user) in the model.Pls help Thanks in advance -
Multi tenant application in django
I am working on an application where I will need to backup databases separately for each client and generally separate clients from each other. I was looking for a solution and found the term “Multi tenant applications”. Did anyone deal with this approach to building SaaS? Is this something difficult? I would ask for an opinion, hint, what approach is good for a young application. I saw three approaches there: Shared database with shared schema Shared database with isolated schema Isolated database with a shared app server -
Celery Periodic Tasks not running in Django
file structure proj/proj/ celery.py (and other files) /sitesettings/ tasks.py (and other files) celery.py app = Celery('mooncake',broker_url = 'amqp://') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() sitesettings/tasks.py from __future__ import absolute_import, unicode_literals from comma.models import Post from mooncake.celery import app app.conf.beat_schedule = { 'every-5-seconds': { 'task': 'sitesettings.tasks.statisticsTag', 'schedule': 5.0, 'args': () }, } @app.task def statisticsTag(): print(Post.objects.all()[0]) and run it with celery -A proj beat -l info it out put with [2019-02-22 18:21:08,346: INFO/MainProcess] Scheduler: Sending due task every-5-seconds (sitesettings.tasks.statisticsTag) but no further output. I used to try write it in proj/celery.py, but it cannot run cuz I have to import from another app, it exit with "app not loaded" error. So what should I do? -
Django python 'sql_server.pyodbc' isn't an available database backend
I'm trying to connect my Django app to microsoft sql database on apache server but I get the following error messages: django.core.exceptions.ImproperlyConfigured: 'sql_server.pyodbc' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3' I have installed django-pyodbc-azure and it's showing up as part of (pip freeze list): Django==2.1 django-pyodbc==1.1.3 django-pyodbc-azure==2.1.0.0 pyodbc==4.0.25 Here is settings.py database configuration: 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'name', 'USER': 'user', 'PASSWORD': 'password', 'HOST': 'host', 'PORT': '', 'OPTIONS': { 'driver': 'ODBC Driver 17 for SQL Server', }, }, Inside site-packages folder, it's doesn't show the actual django-pyodbc-azure folder but when i run the command (pip show django-pyodbc-azure), it shows the package location (/usr/local/lib/python3.5/dist-packages) which means it's successfully installed. So I'm not really sure what is the problem. -
Is it dangerous to devlop a Django App on Windows 10 and run the production server on Ubuntu?
I'm using a Shadow PC computer. A Windows 10 cloud desktop with the latest configuration to run graphic apps at full res for 30€/mounth. The drawback is that I can't install a virtual machine with Linux for dev. I have small Django based open source projects. I'm the only one to dev on it. The production server is a VPS with Ubuntu Server. Since I can't get Linux on my machine to run the IDE this let me a few choices : - Dev on Windows 10 and run the production server on Ubuntu. - Dev directly on the production server None of it seems to be very ideal. I feel like the best would be to devlop locally on Windows. However, will I run into big drawbacks when deploying on Linux ? -
How to add data of two different serializers to be passed as refrence in Django Rest Framework
I have two models A and B which are not related two each other. I want to serialize those two models and send them as one request object, suppossedly as below : data{ 'A':{}, 'B':{} } I have seperate serializers for both A and B