Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django rollback transaction after perform_create
I am trying to use transaction.atomic with django without any luck I know I am doing something wrong but I dont know what. class SnapshotView(BaseViewSet): serializer_class = SnapshotSerializer @transaction.atomic def perform_create(self, serializer): # this will call serializer.save() snapshot = snapshot = super().perform_create(serializer) # this will run some code can raise an exception SnapshotServices.create_snapshot(snapshot=snapshot, data=serializer.initial_data) the first method that creates a new snapshot will pass the second will raise but still I can see my snapshot instance in the db, why is that? I am in transaction block and something fails, is django not suppose to do a rollback? the second method will throw a custom exception I read the doc and it seems that I am doing everything right. -
Django admin plugin for scanning table list
Is there any Django Admin plugin, which scans on start the whole schema for table/column list and configures Django Admin for all tables in schema? I want to make admin panel for non-django application, because there is no better admin panel than Django, but I don't want to sync schema definition between node.js and Django -
Error with celery worker in elastic beanstalk (using django and SQS) [ImportError: The curl client requires the pycurl library.]
I'm trying to deploy to elastic beanstalk a django project that uses celery periodic tasks, using SQS. I've been more or less following the instructions here: How to run a celery worker with Django app scalable by AWS Elastic Beanstalk? When I deploy to eb, the periodic tasks are not being executed. Checking the celery-beat log, everything seems right: celery beat v4.2.1 (windowlicker) is starting. __ - ... __ - _ LocalTime -> 2019-01-27 09:48:16 Configuration -> . broker -> sqs://AKIAIVCNK32ABCHNNZSQ:**@localhost// . loader -> celery.loaders.app.AppLoader . scheduler -> django_celery_beat.schedulers.DatabaseScheduler . logfile -> [stderr]@%INFO . maxinterval -> 5.00 seconds (5s) /opt/python/run/venv/local/lib64/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>. """) [2019-01-27 09:48:44,659: INFO/MainProcess] beat: Starting... [2019-01-27 09:48:44,660: INFO/MainProcess] Writing entries... [2019-01-27 09:48:44,809: INFO/MainProcess] DatabaseScheduler: Schedule changed. [2019-01-27 09:48:44,809: INFO/MainProcess] Writing entries... [2019-01-27 09:48:49,865: INFO/MainProcess] Writing entries... [2019-01-27 09:49:00,409: INFO/MainProcess] Scheduler: Sending due task sum_two_numbers (sum_two_numbers) [2019-01-27 09:50:00,050: INFO/MainProcess] Scheduler: Sending due task sum_two_numbers (sum_two_numbers) [2019-01-27 09:51:00,045: INFO/MainProcess] Scheduler: Sending due task sum_two_numbers (sum_two_numbers) [2019-01-27 09:51:50,543: INFO/MainProcess] Writing entries... [2019-01-27 09:52:00,048: INFO/MainProcess] Scheduler: Sending due task sum_two_numbers (sum_two_numbers) [2019-01-27 09:53:00,045: INFO/MainProcess] Scheduler: … -
How can I set the field value in django admin based in another field's lookup?
I'd like to get the product price of the selected product and set to price in Order_line. Theres are the models: class Category(models.Model): name = models.CharField(max_length=255) class Product(models.Model): part_number = models.CharField(max_length=255) category = models.ForeignKey('Category') price = models.DecimalField(max_digits=10, decimal_places=2) class Order(models.Model): customer = models.CharField(max_length=255) class Order_line(models.Model): order = models.ForeignKey('Order', on_delete=models.CASCADE) category = models.ForeignKey('Category', on_delete=models.CASCADE) product = models.ForeignKey('Product', on_delete=models.CASCADE) price = models.DecimalField(max_digits=10, decimal_places=2) -
Django is usable for data persistence?
I want use data persistence, but I had seen that spring for Java is better. But I want learn python but also I want use data persistence. What is your recommendation? -
Wagtail ListBlock - how to access first (any) element in template?
I have ListBlock called imagesin Wagtail. It works well. If I put {% page.images %} in a template, it render the html code like: <ul> <li>item1</li> <li>item2</li> </ul> But I am unable to find out how to get the first item of the list isolated. Or at least how to iterate over the list manually. I am pretty sure the solution is simple, however I am unable to google it, find in the docs, or understand from the wagtail source. -
Django Channels tutorial error - ConnectionRefusedError: [Errno 10061]
I am following the tutorial but when i check if the channel layer can communicate with Redis it is giving me error. I am using Window 10 OS. ERROR File "C:\Users\Suleman\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 935, in create_connection await self.sock_connect(sock, address) File "C:\Users\Suleman\AppData\Local\Programs\Python\Python37-32\lib\asyncio\selector_events.py", line 475, in sock_connect return await fut File "C:\Users\Suleman\AppData\Local\Programs\Python\Python37-32\lib\asyncio\selector_events.py", line 505, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 10061] Connect call failed ('127.0.0.1', 6379) setting.py CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { "hosts": [('127.0.0.1', 6379)], }, }, } -
Why am I receiving Forbidden (CSRF token missing or incorrect)?
I have been receiving Forbidden (CSRF token missing or incorrect) I have tried different solutions found on Stack Overflow but I am unable to fix it! I have tried to use the render_to_response, and when I do that I receive this error: This is usually caused by not using RequestContext. "A {% csrf_token %} was used in a template, but the context " This is the forms.py from django import forms from django.forms import widgets class AskForm(forms.Form): name = forms.CharField( max_length=30, widget=forms.TextInput( attrs={ 'placeholder': 'Write your name here' 'class': 'ask-page-input' 'label': 'Student Name' } )) email = forms.EmailField( max_length=254, widget=forms.EmailInput( attrs={ 'placeholder': 'Write your Email here' 'class': 'ask-page-input' 'label': 'Email' } )) subject = forms.CharField( max_length=50 widget=forms.TextInput( attrs={ 'placeholder': 'Write your Question or Related Subject here' 'class': 'ask-page-input' 'label': 'Subject' } )) message = forms.CharField( max_length=2000, widget=forms.Textarea( attrs={ 'placeholder': 'Write your message here' 'class': 'ask-page-input' 'label': 'Message' } )) source = forms.CharField( # A hidden input for internal use max_length=50, # tell from which page the user sent the message widget=forms.HiddenInput() ) def clean(self): cleaned_data = super(ContactForm, self).clean() name = cleaned_data.get('name') email = cleaned_data.get('email') subject = cleaned_data.get('subject') message = cleaned_data.get('message') if not name and not email and not subject and … -
Wagtail url prefix for a custom Page model
This question is probably trivial, but I am unable to see a simple solution. I have custom page model representing Post: class PostPage(Page): I would like to make all instances of this model (all Posts) accessible only with url prefix /posts/ Example: User creates new Post, the assigned slug will be awesome-first-post What should happen is, that /awesome-first-post/ will result in 404, while /posts/awesome-first-post/ will display the post. Note: I want this prefix only for the specific model Postpage. Other pages should be served directly from their slug. -
how to get django pagination unique item id across all pages?
I am learning how to implement django pagination. I want to let user save all changes (the whole form no matter which pagination )when he/she clicks the save-all button. However, when using forloop.counter0, the django will render duplicate forloop counter. How can I generate continuous unique id from 0 to n-1 so that at views.py, the views can recognize every items? Thanks! {% for thing in things %} <tr id="tr-{{ thing.id }}"> <td style="display:none"><input type="text" name="hidden-id-{{ forloop.counter0 }}" value="{{ thing.id }}"></td> </tr> {% endfor %} -
How to save bio using forms.ModelForm
I tried multiple links on stackov. but none worked, I can't get my bio form to save the data on the db for the user profile :/ I managed to save the first name and last name, but I can't make the bio save... This is my code: profile.html <div class="tab-pane active" id="home"> <br> <div class="form-group"> <div class="col-6"> <form method="POST" enctype="multipart/form-data"> {% csrf_token %} <label for="first_name"> <h4>First name</h4> </label> {{ user_ProfileForm.first_name |as_crispy_field }} <label for="last_name"> <h4>Last name</h4> </label> {{ user_ProfileForm.last_name |as_crispy_field }} <p> {{ user_BioAndSocialForm.bio |as_crispy_field }} </p> <div class="form-group"> <button class="btn btn-outline-info" type="submit">Update</button> </div> </form> </div> </div> <br> <hr> </div> views.py @login_required def profile(request): if request.method == 'POST': user_ProfileForm = UserProfileForm(request.POST, instance=request.user) user_BioAndSocialForm = BioAndSocialForm(request.POST, instance=request.user) if user_ProfileForm.is_valid() and user_BioAndSocialForm.is_valid: user_ProfileForm.save() user_BioAndSocialForm.save() messages.success(request, f'Profile updated!') return HttpResponseRedirect(request.path_info) else: messages.error(request, _('Please correct the error below.')) else: user_ProfileForm = UserProfileForm(instance=request.user) user_BioAndSocialForm = BioAndSocialForm(instance=request.user) context = { 'user_ProfileForm': user_ProfileForm, 'user_BioAndSocialForm': user_BioAndSocialForm } return render(request, 'users/profile.html', context) forms.py class BioAndSocialForm(forms.ModelForm): class Meta: model = Profile fields = ['bio'] def __init__(self, *args, **kwargs): super(BioAndSocialForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_show_labels = False models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) bio = models.TextField(max_length=500, blank=True) birth_date = models.DateField(null=True, blank=True) #Image feature upload image = models.ImageField(default='default.jpg', upload_to='profile_pics') … -
Deploy Django and ReactJS on Nginx
I deployed Django app on Nginx with configuration below server { listen 80; server_name server_domain_or_IP; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/sammy/myprojectdir; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } } Now, I want to deploy React App in the same server. After the deployment of React App, I still want to access Django Admin through server_domain_or_IP/admin and REST APIs through server_domain_or_IP/[api_url]. The URL to serve the index.html from React Apps will be on server_domain_or_IP. Can I just add another location like below and things will still go well? # where my frontend js files are location /frontend { alias /home/sammy/frontend; } In order to clear confusion between React App and Rest APIs route, I am planning to append /api on the Rest API route. Inside React JS, I am already calling the API with http://127.0.0.1:8000/author_list/. Will Nginx works fine without /api? -
How do I access variables from form_valid in get_success_url in a FormView?
After a user submits my form, I want to redirect the user to one of two URLs depending on the form input. Here is my code: class MyClass(FormView): template_name = 'my_template.html' form_class = MyForm def form_valid(self, form, *args, **kwargs): response = super().form_valid(form, *args, **kwargs) self.title = form.cleaned_data.get('title') self.special_id = form.cleaned_data.get('special_id') return response def get_success_url(self): if self.special_id: next_page = reverse_lazy('home:home', kwargs={'special_id': self.special_id}) else: initial_link = reverse_lazy('home:home') next_page = '{}?title={}'.format(initial_link, self.title) return next_page This code above does not work. One problem is that get_success_url doesn't recognize the variables self.special_id or self.title. How can I redirect users to different pages depending on the values in the form? -
Generating files after adding model instance through django admin interface
I'm writing a model for a website. When a user adds an instance of the model through the Django admin, I want to catch the event and automatically generate files, including adding a reference path field for those created files. Django admin has a clean method that can be overridden. I can create and update files and fields through this. def clean(self): info = self.cleaned_data.get('info') ... #Generate IO paths from info self.cleaned_data['template_path'] = template_path self.instance.template_path = template_path return self.cleaned_data I need to create a distinction between add and change events, so I'm not writing files and changing the pathing post object creation. Is there a way to do this within clean, or should I be looking elsewhere to create fields & update fields? -
How to choose particular field of another table as Foreign key of a Table? Sqlite3,Django==2.1
I have the following models: class Student(AbstractUser): email = models.EmailField(unique=True) roll = models.CharField(max_length=200, blank=False, unique=True, primary_key=True) contact_no = models.DecimalField( max_digits=10, decimal_places=0, blank=False, unique=True) objects = UserManager() class Event(models.Model): type_of_event = models.ForeignKey(EventType, on_delete=models.CASCADE) name = models.CharField(max_length=100) description = models.TextField() event_date = models.DateField() venue = models.CharField(max_length=200) entry_fee = models.FloatField() def __str__(self): return self.name def get_absolute_url(self): return reverse('dashboard') class EventParticipants(models.Model): event_name = models.ForeignKey(Event, on_delete=models.CASCADE) participant_roll = models.ForeignKey( Student, on_delete=models.CASCADE, default="123") How do I make the roll field in the model Student as the foreign key in the table EventParticipants. By default the username field from model Student is chosen as the foreign key. -
How to use more than two models in the same form using modelForms?
I am creating a new application using Django, my application is in need of a form to add data on the db. I am using 4 models which are all connected by foreign keys. How can I use modelForm's to enter data to the form and add them directly to db, if it's not possible what should be my approach? I checked the existing solutions which are for 2 models only, I couldn't find a way to tweak it to my own problem. I tried using inlineformset but as I said couldn't figure out how can I implement it with all my models together. I also looked through the Django documentation couple times but couldn't find anything this sort (maybe I am missing). My models are like this: class Question(models.Model): year = models.CharField(max_length=5) source = models.CharField(max_length=140) problemNumber = models.CharField(max_length=16) weblink = models.CharField(max_length=200) date_posted = models.DateTimeField(default=timezone.now) problemStatement = models.TextField() author = models.ForeignKey(User, on_delete=models.PROTECT) class QLevel(models.Model): qID = models.ForeignKey(Question, on_delete=models.CASCADE) level = models.CharField(max_length=16) class QMethod(models.Model): qID = models.ForeignKey(Question, on_delete=models.CASCADE) method = models.CharField(max_length=40) class QSubject(models.Model): qID = models.ForeignKey(Question, on_delete=models.CASCADE) subject = models.CharField(max_length=35) As can be seen 3 of the models are connected to Question model with a foreign key, whilist Question model is … -
What is the best way to organize images on a file system?
I have a site where I'd like to store multiple images (profile images, profile cover images, status images, etc.) What is the best way to store images on a file system? For example, would something like: Images avatars -ex1.jpg -ex2.jpg -ex3.jpg covers -ex1.jpg -ex2.jpg -ex3.jpg This is how Twitter lays out its images, will this make the file system sluggish? Or is better to do something like this: Images avatars user1 -ex1.jpg -ex2.jpg -ex3.jpg covers user1 -ex1.jpg -ex2.jpg -ex3.jpg What is the best way to organize images in a file system? -
I Want to start this animation on button click but form is valid?
I want to start this animation because I am creating an audio file which is taking time to prevent the user from further click I want to start this animation. Not getting any solution for it <form action="/textanalysis/upload_link/summarization/from_link" method="POST" id="form_id"> <h4 id="link2">Enter the Url::</h4> {{form.url}}<br> <h4 id="link2">Enter the No of Lines::</h4> {{form.no_of_lines}}<br><br> {%csrf_token%} <button type="submit" name="" class='btn btn-lg btn-primary' name="btnform2" value="content" onclick="ShowLoading();">Get Summary</button> </form> </div> <script type="text/javascript"> function ShowLoading(e) { var div = document.createElement('div'); var img = document.createElement('img'); img.src = "{% static 'css/images/final1.gif' %}"; div.innerHTML = "Loading... Be Patient We are Creating An Audio File For Your Summary<br />"; div.style.cssText = 'position: fixed; left:25%; top: 46%;z- index: 5000; width: 50%; text-align: center; background: #EDDBB0; border: 1px solid #B22222'; div.appendChild(img); document.body.appendChild(div); return true; } #django view if request.method=='POST': form=Take_User_Url_Form(request.POST) if form.is_valid(): #print(form.cleaned_data['no_of_lines']) link=form.cleaned_data['url'] no_of_lines=form.cleaned_data['no_of_lines'] -
Exception Type: AttributeError at /notifier/not/ Exception Value: 'AsgiRequest' object has no attribute 'loop'
when i tried to run a piece if code in my django application i have been faced with some strange error def main(request): async def hello(request): ws = web.WebSocketResponse() await ws.prepare(request) msg="this is awesome" ws.send_str(msg) # return HttpResponse("ok") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop = asyncio.get_event_loop() loop.run_until_complete(hello(request)) loop.close() when i run this code i just get Exception Value: 'AsgiRequest' object has no attribute 'loop' here is the complete traceback of the issue Environment: Request Method: GET Request URL: http://127.0.0.1:8000/notifier/not/ Django Version: 2.0.7 Python Version: 3.6.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest', 'accounts', 'connect', 'drones', 'notifier', 'rest_framework', 'rest_framework.authtoken', 'corsheaders', 'channels', 'oauth2_provider', 'social_django', 'rest_framework_social_oauth2', 'drfpasswordless', 'taggit', 'taggit_serializer', 'elasticsearch'] Installed Middleware: ['corsheaders.middleware.CorsPostCsrfMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', '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'] Traceback: File "C:\Users\madhumani\workspace\ven\lib\site-packages\django\core\handlers\exception.py" in inner 35. response = get_response(request) File "C:\Users\madhumani\workspace\ven\lib\site-packages\django\core\handlers\base.py" in _get_response 128. response = self.process_exception_by_middleware(e, request) File "C:\Users\madhumani\workspace\ven\lib\site-packages\django\core\handlers\base.py" in _get_response 126. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\madhumani\workspace\ven\drfc\notifier\views.py" in main 32. loop.run_until_complete(hello(request)) File "c:\users\madhumani\appdata\local\programs\python\python36-32\Lib\asyncio\base_events.py" in run_until_complete 467. return future.result() File "C:\Users\madhumani\workspace\ven\drfc\notifier\views.py" in hello 23. await ws.prepare(request) File "C:\Users\madhumani\workspace\ven\lib\site-packages\aiohttp\web_ws.py" in prepare 106. protocol, writer = self._pre_start(request) File "C:\Users\madhumani\workspace\ven\lib\site-packages\aiohttp\web_ws.py" in _pre_start 183. self._loop = request.loop Exception Type: AttributeError at /notifier/not/ Exception Value: 'AsgiRequest' object has no attribute 'loop' -
Can I use a URL other than "accounts" for django-allauth? I already have an app named "accounts" in my django project?
Can I change the following code: urlpatterns = [ ... url(r'^accounts/', include('allauth.urls')), ... ] to : urlpatterns = [ ... url(r'^something_else/', include('allauth.urls')), ... ] since I already have an app "accounts" in my django projects? Is the name "accounts" deeply integrated with django-allauth source code? -
Django: delete cookie from request
I know how to delete a cookie from response: response = HttpResponseRedirect(self.get_success_url()) response.delete_cookie("item_id") return response But how to delete a cookie from request? I've a view that only has a request but not a response: I'd like to delete the cart_id cookie when user arrives at my 'thanks.html' page. def thanks(request): order_number = Order.objects.latest('id').id return render(request, 'thanks.html', dict(order_number=order_number)) -
KeyError: <type="str> while making migration in Django
I created a model and Tried to migrate it, it is throwing error. from __future__ import unicode_literals from django.utils import timezone from django.db import models # Create your models here. class Post(models.Model): title = models.CharField(max_length = 200) body = models.TextField() created_at = models.DateTimeField(default=timezone.now, blank = True) This is the error I am getting after creating the Model. I am using mysql instead of sqlite3. Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemigrations.py", line 110, in handle loader.check_consistent_history(connection) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 283, in check_consistent_history applied = recorder.applied_migrations() File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 65, in applied_migrations self.ensure_schema() File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 52, in ensure_schema if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()): File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 254, in cursor return self._cursor() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 229, in _cursor self.ensure_connection() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 213, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 189, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 276, in get_new_connection conn.encoders[SafeBytes] = conn.encoders[bytes] KeyError: <type 'str'> -
How can I filter products to show only those belonging to selected category in Django Admin?
I am trying to filter the options shown in a foreignkey field within Django Admin inline. Using formfield_for_foreignkey I'm able to show products with category_id = 4 but instead of the 4 I would like to filter based in the category field in the inline. Using kwargs["queryset"] = Product.objects.filter(category=F('order_line__category')) does not get the category field value. class Order_lineInline(admin.StackedInline): model = Order_line def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "product": kwargs["queryset"] = Product.objects.filter(category=4) return super().formfield_for_foreignkey(db_field, request, **kwargs) class Category(models.Model): name = models.CharField(max_length=255) class Product(models.Model): part_number = models.CharField(max_length=255) category = models.ForeignKey('Category') price = models.DecimalField(max_digits=10, decimal_places=2) class Order(models.Model): customer = models.CharField(max_length=255) class Order_line(models.Model): order = models.ForeignKey('Order', on_delete=models.CASCADE) category = models.ForeignKey('Category', on_delete=models.CASCADE) product = models.ForeignKey('Product', on_delete=models.CASCADE) price = models.DecimalField(max_digits=10, decimal_places=2) -
login with facebook is not working django graphql
I am using the package django-graphql-social-auth for social login like login to facebook, google, twitter, etc. I copied the code from the example project, however, I could not login to facebook. I have created an app in facebook developer page as well. I get the following issue { "errors": [ { "message": "400 Client Error: Bad Request for url: https://graph.facebook.com/v2.9/me?access_token=f9************50&appsecret_proof=c*********ef0450ea076e42bfd9c85c6d07", "locations": [ { "line": 2, "column": 3 } ], "path": [ "socialAuth" ] } ], "data": { "socialAuth": null } } What i did is, i copied app id to SOCIAL_AUTH_FACEBOOK_KEY app secret to SOCIAL_AUTH_FACEBOOK_SECRET then in the mutation i provided the provider name as "facebook" and accessToken an app secret but it did not work and i tried accessToken with the Client Token from facebook developer page but that also raised same error. I have a doubt in accessToken part. what that accessToken should have from facebook developer page? -
How can I override "settings_overrides" variable in leaflet_map from within inside Django template
Summary I have a geodjango project to display web maps. Which I can do with no problem. However, I want to customize my map configuration from within my django template instead of from my django settings. (From django settings I can do it alright). To customize, I have to pass a python dictionary to a variable called settings_overrides. The problem is I can not figure it out how and if this is possible from within a django template. Description Let's say I want to override "SPATIAL_EXTENT" inside my template code where python dictionary that leaflet_map expects is like this: ext = {'SPATIAL_EXTENT': (-154.609, 1.561, -40.611, 65.921)} settings_overrides = ext Note: This is what I understood!! I might be wrong! See below for the signature of the leaflet_map function. This is calling function inside the template(index.html) where I want to pass the new extent to the setting_overrides: {% leaflet_map "main" callback="window.map_init_basic" creatediv=False, settings_overrides=ext %} (A) And the signature of the leaflet_map function which is located in: leaflet/templatetags/leaflet_tags.py is as follow: def leaflet_map(name, callback=None, fitextent=True, creatediv=True, loadevent=app_settings.get('LOADEVENT'), settings_overrides={}): if settings_overrides == '': settings_overrides = {} instance_app_settings = app_settings.copy() instance_app_settings.update(**settings_overrides) .... (B) As you can see from (B) in the signature, I have …