119 views
Skip to first unread message

Perceval Maturure

unread,
Oct 22, 2019, 4:03:49 PM10/22/19
to django-users
dear Django users 
Is there a way to display data  from a single model on 3 different bootstrap cards ordered by created date.
So at the end I can 3 cars each with 2 different items/ records from the model

--
Sent from Gmail Mobile

Perceval Maturure

unread,
Oct 27, 2019, 10:55:34 AM10/27/19
to django-users

dear django users

how do youu make the the first level menu clickable in the customisation of this code.



  <li> {%  show_menu 0 100 100 100 "menu/custom-menu.html"  %}  </li>

--
Perceval Maturure
083 303 9423

Mohammad yunus

unread,
Oct 29, 2019, 9:30:06 AM10/29/19
to django...@googlegroups.com
Can anyone tell me how to connect mysql database...... with step by step?

Kasper Laudrup

unread,
Oct 29, 2019, 10:39:10 AM10/29/19
to django...@googlegroups.com
Hi Mohammad,

On 29/10/2019 14.29, Mohammad yunus wrote:
> Can anyone tell me how to connect mysql database...... with step by step?
>

Have you done any research at all?

There are tons of guides out there, including the official Django
documentation.

This one for example:

https://www.digitalocean.com/community/tutorials/how-to-create-a-django-app-and-connect-it-to-a-database

If you have any specific issues or problems you need to be more specific.

Kind regards,

Kasper Laudrup

dupakoor kannan

unread,
Oct 29, 2019, 10:43:46 AM10/29/19
to django...@googlegroups.com

On Tue, Oct 29, 2019 at 9:30 AM Mohammad yunus <yunu...@gmail.com> wrote:
Can anyone tell me how to connect mysql database...... with step by step?

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEQiGcNGkopjWW6ejWqQAb3721XsCUa%3DS%2B7uOM5oiyReKejNUw%40mail.gmail.com.

Bill Hughes

unread,
Oct 29, 2019, 4:32:57 PM10/29/19
to django...@googlegroups.com
Yes, RTFB!

From: django...@googlegroups.com <django...@googlegroups.com> on behalf of Mohammad yunus <yunu...@gmail.com>
Sent: Tuesday, October 29, 2019 1:29 PM
To: django...@googlegroups.com <django...@googlegroups.com>
Subject:
 
Can anyone tell me how to connect mysql database...... with step by step?

--

Mohammad yunus

unread,
Nov 1, 2019, 9:43:12 AM11/1/19
to django...@googlegroups.com
Can anyone tell me about how to set mysql database connection,and also tell me requirements for this steps,.....
Can someone tell me which database is good for Django framework .I know about default database sqlite (is it good for it)

Kasper Laudrup

unread,
Nov 1, 2019, 10:04:25 AM11/1/19
to django...@googlegroups.com
Hi Mohammad,

On 01/11/2019 14.42, Mohammad yunus wrote:
> Can anyone tell me about how to set mysql database connection,and also
> tell me requirements for this steps,.....

You've asked this question before and got a few answers. Have you looked
into those?

> Can someone tell me which database is good for Django framework .I know
> about default database sqlite (is it good for it)
>

Here's a comparison of the three:

https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql-vs-postgresql-a-comparison-of-relational-database-management-systems

Sqlite is definitely not a good choice for something like Django in a
production environment IMO. It's not really what it's designed for.

I would personally prefer postgresql, but that's probably mainly because
of mysqls history with regards to security etc. That might not be the
case today, but someone else can probably elaborate.

Anyway, have a look at the link and come back with any questions you
might have.

Kind regards,

Kasper Laudrup

Uzama Zaid Mohammed Jaward

unread,
Nov 1, 2019, 12:19:59 PM11/1/19
to django...@googlegroups.com

Don’t look good database for Django. That is not sense anymore. You have to choose a right database according to your application or business requirements. 

On Fri, Nov 1, 2019 at 19:12, Mohammad yunus <yunu...@gmail.com> wrote:
Can anyone tell me about how to set mysql database connection,and also tell me requirements for this steps,.....
Can someone tell me which database is good for Django framework .I know about default database sqlite (is it good for it)

--
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...@googlegroups.com.

Paras Jain

unread,
Nov 1, 2019, 2:48:17 PM11/1/19
to django...@googlegroups.com
Hi, i am given this task can somebody tell what i have to do in this

The Task:

