Alex
If it works locally, it means that there are migrations for that table.
Anonymous
Imran
S
Hi how can I serve django project in https
S
Please help me
ELMAN | 𐰣𐰀𐰢𐰞𐰅
Hello friends,
I have a question.
I have a loop function and I want to run it in views.py,
But when I'm loading website, It does not load until my function be run completely!
I want to load website without running my loop function completely!
How can I do that?
Abhinav
I am getting an error " cannot import name 'consumers' from 'chat' " while running my server where i gave from . import consumers
Abhinav
Can someone help me with this
Aaush
Can anyone tell me how to do this proj.
I have to create a page where User can Select/Unselect mutliple Images and After clicking on submit button, user can View those Images in his Album!
Abhinav
import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter,URLRouter
from channels.auth import AuthMiddlewareStack
import chat.routing
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = ProtocolTypeRouter({
"http":get_asgi_application(),
"websocket":AuthMiddlewareStack(
URLRouter(
chat.routing.websocket_urlpatterns
)
)
})
My asgi.py file
Abhinav
from django.urls import re_path
from channels.routing import ProtocolTypeRouter, URLRouter
from . import consumers
websocket_urlpatterns = [
re_path(r'', consumers.ChatConsumer.as_asgi()),
]
Abhinav
My consumer.py file
Aaush
Can anyone tell me how to do this proj.
I have to create a page where User can Select/Unselect mutliple Images and After clicking on submit button, user can View those Images in his Album!
Aaush
Can you tell me how to Make a Checkbox logic in Views Django? So that I can select multiple Images and Submit them to album page?
Aaush
With Ajax?
T4P4N
Aaush
I have to Upload those Image from Backend
Aaush
Like from Django admin panel..I can Upload Image on the page and then I have to do the selection work..
mourya
Can any one know how to write test cases in python and django
Mirco
Arpit
Appconfig file must supply a name attribute is the error coming..I have got similar error solution on stackoverflow but that is insuffuicient to resolve my error
Arpit
from django.apps import AppConfig
class MyAppConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'myapp'
Arpit
This is my code in which I have already supplied the name attribute but then also the error is coming.
cj
cj
if that's the second case, you should specify it, like
name = 'apps.myapp' or wherever your app is located
Arpit
Aaush
I want to render SUBMIT button to another html page with Selected Inputs of this page, how to do this ?
..
Aaush
No , I have to use AJAX!
Aaush
How to do this with AJAX ans Views
Alex|Web developer
all hello, please help
Alex|Web developer
{in terminals input}python manage.py makemigrations
SystemCheckError: System check identified some issues:
ERRORS:
<class 'mainapp.admin.CategoryAdmin'>: (admin.E108) The value of 'list_display[2]' refers to 'order_of_display', which is not a callable, an attribute of 'CategoryAdmin', or an attribute or method on 'mainapp.Category'.
<class 'mainapp.admin.CategoryAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'order_of_display', which does not refer to a Field.
<class 'mainapp.admin.CategoryAdmin'>: (admin.E121) The value of 'list_editable[0]' refers to 'order_of_display', which is not a field of 'mainapp.Category'.
Mirco
Alex|Web developer
sorry text error
Alex|Web developer
its right:
Alex|Web developer
{in terminals input}python manage.py makemigrations
C:\Users\ogure\PycharmProjects\Shop\venv\lib\site-packages\django\core\management\commands\makemigrations.py:105: RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default':
warnings.warn(
No changes detected
M?
I want to add second model inside my first model, why my solve doesn't work&
class Slot(models.Model):
owner = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.CASCADE)
outletsSlotInventory = models.ForeignKey(OutletsSlotInventory, on_delete=models.CASCADE)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)
class Meta:
unique_together = [['owner', 'outletsSlotInventory']]
@property
def outletToSlot(self):
outletToSlots = self.outletToSlot_set.all()
myOutletsToSlots = outletToSlots.filter(owner.id=id);
return myOutletsToSlots
def __str__(self) -> str:
return str(id)
class OutletToSlot(models.Model):
outletToSlotId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
expireTime = models.DateTimeField(blank=True)
outlet = models.ForeignKey(Outlet, null=True, blank=True, on_delete=models.CASCADE, default=0)
slot = models.OneToOneField(Slot, null=True, blank=True, on_delete=models.CASCADE)
def __str__(self) -> str:
return "{0} - {1}".format(self.outlet.label, self.slot)
Mirco
Alex|Web developer
yes
Mirco
yes
Yes what ? Which one ?
Alex|Web developer
settings
Alex|Web developer
Yes what ? Which one ?
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django_db',
'USER': 'postgres',
'PASSWORD': '1111',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
Mirco
Mirco
😅 you should
Mirco
Alex|Web developer
Google it 😊
I installed the database, are you talking about this?
Mirco
I installed the database, are you talking about this?
I'm talking about if you are able to connect to it with those credentials and that database
Type this one into your terminal and tell us what you see
psql -h localhost -U postgres django_db
Use the password you have hardcoded inside the settings ( very bad! )
Alex|Web developer
Mirco
I suppose you have to install psql
Alex|Web developer
@pyflare okay can you advise where is the best place to learn django?
Collo
Am having templatedoes not exit how will I solve it
Alex
I want to add second model inside my first model, why my solve doesn't work&
class Slot(models.Model):
owner = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.CASCADE)
outletsSlotInventory = models.ForeignKey(OutletsSlotInventory, on_delete=models.CASCADE)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)
class Meta:
unique_together = [['owner', 'outletsSlotInventory']]
@property
def outletToSlot(self):
outletToSlots = self.outletToSlot_set.all()
myOutletsToSlots = outletToSlots.filter(owner.id=id);
return myOutletsToSlots
def __str__(self) -> str:
return str(id)
class OutletToSlot(models.Model):
outletToSlotId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
expireTime = models.DateTimeField(blank=True)
outlet = models.ForeignKey(Outlet, null=True, blank=True, on_delete=models.CASCADE, default=0)
slot = models.OneToOneField(Slot, null=True, blank=True, on_delete=models.CASCADE)
def __str__(self) -> str:
return "{0} - {1}".format(self.outlet.label, self.slot)
What exactly is not working? Provide an error message (by a paste service) if there is any.
M?
M?
thx
Alex
I want to add second model inside my first model, why my solve doesn't work&
class Slot(models.Model):
owner = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.CASCADE)
outletsSlotInventory = models.ForeignKey(OutletsSlotInventory, on_delete=models.CASCADE)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)
class Meta:
unique_together = [['owner', 'outletsSlotInventory']]
@property
def outletToSlot(self):
outletToSlots = self.outletToSlot_set.all()
myOutletsToSlots = outletToSlots.filter(owner.id=id);
return myOutletsToSlots
def __str__(self) -> str:
return str(id)
class OutletToSlot(models.Model):
outletToSlotId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
expireTime = models.DateTimeField(blank=True)
outlet = models.ForeignKey(Outlet, null=True, blank=True, on_delete=models.CASCADE, default=0)
slot = models.OneToOneField(Slot, null=True, blank=True, on_delete=models.CASCADE)
def __str__(self) -> str:
return "{0} - {1}".format(self.outlet.label, self.slot)
> outletsSlotInventory = models.ForeignKey(OutletsSlotInventory, on_delete=models.CASCADE)
> outlet = models.ForeignKey(Outlet, null=True, blank=True, on_delete=models.CASCADE, default=0)
Actually you don't have to link both of the models, but just one. And I doubt that you have zero id outlet (default=0)
Alex
I want to add second model inside my first model, why my solve doesn't work&
class Slot(models.Model):
owner = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.CASCADE)
outletsSlotInventory = models.ForeignKey(OutletsSlotInventory, on_delete=models.CASCADE)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)
class Meta:
unique_together = [['owner', 'outletsSlotInventory']]
@property
def outletToSlot(self):
outletToSlots = self.outletToSlot_set.all()
myOutletsToSlots = outletToSlots.filter(owner.id=id);
return myOutletsToSlots
def __str__(self) -> str:
return str(id)
class OutletToSlot(models.Model):
outletToSlotId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
expireTime = models.DateTimeField(blank=True)
outlet = models.ForeignKey(Outlet, null=True, blank=True, on_delete=models.CASCADE, default=0)
slot = models.OneToOneField(Slot, null=True, blank=True, on_delete=models.CASCADE)
def __str__(self) -> str:
return "{0} - {1}".format(self.outlet.label, self.slot)
@property
def outletToSlot(self):
outletToSlots = self.outletToSlot_set.all()
myOutletsToSlots = outletToSlots.filter(owner.id=id);
return myOutletsToSlots
typical N + 1 problem https://stackoverflow.com/questions/97197/what-is-the-n1-selects-problem-in-orm-object-relational-mapping
You better to move that logic to a model manager and rewrite it to just one db query
M?
thx alex
Umut
hello is there a way to run rtsp in my django project
Jean-Yves
Hello everybody , how can i create a deleteView without template_name
Jean-Yves
https://www.toptal.com/developers/hastebin/aqihedutew.rb
Aaush
How to render html file with ajax and Django view!
Aaush
I want to call an Ajax Fnc when submit button in clicked and show the Selected data on another Html file
Doragonsureiyā
How to render html file with ajax and Django view!
Step 1: Open a browser
Step 2: Write down https://google.com or https://duck.com and press Enter
Step 3: In the search box, write down the same words you asked here
Step 4: Read the first results
Aaush
😂😂 I have already done that , but still getting errors
Shubham
Render your html like u do normally and then write js code that will do Ajax calls and get data
Aaush
I don't know Ajax ..thats the problem
..
I don't know Ajax ..thats the problem
So start with basic learning then implement the same in ur project. U will never get the exact thing u need in ur project. U hv learn the basics and then try to become pro
..
Don't worry with bit practice u will be able to implement the thing u need ur project
Aaush
You're saying right...but I am reaching the deadline that's why ...
Prashant
I have to implement login 3 roles superadmin, admin and employee
Anyone can suggest me what is the best way to doing that
Prashant
And admin is company specific
Prashant
With JWT authentication in rest api
not_found
https://stackoverflow.com/questions/71169789/django-websocket-and-webrtc
Arsalan
I wanted to add a lock mechanism in my project, can someone guide me with it?
Anonymous
How can I target charfield choises in django in models.py
Aaush
Use this,
Name = models.CharField(max_length=20)
Aaush