Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django CreateView maintaining data between requests
I'm currently using class-based views for a service that uses external APIs and facing a problem with CreateView that does not maintain initial data between GET (rendering the form) and POST (uploading data). This view/route actually gets data from a webservice and the user is just required to be shown the data and upload a file. The webservice request is wrapped in a fetch method of the model manager: class OrderManager(models.Manager): def fetch(self, user): data = requests.get(...).json() return dict(student=user, foo=data['bar']) And for the CreateView: class OrderForm(ModelForm): class Meta: fields = ['picture'] model = Order class OrderCreateView(LoginRequiredMixin, CreateView): form_class = OrderForm model = Order def get_initial(self): return self.model.objects.fetch(self.request.user) It works fine, when the user hits GET /order/new/ it correctly renders the data fetched from the webservice and presents the file upload form. But when the form is submitted, it again runs get_initial(...) instead of maintaining data from the previous request, and hits the webservice once again. I'd like to maintain this data between GET and POST requests so I don't need to fetch data again, how is it possible with class-based views, and preferably without a lot of extra work? I was thinking about caching the requests but it doesn't really … -
Google Map not rendering Json Data in Django
I'm trying to display specific coordinates in a database on a google map with markers. Right now I'm trying to use a simple marker. Background: I have a local json file in static/maps/jason_data.json I'm using google api and I'm using their template here. <div id="map"></div> <script async defer src="https://maps.googleapis.com/maps/api/js?key=APIKEY&callback=initMap"> </script> <head> <style> #map { height: 600px; width: 800px; margin: 0 auto; } </style> </head> <body> <div id="map"></div> <script> var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { zoom: 14, center: new google.maps.LatLng(a,b), mapTypeId: 'roadmap' }); results = map.data.loadGeoJson('/maps/json_data.json'); window.eqfeed_callback = function(results) { for (var i = 0; i < results.features.length; i++) { var coords = results[i].features[0].geometry.coordinates; var latLng = new google.maps.LatLng(coords[1],coords[0]); var marker = new google.maps.Marker({ position: latLng, map: map }); } } </script> </body> </html> </div> The error I'm getting is Error parsing /maps/json_file.json: SyntaxError: Unexpected token < in JSON at position 1 An example of the json file {"id48": {"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": ["a", "-b"]}, "type": "Point"}], "properties": {"prop1": "property", "id": 48}},...} I'm trying to format the json file through python similar to other GEOJson options. My apologies I haven't used javascript before. -
Django site goes down for a minute at a time throughout the day
Here is a timeline of the uptime for the past 24 hours. The uptime is green and red is the downtime. top output: Here is Google Analytics for sessions on hourly basis: -
Starting Django virtual environment + build commands with gulp
I am trying to make my Django project super portable and easy to start/stop. I'm using python's virutal environments along with a pip requirements file to manage python versions and pip packages. One concern I've always wondered about is migrating test data between databases. I'm utilizing: python manage.py dumpdata > fixtures/data.json to dump the current test data to a file and I want the next developer to pull this test data when they start their env using: python manage.py loaddata fixtures/data.txt So, the overall goal is to create a simple gulp command to do the following: pull latest git commit, start virtual env, merge test data into database, start server I couldn't get gulp to start the virtual enviorment but if there is another way I should try and automate this, let me know. -
How can I show model object through Forms to template?
There is a complex structure in my models and I don't know how I can link a Foreign Key to a Many to Many field on the same template. It be easier to explain once the models.py is seen : class Font(models.Model): font_name = models.CharField(max_length=100) ... class Background(models.Model): bk_color = models.CharField(max_length=20, blank=True) ... class FormOne(models.Model): name = models.CharField(max_length=40) background = models.ForeignKey(Background, blank=True, null=True) checkbox = models.ManyToManyField(Font, blank=True) ... I would like to do the following for each Font Item add a background color (bk_color) from the Foreign Key. Here comes the tricky part, this should be done on a Form. The user cannot choose his background, it's defined by the admin only through a Radio Select. so I would like it the Form to show me something like this for the background color on each item. Title : ____________ Checkbox : [ X ] font_name1 - #333333 <-- Color Set by the admin on the administration panel [ _ ] font_name2 - #94D32F [ X ] font_name3 - #ffffff The problem is that if I show the colors by the views I cannot give each checkbox item his own specific color. How can I achieve the following ? forms.py : … -
Unable to migrate database using postactivate hooks on django and virtualenvwrapper
I am new to website creation and am looking to create a website using django and mysql. I have been following the following tutorial: http://www.marinamele.com/taskbuster-django-tutorial/install-and-configure-posgresql-for-django (note: I have been following the tutorial from the start, not just from that point). My problem comes near the bottom of that page when I try to migrate the database using python3 manage.py migrate. This is the error I get: Traceback (most recent call last): File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/db/backends/base/base.py", line 171, in connect self.connection = self.get_new_connection(conn_params) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection connection = Database.connect(**conn_params) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/psycopg2/init.py", line 164, in connect conn = _connect(dsn, connection_factory=connection_factory, async=async) psycopg2.OperationalError: FATAL: role "‘sohaib_taskbuster’" does not exist The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/core/management/init.py", line 367, in execute_from_command_line utility.execute() File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/core/management/init.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute output = self.handle(*args, **options) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 83, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/db/migrations/executor.py", line 20, in init self.loader = MigrationLoader(self.connection) File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/db/migrations/loader.py", line 52, in init self.build_graph() File "/Users/sohaiba/.virtualenvs/env1/lib/python3.5/site-packages/django/db/migrations/loader.py", line 203, in build_graph … -
JOIN repeated rows django ORM python
I have the following model class Cierre(models.Model): bus=models.ForeignKey(Bus) ruta=models.ForeignKey(Ruta,editable=False) conductor=models.ForeignKey(Conductor,editable=False) total_pasajeros = models.IntegerField(editable=False) total_viaje = models.FloatField(editable=False) and with this data Ruta Bus conductor Total pasajeros Valor total viaje 1 qwe789 1111111 50 107500.0 1 qwe789 1111111 100 215000.0 2 qwe789 1111111 50 102500.0 i need if the column 'Ruta' and column 'conductor' is been repeat, to join respective column 'valor total viaje' the result i want is this: Ruta Bus conductor Total pasajeros Valor total viaje 1 qwe789 1111111 50 322500.0 2 qwe789 1111111 50 102500.0 i have tried: cierre = Cierre.objects.annotate(sales=Sum('ruta')) and cierre = Cierre.objects.annotate( count_ruta = Count('ruta') ).order_by( 'ruta' ).filter( count_ruta__gt=1 ).distinct() -
Nginx+uWSGI+Django are returning 502 when big request body and expired session
I have a django view that process POST request with random size(between 20 char to 30k char). This API is only available for resisted users and is validated with a session header. The API works well with my test cases but I notice some 502 in the nginx log. The error log show this line:: 2016/12/26 19:53:15 [error] 1048#0: *72 sendfile() failed (32: Broken pipe) while sending request to upstream, client: XXX.XXX.XXX.XXX, server: , request: "POST /api/v1/purchase HTTP/1.1", upstream: "uwsgi://unix:///opt/project/sockets/uwsgi.sock:", host: "staging.example.com" After some tests I managed to recreate this call with a big body request. curl -XPOST https://staging.example.com/api/v1/purchase \ -H "Accept: application/json" \ -H "token: development-token" \ -H "session: bad-session" \ -i -d '{"receipt-data": "<25677 character string>"}' HTTP/1.1 100 Continue HTTP/1.1 502 Bad Gateway Server: nginx/1.4.6 (Ubuntu) Date: Mon, 26 Dec 2016 19:54:32 GMT Content-Type: text/html Content-Length: 181 Connection: keep-alive <html> <head><title>502 Bad Gateway</title></head> <body bgcolor="white"> <center><h1>502 Bad Gateway</h1></center> <hr><center>nginx/1.4.6 (Ubuntu)</center> </body> </html> What it seems to happen is that the django checks that the session is not valid and return the response(403) before the client finish deliver the body. If I'm correct, is there a way to make django to send that 100 status after check the headers … -
Django ChoiceField Validation of Dynamically Built List - "That choice is not one of the available choices"
I am trying to build the ChoiceField of a Django form dynamically depending on result of a Python list. Basically Python list is itself returned from a constants dictionary depending on supplied key. Items in returned list are integers which is why a second lookup is performed while building form ChoiceField, so that attached string constants can be added along with integer variable to each element of form list parameter. So ChoiceField is built as: [integer, constants.get_str(integer) for status in statuses] where constants.get_str()returns the linked string representation of integer elements in returned statuses. All works fine in terms of form display. However I keep getting form error of "xx choice is not one of the available choices". Looking at Django form ChoiceField validation code: def valid_value(self, value): "Check to see if the provided value is a valid choice" text_value = force_text(value) for k, v in self.choices: if isinstance(v, (list, tuple)): # This is an optgroup, so look inside the group for options for k2, v2 in v: if value == k2 or text_value == force_text(k2): return True else: if value == k or text_value == force_text(k): return True return False supplied variable to form ChoiceField is not of list or … -
Unable to match trailing slash after email address in url regex
I can't match an email address with a trailing slash in my url regex, and I can't figure out why. Here's the regex that matches the email address with no trailing slash: r'^customer/(?P<customer_email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,63}$)$' As expected, this matches /customer/someone@example.com, and not /customer/someone@example.com/ I would have thought that appending /? would work, given that the regex to match the domain suffix of the email address should not greedily match the slash. (This was the solution to many of the other duplicate regex trailing-slash questions). r'^customer/(?P<customer_email>[\w.%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,63}$)/?$' As expected, this matches /customer/someone@example.com, but unexpectedly it doesn't match /customer/someone@example.com/. Why? APPEND_SLASH in settings.py is not set. I don't want to capture the slash as part of the customer_email url parameter. -
How to update a model which contains m2m field django?
I have the following model, from which I created a ModelForm. I included the save_m2m because it was not saving the many to many fields when I was submitting the form. I also use 2 different views to create or update because I thought this was what was causing the creation of a new record. However, instead of updating the instance, it creates a new one. So how can I edit a model's data which contains many to many fields? models.py class GeneralContract(models.Model): idcontract = models.IntegerField(primary_key=True) client=models.ForeignKey(Person) issuedate = models.DateTimeField() # Field name made lowercase. plan = models.ManyToManyField(Generalbusinessplans) annualpremium = models.FloatField() # Field name made lowercase. doses = models.IntegerField(blank=True, null=True) views.py def addContractGeneralView(request): added=False if request.method == 'POST': contract_form = GeneralContractForm(request.POST) if contract_form.is_valid(): profile = contract_form.save(commit=False) p = Person.objects.get(idperson=contract_form.cleaned_data['client'].idperson) print p if p.isclient == 0: print 'in if' p.isclient = 1 p.save() profile.save() contract_form.save_m2m() print profile.plan added = True else: print contract_form.errors else: contract_form = GeneralContractForm() return render(request, 'leadsMasterApp/addContractGeneral.html', {'add_contract_form':contract_form,'added': added}) def editContractGeneralView(request,pk): instance=get_object_or_404(GeneralContract, pk=pk) added=False if request.method == 'POST': contract_form = GeneralContractForm(request.POST,instance=instance) if contract_form.is_valid(): profile = contract_form.save(commit=False) p = Person.objects.get(idperson=contract_form.cleaned_data['client'].idperson) print p if p.isclient == 0: print 'in if' p.isclient = 1 p.save() profile.save() contract_form.save_m2m() print profile.plan added = … -
Error loading cx_Oracle : No module named 'cx_Oracle' in WINDOWS
I am trying to connect to Oracle database with Django using Visual Studio 2015. I get the following error: improperlyConfigured: No module named 'cx_Oracle' Note: 1) cx_Oracle works perfectly in python 2) Already have the latest cx_Oracle installed 3) Tried installing Oracle Instant Client 12.1 and set its PATH in the environment variable Can anyone help with this? Thank you! -
I cant override method save in model
I need your help. I want to add Youtube video on my site, but there is a subtetly. In browser user see URl like that: https://www.youtube.com/watch?v=iD8THN4wySA But for forms on my site i need change URl like that: https://www.youtube.com/embed/iD8THN4wySA So i create a model with that code: class Video(models.Model): user = models.ForeignKey('auth.User') title = models.CharField(u'Заголовок',max_length =200) url = models.CharField(u'URL-адрес',max_length=200) width = models.IntegerField(u'Ширина',) height = models.IntegerField(u'Высота',) published_date = models.DateTimeField(u'Время публикации',blank=True, null=True) def save(self, *args, **kwargs): self.url = self.url.replace('https://www.youtube.com/watch?v=','https://www.youtube.com/embed/') super(Video, self).save(*args, **kwargs) def __str__(self): return self.title That's work in my local testing (manage.py runserver), but on site url dont changed. What i do wrong? -
How can admin form choose a random initial object from Foreign Key each time content is created?
I want to create a Radio Select form where the initial select changes randomly everytime a content is about to be created, so the admin doesn't have to change it, unless he wants to. I am using a Foreign Key to link the objects of a model to another one. How can I achieve this ? Here is what I thought to do (something like this) : app/forms.py class FormOneForm(forms.ModelForm): class Meta: model = FormOne fields = ['name', 'background'] random_idx = random.randint(0, Background.objects.count() - 1) initial = Background.objects.get(id=random_idx) background = BackgroundChoiceField(widget=forms.RadioSelect, queryset=Background.objects.all(), initial=initial) Note that the random select should not change when the form is saved but when I access the form on the admin panel, so the default value has to change each time I enter the page. app/models.py class Background(models.Model): bk_color = models.CharField(max_length=20, blank=True) def __str__(self): return self.bk_color class FormOne(models.Model): name = models.CharField(max_length=40) background = models.ForeignKey(Background, blank=True, null=True) def __str__(self): return self.name Any suggestion ? I prefer not to use order_by() for performance issues on production level. -
Run docker container from python webapp
I have a Django webapp where I want to run multiple script in separate docker containers via the web frontend. These scripts all have different dependancies, different languages and are long running and I want the possibility to run many in parallel. I was thinking of either having my django app call a celery task queue which then calls my docker command using subprocess. using an asynchronous webframework such as tornado What is a better way to call these from the webapp view? -
How can filter by list in django
I am trying to filter a queryset by a list I am getting unicode data into format of 1,4,5,6 by category = request.GET['category'] print type(category) i extaracted data into list by l1=[] category_list =category.split(',') for i in category_list: a =int(i) l1.append(a) Now l1 is type of list containing data l1=[1,4,5,6] Now when i am trying to filter a queryset by this data = Leads.objects.filter(item_required__id= 1 ) then i am getting a error int() argument must be a string or a number, not 'list' So how can i fix this. Thanks in advance. -
"Select a valid choice." when using modelform_factory() on django_enums.EnumField
I have an EnumField from django_enums in my model and now want to implement selecting values in a form. Here is my enum and my model: models.py from django_enums import enum # uses enum34 class StatusEnum(enum.Enum): __order__ = 'AT BT BC AC' # for python 2 AT = (u'AT', u'Активен') BT = (u'BT', u'Блокирован временно') BC = (u'BC', u'Блокирован навсегда') AC = (u'AC', u'Активен навсегда') class EmployeesStatus(models.Model): name = models.CharField(max_length=128) status = enum.EnumField(StatusEnum, default=StatusEnum.AT) status_comment = models.CharField(max_length=128, blank=True, default='') department = models.ForeignKey(Departments, null=True) position = models.CharField(max_length=256, blank=True) I try to use it this way (in the class of a library, which gets model and field list): Form = modelform_factory(self.model, fields=self.fields) form = Form({'name': 'Kelly', 'status' : 'AT', 'department' : 1}) And it understands what to select: <tr><th><label for="id_status">Status:</label></th><td><ul class="errorlist"><li>Select a valid choice. Активен is not one of the available choices.</li></ul><select id="id_status" name="status" required> <option value="AT" selected="selected">Активен</option> <option value="BT">Блокирован временно</option> <option value="BC">Блокирован навсегда</option> <option value="AC">Активен навсегда</option> </select></td></tr> But as you can see with error "Select a valid choice. Активен is not one of the available choices.". I guess it waits key "AT" instead of value "Активен" but it takes the value by itself. How can I fix it? -
Does this belong on the front end or back end?
The web app i'm working on downloads mp3's from a separate source and provides them to the users. I'm worried this won't scale, since given a ton of users making requests for mp3's, my server has to download each of mp3 from the separate source before they are available for download by the users. Am i underestimating the performance of modern hosting services like AWS? Obviously I'd like to avoid the latency of the "extra" download, but rewriting that code in javascript is daunting to me so if its feasible I'd like avoid it for now. Conceptually its similar to those youtube-to-mp3 websites. Do those work by having the client machines directly download and convert the files from youtube? Or do their servers download the files and do all the work before uploading them to the client? -
default text for foreign key in form in django
I know that is the simple question but I have trouble with this I have a table that shows colors and I used this as foreign key in Post table class Post(models.Model): """docstring for Post""" user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1 ) slug = models.SlugField(unique=True) post_title = models.CharField(max_length=50, help_text="write about your product") color=models.ForeignKey(Color) phone=models.CharField(max_length=20) now when I want to show the form of Post to show the first row like this in color field now I want to show choose color instead of --------. -
Filtering data by date range
I have my payment model I what to be able to select by date class LeasePayment(CommonInfo): version = IntegerVersionField( ) amount = models.DecimalField(max_digits=7, decimal_places=2) lease = models.ForeignKey(Lease) leaseterm = models.ForeignKey(LeaseTerm) payment_date = models.DateTimeField() method = models.CharField(max_length=2, default='Ch', choices=PAYMENT_METHOD_CHOICES) Basically I want to be able to input 2 dates and display all the data between them . Righ now I started to implement this solution https://groups.google.com/forum/#!topic/django-filter/lbi_B4zYq4M based on django_filter. However since the task is pretty trivial was wondering if there an easier way. -
Celery beat periodic tasks fail when the app/tasks.py imports a Model
I have a program structure identical to the celery django demo that works fine. The problem is that in my demoapp/tasks.py analogue I import a model which triggers django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Strange to say the least. The entire point of the schedule is to update the database, so, unable to import models, it is useless. Here is the model code, however the error occurs no matter how many fields the model have, making me believe the error isn't there. I am tracking trains. from django.db import models # Create your models here. class Service(models.Model): id = models.TextField(primary_key=True) scheduled = models.DateTimeField() expected = models.DateTimeField(null=True, blank=True) # null means cancelled service = models.TextField() platform = models.TextField() origin = models.TextField() dest = models.TextField() And, for good measure, here are the contents of my celery.py: from __future__ import absolute_import, unicode_literals import os from celery import Celery from shitternrailways.tasks import get_trips # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'arlyon.settings') app = Celery('arlyon') # Using a string here means the worker don't have to serialize # the configuration object to child processes. # - namespace='CELERY' means all celery-related configuration keys # should have a `CELERY_` prefix. app.config_from_object('django.conf:settings', namespace='CELERY') @app.on_after_configure.connect … -
ImportError: DLL load failed: %1 is not a valid Win32 application. noob needs h3lp
I'm trying to run this script (http://forum.top-hat-sec.com/index.php?topic=5128.0), I am a noob in programming i've installed python34 and whenever I run it in CMD I get this : C:\Python34>nute.py Traceback (most recent call last): File "C:\Python34\nute.py", line 7, in <module> import lxml.html File "C:\Python34\lxml\html\__init__.py", line 42, in <module> from lxml import etree ImportError: DLL load failed: %1 is not a valid Win32 application. -
Elasticsearch/Django error: How to solve elasticsearch.exceptions.ConnectionError?
I am trying to use elasticsearch in my Django project. So, I followed the installation process recommended in this link. When I create a new index it raises an error - elasticsearch.exceptions.ConnectionError: ConnectionError(: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it) caused by: NewConnectionError(: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it) Even the same error raises when I do python manage.py rebuild_index for my Django project. I would appreciate helping me solve this. TraceBack: PUT http://localhost:9200/my-index [status:N/A request:2.168s] Traceback (most recent call last): File "c:\python34\lib\site-packages\django\core\management\commands\shell.py", line 69, in handle self.run_shell(shell=options['interface']) File "c:\python34\lib\site-packages\django\core\management\commands\shell.py", line 61, in run_shell raise ImportError ImportError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\python34\lib\site-packages\urllib3\connection.py", line 138, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "c:\python34\lib\site-packages\urllib3\util\connection.py", line 98, in create_connection raise err File "c:\python34\lib\site-packages\urllib3\util\connection.py", line 88, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\python34\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 78, in perform_request response = … -
why is this django template elif not working
I can't figure out why this simple if ... else ... endif is not working. The two variables being compared in the if are equal in the page output so the if should not trigger but it does. Any help is appreciated. {% if view.get_player_id != user.id %} <h1>'{{ view.get_player_id }}' '{{ user.id }}' Only {{ view.get_player_name }} can edit this page</h1> {% else %} ... {% endif %} And this is the page output: '4' '4' Only Leo Messi can edit this page -
ipython plotly map render on a django template
This is what I am doing in an ipython notebook where the plotly graphs and everything gets generated without fail. After that I am taking the html form of the notebook and embedding it in a django template where everything is working other than the plotly graphs. I am not sure what needs to be done thats why I also tried installing plotly on npm and also including a reference to plotly.js through my template. Below are the codes. import pandas as pd import numpy as np from plotly.offline import download_plotlyjs, init_notebook_mode, iplot from plotly.graph_objs import * init_notebook_mode() data = pd.read_csv("storage/AviationDataUp.csv") useful_columns = ['Event.Date', 'Location', 'Country', 'Latitude', 'Longitude', 'Purpose.of.Flight',\ 'Total.Fatal.Injuries','Number.of.Engines','Air.Carrier'] data = data[useful_columns] data = data[data['Country']=='United States'] accident_trace = Scattergeo( locationmode = 'ISO-3', lon = data['Longitude'], lat = data['Latitude'], mode = 'markers', marker = dict( size = 2, opacity = 0.75, color="rgb(0, 130, 250)"), name = 'Accidents' ) layout = dict( title = 'Aviation Accidents in USA', geo = dict( scope = 'usa', projection = dict(), showland = True, landcolor = 'rgb(250, 250, 250)', subunitwidth = 1, subunitcolor = 'rgb(217, 217, 217)', countrywidth = 1, countrycolor = 'rgb(217, 217, 217)', showlakes = True, lakecolor = 'rgb(255, 255, 255)' ) ) …