Create a basic rest API that can perform CRUD operations on Users and their Blog with the following features/constraints.

❏ Use persistent model on database of your choice 

❏ Only the creator of the blog should be able to modify it. 

❏ Read access should be available to everyone. 

❏ Anymore ACLs you might think should be present in it. 

❏ Do not hesitate on improvising.


We are not looking for perfection but your willingness and approach to tackle a problem.


On Fri, Nov 1, 2019 at 7:12 PM Mohammad yunus <yunu...@gmail.com> wrote:
Can anyone tell me about how to set mysql database connection,and also tell me requirements for this steps,.....
Can someone tell me which database is good for Django framework .I know about default database sqlite (is it good for it)

--

Paras Jain

unread,
Nov 5, 2019, 12:41:35 AM11/5/19
to django...@googlegroups.com

please somebody tell me what steps should i follow please need help


Create a Django Web App called “Profile Storer” where a company can sign up using Email.


Once signed up, he can add more people to his team. Every team member can be either “Normal” type or “Manager” type. When you add a team member, that particular person gets an email with password, which he/she can use to login.


When a Manager type user logs in, he sees a list of all users of that company, he can go and edit any of the profile.


When a Normal user logs in, he sees only his own profile that he can edit.



Questions in Profile:

Name, Phone, Gender, Hobbies, Profile Picture.

Paras Jain

unread,
Nov 5, 2019, 7:08:37 AM11/5/19
to django...@googlegroups.com
on hitting submit i have to send email and password to user email id which will be used for login in django

Suraj Thapa FC

unread,
Nov 5, 2019, 8:00:48 AM11/5/19
to django...@googlegroups.com
Send it then

On Tue, 5 Nov 2019, 5:38 pm Paras Jain, <parasj...@gmail.com> wrote:
on hitting submit i have to send email and password to user email id which will be used for login in django

--
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...@googlegroups.com.

Pranjul Kimothi

unread,
Nov 5, 2019, 8:02:31 AM11/5/19
to django...@googlegroups.com
How Can I use Django as backend for an Arduino application .?? Any suggestions 

Bruckner de Villiers

unread,
Nov 5, 2019, 10:00:21 AM11/5/19
to django...@googlegroups.com

Udemy has a good course leading up to this topic – Python and Django Full Stack Web Development, still based on Django 1.x, but Django 2.x code is incuded.

Regards,

 

Bruckner de Villiers

083 625 1086

--

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...@googlegroups.com.

Paras Jain

unread,
Nov 5, 2019, 1:06:02 PM11/5/19
to django...@googlegroups.com
bro i was asking the code how to use it to send , email and password  to particular email

Integr@te System

unread,
Nov 5, 2019, 1:44:38 PM11/5/19
to django...@googlegroups.com
plz go to check send mail module.

Kasper Laudrup

unread,
Nov 5, 2019, 1:57:59 PM11/5/19
to django...@googlegroups.com
Hi Paras,

On 05/11/2019 19.04, Paras Jain wrote:
> bro i was asking the code how to use it to send , email and password  to
> particular email
>

No you didn't. You wrote:

> on hitting submit i have to send email and password to user
> email id which will be used for login in django

How is anyone supposed to know what you mean by that? It isn't even a
proper question.

If you seriously want someone to help you, take a bit of time to explain
what you want to achieve, what you have tried etc.

Your follow up explanation to your "bro" isn't making it much better.

This isn't only related to this mailing list btw. but a good idea in
general.

Kind regards,

Kasper Laudrup

Paras Jain

unread,
Nov 7, 2019, 9:57:45 AM11/7/19
to django...@googlegroups.com
this is my models.py file i created and migrated but model in not created in my admin page as database please somebody help

from django.db import models

# Create your models here.
class Company(models.Model):
    email = models.EmailField()


    def __init__():
        return self.email

himanshu chouhan

unread,
Nov 7, 2019, 10:00:35 AM11/7/19
to django...@googlegroups.com
you need to register ur model as well.

--
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...@googlegroups.com.

himanshu chouhan

unread,
Nov 7, 2019, 10:01:57 AM11/7/19
to django...@googlegroups.com

Paras Jain

unread,
Nov 7, 2019, 11:45:08 AM11/7/19
to django...@googlegroups.com
i registered also not getting it

Paras Jain

