Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Best API Gateway framework?
I have built my microservice in Django and deployed in Heroku. I also built an API Gateway in Django but it was an overkill and increased latency. Which is the best framework I can use either on python or any language which helps to maintain efficiency and reduce latency? Is Amazon API Gateway service an alternative to this? -
passing parameters from models
I have this model where I upload a file and save it to s3 . Here is the model. class ExcelFiles(models.Model): PLAN_CHOICES = ( ('x1', 'x1'), ('x2', 'x2'), ('x3', 'x3') ) company =models.CharField(max_length=80) plan_type=models.CharField( max_length=20, choices=PLAN_CHOICES,default='BASE') excelFile = models.FileField(blank=False, null=False, upload_to=excel_directory_path) and here is the code for excel_diectory_path def excel_directory_path(instance, filename): print("instnace", instance) present_date = date.today() #import pdb;pdb.set_trace(); return 'company_excel_sheets/{}-{}-{}/'.format(present_date.year, present_date.month, present_date.day, filename) What i basically wanted is to store my files company_excel_sheets/company/plan_type/time so that no files get overwritten while saving in s3 . -
Is Docker an alternative for 'virtualenv' while develping Django project?
A virtual environment is required when creating an application and now I am using 'virtualenv' for creating a virtual environment while developing my Django application. I heard of Docker about its virtual environment. Am I able to use Docker as an alternative to virtualenv? -
djangomultimodelform with Inlineform using django-multform package
I have a problem with handling the Updateview in django. My design contains 2 models and one Inlineformset. This view will be added with more models and inlineformsets if this works. My createview works fine. But the Updateview gives the attached error error image. 1) Any idea why this is causing. 2 ) Any better way to handle multiple forms and multipleinlineforms together for CRUD operations Forms class CompanyManagementForm(forms.ModelForm): entitynamepreferred=forms.CharField(max_length=200, required=False, label='COMPANY Name (Optional):') clientcategory=forms.ModelChoiceField(keyword.objects.filter(keywordtype = 'CLIENT_CATEGORY'), required=False) class Meta: model=EntityList fields =('entitynamepreferred', 'clientcategory') labels ={'entitynamepreferred' : 'COMPANY Name (Preferred):', 'clientcategory': ' Client category', widgets = { 'entitynamepreferred': forms.TextInput(attrs={'class':'form-control'}), } def __init__(self, * args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-4' self.helper.field_class = 'col-lg-8' self.helper.layout = Layout( Fieldset( 'first arg is the legend of the fieldset', 'entitynamepreferred', 'clientcategory' )) class TransactionProfileform(forms.ModelForm): # this has a relationship with CompanyManagementmodel above class Meta: model=TransactionProfile fields =('sourceoffund', 'sourcedetaileddescription', 'expectedtransactioninentity1') def __init__(self, * args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-4' self.helper.field_class = 'col-lg-8' self.helper.layout = Layout( Fieldset( 'first arg is the legend of the fieldset', 'sourceoffund', 'sourcedetaileddescription', 'expectedtransactioninentity1' )) class Roleform(forms.ModelForm): class Meta: model=Roles fields = ('personrole', 'personname') exclude = () Rolesformset = … -
How to write python code in HTML in Django?
I need to create a path in an HTML code that is used to generate a download link. {% for data in all_data %} {% path_zip = '/home/harish/Desktop/cvision/users_output_files/{0}.zip'.format(data.id) %} <tr> <td> {{data.id}} </td> <td> {{data.childname}} </td> <td> {{data.age}} </td> <td> {{data.gender}} </td> <td> <a href={{path_zip}} download></a> </td> </tr> {% endfor %} But this code is not working. And the following is the error. Invalid block tag on line 40: 'path_zip', expected 'empty' or 'endfor'. Did you forget to register or load this tag? How do I solve it? -
Best way to make admin site work in apps where USERNAME_FIELD is email?
I'm writing a Django app where users sign up and login with their emails rather than usernames. At first, I just changed the USERNAME_FIELD and set username=None on the Custom User Model. But then I noticed that this broke createsuperuser, and thus made the admin feature useless. What would be the best way around this? Should I still keep the username field and use it for the admin site, or should I just drop it and find a workaround? -
Issue with Saving Data into Database in Django using Instance
My Code is working but not saving into Database. I will like to know where the issue is coming from. However, I have tired my best in checking for the error. I am getting success message after submission. Please, kindly assist to fish out the issue. You can see from the below Picture attached with the question. models.py class Info(models.Model): MASJID_TYPE = ( ('Ratibi', 'Ratibi'), ('Jummah Masjid', 'Jummah Masjid'), ('Central Masjid', 'Central Masjid'), ) SECT = ( ('Al-Sunnah', 'Al-Sunnah'), ('Salafee', 'Salafee'), ('Sufi', 'Sufi'), ('Ahamadiyah', 'Ahamadiyah'), ) STATUS = ( ('Completed', 'Complete'), ('Un-Completed', 'Un-Completed'), ('Proposed', 'Proposed'), ) user = models.ForeignKey(CustomUser, on_delete=models.CASCADE) name = models.CharField(max_length=100) masjid_type = models.CharField(max_length=50, choices=MASJID_TYPE) address = models.TextField() sect = models.CharField(max_length=250, choices=SECT) state = models.CharField(max_length=50) city = models.CharField(max_length=50) LGA = models.CharField(max_length=50) status = models.CharField(max_length=150, choices=STATUS) history = models.TextField(blank=False, null=False) founder = models.DateField("Founder Year", blank=False, null=False) latitude = models.FloatField(max_length=20, blank=False, null=False) longitude = models.FloatField(max_length=20, blank=False, null=False) congregation = models.IntegerField(blank=False, null=False) image = models.ImageField(upload_to='masjid', blank=False, null=False) approval = models.BooleanField(default=False) created_at = models.DateTimeField(auto_now_add=True) update_at = models.DateTimeField(auto_now=True) def __str__(self): return self.name def get_absolute_url(self): return reverse('masjid_detail', kwargs={'pk': self.pk}) class Imam(models.Model): CERTIFICATE = ( ('PhD', 'PhD'), ('MSc', 'MSc'), ('Bsc', 'Bsc'), ) masjid = models.ForeignKey(Info, on_delete=models.CASCADE) first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) imam_address = models.TextField(blank=False, … -
How to call view in another app using template tags in django?
I am Getting an error Reverse for 'question_list' not found. 'question_list' is not a valid view function or pattern name. after using the template tag 'collab_app:question_list' in template. home.html: {% extends "_base.html" %} {% load static %} {% load socialaccount %} {% block title %}Home{% endblock title %} {% block content %} <h1>Homepage</h1> <a href="{% url 'collab_app:question_list' %}">Ask Question Here</a> <img class="collabimage" src="{% static 'images/collab.jpg' %}" ><br> {% if user.is_authenticated %} Hi {{ user.email }} <p><a href="{% url 'account_logout' %}">Log Out</a></p> {% else %} <p>You are not logged in</p> <!--Github--> <a href="{% provider_login_url 'github' %}" ><p class="git">Github</p></a> <a href="{% url 'account_login' %}">Login</a> <a href="{% url 'account_signup' %}">Sign Up</a> {% endif %} {% endblock content %} views.py: class HomePageView(generic.TemplateView): template_name = "home.html" urls.py in users app: from django.urls import path, include from .views import SignupPageView from .views import HomePageView app_name = "users" urlpatterns = [ path("", HomePageView.as_view(), name="home"), path("signup/", SignupPageView.as_view(), name="signup"), ] urls.py in project: from django.contrib import admin from django.urls import path, include from users.views import HomePageView urlpatterns = [ path("", include("users.urls")), path("collab/", include("collab_app.urls"),), # , "collab_app")), ] urls.py in collap_app: from django.contrib import admin from django.urls import path, include from collab_app import views from users.views import HomePageView app_name = … -
Matching either pattern with re_path in Django 3.0
I'm struggling to figure out how to use a regex with re_path in Django to match either of a set of patterns. I want to match /bucket/, /buckets/, /pail/, or /pails to a single view. In my primary urls file I've got: from bucket import urls as bucket_urls urlpatterns = [ re_path(r'^(?:bucket)s?/', include(bucket_urls)) ] and in the bucket.urls module I have: urlpatterns = [ path("new", views.BucketCreate.as_view(), name="create_bucket"), ... path('', BucketList.as_view(selection="recent"), name="buckets") ] This works for /bucket/ and /buckets/, as well as /bucket/new/ and /buckets/new/ as well as other urls extended from bucket(s). If I change it to '^(?:bucket|pail)s?/' none of the bucket(s) or pail(s) urls work. If I change it to '^(bucket)s?/' none of the bucket(s) urls work. If I understand correctly, this is because the () is capturing the bucket part and the ?: stops that? trying this works urlpatterns = [ re_path(r'^buckets?/', include(bucket_urls)), re_path(r'^pails?/', include(bucket_urls)), ] but gives this warning: ?: (urls.W005) URL namespace 'bucket' isn't unique. You may not be able to reverse all URLs in this namespace Should I worry about that warning? Any pointers on how I can match /bucket/, /buckets/, /pail/, or /pails/ with a single regex so I don't get the warning? -
Error upon submitting empty forms in Django
I have a webpage with two forms, form1 and form2. Upon submitting empty forms, I am getting errors 1)MultiValueDictKeyError at /profiles/adminKaLogin/ 2)invalid literal for int() with base 10 for form1 and form2 respectively. Given below are the HTML and views.py file contents: HTML: <div> <h2>Check the boxes below to display records!</h2> <form method="POST" action="/profiles/adminKaLogin/"> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" class="custom-control-input" id="defaultInline1" name="inlineDefaultRadiosExample" value="1"> <label class="custom-control-label" for="defaultInline1">Vendor 1</label> </div> <!-- Default inline 2--> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" class="custom-control-input" id="defaultInline2" name="inlineDefaultRadiosExample" value="2"> <label class="custom-control-label" for="defaultInline2">Vendor 2</label> </div> <br> <h3> Select time period</h3> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" class="custom-control-input" id="defaultInlines1" name="inlineDefaultRadiosExample1" value="1"> <label class="custom-control-label" for="defaultInlines1">1 Month</label> </div> <!-- Default inline 2--> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" class="custom-control-input" id="defaultInlines2" name="inlineDefaultRadiosExample1" value="2"> <label class="custom-control-label" for="defaultInlines2">2 Months</label> </div> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" class="custom-control-input" id="defaultInlines3" name="inlineDefaultRadiosExample1" value="6"> <label class="custom-control-label" for="defaultInlines3">6 Months</label> </div> <br> <button type="submit" class="btn btn-primary" name="form1">Submit</button> {% if model %} <table> <thead> <tr> <th style = "padding: 20px;">Vendor ID</th> <th style = "padding: 20px;">Employee ID</th> <th style = "padding: 20px;">Debit</th> <th style = "padding: 20px;">Credit</th> <th style = "padding: 20px;">Time of transaction</th> </tr> </thead> <tbody> {% for i in model %} {% for j in i %} <tr> … -
Identity error at attemt_myuser.email.UNIQUE constraint failed in django project
enter code here #This is my models .py : 'like so' while post operation through POATMAN im getting error. :connection error after that again hitting POST button data is getting and access token is creating but it is showing unique constrain failed. from django.db import models from django.contrib.auth.models import ( BaseUserManager, AbstractBaseUser ) import datetime class MyUserManager(BaseUserManager): def create_user(self, email, date_of_birth, password=None): """ Creates and saves a User with the given email, date of birth and password. """ if not email: raise ValueError('Users must have an email address') user = self.model( email=self.normalize_email(email), date_of_birth=date_of_birth, ) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, date_of_birth, password=None): """ Creates and saves a superuser with the given email, date of birth and password. """ user = self.create_user( email, password=password, date_of_birth=date_of_birth, ) user.is_admin = True user.save(using=self._db) return user class MyUser(AbstractBaseUser): email = models.EmailField( verbose_name='email address', max_length=255, unique=True, ) date_of_birth = models.DateField() is_active = models.BooleanField(default=True) is_admin = models.BooleanField(default=False) objects = MyUserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['date_of_birth'] def __str__(self): return self.email def has_perm(self, perm, obj=None): "Does the user have a specific permission?" # Simplest possible answer: Yes, always return True def has_module_perms(self, app_label): "Does the user have permissions to view the app `app_label`?" # Simplest possible answer: … -
how to make horizontal product list view in django template
how to make horizontal product list view in django template you can take a look at my product list image here, [1]: https://i.stack.imgur.com/b6ZBH.png views.py: {% for product in object_list %} <div class='row'> <div class="col-sm-6 col-md-4 col-lg-3 p-b-35 isotope-item men {{ col_class_set }}"> <!-- Block2 --> <div class="block2"> <div class="block2-pic hov-img0"> <img src="{{ product.image.url }}" alt="IMG-PRODUCT"> <a href="#" class="block2-btn flex-c-m stext-103 cl2 size-102 bg0 bor2 hov-btn1 p-lr-15 trans-04 js-show-modal1"> Quick View </a> </div> <div class="block2-txt flex-w flex-t p-t-14"> <div class="block2-txt-child1 flex-col-l "> <a href="product-detail.html" class="stext-104 cl4 hov-cl1 trans-04 js-name-b2 p-b-6"> {{product.title}} </a> <span class="stext-105 cl3"> ${{product.price}} </span> </div> <div class="block2-txt-child2 flex-r p-t-3"> <a href="#" class="btn-addwish-b2 dis-block pos-relative js-addwish-b2"> <img class="icon-heart1 dis-block trans-04" src="images/icons/icon-heart-01.png" alt="ICON"> <img class="icon-heart2 dis-block trans-04 ab-t-l" src="{% static "images/icons/icon-heart-02.png" %}" alt="ICON"> </a> </div> </div> </div> </div> </div> {% endfor %} -
Pass variable from one method to another in python/django
I want to pass variable from details method to downloader method and perform operations.I tried several methods but not working Views.py from django.shortcuts import render import pytube from .forms import VideoDownloadForm # Create your views here. def details(request): if request.method == 'POST': form = VideoDownloadForm(request.POST, request.FILES) if form.is_valid(): f = form.cleaned_data['Url'] yt = pytube.YouTube(f) # <-----Pass this 'yt' from here thumb = yt.thumbnail_url title = yt.title return render(request, 'ytdownloader/details.html', {'title': title, 'thumbnail': thumb}) else: form = VideoDownloadForm() return render(request, 'ytdownloader/front.html', {'form': form}) def downloader(request): #<----to this method videos = yt.streams.filter(progressive=True, type='video', subtype='mp4').order_by('resolution').desc().first() videos.download('C:\\Users\\user\\Downloads') return render(request, 'ytdownloader/details.html') details.html {% extends 'ytdownloader/base.html'%} {% block content%} <h1> {{title}}</h1> <a href="{{thumbnail}}"><img src="{{thumbnail}}" alt=""></a> <a href="{% url 'download'%}"><button type="submit" class="btn btn-primary ">Download</button></a> {%endblock%} -
Django formset_factory with extra parameter
I want to use formset_factory to allow user add multiple products with on button "Add to cart". forms.py: class CartAddItemForm2(forms.Form): item_id = forms.IntegerField() quantity = forms.IntegerField() update = forms.BooleanField(required=False, initial=False, widget=forms.HiddenInput) CartAddItemFormset = formset_factory(CartAddItemForm2, extra=1) views.py: cart_item_formset = CartAddItemFormset() ... return render(request, template_name, {'item': item, ... 'cart_item_formset': cart_item_formset, 'setting': setting}) Another cart_add() function to handle the post: @require_POST def cart_add(request): """ Add multiple items to the cart/quote """ cart = Cart(request) formset = CartAddItemFormset(request.POST) if formset.is_valid(): idx = 0 for form in formset: cd = form.cleaned_data item = get_object_or_404(Item, id=cd['item_id']) quantity = cd['quantity'] if quantity > 0: cart.add(item=item, quantity=quantity, update_quantity=cd['update']) idx = idx + 1 return redirect('cart:cart_detail') I have used Bootstrap for HTML so I have to write the template manually. Sample code for the template is shown here. <td class="py-4 text-center"> <input value="1" name="form-0-quantity" id="id_form-0-quantity" class="text-center"> <input type="hidden" name="form-0-item_id" value="{{ item.id }}" id="id_form-0-item_id"> <input type="hidden" name="form-0-update" value="False" id="id_form-0-update"> </td> {% for accessory in item.sorted_accessories %} <tr> <td class="py-4 text-center">{{ accessory.code }}</td> <td class="py-4 text-center">{{ accessory.name|truncatechars:54 }}</td> <td class="py-4 text-center">${{ accessory.price }}</td> <td class="py-4 text-center"> <input value="1" name="form-{{forloop.counter}}-quantity" id="id_form-{{forloop.counter}}-quantity" class="text-center"> <input type="hidden" name="form-{{forloop.counter}}-item_id" value="{{ accessory.id }}" id="id_form-{{forloop.counter}}-item_id"> <input type="hidden" name="form-{{forloop.counter}}-update" value="False" id="id_form-{{forloop.counter}}-update"> </td> </tr> {% endfor %} The problem is: … -
How can I access ForeignKey model attributes in Angular using serialized data from Django
I am using Angular 8 and Django 3. I want to create a page for a Restaurant that shows all of the Recipes that the Restaurant has. I have a Restaurant model and a Recipe model with ForeignKey relation as follows: models.py class Restaurant(models.Model): name = models.CharField(max_length=100) class Recipe(models.Model): name = models.CharField(max_length=30) restaurant = models.ForeignKey(Restaurant, related_name='recipe', on_delete=models.CASCADE) I am serializing the data for the Restaurant using a PrimaryKeyRelatedField: serializers.py class RecipeShort(serializers.ModelSerializer): class Meta: model = Recipe fields = ('id','name') class RestaurantDetail(serializers.ModelSerializer): recipe = serializers.PrimaryKeyRelatedField(many=True, read_only=True) class Meta: model = Restaurant fields = ('id', 'name', 'food', 'recipe') When I put in the url (http://127.0.0.1:8000/restaurants/restaurantdetail/2) in Postman I get the correct response data because it is giving me the name of the Restaurant as well as an array of Recipe pk values that are related to the Restaurant. So I am serializing correctly. { "id": 2, "name": "sec", "recipe": [ 3, 4 ] } What I want to do however, is in my Angular html file be able to access the name of each Recipe in the array. All I can access is the pk value when I loop over the array. Is there an easy way to do this or do … -
Is there anyway to use a text editor in django template to let user create and add code to a python file?
Is there any way to use a text editor in html template to let user write code in front end, then save it as python file in the database. I am using django framework and mongodb. -
Django signals post_save update Related objects
When the student enrollment record (discount type) is updated the student discount (discount type) is also updated, but what should i do if i want to update the student enrollment record (discount type) using student discount (discount type) This is my models.py class studentDiscount(models.Model): Students_Enrollment_Records = models.ForeignKey(StudentsEnrollmentRecord, related_name='+', on_delete=models.CASCADE, null=True) Discount_Type = models.ForeignKey(Discount, related_name='+', on_delete=models.CASCADE, null=True,blank=True) @receiver(pre_save, sender=StudentsEnrollmentRecord) def get_older_instance(sender, instance, *args, **kwargs): try: instance._old_instance = StudentsEnrollmentRecord.objects.get(pk=instance.pk) except StudentsEnrollmentRecord.DoesNotExist: instance._old_instance = None @receiver(post_save, sender=StudentsEnrollmentRecord) def create(sender, instance, created, *args, **kwargs): if not created: older_instance = instance._old_instance if older_instance.Discount_Type != instance.Discount_Type: studentDiscount.objects.filter( Students_Enrollment_Records=instance ).delete() else: return None discount = studentDiscount.objects.filter(Discount_Type=instance.Discount_Type) if created: print("nagsulod") studentDiscount.objects.create( Students_Enrollment_Records=instance, Discount_Type=instance.Discount_Type) else: studentDiscount.objects.create( Students_Enrollment_Records=instance, Discount_Type=instance.Discount_Type) def __str__(self): suser = '{0.Students_Enrollment_Records}' return suser.format(self) class StudentsEnrollmentRecord(models.Model): Student_Users = models.ForeignKey(StudentProfile, on_delete=models.CASCADE,null=True) School_Year = models.ForeignKey(SchoolYear, related_name='+', on_delete=models.CASCADE, null=True, blank=True) Courses = models.ForeignKey(Course, related_name='+', on_delete=models.CASCADE, null=True, blank=True) strands = models.ForeignKey(strand, related_name='+', on_delete=models.CASCADE, null=True, blank=True) Section = models.ForeignKey(Section, related_name='+', on_delete=models.CASCADE, null=True,blank=True) Payment_Type = models.ForeignKey(PaymentType, related_name='+', on_delete=models.CASCADE, null=True) Discount_Type = models.ForeignKey(Discount, related_name='+', on_delete=models.CASCADE, null=True,blank=True) Education_Levels = models.ForeignKey(EducationLevel, related_name='+', on_delete=models.CASCADE,blank=True,null=True) ESC = models.ForeignKey(esc, on_delete=models.CASCADE,null=True,blank=True) Remarks = models.TextField(max_length=500,null=True,blank=True) class Discount(models.Model): Code=models.CharField(max_length=500,blank=True) Discount_Type=models.CharField(max_length=500,blank=True) Remarks=models.TextField(max_length=500,blank=True) TuitionFee_Discount_Amount=models.FloatField(null=True,blank=True) TuitionFee_Discount_Rate = models.FloatField(null=True,blank=True) Miscellaneous_Discount_Amount=models.FloatField(null=True,blank=True) Miscellaneous_Discount_Rate = models.FloatField(null=True,blank=True) if i update the student enrollment record (Discount_Type) the student discount (discount type) update … -
How to use subquery or stored procedure in a field in the Django model
I am trying to insert a data where the value of the field will be the maximum value + 1. Something like: INSERT INTO model (count) VALUES ((SELECT count + 1 FROM model)) How to represent this in the django model? Model.objects.create ( count= ...? ) -
How to execute a Celery task on a date entered by the use
I need to execute the following task on a date that the user defined in the registry, the date was captured in an APIView of Django Rest Framework. @task(bind=True) def expiration_quote(quote, expiration): QuotationOrder.objects.filter(id_quotation_order=quote).update(status=2) return Is it possible with Celery to execute the task on that specific date? How could I do it? -
How to display all modelForm to a Classed Based Detail View
I have been working on this project for a while now but now I am stuck and can't seems to move any further. The issue is I have 4 modelForm I will like to display in a detail view. I have been able to show two of the modelForm by using a for loop on the landlord model and using context_object_name to get the rental model. Where I am stuck is how to get the apartmentBasicInfo and Contract modelForm to display in the detail view. Thanks. Link to the code here: dpaste.com/2BTS9TN -
Django queryset for intersecting ManyToMany relations fields
I have a difficult problem, I'm trying to select models related to each other with ManyToMany relations, depending on the intersection of the models present on each ManyToMany fields. I tried to achieve this with F() but without success, I don't think I'm skilled enough about DB/ORM to solve this. Here is a example: class Event(models.Model): want_private = models.ManyToManyField('User') class User(AbstractUser): events = models.ManyToManyField(Event, related_name='users') First I'd like to select events from a set of users, e.g. those starting with "a": users_a = User.objects.filter(username_startswith="a") So the queryset should be: Event.objects.filter(users=users_a) When it gets complicated is that I would like to: exclude events where a user is at the same time in the users field of the event, in the want_private field of the event, and in the users_a queryset. include events where a user is in at the same time in users field of the event, not in the want_private field of the event, and in the users_a queryset. Do anyone by any chance have an idea to solve this? Thank you very much, Camille. -
Django: too many values to unpack (expected 2)
I am new in Django. In my Django view.py, I have following get method. customer_list = Customer.objects.filter(CustId = '1001') and it returns result. When I substitute with a String like following: getQueryString = "CustId = '1001'" customer_list = Customer.objects.filter(getQueryString) I get the following error: too many values to unpack (expected 2) Any help really appreciated. -
Django signals TypeError: func_receiver() missing 1 required positional argument: 'func_sender'
I faced with problem while trying to play with django signals. I have a project with following structure authexample manage.py posts #django app func.py #here is sender and receiver logic is realised In posts app's models.py i created a simple post model class Post(models.Model): title = models.CharField(max_length=30) body = models.CharField(max_length=50) In my func.py which is located outside post app i realised my signals calling logic by following code from django.db.models import models from posts.models import Post from django.db.models.signals import post_save from django.dispatch import receiver #my sender function def func_sender(title,body): a = Post(title=title,body=body) a.save() #receiver function @receiver(post_save, sender=func_sender) def func_receiver(sender,**kwargs): print("article was saved") Than i am trying to create test article for this purposes i run python manage.py shell from func import * a = Post("test_title","test_body) When this code was executed my test article was created but i expect that after article was created my receiver function func_receiver will execute and prompt me string inside print statement. Why this isn't occur. Guide me please -
How can I integrate Behance social authentication with Django (Python)?
I am developing a website using Django, I have a task to make users can register and login with their Behance accounts. I saw some libraries like 'django-social-auth' and 'python-social-auth' and they seem that they are DEPRECATED. Are there other libraries can I use that support Behance social accounts? Also I read that Behance has dropped OAuth2 support. Is this correct? and if there is any technology can help me accomplish my task PLEASE let me know. -
Django - Dynamic Tables - Add rows and columns
I am learning Django. Are there tutorials on how I can add additional columns to a database when the users clicks "Add Columns".