Re: reg: Django model sequense of the fields

2019-05-18 Thread 'Akash Sinha' via Django users
Position doesn't matters. 
 
  On Fri, May 17, 2019 at 7:12 PM, Test Bot wrote:   
[Just Curious] would it matter in any way what the position of field is in the 
respective tables.

On Fri, May 17, 2019, 5:46 PM 'Akash Sinha' via Django users 
 wrote:

Hello 

This happens for 2 reasons
1st. Those fields might be Foreign key, Foreign key fields are shown at the end 
in DB.

2nd.  You have added those fields later in our model class, if you will add new 
fields in model.py file those fields will be listed at the end.


 
 
  On Wed, May 8, 2019 at 9:22 PM, 'Amitesh Sahay' via Django 
users wrote:   Hello Users, 
I am seeing a very strange issue with my Django models. in my models.py, I have 
21 fields. Out of them , the 6th field is DASHBoard. However, when I see those 
fields in my postgres DB through PgAdminIII, it is listed at the very end of 
the list. 
Sorry, for security reasons I couldn't give the list of the fields here.
Could there be any explanation for this situation?


Regards,
Amitesh Sahay

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1048828608.1995499.1557330720573%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.
  


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/284735666.2028007.1558069879362%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.



-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD%3DM5eRMBwtQfgEacV3SqDCh4zZMDPtJ_yarb1_eazMYpcuDAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/927234931.2311630.1558166418301%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Django permissions framework vs DRF permissions

2019-05-18 Thread Rounak Jain
Newbie here. I want to create hierarchical permissions in Django, very 
similar to one described 
here: https://stackoverflow.com/questions/49300215/django-hierarchy-permissions

I have read about Django permissions framework and 
https://github.com/vintasoftware/django-role-permissions

I don't understand where DRF permissions fit it? Should DRF permissions be 
used in addition to or instead of Django permissions?

Thanks

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1e37c07-e223-4244-bb4a-09e3cd0f7737%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to

2019-05-18 Thread Balaji Shetty
Hello Nelson Varela  . Thank you very Much for your reply.
One more query - Should i check the permission ( by writing the extra code
) for extra Security.
Definitely Your solution works well for me. I have implemented the same
logic. But i want to know through the code



On Fri, May 17, 2019 at 7:32 PM Nelson Varela 
wrote:

> Take a look at django permissions/groups models where you can make groups
> and put these models in each group. After that you add the users to the
> group so they can only edit models in that group
>
> On Monday, May 13, 2019 at 9:30:08 AM UTC+2, Balaji Shetty wrote:
>>
>> Hi
>> Consider the demo Example
>>
>> models.py
>>
>>
>>
>> *from django.db import models
>>
>> class Musician(models.Model):
>> first_name = models.CharField(max_length=50)
>> last_name = models.CharField(max_length=50)
>> instrument = models.CharField(max_length=100)
>>
>> class Album(models.Model):
>> artist = models.ForeignKey(Musician, on_delete=models.CASCADE)
>> name = models.CharField(max_length=100)
>> release_date = models.DateField()
>> num_stars = models.IntegerField()*
>>
>> *class Fan(models.Model):
>> artist = models.ForeignKey(Musician, on_delete=models.CASCADE)
>> Conutry = models.CharField(max_length=100)
>> **Name = models.CharField(max_length=100)
>> *
>>
>> Here We have to keep Track of Musician Album as well as all Fan/Follower
>> of respective Musician.
>>
>>
>> Admin.py
>>
>>
>>
>> *class AlbumInline(admin.TabularInline):
>> model = Album*
>>
>> *class FanInline(admin.TabularInline):
>> model = Fan*
>>
>>
>> class MusicianAdmin(admin.ModelAdmin):
>>
>> inlines = [*AlbumInline,FanInline *, ]
>>
>> # code to register these 3 models
>> -
>>
>> I have seperate Login User Account for Album
>> I have seperate Login User Accpunt for Fan
>>
>>
>> *My Question is*
>>
>>
>> *I want to add only Album record in Album Login Account*
>>
>>
>>
>> *I want to add only Fan Record in Fan Login Account*
>>
>>
>> *Currently *
>> *In both login, Album and Fan Records can be added.  How cam i restrict 
>> these?*
>>
>> --
>>
>>
>> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
>> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
>> *Official: bssh...@sggs.ac.in *
>> *  Mobile: +91-9270696267*
>>
>> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e4a2ad0a-901c-4862-b313-9492783628cb%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAECSbOs3Zq%2Ba0qtK9H5kAspmCDAtjW5V85Bj-aVkixczZ_Ns7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Implementing multiple session support in a chatbot

2019-05-18 Thread Parth Sharma


I am currently implementing a Chatbot purely in python.

In my current implementation, each time the user starts a new chat from a 
session, another Chatbot instance is launched and hence the Chatbot starts 
from the initial state.

I wish to change that behaviour and make it similar to let’s say chat on 
Facebook/Messenger, in which you can seamlessly move between sessions while 
having a chat without inconsistencies. Namely, I want these attributes:

   1. If the user enters anything from let’s say session A it should be 
   immediately visible in all ongoing sessions. Similarly, the Chatbot reply 
   should be visible in all the devices immediately.
   2. Have all sessions show the same chat history

To implement the first point, I used this example 
 from the 
django-channels docs and modified it by creating a single group/chatroom 
for each user. All the sessions from the same user get connected to the 
same group/chatroom and hence receive all the messages in the 
group/chatroom regardless of where they were sent from.

However, this implementation currently has a bug. Each time that a user is 
connected, it initializes a Chatbot instance which starts from the initial 
state again while the older connections have Chatbot instances that are 
currently at a different state.

This leads to inconsistent replies which are different based on which 
window the user typed something in.

Basically instead of having two sessions talk to the same Chatbot instance, 
we have two sessions talking to two different Chatbot instances and 
messages from all these four sources are getting added to the same chatroom.

Moreover, we are wasting resources by keeping multiple Chatbot instances 
per user which increases with the number of currently active sessions.

I want all of the user windows to interact with the same Chatbot instance. 
What would be the best way to implement that?

Currently I can think of three solutions:

   1. Creating another Django project the Chatbot and make requests to that 
   HTTP server. The Chatbot state is maintained in that server and any request 
   from the user will go to the same Chatbot instance.
  - This is straightforward to implement for me (simply spin up another 
  server)
  - This naturally solves all the problems regarding state as all the 
  instances will query the same Chatbot object
   2. Creating a *Master* channel thread which will hold the actual Chatbot 
   instance(a python object) and any new channels will will defer to it for 
   the reply from the Chatbot.
  - This will be complicated to implement
  - I will have to maintain which thread is master and which ones are 
  slaves
  - In situations where a user closes the master thread connection I 
  will somehow have to change one of the slave connections to a master 
  connection and pass the entire object(?!) or atleast pass the state 
  variable and re-create the chatbot instance.
   3. Spawn an independent thread/process in python for the chatbot 
   instance and have all the channel connections talk to that thread/process .
  - This will be hard for me to implement as I don’t currently know how 
  to do IPC in python
   
Are there any other solutions possible? What would be the ideal solution?

I am using the following technologies:

   1. Django  as the main backend, with Django 
   Channels  for WebSockets
   2. RASA NLU  for the NLU component of the 
   chatbot and a finite state machine model implemented using pytransitions 
    for the dialog management 
   in python

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/463657a5-588d-475d-940d-4d7ec0c708d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Learning Djanog Use book

2019-05-18 Thread Rana Solving31
Have anyone better book on Django latest version 2.2 ? which is free 
version ,means without paid ,if i can download this.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8a779a1f-074e-4fde-9fc0-f6ac81770ea8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django permissions framework vs DRF permissions

2019-05-18 Thread Aldian Fazrihady
Hi, based on my experience,  I can create DRF permission based on HTTP
methods.

Django permissions by default are tightly related to ORM models.
DRF permission can be totally unrelated to ORM models.

Regards,

Aldian Fazrihady


On Sat, 18 May 2019, 16:13 Rounak Jain,  wrote:

> Newbie here. I want to create hierarchical permissions in Django, very
> similar to one described here:
> https://stackoverflow.com/questions/49300215/django-hierarchy-permissions
>
> I have read about Django permissions framework and
> https://github.com/vintasoftware/django-role-permissions
>
> I don't understand where DRF permissions fit it? Should DRF permissions be
> used in addition to or instead of Django permissions?
>
> Thanks
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b1e37c07-e223-4244-bb4a-09e3cd0f7737%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAYt-SA2KEU_yo1ghG7caZF0iWhQMxEvOvVvDjd%2BC%3D5tGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Implementing multiple session support in a chatbot

2019-05-18 Thread Chetan Ganji
What you need is to implement 2 design patterns in your django app. Which
ones?

1. *Singleton* Design Pattern for the Chatbot. All the users and all of
their sessions are using the same chatbot instance.

Why?

Because when a new session is created for a user, he will be referring to
the same chatbot instance and all of previous history would be accessible.
You need to add a timestamp to each message. So that when a new session is
created,
all of previous messages can be to sent to this session by filtering on the
timestamp of the messages.

This instance can be used to store all of the sessions of all of the users.
Something like below.
That way when the observer getters and setters are called, they get a list
of active session of the current user.
So the actual message is sent by iterating over the active sessions. Hence
all the sessions get the same message.


class Chatbot(object):

_sessions = {
"username1": {
"mobile": [],
"desktop": []
},

"username2": {
"mobile": [],
"desktop": []
}

}

@classmethod
def get_sessions(self, username):
return self._sessions[username]


Other way to achieve singleton effect is create a instance of the chatbot
and import it wherever it is required.
This will given the same effect as singleton but without implementing it.


nikola = Chatbot()


Now just import nikola everywhere it is required.


2. *Observer* Design Pattern for the syncing of the messages across
multiple sessions.

Why?

Because, you need the chatbot to sync between multiple sessions. Same
message needs to goto multiple recipients.
When a new session is created, you will have to send the previous messages
to this new session.
This is the sole purpose of this design pattern. It's use is already
explained above.

As you are using django channels for websockets, you will have to combine
that code with this pattern.
I don't have any experience with websockets, you will have to figure it out
:P

I hope it helps :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, May 18, 2019 at 7:17 PM Parth Sharma 
wrote:

> I am currently implementing a Chatbot purely in python.
>
> In my current implementation, each time the user starts a new chat from a
> session, another Chatbot instance is launched and hence the Chatbot starts
> from the initial state.
>
> I wish to change that behaviour and make it similar to let’s say chat on
> Facebook/Messenger, in which you can seamlessly move between sessions while
> having a chat without inconsistencies. Namely, I want these attributes:
>
>1. If the user enters anything from let’s say session A it should be
>immediately visible in all ongoing sessions. Similarly, the Chatbot reply
>should be visible in all the devices immediately.
>2. Have all sessions show the same chat history
>
> To implement the first point, I used this example
>  from the
> django-channels docs and modified it by creating a single group/chatroom
> for each user. All the sessions from the same user get connected to the
> same group/chatroom and hence receive all the messages in the
> group/chatroom regardless of where they were sent from.
>
> However, this implementation currently has a bug. Each time that a user is
> connected, it initializes a Chatbot instance which starts from the initial
> state again while the older connections have Chatbot instances that are
> currently at a different state.
>
> This leads to inconsistent replies which are different based on which
> window the user typed something in.
>
> Basically instead of having two sessions talk to the same Chatbot
> instance, we have two sessions talking to two different Chatbot instances
> and messages from all these four sources are getting added to the same
> chatroom.
>
> Moreover, we are wasting resources by keeping multiple Chatbot instances
> per user which increases with the number of currently active sessions.
>
> I want all of the user windows to interact with the same Chatbot instance.
> What would be the best way to implement that?
>
> Currently I can think of three solutions:
>
>1. Creating another Django project the Chatbot and make requests to
>that HTTP server. The Chatbot state is maintained in that server and any
>request from the user will go to the same Chatbot instance.
>   - This is straightforward to implement for me (simply spin up
>   another server)
>   - This naturally solves all the problems regarding state as all the
>   instances will query the same Chatbot object
>2. Creating a *Master* channel thread which will hold the actual
>Chatbot instance(a python object) and any new channels will will defer to
>it for the reply from the Chatbot.
>   - This will be complicated to implement
>   - I will have to maintain which thread is master and which ones are
>   slaves
>   - In situations where a user closes the master thread connection I
>