unread,
Nov 8, 2019, 5:57:31 AM11/8/19
to django...@googlegroups.com
Hy, i am not getting my all fields on the my page which is written inside the forms.py of 'PersonForm'


models.py:
from django.db import models

# Create your models here.
TITLE_CHOICES = (
    ('Normal', 'Manager'),
)


class Company(models.Model):
    email = models.EmailField()

    def __str__(self):                                #will return search add by the user
        return '{}'.format(self.email)


    class Meta:
        verbose_name_plural = 'Company'



class Person(models.Model):
    name = models.CharField(max_length=255)
    email = models.EmailField()
    type = models.CharField(max_length=6, choices=TITLE_CHOICES)

    class Meta:
        verbose_name_plural = 'Person'


forms.py:
from django import forms
from .models import Company,Person

class CompanyForm(forms.ModelForm):
    class Meta:
        model = Company
        fields = ('email',)

class PersonForm(forms.ModelForm):
    class Meta:
        model = Person
        fields = ('type', 'name','email',)

views.py:
from django.shortcuts import render
from .forms import CompanyForm, PersonForm
from django.views.generic  import CreateView

# Create your views here.
def home(request):

    form = CompanyForm()

    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)

        else:
            print('Error form invalid')

    return render(request, 'home.html', {'form':form})

def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})

Nijo Joseph

unread,
Nov 8, 2019, 9:39:30 AM11/8/19
to django...@googlegroups.com
def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})
What is this form for? Adding into Company table. Then make this one to      form= CompanyForm() not PersonForm().

--
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...@googlegroups.com.

Nijo Joseph

unread,
Nov 8, 2019, 9:42:35 AM11/8/19
to django...@googlegroups.com
Or the either way round      instead of form = CompanyForm(request.POST), make it PersonForm(request.POST).

On Fri, 8 Nov 2019, 4:26 pm Paras Jain, <parasj...@gmail.com> wrote:
--

Nijo Joseph

unread,
Nov 8, 2019, 9:44:32 AM11/8/19
to django...@googlegroups.com
In the add function. Sorry for the breaking emails sending from phone.

Paras Jain

unread,
Nov 8, 2019, 10:23:56 AM11/8/19
to django...@googlegroups.com
no worries but thanks for the solution bro really appreciate it

Paras Jain

unread,
Nov 11, 2019, 6:19:21 AM11/11/19
to django...@googlegroups.com
how send email in django for password reset

Kasper Laudrup

unread,
Nov 11, 2019, 6:46:58 AM11/11/19
to django...@googlegroups.com
Hi

On 11/11/2019 12.18, Paras Jain wrote:
> how send email in django for password reset
>

https://lmgtfy.com/?q=django+email+password+reset&s=g

prakash madariya

unread,
Nov 12, 2019, 7:30:34 AM11/12/19
to django...@googlegroups.com
Hello there,

If u go with django auth(django library) u will have all the options to configure the reset password, create password, login and log out process coding.. U just need implement it to ur program by importing the django-auth library..

Refer the below link. 

On Mon, 11 Nov, 2019, 4:48 PM Paras Jain, <parasj...@gmail.com> wrote:
how send email in django for password reset

--
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...@googlegroups.com.

Paras Jain

unread,
Nov 13, 2019, 5:19:44 AM11/13/19
to django...@googlegroups.com
i have just created a model which will have login information in database but it is not showing its appearance i have also done migration

models.py:

from django.db import models

# Create your models here.
class User(models.Model):
    email = models.EmailField()
    password = models.CharField(max_length=50)

    def __str__(self):                               
        return '{}'.format(self.email)

Nitin Kalmaste

unread,
Nov 13, 2019, 6:38:31 AM11/13/19
to django...@googlegroups.com
if your migrations are successful run queries through manage.py shell
There is existing User model inside django.contrb.auth.User

--
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...@googlegroups.com.

Vivek Jha

unread,
Nov 13, 2019, 6:41:50 AM11/13/19
to django...@googlegroups.com
Go to admin.py and import the model and then 


admin.site.register(modelname)

Save and refresh it 

Paras Jain

unread,
Nov 13, 2019, 6:56:09 AM11/13/19
to django...@googlegroups.com
thanks u so  so so much bro i have done such a silly mistake .Really appreciated

Paras Jain

unread,
Nov 13, 2019, 12:18:32 PM11/13/19
to django...@googlegroups.com
now i want to generate random password and send it to mail instead of simple message
views.py:

from django.shortcuts import render
from profilestorer.settings import EMAIL_HOST_USER
from . import forms
from django.core.mail import send_mail



# Create your views here.
def login(request):
    form = forms.SignInForm()
    return render(request, 'company/login.html', {'form':form})


def register(request):
        form = forms.SignUpForm()
        if request.method == 'POST':
            form = forms.SignUpForm(request.POST)
            form.save()
            subject = 'welcome to profile storer'
            message = 'Hope you find the mail'
            recepient = str(form['Email'].value())
            send_mail(subject,
                message, EMAIL_HOST_USER, [recepient], fail_silently = False)
            return render(request, 'company/success.html', {'recepient': recepient})
        return render(request, 'company/register.html', {'form':form})

Kasper Laudrup

unread,
Nov 13, 2019, 5:43:23 PM11/13/19
to django...@googlegroups.com, Paras Jain
Hi Paras,

On 13/11/2019 18.17, Paras Jain wrote:
> now i want to generate random password and send it to mail instead of
> simple message
OK, should be simple enough. Do you have a question or are you just sharing your to-do list?

Btw. of course you don't want these passwords that you want to send in clear text to be permanent right?

Kind regards,

Kasper Laudrup

Paras Jain

unread,
Nov 14, 2019, 8:03:15 AM11/14/19
to django...@googlegroups.com
  i m using only email for sign up and sending the random password  on the mail which will be used for login 
Now I want login to be done using register email and password send to mail 
I m stuck here that I m generating random password but how I will save as password and email in my 'views.Py ' file .so that email password can be used for login
 Please need help

views.py:
from django.shortcuts import render
from profilestorer.settings import EMAIL_HOST_USER
from .forms import SignUp
from django.core.mail import send_mail
from django.utils.crypto import get_random_string
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect, HttpResponse


# Create your views here.
@login_required
def user_logout(request):
    logout(request)
    return HttpResponseRedirect(reverse('company-login'))


def register(request):
        form =SignUpForm()
        if request.method == 'POST':
            form = SignUpForm(data=request.POST)
            unique_id = get_random_string(length=8)
            subject = 'Welcome to profile storer'
            message = 'Please enter this password for login :   ' + unique_id

            recepient = str(form['Email'].value())
            send_mail(subject,
                message, EMAIL_HOST_USER, [recepient], fail_silently = False)
            return render(request, 'company/success.html', {'recepient': recepient})


        return render(request, 'company/register.html', {'form':form})

forms.py:

from django import forms
from django.contrib.auth.forms import UserCreationForm
from .models import User


class SignUp(UserCreationForm):
    email = forms.EmailField(max_length=200)

    class Meta:
        model = User
        fields =('email')

models.py:

from django.db import models
from django.contrib.auth.models import User


# Create your models here.
class User(models.Model):
    email = models.EmailField()
    password = models.CharField(max_length=50)

    def __str__(self):                                #will return search add by the user
        return '{}'.format(self.email)

    class Meta:
        verbose_name_plural = 'User'

Paras Jain

unread,
Nov 15, 2019, 5:15:55 AM11/15/19
to django...@googlegroups.com
 i am not able to send email showing odd type of error need help
views.py:
from django.shortcuts import render, redirect
from django.contrib import messages
from profilestorer.settings import EMAIL_HOST_USER
from django.conf import settings
from .forms import SignUpForm

from django.core.mail import send_mail
from django.utils.crypto import get_random_string
from django.contrib.auth import authenticate,  logout

from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect, HttpResponse
from .models import User

# Create your views here.
def home(request):
    return render(request, 'company/home.html', {'title':'profilestorer'})

@login_required
def user_logout(request):
    logout(request)
    return HttpResponseRedirect(reverse('login'))


def register(request):
    form = SignUpForm()
    if request.method == 'POST':
                form = SignUpForm(request.POST)

                #unique_id = get_random_string(length=8)
                subject = 'Welcome to DataFlair'
                message = 'Hope you are enjoying your Django Tutorials'

                recepient = str(form['Email'].value())
                send_mail(subject, message, EMAIL_HOST_USER, [recepient], fail_silently = False)
                return render(request, 'company/success.html', {'recepient': recepient})
                #return redirect('login')

    #else:
        #form =SignUpForm()

Paras Jain

unread,
Nov 20, 2019, 10:27:43 AM11/20/19
to django...@googlegroups.com
how to take pass one object of one function to other in django

