Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
What knowledge should I have to make my web app?
First of all, thank you for your time in reading this question. I am in charge to develop a website project for my university club, but I don't have web development experience prior to this. The project consists in a simple website that asks you to login with your university email and then asks you 4-5 questions. In the end, there is a table with all different people and what they answered. If you click on one line, it shows the contacts of their person and more additional information. I was thinking to make it with Flask or Django. I have basic knowledge of Python/R/Matlab. What do you suggest to use as framework, what should I learn and how many hours can it take? I asked multiple people already and everybody has different ideas about flask and django and not many people know about the CMS available for those. In case it exists, I would be down to use a pre-existent template. Thank you again, I know how much time is valuable for your all. -
how to sort by many to many field in django query
I have the following model: class Company(models.Model): name = models.CharField(max_length=255, db_index=True) groups = models.ManyToManyField(CompanyGroup, related_name='groups', blank=True) I want to show the latest companies added to the group. I do so with the following: companies = Company.objects.filter( groups__name=group_name ).order_by('-groups__id') The companies don't order. What am i doing wrong? -
how to create model class to map three diffrent models classes and access their filed in django-admin page
I need help to structure the model classes (which key should be foreign key or m2m filed) which will help user to add new "SchPrograms" with its parameters(using tableau inline) from Djanog Admin page. I manage to create a page where anyone can add SchPrograms with the parameters. Currently Parameters comes below of the SchPrograms's filed (list of drop-downs where user can choose different VisVisitParameters for the SchPrograms from the list of drop down) . But, I wanted to have three filter_horizontal the 1st filter_horizontal will have existing SchPrograms when I select any one of the SchPrograms from that list It will will give already assigned VisVisitParameters in the 2nd filter_horizontal for the that "SchPrograms" and then in the 3rd filter_horizontal user can select VisVisitParameters names for the SchPrograms that currently being created. Right now, I can not even have one filter_horizontal as i am using fk field but when I changed it m2m then I got issues to access variables from the other models. Is it possible to have more than 2 filter_horizontal or is there any other way this can be done ? #models.py class SchPrograms(models.Model): program_id = models.AutoField(primary_key=True) program_name = models.CharField(max_length=200, blank=True, null=False) def __str__(self): return u'%s β¦ -
convert PostGIS point object to geoJSON for mapping
I have a Django app with a postgres db of PostGIS activities I'm trying to map on a frontend view using leaflet and Mapbox. at first thought I could serialize the activities in the view and render them in the template as {{ props.activitiesJson|safe }} [can render this as html and see the JSON objects on the page]. views.py (ex) def map(request): mapbox_key = settings.MAPBOX_API_KEY activities = Activity.get_activities_near(lat, lng, radius) props = {'activitiesJson' : serializers.serialize('json', activities),} context = { 'props' : props, 'mapbox_key': mapbox_key } return render(request, 'app/map.html', context) in the JSON however, a location field will be: "location": "SRID=4326;POINT (-73.93805999999999 40.683712)" (https://docs.djangoproject.com/en/2.1/ref/contrib/gis/geos/#django.contrib.gis.geos.Point) which generates a syntaxerror from the parentheses (and would need to be converted, parsed or treated as a string and trimmed down to just the lat, lon to work with anyway. ex: var map_activities = JSON.parse("{{ props.activitiesJson|safe }}"); function populateMap(map_activities){ for(i in map_activities) { var title = map_activities[i].name, // name loc = // position which needs to be converted bc map_activities[i].location alone won't work url = map_activities[i].slug, marker = new L.Marker(new L.latLng(loc), {title: title, icon: mapIcon} ); marker.bindPopup('<p><a href="'+ url + '">' + title + '</a></p>'); markersLayer.addLayer(marker); } } var new_lat = map_activities[0].loc[0] var new_lon = map_activities[0].loc[1] β¦ -
Storing the data in the console in a database and accessing it
I'm building a web app which accesses the location of the user when a particular button is pressed for this I'm using the HTML geolocation api. Below is the location.js file: `var x = document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { x.innerHTML = "Geolocation is not supported by this browser."; } } function showPosition(position) { x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; console.log(position.coords.latitude) console.log(position.coords.longitude) } Below is the snippet of the HTML file: <button onclick="getLocation()">HELP</button> <p id="demo"></p> <script src="../static/location.js"></script> What I want to do is send this information ( i.e. longitude/latitude of the user ) to list of e-mails associated with that user but I don't know how to store this data and access this after the button is pressed. It would be of great use if someone could get me started on how to save this data corresponding to the user and accessing it from the database. -
query chain of models in Django
I have three models for countries, provinces and cities. one of URLs includes the city name where a post should go. I could get the name of the city through the URL . In view function, I could find the city name and then I could find the country which the city is belong to. Now, I want to list all cities under this country. My question is how can I do this where there is no direct relation between city and country. The city is related to the province and the province related to the country. The list I want should includes all cities inside the country regardless of the province. How can I do this? is there any possible solution rather than make direct relation between city and country model? Note: I could get the country ID through the variable post_city. The country ID for selected city was 3. Therefor, I want all of cities that are under the country that has an ID of 3. the models I have are as follow: class Country(models.Model): country_name = models.CharField(max_length=64, unique=True) def __str__(self): return "%s" % (self.country_name) class Province(models.Model): country_id = models.ForeignKey(Country, on_delete=models.CASCADE) province_name = models.CharField(max_length=64) def __str__(self): return "%s" β¦ -
image file is not uploading in django?
I am trying to upload the images via ajax and the front-end code seems to be working and I have the image data in the request.FILES. but the images are not being uploaded on the server side. here is my django view: @login_required def update_profile_image(request): print(request.FILES) if request.method == 'POST': p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user) if p_form.is_valid(): p_form.save() context = {'None': 'none'} return JsonResponse(context) else: return HttpResponse('None') the form is valid but the image is not uploaded in the MEDIA directory. btw this is my AJAX call (which as I said seems to be working). $(document).on('submit', '#profile_edit_form', function(event){ event.preventDefault(); $.ajax({ url : "/users/update_profile_image/", type : 'POST', //enctype : "multipart/form-data", //it is done inside jquery data : formdata, cache : false, contentType : false, processData : false, success : function(data) { console.log('success'); //$('#profile_picture').html(data.) }, error: function(data) { console.log('image-fail'); } }); }); What am I doing wrong in my view function? thanks! -
cannot import name 'include' from 'django.contrib'
i am new to django and am following tutorials on django by thenewboston, i am using django 2.1.1 and even after copying the tutorials word for word i am getting the above error. He however is using django 1.9 for his tutorials, is the django version the real problem ? -
Import not working with export-import Django
I'm using Django 2.x and Django-import-export to enable importing excel file in the admin panel. app/models.py class ChapterQuestion(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) chapter = models.ForeignKey(Chapter, on_delete=models.CASCADE) word = models.CharField(max_length=250) definition = models.CharField(max_length=250) pronunciation = models.CharField(max_length=250, blank=True) synonym = models.CharField(max_length=250, blank=True) antonym = models.CharField(max_length=250, blank=True) comment = models.CharField(max_length=250, blank=True, null=True) app/admin.py class ChapterQuestionResource(resources.ModelResource): class Meta: model = ChapterQuestion fields = ( 'chapter__course__name', 'chapter__name', 'word', 'definition', 'synonym', 'antonym', 'pronunciation', 'comment' ) @admin.register(ChapterQuestion) class ChapterQuestionAdmin(ImportExportModelAdmin): resource_class = ChapterQuestionResource exclude = ['created_by'] list_display = ['word', 'definition', 'chapter', 'get_chapter_course', 'created_by'] But, when I import .xls file, it gives error as (sample file) Errors Line number: 1 - 'id' Hello, world, , , , , Test course 001, Chapter 001 Traceback (most recent call last): File "/Users/anuj/.local/share/virtualenvs/django-vocab-899c1OSV/lib/python3.6/site-packages/import_export/resources.py", line 453, in import_row instance, new = self.get_or_init_instance(instance_loader, row) File "/Users/anuj/.local/share/virtualenvs/django-vocab-899c1OSV/lib/python3.6/site-packages/import_export/resources.py", line 267, in get_or_init_instance instance = self.get_instance(instance_loader, row) File "/Users/anuj/.local/share/virtualenvs/django-vocab-899c1OSV/lib/python3.6/site-packages/import_export/resources.py", line 261, in get_instance return instance_loader.get_instance(row) File "/Users/anuj/.local/share/virtualenvs/django-vocab-899c1OSV/lib/python3.6/site-packages/import_export/instance_loaders.py", line 31, in get_instance field = self.resource.fields[key] KeyError: 'id' Line number: 2 - 'id' hello, world, , this it, that thing, commets are welcome, Test course 001, Chapter 001 Traceback (most recent call last): File "/Users/anuj/.local/share/virtualenvs/django-vocab-899c1OSV/lib/python3.6/site-packages/import_export/resources.py", line 453, in import_row instance, new = self.get_or_init_instance(instance_loader, row) File "/Users/anuj/.local/share/virtualenvs/django-vocab-899c1OSV/lib/python3.6/site-packages/import_export/resources.py", line 267, β¦ -
Pyinstaller and Django Rest
I am trying to use Pyinstaller with django rest, it generates the .exe well but there is an error at the moment of executing the .exe, the error is this ModuleNotFoundError: No module named 'rest_framework' my question is how can I install the dependencies using Pyinstaller, or is there another way to do it. -
Add checkboxes to django admin filter
How do I add checkboxes to django admin filter? If none are selected, show all results. If one is selected, show that filter. If two are selected, show both. class Marker(models.Model): color = models.CharField(max_length=40) It starts out as blue, green, yellow all unchecked. Every result is shown. If blue is checked, the page refreshes and only blue shows up. If yellow is checked, only blue OR yellow show up. -
Where Does Django Store It's Test Databse
When using an SQLite database where does Django store the database that it uses when running tests? Is there way to define this path? I would like to be able to manually look at the contents of the test database following each test. The command python manage.py test --keepdb is supposed to keep the database, which it does, but I cannot seem to find where this database is stored. -
Is count() the most efficient way to count the number of objects?
I need to count the number of objects of a particular model in my database, and display the number with a context processor for the user to view on every page. Right now I'm simply doing Model.objects.count(). It works, but as there are now 400,000+ objects in the db, it has noticeably slowed things down. I'm running on my development server, so maybe once I push to dedicated servers this won't be a problem, but I'm not sure... I'm worried what will happen once we get into the millions or beyond. Any tips? -
Django migrate from inbuilt model to custom user model
I am trying to move existing inbuilt django auth model to custom user model, when i run the migrate it's giving the error. class User(AbstractUser): class Meta: db_table = 'auth_user' when i run migrate below error is coming The field events.Event.attending was declared with a lazy reference to 'users.user', but app 'users' doesn't provide model 'user'. it's coming for all the foreign key relationship withe user model. -
Exclude selection for object present in ThroughModel
I have those three models and one ModelForm. As it stands, I can add same actor to to the movie several times. Im looking for a way to prevent it by inputing a queryset into CastingsForm person field, that will exclude selection of Person if it's id is already present in this movie. class Person(models.Model): first_name = models.CharField(max_length=32) last_name = models.CharField(max_length=32) class Movie(models.Model): title = models.CharField(max_length=128) director = models.ForeignKey(Person, on_delete=models.SET_NULL, null=True) screenplay = models.ForeignKey(Person, on_delete=models.SET_NULL, null=True) starring = models.ManyToManyField(Person, through='ThroughModel') class ThroughModel(models.Model): person = models.ForeignKey(Person, on_delete=models.SET_NULL, null=True) movie = models.ForeignKey(Movie, on_delete=models.CASCADE) role = models.CharField(max_length=128, null=True) and this form class CastingsForm(forms.ModelForm): role = forms.CharField(required=False) person = forms.ModelChoiceField(required=False) movie = forms.ModelChoiceField(Movie.objects.all(), required=False) class Meta: model = ThroughModel fields = ['role', 'person', 'movie'] -
Concat in query throwing unhashable type error
I am getting the error TypeError: unhashable type: 'dict' when I try use $concat in my pymongo query My schema: {'tags': {'variables': [{'value': '3x9', 'var_name': 's'}, {'value': '12:00AM', 'var_name': 'x'}, {'value': 'goog', 'var_name': 'y'}]}, 'url': 'https://www.google.com'}] My query: res = mycol.aggregate([ { '$unwind': '$tags' }, { '$match': { 'tags.tag.name':'A A', 'AR': 12345 } }, { '$project': { { 'itemDescription': { '$concat': [ "$item", " - ", "$description" ] } } , '_id': 0 } } ]) WHat am I doing wrong? -
Django admin for a model with inline
I have an admin form for AuthorMultiName using inlines with AuthorName objects. How would I create an admin model for AuthorAndPosition where I will be able to fill in everything from AuthorMultiNameAdmin and the position field for AuthorAndPosition? class AuthorAndPosition(models.Model): position = models.ForeignKey('Position') #author, editor author = models.ForeignKey('AuthorMultiName') def __str__(self): author_name = AuthorName.objects.filter(author=self.author).first() if author_name is not None: return "name: " + author_name.name else: return "no name" class AuthorName(models.Model): name = models.CharField(max_length=1000) author = models.ForeignKey('AuthorMultiName') books = models.ManyToManyField('Book', null=True, blank=True) class AuthorMultiName(models.Model): gender = models.ForeignKey('Gender') def __str__(self): author_name = AuthorName.objects.filter(author=self).first() if author_name is not None: return "name: " + author_name.name else: return "no name" Admin models: class AuthorNameInline(admin.TabularInline): model = AuthorName class AuthorMultiNameAdmin(admin.ModelAdmin): inlines = [ AuthorNameInline, ] class AuthorAndPositionAdmin(admin.ModelAdmin): #how to add position field and everything from AuthorAdmin (AuthorNameInlines and gender)? -
Error restarting Apache on RHEL 7 with virtual host and mod_wsgi
I am trying to run a Django Application on Apache on a RHEL 7 server. My httpd.conf is as follows LoadModule wsgi_module modules/mod_wsgi.so <VirtualHost *:8000> ServerAdmin admin@XH_Toolkit.com ServerName www.XH_Toolkit.com ServerAlias XH_Toolkit.com Alias /style.css /var/www/html/XH_Toolkit/home/static/home/style.css Alias /static/ /var/www/html/XH_Toolkit/home/static/ <Directory /var/www/html/XH_Toolkit/home/static> Require all granted </Directory> WSGIDaemonProcess www.XH_Toolkit.com display-name=XH_Toolkit user=myuser group=myuser processes=2 threads=15 WSGIScriptAlias / /var/www/html/XH_Toolkit/XH_Toolkit.wsgi WSGIProcessGroup www.XH_Toolkit.com ErrorLog "/var/www/html/XH_Toolkit/logs/error_log" CustomLog "/var/www/html/XH_Toolkit/logs/access_log" common </VirtualHost> When I attempt to restart Apache the output is as follows sudo service httpd restart Redirecting to /bin/systemctl restart httpd.service Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details. When I run systemctl status httpd.server systemctl status httpd.service β httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2018-10-17 16:43:13 UTC; 3min 53s ago Docs: man:httpd(8) man:apachectl(8) Process: 6236 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE) Process: 32418 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=1/FAILURE) Main PID: 6413 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ββ6413 /usr/sbin/httpd -DFOREGROUND ββ6415 /usr/sbin/httpd -DFOREGROUND ββ6416 /usr/sbin/httpd -DFOREGROUND ββ6417 /usr/sbin/httpd -DFOREGROUND ββ6418 /usr/sbin/httpd -DFOREGROUND ββ6419 /usr/sbin/httpd -DFOREGROUND It seems that when I comment out this section of the β¦ -
Django : TemplateDoesNotExist at /
I'm trying to upgrade a django project from 1.8 to 1.10. I have changed a view function from from django.shortcuts import render from django.http import HttpResponse from django.template import RequestContext, loader from django.shortcuts import render from django.core.mail import EmailMessage from django.http import HttpResponseRedirect from sellmyland.settings import DEFAULT_FROM_EMAIL from ipware.ip import get_ip import json from myapp.forms import myform def index(request): form = myform() # return render('longform.html', {"form": form}, context_instance=RequestContext(request)) return render(request, 'longform.html', {'form': form}) settings.py: # TEMPLATE_DIRS = ( # # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # # Always use forward slashes, even on Windows. # # Don't forget to use absolute paths, not relative paths. # os.path.join(BASE_DIR, 'templates'), # ) TEMPLATE_DIRS = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', # 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'DIRS': os.path.join(os.path.dirname(BASE_DIR),'templates'), 'APP_DIRS': True, 'OPTIONS': { # some options }, }, ] You can see the commented out version in the code. I'm getting the error above. Here is the traceback: Traceback: File "E:...\lib\site-packages\django\core\handlers\exception.py" in inner 42. response = get_response(request) File "E:...\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response 249. response = self._get_response(request) File "E:...\lib\site-packages\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "E:...\lib\site-packages\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "E:\ENVS\r3\sellmyland3\app1\views.py" in index 30. return render(request, 'longform.html', {'form': form}) File β¦ -
Django Own user model with login system
I make App with command Django-admin startapp accounts. Inside this, I want to create own login signup system. can anyone tell me how to create:- Own user model(not an auth_user, my own model). Setup form.py with authenticate(). That authenticate() function run for my user model, not an auth_user. how to use objects.get(), objects.all(), etc for my own user model. make a signup page and insert all data in my table own user table, not in auth_user as well as create the login page to check the user authentication. can anyone give me a source code of it. it would help me a lot. Thank you -
Serializer is_valid() is returning true though fields are empty
I Tried and run the code with function-based view and it was working perfectly then I tried to switch to modelViewSet. Here is my code for Serializers : UserSerializer class UserSerializer(serializers.ModelSerializer): class Meta: model = get_user_model() username = serializers.CharField(required=True) email = email = serializers.EmailField(validators=[UniqueValidator(queryset=get_user_model().objects.all())]) phone = serializers.CharField(required=True) full_name = serializers.CharField(required=True) user_type = serializers.CharField(required=True) password = serializers.CharField(write_only=True) fields=('username', 'email', 'phone', 'full_name', 'user_type','password') def create(self, validated_data): user = get_user_model().objects.create( username=validated_data['username'], email=validated_data['email'], phone=validated_data['phone'], full_name=validated_data['full_name'], user_type=validated_data['user_type'] ) user.set_password(validated_data['password']) user.save() return user Here is my modelViewSet : class RegisterView(viewsets.ModelViewSet): queryset = '' def create(self, request): if request.data.get('user', dict()).get('user_type') == 'employee': userSerializer = UserSerializer(data=request.data.get('user', dict())) if userSerializer.is_valid(raise_exception=ValueError): serializer = EmployeeSerializer(data=request.data) if serializer.is_valid(raise_exception=ValueError): serializer.create(validated_data=request.data) return Response(serializer.data, status=HTTP_201_CREATED) return Response(serializer.error_messages, status=HTTP_400_BAD_REQUEST) def get_serializer_class(self): if self.request.data.get('user', dict()).get('user_type') == 'employee': return EmployeeSerializer if self.request.data.get('user', dict()).get('user_type') == 'customer': return CustomerSerializer if self.action == 'customer': return CustomerSerializer return EmployeeSerializer Now If I dont pass username or password then is_valid for userSerializer is giving error but if I dont pass email or phone or full_name is_valid doesnt raise any exception and it remains true. It was working correctly with Function-based view or may be I am missing something. My concern is it should give error if any value is missing in request.data -
Looking to rename Django Ajax "like" button, but not working
Currently my button functions, but I've placed it inside of a django for loop. I'd like to move the js logic to a separate file, but first I need to give it a better name. Here is a snippet of my code: {% for post in posts %} ..... <script type="text/javascript"> function toggleLike{{post.id}}(){ $.ajax({ url: "{% url 'photo_blog-post_like_api' post.id %}", success: function(data) { $("#likeCount{{post.id}}").html(data.like_count + ' likes'); $('#imageElement{{post.id}}').html(data.img); } }); }; </script> <a id=imageElement{{post.id}} onclick="toggleLike{{post.id}}()"><img src="/media/nav_buttons/liked.svg" height="17" width="17"></a> .... <post info here> .... {% endfor %} When I remove the {{post.id}} from the function name, and onclick call, the button only functions for the post on the bottom of the page. All of the other buttons toggle the information for that one post. How can I give this function a general name, but still have it interact uniquely with each post? -
How to allow auth users to send newsletters from django admin
I'm implementing a newsletter app for a company website. My goal is to allow the 'future' website administrator to fire a newsletter directly from the admin. For doing so, I wrote the following code: models.py from django.db import models from ckeditor.fields import RichTextField class NewsletterSubscription(models.Model): datetime = models.DateTimeField(auto_now_add = True) email = models.EmailField(max_length=128) class Meta: verbose_name = 'Iscritto Newsletter' verbose_name_plural = 'Iscritti Newsletter' def __unicode__(self): return self.email class Newsletter(models.Model): EMAIL_STATUS_CHOICES = ( ('Draft', 'Draft'), ('Pubblicata', 'Pubblicata') ) subject = models.CharField(max_length=250) body = RichTextField() email = models.ManyToManyField(NewsletterSubscription) status = models.CharField(max_length=10, choices=EMAIL_STATUS_CHOICES) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) def __unicode__(self): return self.subject I'd like to know if is possible to add to the NewsletterAdminForm a sort of button which allows to fire the email. admin.py from django import forms from django.contrib import admin from .models import NewsletterSubscription, Newsletter from ckeditor.widgets import CKEditorWidget class NewsletterSubscriptionAdmin(admin.ModelAdmin): list_display = ('email', 'datetime', ) class NewsletterAdminForm(forms.ModelForm): body = forms.CharField(widget=CKEditorWidget()) class Meta: model = Newsletter fields = '__all__' class NewsletterAdmin(admin.ModelAdmin): form = NewsletterAdminForm admin.site.register(NewsletterSubscription, NewsletterSubscriptionAdmin) admin.site.register(Newsletter, NewsletterAdmin) Thank you in advance for any help you can provide. -
Selenium in Heroku
I have developed a basic system that scraping 1 internal systems manipulates the information and brings back to my user a unique information consolidation. I used Django and Selenium. On the local machine it works perfectly, however, going up to Heroku, I can not configure it correctly, it follows the step-by-step prints and the presented error. Error: 2018-10-12T15:15:49.760982+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/consuapp/consulta/" host=ecoviabilidade.herokuapp.c om request_id=b0b9b9d6-1798-4eb9-b973-f33e671887b3 fwd="201.81.178.239" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https I look the web page : https://devcenter.heroku.com/articles/request-timeout But i not understood nothing, how to do this using selenium with django. Connection ChromeDriver def post(self, request): CHROMEDRIVER_PATH = '/app/.chromedriver/bin/chromedriver' chrome_bin = os.environ.get('GOOGLE_CHROME_BIN', "chromedriver") options = webdriver.ChromeOptions() options.binary_location = chrome_bin options.add_argument("--disable-gpu") options.add_argument("--no-sandbox") options.add_argument('headless') self.driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=options) self.campo_x_site = request.POST['x'] self.campo_y_site = request.POST['y'] self.driver.get('www.example.com') wait = WebDriverWait(self.driver, 280) log_in(self, wait) self.search(wait) self.driver.close() i'm not dev, i'm study yet. -
PyFCM subscribe_registration_ids_to_topic() not creating Firebase Cloud Messaging topic
I am using PyFCM, found here, to send push notifications to my Ionic App from Django Rest Framework through Firebase Cloud Messaging. The Issue is that subscribe_registration_ids_to_topic() seems to not actually create a topic in Firebase. I understand that: (1) Subscribing a user to a topic that is not created yet will create the topic and subscribe the user to it. (2) The Firebase Console can take up to 14 hours to show newly created topics. It has been 28+ hours since I subscribed user to topic (3) The newly created topic should be available to use immediately and After 14 hours or so the topic should be available to use in the Firebase console. My exact issue is that after calling subscribe_registration_ids_to_topic() I see no topic created, even after 28+ hours Here Is how I used the library, If you notice I have push_service.notify_single_device() which sends notification as expected. Below that line is push_service.notify_topic_subscribers() which does NOT send notification: In models.py from pyfcm import FCMNotification push_service = FCMNotification(api_key="my-api-key") push_service.notify_topic_subscribers(topic_name="test", message_body="Hello Test Members!") class Group(models.Model): name = models.CharField(max_length=80) group_image = models.ImageField(blank=True, null=False) description = models.TextField(blank=True, null=True) userprofiles = models.ManyToManyField(Userprofile, null=True, blank=True) ministry = models.ForeignKey(Ministry, on_delete=models.CASCADE,null=True, blank=True) def save(self, *args, **kwargs): β¦