Re: models.py

2017-10-18 Thread harsh sharma
thanks :)

On Wednesday, October 18, 2017 at 2:12:51 PM UTC+5:30, Andréas Kühne wrote:
>
> Hi,
>
> The __str__ function is described here:
> https://docs.djangoproject.com/en/1.11/ref/models/instances/#str
>
> It is mainly used in django in the admin interface when you haven't setup 
> any rules for the list layout. You can also see it when you look at an 
> object in the python shell (athough that technically is the __repr__ 
> function :-))
>
> The get_absolute_url function is described here:
>
> https://docs.djangoproject.com/en/1.11/ref/models/instances/#get-absolute-url
>
> I use it mainly for 2 things:
> 1. In the admin interface you get a button that takes you to the page the 
> the absolut url points to.
> 2. When using in conjunction with django rest framework you use it for the 
> url that is sent to the client.
>
> Best regards,
>
> Andréas
>
> 2017-10-18 10:13 GMT+02:00 harsh sharma  >:
>
>> what are the use of these function in models.py 
>>
>> def __str__(self):
>> return self.title
>>
>> and 
>> def get_absolute_url(self):
>>return reverse('shop:product", agrs=[self.id,self,slug])
>>
>>
>>
>> -- 
>> 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 post to this group, send email to django...@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/221db76d-e44d-49b8-ac08-953bb49120e8%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/221db76d-e44d-49b8-ac08-953bb49120e8%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/200e0344-052b-4556-9c38-e386fe98be99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


'WSGIRequest' object has no attribute 'user'

2017-12-24 Thread harsh sharma
i am getting  this error  when ever i try to run localhost/admin 


-- 
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/2f504ec2-ddde-4bd9-95ed-74edf91584b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 'WSGIRequest' object has no attribute 'user'

2018-01-14 Thread harsh sharma

thanks  Etienne ,
The problem is solved 
On Monday, December 25, 2017 at 10:25:34 AM UTC+5:30, harsh sharma wrote:
>
> i am getting  this error  when ever i try to run localhost/admin 
>
>
>  

-- 
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/0d53f0f7-45c9-4798-83bb-23787ca7ab1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unable to save object Django (2.0)

2018-01-23 Thread harsh sharma
i am trying to save the basic information about a person 
i have created a model form for it but i am unable to save the object 
(unable to update the database)

here is my views file

@login_required
def dashboard(request):
if request.method=="post":
form = linkform(request.POST)
if form.is_valid():
try:
notes = form.cleaned_data['note']
link = form.cleaned_data['link']
number = form.cleaned_data['number']
perso = person.object.create_person(notes,link,number)
perso.save()
return HttpResponse('succeess')
except:
return HttpResponse('can not create object')
else:
return HttpResponse('bad form')
else:
form = linkform(request.POST)
return render(request, 'dashboard.html', {'form':form})


here is my model file :

class personmanager(models.Manager):
def create_person(self,note,link,number):
pers = self.create(note=note,link=link,number=number)
return pers



class person(models.Model):
notes = models.TextField()
link = models.URLField()
number = models.IntegerField()
object = personmanager()

-- 
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/dafa4659-4927-4dc9-a8eb-fd1b63da86eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 2 - How do I make search box?

2018-01-25 Thread harsh sharma
i think you can create a form for this and integrate in your template. 
through which u can search in your database . and for more details check 
https://docs.djangoproject.com/en/2.0/topics/forms/

On Tuesday, January 23, 2018 at 5:04:48 PM UTC+5:30, Carl Brubaker wrote:
>
> I am trying to make a search field in a template and connect it back to my 
> database so I can "find" stuff.
>
> I found this in the django docs:
>
> >>> Author.objects.filter(name__unaccent__icontains='Helen')[ >>> Mirren>, , ]
>
> which is helpful, but I'm having trouble connecting to my template:
>
> 
>
> I'm not sure what to call my variable or how to integrate it into models. All 
> of the existing stuff I can find is django 1.
>
> 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/3bc83af1-23e0-4f08-900a-485f37aec8d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
change that variable but still i mm unable to save the object

On Friday, January 26, 2018 at 10:56:14 AM UTC+5:30, Omar Abou Mrad wrote:
>
>
> On Tue, Jan 23, 2018 at 10:10 PM, harsh sharma  > wrote:
>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>>
>>
> Your "except" swallows the exceptions that are happening and you're unable
> to figure out the reason it's failing.
>  
>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
> The problem is due to your use of "note" whereas the field name
> is actually "notes" (plural)
>  
> Finally, the entire "create_person" serves no purpose as you're just
> aliasing "create"
>
> person.object.create_person(a=a, b=b, c=c)
> Person.objects.create(a=a, b=b, c=c)
>
> Regards,
>

-- 
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/9cc034c1-6445-40ea-9da2-bc16ee6f9d57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
thank you the problem has being solve 

regards

On Friday, January 26, 2018 at 10:56:14 AM UTC+5:30, Omar Abou Mrad wrote:
>
>
> On Tue, Jan 23, 2018 at 10:10 PM, harsh sharma  > wrote:
>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>>
>>
> Your "except" swallows the exceptions that are happening and you're unable
> to figure out the reason it's failing.
>  
>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
> The problem is due to your use of "note" whereas the field name
> is actually "notes" (plural)
>  
> Finally, the entire "create_person" serves no purpose as you're just
> aliasing "create"
>
> person.object.create_person(a=a, b=b, c=c)
> Person.objects.create(a=a, b=b, c=c)
>
> Regards,
>

-- 
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/efc92a9a-628e-4f4b-bd0b-248e01af8a52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
their is no error message 
i am doing something wrong in my forms
which is being solved
thank you

 
regards

On Friday, January 26, 2018 at 3:09:43 AM UTC+5:30, Andy wrote:
>
> what is the actual error message?
>
> Am Dienstag, 23. Januar 2018 21:10:00 UTC+1 schrieb harsh sharma:
>>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>> return HttpResponse('can not create object')
>> else:
>> return HttpResponse('bad form')
>> else:
>> form = linkform(request.POST)
>> return render(request, 'dashboard.html', {'form':form})
>>
>>
>> here is my model file :
>>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
>>
>> class person(models.Model):
>> notes = models.TextField()
>> link = models.URLField()
>> number = models.IntegerField()
>> object = personmanager()
>>
>>

-- 
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/391cbb98-31a0-4f94-ab20-3692e204fd1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
thank you 

regards 

On Wednesday, January 24, 2018 at 2:58:07 PM UTC+5:30, Anoosha Masood Keen 
wrote:
>
> Try this in models.py file
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *class personmanager(models.Model):notes = models.TextField()link 
> = models.URLField()number = models.IntegerField()def 
> create_person(self,note,link,number):self.notes=note
> self.link=linkself.number=numberreturn selfdef 
> __str__(self):return self.notesobject = 
> personmanager()a=object.create_person("this","c.com 
> <http://c.com>",1);a.save()*
>
> On Tuesday, January 23, 2018 at 8:10:00 PM UTC, harsh sharma wrote:
>>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>> return HttpResponse('can not create object')
>> else:
>> return HttpResponse('bad form')
>> else:
>> form = linkform(request.POST)
>> return render(request, 'dashboard.html', {'form':form})
>>
>>
>> here is my model file :
>>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
>>
>> class person(models.Model):
>> notes = models.TextField()
>> link = models.URLField()
>> number = models.IntegerField()
>> object = personmanager()
>>
>>

-- 
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/6e137774-e270-4673-b36f-a9102bccc29b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


template syntax error

2018-03-04 Thread harsh sharma
i created a model in which i have an image filed but when ever i am trying 
to get an uploaded image on the 
in my model.py 

image = models.ImageField(upload_to='static/pictures',)


setting.py

STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static", "./static"),
'/var/www/static/',
]


index.html file

{% load static %}
https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5882b15f-d674-44b9-ba67-74eeecd39137%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


type object 'Story' has no attribute 'object'

2017-09-11 Thread harsh sharma
why i m getting this
error  :-type object 'Story' has no attribute 'object'


this is my views.py file:

from django.shortcuts import render,render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from .models import *
from django.http import HttpResponse,HttpRequest
# Create your views here.



def home(request):

story = Story.object.all()
return render_to_response('show.html',{'story':story})


this is my models.py file:

from django.db import models
from django.forms import ModelForm;
# Create your models here.

class Story(models.Model):
stories = models.CharField(max_length=1024)


class storyform(ModelForm):
class Meta:
model = Story
fields = ['stories']



-- 
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/711b4bc2-c974-46f7-a88b-d90ad561d92f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: type object 'Story' has no attribute 'object'

2017-09-11 Thread harsh sharma
Thanks for helping 

-- 
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/c37d10a2-4e7b-4d24-9217-c042b4d16eb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


The view blog.views.create didn't return an HttpResponse object. It returned None instead.can any one help me this issue please nooob here

2017-09-11 Thread harsh sharma
 here i m learning django and i m stuck on one thing 
the web page returning 

The view blog.views.create didn't return an HttpResponse object. It returned 
None instead.



and here is my views.py  file



def home(request):

story = Story.objects.all()
return render_to_response('show.html',{'story':story})




def create(request):
if request.method == "get":
form = storyform()
return render(request,'form.html',{'form':form})
elif request.method == "post":
form= storyform(request.POST)
form.save()
return HttpResponseRedirect('/home')

-- 
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/067af0b0-6761-4daf-a1c0-02fcd1585048%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django.urls.exceptions.NoReverseMatch: Reverse for 'index' not found. 'index' is not a valid view function or pattern name.

2017-09-27 Thread harsh sharma
i m a noob in django And i dont know why i am getting this error

my views.py file:

from django.shortcuts import render,render_to_response
from django.http import HttpResponse
from all.models import ALL
from django.template import RequestContext
# Create your views here.
def home(request):
return render(request, 'index.html', {'ne': ne})


def technology(request):
return HttpResponse('hello')

def index(request):
assert isinstance(request , HttpResponse)

return render(request, 'index.html') . 

my url file

url(r'^$', all.views.index),
url(r'^technology', all.views.index),
url(r'^index$', all.views.home),
url(r'^admin/', admin.site.urls),
]

-- 
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/41876d02-56e0-48c8-8722-17fc08ed32f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django.core.exceptions.ImproperlyConfigured:

2017-10-01 Thread harsh sharma
i am getting this error whenever i m trying to run django-admin runserver

django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but 
settings are not configured. You must eit
her define the environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings.

my wsgi file

import os
from django.conf import settings
from django.core.wsgi import get_wsgi_application

settings.configure(DEBUG=True)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings")

application = get_wsgi_application()

-- 
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/568cdb67-2a6f-4e3b-9ba8-842d0c721e7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: need help in django application

2017-10-02 Thread harsh sharma
https://docs.djangoproject.com/en/1.11/topics/forms/ you can check this


On Monday, October 2, 2017 at 4:55:14 PM UTC+5:30, djangor wrote:
>
> I m doing a project in django. I've created model classes for each form, 
> master tables and generated db tables from classes. Next for the 
> corresponding classes/tables, 
> I want to create HTML forms with post data handling and after each next 
> button in the forms that I use for submit/ moving to the next related form. 
> Pls help me generate and use the forms.

-- 
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/e10b7a73-920b-4b82-8e90-66d9379e695f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can anyone help me in Template error?

2017-10-18 Thread harsh sharma
in your template folder -> account  login.py to login .html .. if your html 
file is login.py 
and you have to specify full path like  
render(request,"accounts/login.html",context)
 
On Saturday, October 14, 2017 at 3:19:53 PM UTC+5:30, utpalbr...@gmail.com 
wrote:
>
> my code that caused an error :
> ///
> from django.shortcuts import render
> from django.http import HttpResponse
> from django.template import loader
> # Create your views here.
>
> def home(request) :
> return render(request,'login.html',context) 
> ///
> above code is in my views.py of my app name "accounts"
> my project name "tutorial"
> All my directories are :
>
> tutorial->
>  accounts
>  tutorial
>  manage.py
> and accounts->
> migrations
> __pycache__
> templates
> admin.py
> apps.py
> __init__.py
> models.py
> tests.py
> urls.py
> views.py
>
> and templates->
>  accounts->
>  login.py
>
>

-- 
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/d7fae195-4f43-49ea-b23e-63c05bc3cfc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


models.py

2017-10-18 Thread harsh sharma
what are the use of these function in models.py 

def __str__(self):
return self.title

and 
def get_absolute_url(self):
   return reverse('shop:product", agrs=[self.id,self,slug])



-- 
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/221db76d-e44d-49b8-ac08-953bb49120e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.