Bob Gailer

unread,
Nov 20, 2019, 10:38:32 AM11/20/19
to Django users

On Nov 20, 2019 10:27 AM, "Paras Jain" <parasj...@gmail.com> wrote:
>
> how to take pass one object of one function to other in django

I do not understand your question. Perhaps someone else will understand it and give you the answer you're seeking. If you don't get an answer please try restating your question or give us an example of what you're trying to do.

Bob Gailer

Paras Jain

unread,
Nov 20, 2019, 12:53:23 PM11/20/19
to django...@googlegroups.com
  'user = User.objects.get(email=email) '  i have to pass this 'user' instance  from login function to detail function  in django

  views.py:
   
        def login(request):
            if request.method == 'POST':
                email  = request.POST['email']
                password = request.POST['password']
       
                user = User.objects.get(email=email)  
                if user.password == password:
       
                    if user.type == 'Manager':
                        return redirect('company-add')
       
       
                    if user.type == 'Normal':
                        details = user            # i want this instance user  to be passed onto detail function
       
       
                        #return redirect('company-detail',{'details':details})
       
       
                else:
                    messages.success(request, 'invalids credentials')
                    return redirect('company-login')
       
            else:
                return render(request, 'company/login.html')
       
        def detail(request):
       
                return render(request, 'company/detail.html')
   
   

    urls.py:
        from django.urls import path
        from .import views
       
        urlpatterns=[
            path('', views.home, name='company-home'),
            path('register/', views.register, name='company-register'),
            path('detail/', views.detail, name='company-detail'),
            path('login/', views.login, name='company-login'),
            path('add/', views.add, name='company-add'),



--
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...@googlegroups.com.

Paras Jain

unread,
Nov 20, 2019, 2:29:21 PM11/20/19
to django...@googlegroups.com
my render function its not working in detail function its not rendering to detail.html.please help any one

views.py:
def detail(request,user):
    print('hobbies : ', user.hobbies)
    return render(request, 'company/detail.html',{'details':user})


def login(request):
    if request.method == 'POST':
        email  = request.POST['email']
        password = request.POST['password']

        user = User.objects.get(email=email)  

        if user.password == password:

            if user.type == 'Manager':
                return redirect('company-add')

            if user.type == 'Normal':
                print('hobbies : ', user.hobbies)
                return detail(request, user)     #calling the detail function

        else:
            messages.success(request, 'invalids credentials')
            return redirect('company-login')

    else:
        return render(request, 'company/login.html')

urls.py
]

Jordan Micle

unread,
Nov 20, 2019, 2:34:19 PM11/20/19
to Django users
def detail(request,user):
    print('hobbies : ', user.hobbies)
    return render(request, 'company/detail.html',{'details':user})

change detail function like this 
def detail(request):
    print('hobbies : ', user.hobbies)
    return render(request, 'company/detail.html',{'details':request.user})

Kasper Laudrup

unread,
Nov 20, 2019, 3:05:17 PM11/20/19
to django...@googlegroups.com
Hi Paras,

I hope I'm mistaken but these lines:

On 20/11/2019 18.52, Paras Jain wrote:
>                 user = User.objects.get(email=email)
>                 if user.password == password:
>

Makes it look like you are storing users passwords in cleartext.

If that is correct, then please don't do that. Never, ever. This is
hopefully just a hobby project, but still it's good to do things
correctly and learn good habits from the beginning.

Considering your question, you generally can't as HTTP is basically
stateless, so the "details" view doesn't know about the user object you
created in your "login" view.

A workaround for this is using session cookies which isn't exactly
trivial to handle, so thankfully Django provides a way to make that very
transparent with Django authentication:

https://docs.djangoproject.com/en/2.2/topics/auth/

If you read up on that documentation you would find the answer to your
question.

It seems a bit like your trying to reinvent something Django already
provides for you, I could be wrong of course.

Kind regards,

Kasper Laudrup

Paras Jain

unread,
Nov 21, 2019, 12:03:29 AM11/21/19
to django...@googlegroups.com
but i have passed two argument in login function its showing error
  if user.type == 'Normal':
                print('hobbies : ', user.hobbies)
                return detail(request, user)   

def detail(request):
    print('hobbies : ', user.hobbies)
    return render(request, 'company/detail.html',{'details':request.user})

it wont work tell me what should i do to get at render page

--
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...@googlegroups.com.

