Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django : url change depends on model exist
I'd like to make user access to page depends on model exist. and I use CBV. Do I have to control views? or urls? Is FBV only way to control url? How can I control user access url? hope kindly help me. i'd like to control for example:(as you know, this is invalid syntax. hope you know what i'm saying.) from django.urls import path from . import views, models app_name = "papers" urlpatterns = [ path( "memberagreement/<int:preassociation_pk>/", {% if models.MemberAgreement.association.get(pk=preassociaion_pk) is not NULL %} views.member_agreement_detail_vc.as_view(), {% else %} views.member_agreement_create_vc.as_view(), {% endif %} name="member_agreement_vc", ) ] -
Django 3.0 images: Unable to display images in template
I have model named Book in models.py file. And based on this model, a view has been created to display images as products. Which renders books(products) on shop.html template. Problem is that i am unable to get their cover images which are saved across each publishers id who is seller of those books. This is code of shop.html (in which i am trying to display image). <div class="container mt-4"> <div class="row"> {% for b in books|slice:":10" %} <div class="col-lg-2 col-md-3 col-sm-4"> <div class="book-card"> <div class="book-card__book-front"> <img src={{MEDIA_URL}}{{b.cover.url}} alt="book-image"> </div> </div> <div class="book-card__title"> {{ b.title }} </div> </div> </div> </div> {% endfor %} </div> </div> This is the model in which i am putting covers of books against publisher's ids (names) def book_cover_path(instance, filename): return os.path.join( "covers", instance.publisher.user.username, str( instance.pk) + '.' + filename.split('.')[-1] ) class Book(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) title = models.CharField('Title', max_length=255) authors = models.ManyToManyField(Author, related_name='books_written') publisher = models.ForeignKey(Publisher, on_delete=models.DO_NOTHING, related_name='books_published') price = models.DecimalField('Price', decimal_places=2, max_digits=10) description = models.TextField('Description') upload_timestamp = models.DateTimeField('Uploading DateTime', auto_now_add=True) categories = models.ManyToManyField(Category, related_name='book_category') cover = models.ImageField(upload_to=book_cover_path, null=True,blank=True) class Meta: unique_together = ('title', 'publisher') get_latest_by = '-upload_timestamp' This is view in views.py def shop(req): bookz = Book.objects.order_by('title') var = {'books': bookz, 'range': 10} … -
ModelChoiceFilter is throwing error in Django
I have following Filter class. class CallSummaryFilterSet(filters.FilterSet): ringing_mobile_number = filters.ModelChoiceFilter(queryset=CallSummary.objects.all(),method='filter_mobile_number') class Meta: model = CallSummary fields = ('caller', 'callee') def filter_mobile_number(self, queryset, name, value): queryset = queryset.filter(Q(caller=value) | Q(callee=value)) return queryset Request Format :- http://127.0.0.1:8000/call-summaries/?ringing_mobile_number=1234567890 it's throwing following error. {'ringing_mobile_number': [ErrorDetail(string='Select a valid choice. That choice is not one of the available choices.', code='invalid_choice')]} -
applying google-oauth2 in django
i am trying to use google auth2 and is struck at the type of request the function is demanding in django i.e try: # Specify the CLIENT_ID of the app that accesses the backend: idinfo = id_token.verify_oauth2_token(token, requests.Request(), CLIENT_ID) # Or, if multiple clients access the backend server: # idinfo = id_token.verify_oauth2_token(token, requests.Request()) # if idinfo['aud'] not in [CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3]: # raise ValueError('Could not verify audience.') if idinfo['iss'] not in ['accounts.google.com', 'https://accounts.google.com']: raise ValueError('Wrong issuer.') # If auth request is from a G Suite domain: # if idinfo['hd'] != GSUITE_DOMAIN_NAME: # raise ValueError('Wrong hosted domain.') # ID token is valid. Get the user's Google Account ID from the decoded token. userid = idinfo['sub'] this is from the https://developers.google.com/identity/sign-in/web/backend-auth where request is from the following function var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://yourbackend.example.com/tokensignin'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onload = function() { console.log('Signed in as: ' + xhr.responseText); }; xhr.send('idtoken=' + id_token); shall i pass it directly or just the token value -
Accessing a property coming from manytomany field
This is my models.py: class Role(models.Model): type= models.CharField(max_length=30) class Profile(models.Model): role = models.ManyToManyField(Role, blank=True) def is_composer(self): return self.role['Composer'] This is my view.py: from .models import Profile, Role def profiles_filtered(request, type): model = Profile if type == 'composers': queryset = Profile.objects.filter(is_composer = True) My urls.py: urlpatterns = [ path('profiles/<str:type>/', views.profiles_filtered, name="profiles"), ] And my template: <li><a href="{% url 'profiles' 'composers' %}"> Composers</a></li> When I click on the link, I get to /profiles/composers/, which should list all the profiles containing the role 'Composer'. I get a FieldError at /profiles/composers/ Cannot resolve keyword 'is_composer' into field. The Role type contains many roles, one of which is 'Composer'. How can I list only the profiles which contain a 'Composer' role? -
django Error: AttributeError: 'ModelFormOptions' object has no attribute 'private_fields'
I have two tables 1. intake request (this table has a field that should be shown as drop down values from the 2nd table) 2. drop down list (this table contains the list of values for all sorts of fields. Which is what I want to show as drop down in various forms) List Category List Of Value Choices technology_used spark technology_used oracle country USA country Canada So for a technology_used in intake request I need to show only spark and oracle in drop down For country field in intake request I need to show only USA and Canada **models.py** class DropDownList(models.Model): list_category = models.CharField(max_length=20) list_value = models.CharField(max_length=50) def __str__(self): return self.list_value class Meta: managed = True db_table = 'domain_DropDownList' class DatastoreIntakeRequest(models.Model): user = models.ForeignKey(User, default=1, on_delete=models.CASCADE) technology_used = models.ForeignKey(DropDownList, default=1, on_delete=models.SET_NULL, null=True) def __str__(self): return self.therapeutic_area def get_absolute_url(self): return reverse('domain:intake_detail', kwargs={'pk': self.pk}) #excluding country class here **forms.py** class DatastoreIntakeRequestForm(forms.ModelForm): class Meta: model = DatastoreIntakeRequest fields = ['technology_used',] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['technology_used'].queryset = DropDownList.objects.none() if 'technology_used' in self.data: try: list_cat = 'technology_used' self.fields['technology_used'].queryset = DropDownList.objects.filter(list_category=list_cat).order_by('list_value') except (ValueError, TypeError): pass # invalid input from the client; ignore and fallback to empty City queryset **views.py** class DatastoreIntakeRequestCreateView(CreateView): form_class = … -
Why do I get TemplateDoesNotExist for only 1 template?
I have a form I would like to display on a html template named query_page.html but I keep getting the TemplateDoesNot exist error even though I have the template. I don't think it is related to my settings.py as my 10 other templates work perfectly. I think it might be related to how I am mapping in urls.py class QueryView(FormView): form_class = QueryForm template_name = 'query_page.html' def form_valid(self, form): print(form.cleaned_data) return super().form_valid(form) urlpatterns = [ path('', views.index, name='index'), path('patient_new/', views.patient_new, name='patient_new'), path('location_new/', views.location_new, name='location_new'), path('location_list/', views.location_temps, name='location_list'), re_path('patient/(?P<pk>\d+)$', views.PatientDetailView.as_view(), name='patient_detail'), re_path('location/(?P<pk>\d+)$', views.LocationDetailView.as_view(), name='location_detail'), re_path('patient/(?P<pk>\d+)/edit/$', views.PatientUpdateView.as_view(), name='patient_edit'), re_path('my_form/$', require_POST(views.MyFormView.as_view()), name='my_form_view_url'), re_path('patient/(?P<pk>\d+)/remove/$', views.PatientDeleteView.as_view(), name='patient_remove'), #re_path('patient/(?P<pk>\d+)/query/$', views.profile_search, name='query'), re_path('patient/(?P<pk>\d+)/query/$', views.QueryView.as_view(), name='query'), re_path('location/(?P<pk>\d+)/edit/$', views.LocationUpdateView.as_view(), name='location_edit'), re_path('location/(?P<pk>\d+)/remove/$', views.LocationDeleteView.as_view(), name='location_remove'), ] it is this line: re_path('patient/(?P<pk>\d+)/query/$', views.QueryView.as_view(), name='query') Link to the form: <p><a class="btn btn-primary" href="{% url 'query' pk=patient.pk %}">Query</a></p> -
CrispyError at /register/ |as_crispy_field got passed an invalid or inexistent field
My Error traceback: (I get this whenever I open my Register page) Environment: Request Method: GET Request URL: http://127.0.0.1:8000/register/ Django Version: 3.0.4 Python Version: 3.7.3 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap4', 'crispy_forms', 'django_tables2', 'staffplanner.apps.StaffplannerConfig', 'accounts.apps.AccountsConfig'] Installed Middleware: ['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'] Template error: In template D:\ng_projects\Planner-5\NG\staffplanner\templates\staffplanner\match.html, error at line 0 |as_crispy_field got passed an invalid or inexistent field 1 : 2 : {% load static %} 3 : {% load crispy_forms_tags %} 4 : {% load render_table from django_tables2 %} 5 : <!DOCTYPE html> 6 : <html lang="en"> 7 : <head> 8 : <meta charset="UTF-8"> 9 : <meta name="viewport" content="width=device-width, initial-scale=1.0"> 10 : <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> Traceback (most recent call last): File "C:\Users\noori\Envs\planner\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\noori\Envs\planner\lib\site-packages\django\core\handlers\base.py", line 145, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\noori\Envs\planner\lib\site-packages\django\core\handlers\base.py", line 143, in _get_response response = response.render() File "C:\Users\noori\Envs\planner\lib\site-packages\django\template\response.py", line 105, in render self.content = self.rendered_content File "C:\Users\noori\Envs\planner\lib\site-packages\django\template\response.py", line 83, in rendered_content return template.render(context, self._request) File "C:\Users\noori\Envs\planner\lib\site-packages\django\template\backends\django.py", line 61, in render return self.template.render(context) File "C:\Users\noori\Envs\planner\lib\site-packages\django\template\base.py", line 171, in render return self._render(context) File "C:\Users\noori\Envs\planner\lib\site-packages\django\template\base.py", line 163, in _render return self.nodelist.render(context) File "C:\Users\noori\Envs\planner\lib\site-packages\django\template\base.py", line 936, in render bit = node.render_annotated(context) File "C:\Users\noori\Envs\planner\lib\site-packages\django\template\base.py", … -
Django model translation using gettext
There is little information on why to use gettext to translate content from the database what are its advantages and implications? Why hardly anyone talks about this? I see more information about: django-modeltranslation django-parler django-hvad Would it be more scalable to use django-vinaigrette? or are there some other alternatives? -
error during trying to connect to my server via ssh , can not connect to my vps server vis ssh
i've build a website using django and apache but today it suddenly raised an error when i try to open my website it show only Apache2 Ubuntu Default Page This is the default welcome page used to test the correct operation of the Apache2 server after installation on Ubuntu systems. It is based on the equivalent page on Debian etc .. before worked fine for about 9 month , i tried to connect to the server via ssh terminal ssh username@my_ip_address but it raised this error @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:the_key Please contact your system administrator. Add correct host key in /home/username/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /home/username/.ssh/known_hosts:2 ECDSA host key for my_ip has changed and you have requested strict checking. Host key verification failed. and i run this command ssh-keygen -R my_ip and the output Host 51.83.98.146 found: line 2 /home/username/.ssh/known_hosts updated. Original contents retained … -
how to update the date?
when i'm updating the except all fields then updating well when i adding date field its not updating any data... plz let me know why.... forms.py class EmployeeForm(ModelForm): class Meta: model = Employee fields = "__all__" widgets = { 'edob': DateInput(), 'egender': forms.RadioSelect(), } models.py class Employee(models.Model): eid = models.CharField(max_length=20) ename = models.CharField(max_length=100) eemail = models.EmailField() econtact = models.CharField(max_length=15) esalary = models.CharField(max_length=100) egender = models.CharField(max_length=20, choices=G_CHOICES, default='male') edob = models.DateField() def __str__(self): return self.ename class Meta: db_table = "employee" update.html <div class="form-group row"> <label class="col-sm-2 col-form-label">Employee DOB:</label> <div class="col-sm-4"> <input type="text" name="edob" id="id_edob" required maxlength="15" value="{{ employee.edob }}" /> </div> how to solve this didn't getting .... -
Django Rest Framework,Filtering objects based on Forignkey relationship
I have a simple Blog app where anyone can add post and comment to post. Comments have forignkey relationship with Post. When I select url patch posts/<post id>/comments it shows all comments instead of the comments from related posts. All other CRUD functions works fine with the project. The Git Link :https://github.com/Anoop-George/DjangoBlog.git The problem occurs in view.py where comment object unable to filter comments which are related to specific posts. class CommentListCreate(APIView): def get(self, request,pk): **comment = Comment.objects.filter()** # I need filter here serializer = CommentSerializers(comment, many=True) return Response(serializer.data) -
Django Rest Framework - Django ORM instance.delete() doesn't delete the instance...?
I have the following API delete view: @action(detail=True, methods=['delete'], permission_classes=[IsAuthenticatedViaJWTCookie]) def delete(self, request, pk=None, *args, **kwargs): queryset = self.get_queryset().get(id=pk) if queryset.user == request.user: queryset.delete() return Response(status=status.HTTP_204_NO_CONTENT) else: response = standardized_json_error_response( message='Artwork Object Could Not Be Deleted', data=[] ) return Response(data=response, status=status.HTTP_401_UNAUTHORIZED) When calling this view from an axios.delete request, I can see that the delete request is being made, and hitting the endpoint. All good so far. Yet, in the listing API view, the target instance to be deleted is still being listed. Doesn't matter how many times that endpoint is refreshed, or how long I wait. What is worse still, is when I call that endpoint again using axios.delete in the front end, for a second time, the record is then permanently deleted? Has anyone experienced such odd behaviour before with Django, or could this be a third party issue? *I have installed django-cleanup...? -
Heroku Debug Flag not stopping django debugging
I'm currently have Django project in heroku but I tried to stop the debug mode but unfortunately it's not working. First I tried to stop it from settings.py DEBUG=False DEBUG = os.environ.get('DEBUG', False) both not helping tried also to set env variable heroku config:set DEBUG=False heroku config:unset DEBUG both also not helping I tried to assign wrong value the debug in settings.py for testing which caused to crash the deployment. Hopefully some one can help with this. -
'ForwardManyToOneDescriptor' object has no attribute 'all
Now, i have problem w M2O relectionship :( Model.py class StorageDoc(models.Model): # tabela dokumentująca ruch na magazynie typeList = ( (' ', " "), ('WZ', "WZ"), ('PZ', "PZ"), ('PM', "PM") ) docType = models.CharField(max_length=10, choices=typeList, default=' ') storageName = models.ForeignKey(DictStorage, on_delete=models.DO_NOTHING) createTime = models.DateTimeField(auto_now=True) orderNumber = models.CharField(max_length=64, blank=True) class StorageDocPosition(models.Model): storageDoc = models.ForeignKey(StorageDoc, on_delete=models.DO_NOTHING, related_name="sds") item = models.ForeignKey(Part, on_delete=models.DO_NOTHING) volumeUsed = models.IntegerField() volumeBefore = models.IntegerField() volumeAfter = models.IntegerField() views.py def StorageDocList (request): s_documents = StorageDocPosition.objects.all().prefetch_related("storageDoc") for s_document in s_documents: s_documentP = StorageDocPosition.storageDoc.all() return render(request, 'StorageDocList.html', {'storageDocAll': s_documents}) my error is: 'ForwardManyToOneDescriptor' object has no attribute 'all' why I can not use "all" in this case? How fix it? Thanks for help : -
Why doesn't Django detect the Summernote module?
So I'm currently using Django ver. 3.x, and trying to load summernote on my webpage. I'm using Bootstrap4 btw. I've done exactly the same as written in https://github.com/summernote/django-summernote. However, when I execute python manage.py makemigrations after migration, I get this error : "ModuleNotFoundError: No module named 'django-summernote'" Below is the full error script. Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\user\Envs\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Users\user\Envs\venv\lib\site-packages\django\core\management\__init__.py", line 377, in execute django.setup() File "C:\Users\user\Envs\venv\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\user\Envs\venv\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Users\user\Envs\venv\lib\site-packages\django\apps\config.py", line 90, in create module = import_module(entry) File "C:\Users\user\Envs\venv\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'django-summernote' I don't see what I've done wrong. I would very much appreciate your help. :) -
Child class inherits from concrete parent: django.db.utils.OperationalError: foreign key mismatch
I have a concrete parent class Sub and a child class SubOrder. One Sub can "have" (i.e. be in ) many SubOrders and one SubOrder can "have" (contain) many Subs. My classes are as below, but when I try to create a Sub-object, I get the error: django.db.utils.OperationalError: foreign key mismatch - "orders_suborder" referencing "orders_sub" What's the issue here? Do I need to use ManyToManyField (if so, why & where?) and why am I getting this error? class Sub(Dish): dish = models.OneToOneField(Dish, on_delete=models.CASCADE, related_name="dish_id_sub", parent_link=True) def __str__(self): return f"{self.name}, Price: ${self.price}" class SubOrder(Sub): sub_id = models.ForeignKey(Sub, related_name="sub_id", parent_link=True) item_id = models.ForeignKey(Item, on_delete=models.CASCADE, primary_key=True, related_name="sub_item_id") extra_count = models.IntegerField(default=0, validators=[MaxValueValidator(4), MinValueValidator(0)]) MUSHIES = 'M' PEPPERS = 'P' ONIONS = 'O' XTRCHEESE = 'C' EXTRA_CHOICES = ((MUSHIES, 'Mushrooms'), (PEPPERS, 'Peppers'), (ONIONS, 'Onions'), (XTRCHEESE, 'Extra Cheese'),) extra_1 = models.CharField(max_length=1, choices=EXTRA_CHOICES, blank=True) extra_2 = models.CharField(max_length=1, choices=EXTRA_CHOICES, blank=True) extra_3 = models.CharField(max_length=1, choices=EXTRA_CHOICES, blank=True) extra_4 = models.CharField(max_length=1, choices=EXTRA_CHOICES, blank=True) def __str__(self): extras = [] for i in range(extra_count): str = "extra_"+i extras.append(str) return f"Sub Order: Item {self.item_id}, {self.name}, size: {self.size}. {self.extra_count} Extras: {extras}" If it matters, here's the Sub's parent class Dish, but I don't think that's the issue: class Dish(models.Model): PIZZA = 'PIZZA' SUB = 'SUB' … -
Django isn't recognizing that a user has been authenticated after loggin in. I have to refresh the page one more time before it goes through
As the title states when I login and put in my credentials it redirects me to an html page where I have a condition of and it evaluates this to False. {% if user.is_authenticated %} However when I refresh the page it evaluates this condition to true even though I haven't done anything. Any possible explanations or solutions this? Thank you for any and all help! -
Django, display form based on value of another form
I'm trying to show or hide a crispy form based on the value of other form. I have the following form: <div class="form-group col-2 0 mb-0" id="field_three"> {{form.numero_mensilità|as_crispy_field}} </div> <div class="form-group col-2 0 mb-0 d-none" id="field_four"> {{form.mese_pagamento_13|as_crispy_field}} </div> I want that when client digit in the first form (id=field_three) the value 13, automatically django show me the second form (id="field_four"). These will be happen during the filling of the form, so if the client change the value from 13 to 12 ad example, the field disappears. I have tried to perform this script but does not work: // this is executed once when the page loads $(document).ready(function() { // set things up so my function will be called when field_three changes $('#field_three').change( function() { check_field_value(this.value); }); // function that hides/shows field_four based upon field_three value function check_field_value(new_val) { if(new_val != '13') { // #id_field_four should be actually the id of the HTML element // that surrounds everything you want to hide. Since you did // not post your HTML I can't finish this part for you. $('#field_four').removeClass('d-none'); } else { $('#field_four').addClass('d-none'); } } -
Django SSE and Websocket
I want to use Webscokets and SSE in django, I know i can do it with ASGI, uWSGI and for WebSockets Django Channels. My question is what is the difference between ASGI an uWSGI and which one is better solution in 2020 -
Django model attributes not getting displayed in html page
Apologies for the noobish question, I am new to Django and trying to make an e-commerce app. What I want to do, is that show users variations available for an item in the product page. I've created a model for variations, and added some variations in my admin panel, but when I'm trying to display those, it is not happening. I think the way I'm accessing it is wrong. Can anyone please help me solve the problem? Thanks in advance! My models.py: class Item(models.Model): title = models.CharField(max_length=120) price = models.FloatField() class Variation(models.Model): item = models.ForeignKey(Item, on_delete=models.CASCADE) name = models.CharField(max_length=50) # size, color class Meta: unique_together = ( ('item', 'name') ) class ItemVariation(models.Model): variation = models.ForeignKey(Variation, on_delete=models.CASCADE) value = models.CharField(max_length=50) # small, medium large etc class Meta: unique_together = ( ('variation', 'value') ) My sinngle_product.html: The form part <h1 class="product-title">{{ item.title }}</h1> <a href="#"> <span class="badge purple mr-1">{{ object.get_category_display }}</span> </a> <span class="review-no text-danger">41 reviews</span> </div> {% if object.discount_price %} <h4 class="price">price: <del><span>${{ object.price }}</span></h4></del> <h4 class="price text-primary">current price: <span>${{ object.discount_price }}</span> <span class="badge badge-pill badge-warning">Limited Time Offer!</span> {% else %} <h4 class="price">current price: <span>${{ object.price }}</span> {% endif %} <p class="vote text-success"><strong>91%</strong> of buyers enjoyed this product! <strong>(87 votes)</strong></p> <form … -
GraphQL API export of Django project in SDL representation not possible anymore
I'm trying to export the GraphQL API of my backend server with python manage.py graphql_schema --schema <django-app>.schema.schema --out <django-project>/schema.graphql. The generated file contains the introspectable representation like exported with ... --out schema.json. I was able to output the SDL representation of this project before. It seems like a package I introduced later is the root cause ot this issue. I added the following GraphQL dependencies over time: graphene==2.1.8 graphene-django==2.8.0 graphene-django-cud==0.4.4 graphene-file-upload==1.2.2 graphene-subscriptions==1.0.2 graphql-core==2.3.1 graphql-relay==2.0.1 Had someone else this behavior as well and knows how to fix or workaround it? -
what is benefit of using Redis for my Django web app?
Actually i created a simple web app with Django. I want to use server-push functionality in my web app. I think this type of functionality can be achieved through WebSockets using Django-channels. But if I want to use WebSockets in Django-channels then I also need to run Redis server parallel as well but why I need to run Redis server.what is the use of Redis with Django-server I'm so confused. -
'Django-admin not recognized as a command'
So I wanted to try Django and as the tutorial said I went ahead and installed virtualenv. I create the venv and cd into it. Then i try to create a project inside it but i cant. I put the file inside PATH and tried once again "django-admin startproject [name of my project]" and got this error: 'django-admin' is not recognized as an internal or external command, operable program or batch file. And i know there are a couple of simular forums here on stack overflow already but as far as i saw nothing worked. -
how to combine or integrate reactjs and Django
I created front end in Reactjs and backend in Django and linked using Django rest API. but react runs in localhost:3000 and Django in localhost:8000. How to combine or integrate these two and runs in the same address.