'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: Django foms problems .. please help me

2017-12-24 Thread Costja Covtushenko
Hi Vijay,

Can you be more specific?
What invalid section do you get?
And what is the data you are using in choice field?


Regards,
Constantine C.

> On Dec 23, 2017, at 2:39 PM, vijaysundeep  wrote:
> 
> Hi Everyone,
> 
> I am trying to pass current user  as request.user.
> 
> It handles properly in forms and i am getting choice filed with the help of 
> it.
> 
> But, when i tried to read the data throough post method. it is going to form 
> invalid section..
> 
> Please help me ASAP.
> 
> views.py
> def instancecreate(request):
> if request.method=='POST':
> print('POST FORM @')
> form=InstanceCreationForm(request.user,request.POST)
> 
> if form.is_valid():
> images = request.POST['name']
> print('you handled post data')
> print(images)
> return HttpResponse(images)
> else:
> print('NOT a Valid Form !')
> form=InstanceCreationForm(request.user)
> return render(request, 'url/User/cinstance.html', {'form': form})
> 
> 
> else:
> 
> form=InstanceCreationForm(request.user)
> return render(request, 'url/User/cinstance.html', {'form': form})
> 
> -- 
> 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/138500c0-6721-4ba8-ad32-2a51816ef25d%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/AF66F2B2-31C9-4905-A4B4-20B629E3A1E9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 'Question' object has no attribute 'choice_text'

2017-12-24 Thread Daniel Hepper
Are you sure your polls/models.py is correct?
I assume you are at „Part 2: Playing with the API“. Here is what your 
polls/models.py should look like at this point of the tutorial:
https://github.com/consideratecode/django-tutorial-step-by-step/blob/2.0/2.4/mysite/polls/models.py

My guess is that you have a typo in your __str__ method. This gets triggered in 
the first session because your Question had Choices, which it doesn‘t in your 
second session, maybe because you deleted them. But that‘s really just a guess 
without looking at your code.

I‘ve put together the complete code for the tutorial, step-by-step:
https://consideratecode.com/2017/12/15/django-tutorial-step-by-step/

Hope that helps,
Daniel

> Am 24.12.2017 um 17:44 schrieb Artem Tantsura :
> 
> I've made anything by site tutorial, just repeat all steps and code. And when 
> I wrote this:
> 
>  >>> from polls.models import Question, Choice
> # Make sure our __str__() addition worked.
> >>> Question.objects.all()
> ]>
> 
> # Django provides a rich database lookup API that's entirely driven by
> # keyword arguments.
> >>> Question.objects.filter(id=1)
> ]>
> >>> Question.objects.filter(question_text__startswith='What')
> ]>
> 
> >>> from django.utils import timezone
> >>> current_year = timezone.now().year
> >>> Question.objects.get(pub_date__year=current_year)
> 
> 
> 
> >>> Question.objects.get(id=2)
> Traceback (most recent call last):
> ...
> DoesNotExist: Question matching query does not exist.
> 
> 
> >>> Question.objects.get(pk=1)
> 
> 
> >>> q = Question.objects.get(pk=1)
> >>> q.was_published_recently()
> True
> 
> >>> q = Question.objects.get(pk=1)
> >>> q.choice_set.all()
> 
> Im getting 'Question' object has no attribute 'choice_text'. 
> But then I have got some magic solution! I define if Im writting only this:
> >>>from polls.models import Choice, Question
> >>>from django.utils import timezone
> 
> >>>q = Question.objects.get(pk=1)
> 
> >>>q.choice_set.all()
> Out[4]: 
> Then I dont have any problems, but I have done the same main steps then 
> before(like in tutorial)! Sorry, but WTF is going on?
> -- 
> 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/33e82e65-b97a-46f9-be2c-38905fccc01a%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/535EC403-6756-42B8-A18C-E3CDFAAF99AD%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django admin code modification

2017-12-24 Thread Carl Brubaker
I am trying to make a customer database (name, address, etc) and I need to 
be able to add new customers, edit customer info, delete customers, and 
search for them through name and phone number (and possibly more). When I 
enter the admin site and select my app, I have all of those fields given to 
me as well as a search field. 

Also, is there documentation as to what the generic views are? I have tried 
to find them and failed miserably.

Thanks for your help.

-- 
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/8d69cd14-319c-4a1e-9910-fb87bbf0ac20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


'Question' object has no attribute 'choice_text'

2017-12-24 Thread Artem Tantsura
I've made anything by site tutorial, just repeat all steps and code. And 
when I wrote this:

 >>> from polls.models import Question, Choice

# Make sure our __str__() addition worked.>>> Question.objects.all()]>
# Django provides a rich database lookup API that's entirely driven by# keyword 
arguments.>>> Question.objects.filter(id=1)] Question.objects.filter(question_text__startswith='What')]>
>>> from django.utils import timezone>>> current_year = timezone.now().year>>> 
>>> Question.objects.get(pub_date__year=current_year)

>>> Question.objects.get(id=2)Traceback (most recent call last):
...DoesNotExist: Question matching query does not exist.

>>> Question.objects.get(pk=1)
>>> q = Question.objects.get(pk=1)>>> q.was_published_recently()True
>>> q = Question.objects.get(pk=1)>>> q.choice_set.all()


Im getting 'Question' object has no attribute 'choice_text'. 