Paras Jain

unread,
Nov 21, 2019, 12:04:31 AM11/21/19
to django...@googlegroups.com
i need the code i am not able to understand by reading documenetation

--
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...@googlegroups.com.

Kasper Laudrup

unread,
Nov 21, 2019, 3:37:25 AM11/21/19
to django...@googlegroups.com
Hi Paras,

On 21/11/2019 06.03, Paras Jain wrote:
> i need the code i am not able to understand by reading documenetation
>

Then I suggest you focus on writing your requirements down and pay
someone to write the code for you.

If you're not even willing to learn, then software development is
clearly not for you.

Kind regards,

Kasper Laudrup

Paras Jain

unread,
Nov 21, 2019, 3:52:26 AM11/21/19
to django...@googlegroups.com
my render is not working on calling the detail function : its not helping me to reach the /detail url
  views.py:
    def detail(request,user):
    #print('hobbies : ', user.hobbies)

    return render(request, 'company/detail.html',{'details':user})

def login(request):
    if request.method == 'POST':
        email  = request.POST['email']
        password = request.POST['password']

        user = User.objects.get(email=email)   # get will fetch details from database and it will match value with post


        if user.password == password:

            if user.type == 'Manager':
                return redirect('company-add')

            if user.type == 'Normal':
                print('hobbies : ', user.hobbies)
                return detail(request,user)
        else:
            messages.success(request, 'invalids credentials')
            return redirect('company-login')

    else:
        return render(request, 'company/login.html')

    urls.py:
        from django.urls import path
        from .import views
       
        urlpatterns=[
            path('', views.home, name='company-home'),
            path('register/', views.register, name='company-register'),
            path('detail/', views.detail, name='company-detail'),
            path('login/', views.login, name='company-login'),
            path('add/', views.add, name='company-add'),
--
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...@googlegroups.com.

Paras Jain

unread,
Nov 21, 2019, 5:15:59 AM11/21/19
to django...@googlegroups.com
i am not rendring to detail page
views.py:
def detail(request):
    #print('hobbies : ', user.hobbies)
    return render(request, 'company/detail.html',{'details':request.user})


def login(request):
    if request.method == 'POST':
        email  = request.POST['email']
        password = request.POST['password']

        user = User.objects.get(email=email)   # get will fetch details from database and it will match value with post

        if user.password == password:

            if user.type == 'Manager':
                return redirect('company-add')

            if user.type == 'Normal':
                print('hobbies : ', user.hobbies)
                return HttpResponseRedirect(reverse('company-detail'),user)
                # return redirect('company-detail',user)
                # return detail(request,user)

        else:
            messages.success(request, 'invalids credentials')
            return redirect('company-login')

    else:
        return render(request, 'company/login.html')


urls.py:
from django.urls import path
from django.conf.urls import  url
#from .views import HomePageView

from .import views

urlpatterns=[
    path('', views.home, name='company-home'),
    path('register/', views.register, name='company-register'),
    path('detail/<int:pk>', views.detail, name='company-detail'),

Paras Jain

unread,
Nov 23, 2019, 4:28:06 AM11/23/19
to django...@googlegroups.com
i want my 'user_id' to be passed from detail function to edit profile function but how?? need help

def detail(request,user_id):
    details = get_object_or_404(User, pk=user_id)      
    return render(request, 'company/detail.html',{'details':details})



def edit_profile(request):
    return render(request, 'company/edit_profile.html')

Raja Sekar Sambath

unread,
Nov 23, 2019, 11:27:45 AM11/23/19
to django...@googlegroups.com
Hi,
request object will have the user information of currently logged-in user.

try with request.user

--
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...@googlegroups.com.


--
Thanks & Regards,

Raja Sekar Sampath

Kasper Laudrup

unread,
Nov 23, 2019, 11:54:38 AM11/23/19
to django...@googlegroups.com
Hi Raja,

On 23/11/2019 17.26, Raja Sekar Sambath wrote:
> Hi,
> request object will have the user information of currently logged-in user.
>
> try with request.user
>

Paras is trying to reimplement Djangos authentication system because he
cannot be bothered to read the documentation, doesn't understand how
HTTP works and cannot be bothered to learn that either.

Don't waste your time trying to help him.

Kind regards,

Kasper Laudrup

Paras Jain

unread,
Nov 23, 2019, 11:49:01 PM11/23/19
to django...@googlegroups.com
bro dont say this i tried to read but i was unable to understand built in function django and this is part of my project its different

--
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...@googlegroups.com.

Paras Jain

unread,
Nov 24, 2019, 11:50:53 AM11/24/19
to django...@googlegroups.com
its showing error like this:

TypeError at /edit_profile/

edit_profile() missing 1 required positional argument: 'pk'
views.py:
def edit_profile(request, pk):
    post = get_object_or_404(User, pk=pk)
    if request.method == "POST":
        form = EditProfileForm(request.POST, instance=post)
        if form.is_valid():
            post = form.save(commit=False)
            post.save()
            return redirect('company/detail.html', pk=post.pk)
    else:
        return render(request,'company/edit_profile.html')


def detail(request,pk):
    details = get_object_or_404(User, pk=pk)         #it will create object

    return render(request, 'company/detail.html',{'details':details})


urls.py:

from django.urls import path
from django.conf.urls import  url
#from .views import HomePageView
from .import views

urlpatterns=[
    path('', views.home, name='company-home'),
    path('register/', views.register, name='company-register'),
    path('detail/<int:pk>', views.detail, name='company-detail'),
    path('login/', views.login, name='company-login'),
    path('add/', views.add, name='company-add'),
    path('edit_profile/', views.edit_profile, name='company-edit'),


]


sum abiut

unread,
Nov 26, 2019, 3:44:25 PM11/26/19
to django...@googlegroups.com
Check your url, you are passing a primary key in the edit_profile function but you are not indicating that in your url.


--
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...@googlegroups.com.

vaneet bawa

unread,
Nov 27, 2019, 7:38:16 AM11/27/19
to django...@googlegroups.com
can someone please tell me that how I can display the message on the url from which I am getting the response

Anirudh Jain

unread,
Nov 27, 2019, 8:29:03 AM11/27/19
to django...@googlegroups.com
Message on the URL ? Could you please give an example ?

On Wed, 27 Nov 2019, 18:08 vaneet bawa, <vaneet...@gmail.com> wrote:
can someone please tell me that how I can display the message on the url from which I am getting the response

--
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...@googlegroups.com.

Integr@te System

unread,
Nov 27, 2019, 8:39:51 AM11/27/19
to django...@googlegroups.com
Hi man,

U mean that use alert() method on onload page event!?

RAJAT MAAN

unread,
Nov 28, 2019, 6:09:46 AM11/28/19
to Django users


can someone help me where I am getting wrong? Unable to compare df1 == df2.


import mysql.connector as mysql
import socket
import sys  

def server_program():
HOST = '192.168.0.115' 
PORT = 8888
 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

print('socket created')

try:
    s.bind((HOST, PORT))
except socket.error as err:
    print('Bind Failed, Error Code: ' + str(err[0]) + ', Message: ' + err[1])
    sys.exit()
 
print('Socket Bind Success!')
 
s.listen(10)
print ('Socket is now listening')
 
 
while 1:
    conn, addr = s.accept()
    print ('Connect with ' + addr[0] + ':' + str(addr[1]))
    df1 = conn.recv(1024).decode()
    print(df1)
    break
    conn.close()
s.close()

mydb=mysql.connect(
user = 'rajat',
    passwd = 'rajat',
    host = 'localhost',
    database = 'myforum'
)

mycursor=mydb.cursor()
mycursor.execute("SELECT * FROM form_simpleform WHERE id=1")

df2=mycursor.fetchone()
print(df2)

if df1 == df2:
print('yes Data Exists')
else:
print('No Data')

if __name__ == '__main__':
    server_program() 

vaneet bawa

unread,
Nov 28, 2019, 7:06:06 AM11/28/19
to django...@googlegroups.com
Exception Type: TemplateDoesNotExist 

Could someone please tell me that i m getting this error how I can handle it...

what i m trying to do is i have created a input field and in that field i m providing a message and then i want that on button click that message should be displayed on my console....

Best Regards
Vaneet

Saswat Ray

unread,
Nov 28, 2019, 7:12:39 AM11/28/19
to django...@googlegroups.com
Django app expects a response from your  view file to render and show to user.You need add a template to render. like in views.py
return render(request, "xyz.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...@googlegroups.com.

vaneet bawa

unread,
Nov 28, 2019, 7:29:23 AM11/28/19
to django...@googlegroups.com
First of all thanks Saswat for the response but i have already done this thing on my views.py but my html file is not displaying anything rather it throws an exception templatedoesnot exit

I hope you are geeting what i am saying 

Best Regards
Vaneet



On 28-Nov-2019, at 5:42 PM, Saswat Ray <ray.s...@gmail.com> wrote:



Integr@te System

unread,
Nov 28, 2019, 7:43:25 AM11/28/19
to django...@googlegroups.com
Hi man,

where ur template coming from!? to display content you want to.

Saswat Ray

unread,
Nov 28, 2019, 7:53:03 AM11/28/19
to django...@googlegroups.com
Without looking your code and folder structure its hard to tell.

Thanks,
Saswat




Integr@te System

unread,
Nov 28, 2019, 1:17:54 PM11/28/19
to django...@googlegroups.com
Hi man,

plz show err msg.

--
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...@googlegroups.com.

Kasper Laudrup

unread,
Nov 28, 2019, 2:31:46 PM11/28/19
to django...@googlegroups.com
Hi Rajat,

On 28/11/2019 07.06, RAJAT MAAN wrote:
>
>
> can someone help me where I am getting wrong? Unable to compare df1 == df2.
>

I don't see how this is related to Django. You'll probably have a much
better chance of getting help if you ask in the relevant forum/mailing list.

Kind regards,
Kasper Laudrup

Integr@te System

unread,
Nov 28, 2019, 2:37:10 PM11/28/19
to django...@googlegroups.com
Hi guy,

also see df1 go to GC when conn.close()

--
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...@googlegroups.com.

Kasper Laudrup

unread,
Nov 28, 2019, 2:52:55 PM11/28/19
to django...@googlegroups.com
Hi "Guy"

On 28/11/2019 20.35, Integr@te System wrote:
> Hi guy,
>
> also see df1 go to GC when conn.close()
>

I think you answered the wrong person here. I cannot see how this is
related to my answer.

Kind regards,

Kasper Laudrup

Integr@te System

unread,
Nov 29, 2019, 1:06:01 AM11/29/19
to django...@googlegroups.com
Hi Kasper,

dont serious here is group to share knowledges.


--
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...@googlegroups.com.

13515...@qq.com

unread,
Dec 3, 2019, 7:21:27 PM12/3/19
to django-users
r u mean u want to display the response?


wblueboat
--
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...@googlegroups.com.

Karan Mittal

unread,
Dec 4, 2019, 3:24:22 AM12/4/19
to django...@googlegroups.com
I think he wants to use get method. Like the search page reuslts of google.
For that just make thw {%block content %} inside the title tags of your base template. And use get method for these kind of work where no database interaction is happening.

Karan Mittal, 
Business Analyst at techvalens
Contact me on this mail. 


Kevin Dublin

unread,
Dec 4, 2019, 4:10:30 AM12/4/19
to django...@googlegroups.com
Hmm, do you mean that you would like to post a get response with a message and it pass through the URL? Are you trying to pass it to another view?

I want to clarify because it involves changing the view, template & urls.py.

V.K. Vanama

unread,
Dec 24, 2019, 8:20:32 AM12/24/19
to Django users
The following steps are useful on Microsoft Windows Platform, I am using Microsoft Windows 10 64-bit

Step 1: Create a django project either through command line interface or through any IDE such as JetBrains PyCharm, Atom, etc...
Step 2: Observe the sub-folder name inside the django project contains the same name as the project name.
Step 3: Notice that the sub-folder contains 4 python files named __init__.py, settings.py, urls.py, wsgi.py
Step 4: Open the settings.py file & scroll down to the django project database component which is default to Sq Lite.
Step 5: Remove the default settings corresponding to the Sq Lite and Replace them by MySQL database as follows:-
{
'ENGINE': 'MYSQL',
'USERNAME': 'xxxx', # Replace xxxx with your MySQL database username.
'PASSWORD': 'xxxx', # Replace xxxx with your MySQL database password corresponds to the username provided above.
'HOST':'localhost/remotehost', # If it is remote host, you have to provide its IP Address., & also update the relevant IP Address in the  ALLOWED_HOSTS = [] in the settings.py file itself.
'PORT': 3306, # 3306 is default for MySQL, if you have your own replace it by your port number
}

Step 6: Save/Refresh the settings.py

Mohammad yunus

unread,
Mar 20, 2020, 5:09:12 AM3/20/20
to django...@googlegroups.com
Thx

--
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...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages