Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-23 Thread Gourav Chawla
No sir please! Gourav is just fine.

Also, you would need to go edit/add code in the admin.py file for this to
work.

Try this part of the docs:

https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter

Hope, it helps.

On Mon, 22 Apr, 2019, 1:15 PM Balaji Shetty,  wrote:

> Dear Gaurav Sir
>
> I am very much thankful to you for your reply to my query.
>
> My questions is *How can i make  the customization in Django Admin Panel
> itself to implement necessary logic after user of particular department do
> the login.( How and where to embed proposed Logic
> T1.objects.filter(user=current_user, department=current_user.department)*
>
> If i design separate pages for login using templates and showing necessary
> content user-wise (Login wise),
> Your suggested logic will definitely work  (after making necessary changes
> in schema)
>
>
>
> On Sun, Apr 21, 2019 at 11:00 AM Gourav Chawla <
> gauravchawla.chawla...@gmail.com> wrote:
>
>> First of all, use appropriate model fields for linking objects. For
>> example users should be a foreign key to your(or Django's) user table.
>>
>> Then whenever you want to show data on any interface to any user, just
>> filter content/rows by user department.
>>
>> Something like:
>>
>> T1.objects.filter(user=current_user, department=current_user.department)
>>
>> --
>> 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/a4484706-2f3a-488c-a28c-41f78e2f42ca%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/CAHkVAtuWq0CF2J4X%3DnckroOZZpEk%2B%2BzgT1r76%2Bd-7SeWTYU4QQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django How to write Customized Query ( Display Information Departmentwise)

2019-04-20 Thread Gourav Chawla
First of all, use appropriate model fields for linking objects. For example 
users should be a foreign key to your(or Django's) user table.

Then whenever you want to show data on any interface to any user, just filter 
content/rows by user department.

Something like:

T1.objects.filter(user=current_user, department=current_user.department)

-- 
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/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I pass the CSRF token when using a jQuery post

2017-11-08 Thread Gourav Chawla
See, if this 
helps: https://stackoverflow.com/questions/8614947/jquery-and-django-csrf-token

On Tuesday, November 7, 2017 at 10:25:47 PM UTC+5:30, Tony King wrote:
>
>
> Hi,
>
> I thought I'd finally understood this but it seems I have not and I've 
> spent far too much time trying to do it myself.
>
> I have a view rendering to the template below, which is displaying a 
> number of buttons that when clicked will execute another Python function in 
> the views.py.  This works fine if I disable the CSRF protection but as I've 
> read this is not good practice, I'm desperately trying to get the token 
> included in POST request.  I thought I'd finally cracked it yesterday 
> having found the sample code in the documentation and indeed it appeared to 
> work until first I tried my project in a different browser and then 
> subsequently cleared the cache of Chrome.
>
> What am I doing wrong here?
>
> I've not included the views.py as I'm assuming the issue is in the 
> JavaScript.
>
>
> index.html
> {% load static %}
>
> 
> 
> 
> https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";> >
> 
>
> 
> function getCookie(name) {
> var cookieValue = null;
> if (document.cookie && document.cookie !== '') {
> var cookies = document.cookie.split(';');
> for (var i = 0; i < cookies.length; i++) {
> var cookie = jQuery.trim(cookies[i]);
> // Does this cookie string begin with the name we want?
> if (cookie.substring(0, name.length + 1) === (name + '=')) {
> cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
> break;
> }
> }
> }
> return cookieValue;
> }
> var csrftoken = getCookie('csrftoken');
> $.ajaxSetup({
> beforeSend: function(xhr, settings) {
> xhr.setRequestHeader("X-CSRFToken", csrftoken);
> }
> });
> 
>
> 
> 
> {{ hdr1 }}
> 
>
> 
> 
> {% if my_apps_list %}
> {% for my_apps in my_apps_list %}
> 
> 
>  height="132" width="192">
> 
> 
> $("#app{{ forloop.counter }}").click( function() {
> $.post("{% url 'launch' %}",
> {'appname': '{{ my_apps.app_name }}',
> 'apppath': '{{ my_apps.app_path }}',
> 'appexe': '{{ my_apps.app_exe }}',
> 'appargs': '{{ my_apps.app_args }}',
> 'appusr': '{{ my_apps.app_user }}',
> 'apppwd': '{{ my_apps.app_pwd }}',
> 'applook4': '{{ my_apps.app_wait4 }}',
> 'appdelay': '{{ my_apps.app_delay }}',
> 'appkeys': '{{ my_apps.app_keys }}'
> }, function (msg) {
> document.getElementById('appstatus').innerHTML = msg;
> });
> });
> 
> 
> {% endfor %}
> 
> 
>
> 
> 
>
> {% else %}
> No applications are available.
> {% endif %}
>
> 
>

-- 
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/78149606-ec95-458a-9af8-45f2fa138f00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Creating login page with Django using HTML and CSS

2017-10-09 Thread Gourav Chawla
It isn't clear what are you looking for but if you need instructions on 
creating registration, login, logout views then this[1] is a good place to 
start. Also, look into another chapter where the author talks about using 
django-registration package to remove the hassle of building your own 
registration system.

[1]: http://www.tangowithdjango.com/book17/chapters/login.html

-- 
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/fd5d9546-05ce-49a8-a819-51646c6b48d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Access data associated to a primary key

2017-10-03 Thread Gourav Chawla
Glad, you worked it out. You can use them whenever you want. Function based 
views require you to write more code but give you more clarity on what's 
happening. On the other hand CBV help you keep the codebase cleaner.

At the end of the day, it's you who has to decide what to use.

-- 
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/efdec957-131b-4cfd-a0fc-0a37e52d3ea5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Access data associated to a primary key

2017-10-02 Thread Gourav Chawla
You can create another url, view, template to do that.

Just create a url like : team/id

For the above url create a view, say, teams_under_region which accepts the 
'id'. Based on that id you can then query your database for teams where 
region_member=id. This is just the approach you would follow for functional 
view. But for CBV you have DetailView that takes care of this. Hope this 
helps.

On Monday, October 2, 2017 at 2:53:04 PM UTC+5:30, tangoward15 wrote:
>
> Hi guys, I just want to know how to access and load the data associated to 
> a primary key in a template.
>
> models.py
>
> class Team_Region(models.Model):
> name = models.CharField(max_length=50)
>
> # String representation
> def __str__(self):
> return self.name
>
>
>
> class Team_Name(models.Model):
> t_name = models.CharField(max_length=100)
> logo = models.ImageField(upload_to='team_logos', blank=True)
> region_member = models.ForeignKey(Team_Region, related_name='regions')
>
>
> def __str__(self):
> return self.t_name + ' - ' + str(self.region_member) 
>
>
>
>
> views.py
>
> class TeamRegionListView(ListView):
> context_object_name = 'regions_listview'
> model = Team_Region
> template_name = 'dota_teams/team_regions_list.html'
>
>
> team_regions_list.html
>
> {% block body_block %}
> 
> 
> {% for region in regions_listview %}
> 
> {{ region.name 
> }}
> 
> {% endfor %}
> 
>
> {% endblock %}
>
>
> What I want to achieve is to load the teams' logos and names when the 
> region name link is clicked in the team_regions.html. The teams that will 
> only be displayed in the template are the teams part of the specific ID 
> from Team_Region. Say, region is NA, I want all teams under NA to be 
> displayed in the template.
>
> Not sure how to do this using ListView.
>
> Any suggestions?
>
>
> TIA
>

-- 
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/1b7d75bb-e5ed-4cc5-8b30-7d6487dcb966%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Login with different groups

2017-10-02 Thread Gourav Chawla
You can have a look at Django registrations app[1] for inspiration. Also, 
look at the default Django admin login. All of it is there, you just have 
to search a little more and you'll get it.

[1]: https://github.com/macropin/django-registration

On Monday, October 2, 2017 at 4:55:14 PM UTC+5:30, saheb dua wrote:
>
> Hi all,
> I am new to django , i want to make code for login and registration with 
> different groups. example school management student ,teacher and parents 
> should register first and then login in there groups. i want to know basic 
> structure for that. 
>  
>

-- 
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/1b8d5d29-7742-43f2-b135-f3556e5ee67c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: online training application

2017-09-30 Thread Gourav Chawla

On Thursday, September 28, 2017 at 11:02:58 AM UTC+5:30, Mike Dewhirst 
wrote:
>
> I need to write an online training application - except I don't know a 
> lot about online training. 
>

Please, have a look at OpenEdx[1]. It is also a LMS like Moodle written 
using Django. 

[1]: https://open.edx.org/

-- 
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/26bd58fe-0034-45fc-bccb-e85b8f3379f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.