I Want To Save The Data In My Database Depending On The Catgory Of Data Chosen by User Like I Have 4 Lisitings Like APparetements, Food And Life, Car And Travelling if User Selects Appartements Then A

2023-08-20 Thread Hamza Bilal
{% extends 'home.html' %}
{% load static %}
{% block content %}



  

  
Add Plots In Your Listing
If You Want To Buy The Plot Then Add It In Your Listing
  

  





  

  

  
  

  
{% csrf_token %}

Listing Type
{{ form.listing_type }}
Area
{{ form.area }}
Location
{{ form.location }}

Price
{{ form.price }}
Title
{{ form.title }}
Upload An Image
{{ form.image }}



  
Add Your Listing!
  

  

  

  

  









{% endblock content %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c48d35c9-9dcb-4aaf-a478-822deb83a324n%40googlegroups.com.


I Want To Create An Api of notification In Django Rest API

2023-12-01 Thread Hamza Bilal
I Want To Create An Api of notification In Django Rest API
![Screenshot from 2023-11-30 
03-30-39|690x388](upload://6RwAUFNKt3TWKgrocOu2t4k2TeJ.png)
I Created AN Notification App By Using The Django Channels, Websockt and 
Successfully Sending Notification To The `Webscoketking.com`, Now I Want To 
Create The API of This App For Sending The Notifications Of the Website
models.py
```
from django.db import models
from django.contrib.auth.models import AbstractUser
from channels.layers import get_channel_layer
from asgiref.sync import async_to_sync
import json
# Create your models here.

class CustomUser(AbstractUser):

"""Model class for users"""

USER_CHOICES = [
('expert', 'Expert'),
('business', 'Business'),
('admin', 'Admin'),
]

username = models.CharField(max_length=40, null=True, blank=True)
full_name = models.CharField(max_length=40)
email = models.EmailField(unique=True)
password = models.CharField(max_length=40, null=False, blank=False)
confirm_password = models.CharField(max_length=40, null=False, 
blank=False)
user_choices = models.CharField(max_length=30, choices=USER_CHOICES, 
default='expert')

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']

def __str__(self) -> str:
return f"{self.email}"


class Notification(models.Model):
account_user = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
message = models.TextField()
is_read = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)

def save(self, *args, **kwargs):
print('saving notification')
channel_layer = get_channel_layer()
notification_objs = 
Notification.objects.filter(is_read=False).count()
data = {'count': notification_objs, 'current_notification': 
self.message}
async_to_sync(channel_layer.group_send)(
"test_group", {
"type": "send_notification",
"value": json.dumps(data)
}
)
super(Notification, self).save(*args, **kwargs)


class AccountApproval(models.Model):
account_user = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
approved = models.BooleanField(default=False)
approval_message = models.TextField(blank=True, null=True)

```
COnsumers.py
```
from channels.generic.websocket import WebsocketConsumer
from asgiref.sync import async_to_sync
import json

class TestConsumer(WebsocketConsumer):
def connect(self):
self.room_name = "test"
self.room_group_name = "test_group"
async_to_sync(self.channel_layer.group_add)(
self.room_group_name,
self.channel_name,
)
self.accept()
print("connected")
self.send(text_data=json.dumps({'status': 'connected Through Django 
Channels'}))

def receive(self, text_data):
print(text_data)
self.send(text_data=json.dumps({'status': 'We Got You'}))

def disconneted(self, *args, **kwargs):
print("disconnected")

def send_notification(self, event):
print('Send Notification: ')
data = json.loads(event.get('value'))
self.send(text_data=json.dumps({'status': data}))

print('Send Notification: ')



```
asgi.py
```
"""
ASGI config for hamza project.

It exposes the ASGI callable as a module-level variable named 
``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""
from channels.routing import ProtocolTypeRouter, URLRouter
from django.urls import path
from bilal.consumers import TestConsumer
import os
from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hamza.settings')

asgiapplication = get_asgi_application()

ws_pattern = [
path('ws/test/', TestConsumer.as_asgi())
]

application = ProtocolTypeRouter({
'http': get_asgi_application(),
'websocket': URLRouter(ws_pattern)
})
```

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e2c0bdf-b67f-4167-9236-ac310f1a4a52n%40googlegroups.com.


Re: Exciting Opportunity: Join Our Django WhatsApp Bulk Messaging Project!

2024-02-18 Thread Hamza Bilal
Yes i Want to join this project

On Sun, 18 Feb 2024 at 21:47, SURAJ TIWARI  wrote:

> 🚀 Join Our Django WhatsApp Bulk Messaging Project!
>
> 👋 Hello everyone,
>
> Are you looking for an exciting opportunity to gain hands-on experience in
> Django development? Do you want to work on a meaningful project that
> leverages WhatsApp for bulk messaging? We're thrilled to invite you to join
> our dynamic team!
>
> 🌟 Benefits:
>
>- Get hands-on experience working on a real-world Django project.
>- Learn how to leverage WhatsApp for bulk messaging, a valuable skill
>in today's digital landscape.
>- Opportunities for hybrid work, allowing flexibility in your schedule.
>- Collaborate with experienced developers and gain valuable mentorship.
>- Access to cutting-edge tools and technologies.
>
> 💼 Opportunities Available:
>
>- Django developers
>- Frontend developers
>- UI/UX designers
>- Quality assurance testers
>
> 🤝 How to Join: Simply reply to this message expressing your interest,
> and we'll provide you with all the necessary details to get started on our
> project.
>
> Let's work together to create something amazing and gain valuable
> experience along the way! 💻✨
>
> Best regards,
>
> Suraj Tiwari
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e8a705fd-10d9-4c1a-b4ba-0a7b896dbfean%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BRyv5%2B8TbpSYL7-TVT-yKxB3rBftBXr1HDCeEhn5%3DCEUo6KA%40mail.gmail.com.