But then I have got some magic solution! I define if Im writting only this:

>>>from polls.models import Choice, Question
>>>from django.utils import timezone

>>>q = Question.objects.get(pk=1)

>>>q.choice_set.all()
Out[4]: 

Then I dont have any problems, but I have done the same main steps then 
before(like in tutorial)! Sorry, but WTF is going on?

-- 
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/33e82e65-b97a-46f9-be2c-38905fccc01a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django admin code modification

2017-12-24 Thread Jani Tiainen
Hi.

It would be helpful to know what changes you're after.

Admin is designed to be datacentric view to your models. Trying to make
admin something more is quite a job.

That's why there exists generic class based views. They allow to create
much more flexible views and incorporate for example business logic.


23.12.2017 23.22 "Carl Brubaker"  kirjoitti:

> So there are lots of things I like about the django admin, and somethings
> I would like to change. Since django is kinda about not reinventing the
> wheel, is there an "app" or file or something where I can find the admin
> information to modify it to what I want, and then save it as a new app?
> 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/24f3d510-ba00-4256-93fa-7ee041deec0b%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/CAHn91odysA9Huf8zQ5H6iWJmkyt%2BB01_xkGsKRoBA8BOOpO06Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DJANGO NOT FOUND

2017-12-24 Thread Avraham Serour
did you create a virtualenv for the project? you shouldn't pip install
stuff in the system python.

can you import django using the python console?

On Sun, Dec 24, 2017 at 2:22 AM, Jack 
wrote:

> Hi, i've installed on my ubuntu 16.04 LTS python3.6 and django but django i
> have installed with pip3 and usign virtualenv, but it is ok by console, the
> problem is in eclipse, i installed python, it is OK, but at the moment of
> creating a django project, it drops a message, django not found, i've
> removed the interpreter and add it again because i thought it was the
> problem but the problem continues, i've uninstalled pydev from eclipse and
> the problem is the same.
>
> If someone knows about this, please help me.
>
> Thnks a lot.
>
> --
> 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/58251deb-dc26-4f68-8a1b-c838f0f97e43%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/CAFWa6tK0Ev9jCqT2h%3Dd5K4QocPUjx4MvnNiNwQDQ9ZyAkdv5gg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search results in template

2017-12-24 Thread James Schneider
On Dec 23, 2017 5:36 PM, "Malik Rumi"  wrote:

FIRST, James, let me say how much I *greatly* appreciate you hanging in
there and trying to help me.


No worries.

2nd, as to your two points about the html:
   a. This template, serp_list.html, is identical to ktab_list.html, except
that serp_list has the title 'SEARCH' at the top and some bolierplate text
about this being the search results page. Other than that they are
identical, including the template for loop.
   serp_list is supposed to be called by localhost/serp/, which points
to views.serp, which is an FBV.
   ktab_list is a vanilla implementation of ListView, called by
localhost/index/, and it shows all Entry objects as you would expect.
   The header you see is the blog post header, ie, this is where the
title and the get absoulte url to the detail page is supposed to go. On
/index/ that works like it should. On serp, well, that's why I am here.
  b. Your second point is probably well taken, that the for loop should
completely wrap the article, and that might explain why the author and
comments part of the last three posts were not the same font as the first
post. I have changed that in the html, but it has not changed the result.


Hooray, at least I've gotten something right. ;-


3rd, just because things weren't complicated enough, now I am getting
inconsistent results. Whereas before I got views.serp called, a db query
with 4 results, on the right template, now I am getting a value error
('returns None' - how's that for a news flash?). The only difference is
that I downloaded the free version of pycharm to see if their visual
debugger would help me. So calling the page through pycharm, instead of the
regular terminal, is the only difference, and I don't think that should
make a difference. But either way, I still have no result on my page - and
oh yea, pycharm says the same thing my print statements did - that the
query was there and pulled up the expected objects. They just won't show up
on the template.


Confused. You mentioned PyCharm affected the results but then indicated the
same results?


4th, I don't know how relevant this is, but the form which created the
search box has the form action = '/serp/', but despite that, if I use the
search box in /index/, I stay on /index/ and just get the query attached to
the end of that url, rather than /serp/ plus the query. I have to manually
type in /serp/ to get  views.serp called. When it stays on  /index/ plus
the query, the result shown are just Entry.objects.all(), as you would
expect on a ListView. Any thoughts on that? Is it related? Why isn't my
form action working? THANKS!




A few (possibly dumb) questions:

Have you verified that the serp.html page is the one actually being
rendered? DDT can verify this.

Have you confirmed the context being provided to the template actually
contains the variables and query results you are expecting? DDT can also
verify this.

Can you do something simple like {{ object_list }} in your template just to
see if anything is printed? When doing quick troubleshooting I like to do
this:

|{{ object_list }}|

That way if I see || in the template (and source), I know the variable is
empty.

Do you have any non-standard middleware or template context processors
enabled?

Are your forms set to use a method of GET or POST? Sounds like GET but just
want to verify.

When you are on /index/ and you search, does the runserver console show a
hit against /serp/ (per the form action) or is it simply a hit against
/index/ again? Or is there a redirect for some reason?

-James

-- 
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/CA%2Be%2BciX3a%3D3O9AGv4hF5bff0xD7L8mCrkrrW0nKvRtNCzZ3UxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.