Re: Where to find my web app within mysite directory ?

2019-05-28 Thread Anirudh Jain
If the command you had run did not show any error, then it should be in the
same folder as that of manage.py

On Wed, 29 May 2019, 01:16 Joseph Jones,  wrote:

>
>
> Hello fellow community members,
>>
>> I’m working on a Django project using PyCharm on my pc. I’ve run command
>> ‘>py manage.py startapp hypotheticalapp’.
>> To ensure my app does in fact exist However if I enter into my mysite
>> directory on file explorer the ‘hypotheticalapp’ file is nowhere to be
>> found any advice on what error I am making and how to correct it would be
>> appreciated. Thank you,
>>
>> Joseph
>>
> --
> 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/CAJGsC5McHOD8EdsbT2%3Df2ZkqvZiriOoZvbRy64B%3DpAOMh8Z%3Dtw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAC3mK7evRNfwLQa-2RYQWE0H6mE4nU4LKw8Bb-y-7Fy0DDRK_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with form

2019-05-28 Thread Anirudh Jain
Can you please send the screenshot or text of error. Also, try -
form.save(commit=False)

On Wed, 29 May 2019, 04:53 Saeed Pooladzadeh,  wrote:

> Hi
>
> I'm trying to make a simple crud applicatio and learn from it. I wonder
> why my form can't save the data. Here cames my view:
>
> from django.shortcuts import render
> from saeed.forms import SmodelForm
> from saeed.models import Smodel
> from django.shortcuts import render, redirect
>
>
>
> # Create your views here.
> def emp(request):
> if request.method == "POST":
> form = SmodelForm(request.POST)
> if form.is_valid():
> try:
> form.save()
> return redirect('/show')
> except  AssertionError as error:
>
> print(error)
> pass
>
>
>
>
>
> else:
> form = SmodelForm()
> return render(request,'saeed/index.html',{'form':form})
> #
> def show(request):
> smodels = Smodel.objects.all()
> return render(request,'saeed/show.html',{'smodels':smodels})
> #
>
> def edit(request, id):
> smodels = Smodel.objects.get(id=id)
> return render(request,'saeed/edit.html', {'smodels':smodels})
> #---
>
> def update(request, id):
> smodels = Smodel.objects.get(id=id)
> form = SmodelForm(request.POST, instance = smodels)
> if form.is_valid():
> form.save()
> return redirect("/show")
> return render(request,'saeed/edit.html',{'smodels':smodels})
>
> #-
> def destroy(request, id):
> smodels = Smodel.objects.get(id=id)
> smodels.delete()
> return redirect("/show")
>
>
> and here cames the complete app:
>
>
> https://ln.sync.com/dl/1bf7658d0/pw69mf37-yk85kjaa-qprd4xdx-m8em4rxk
>
> can you please inform me where is wrong?
>
> thanks
>
> 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/83aa34e2-2da1-432d-94ba-ec0beea90608%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/CAC3mK7fp6Nwj%3DBOk9psELGEKDbYPr2oNHhPe5ohLDSrEvAcWJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


need help - following django tutorial to create polls database - missing "on delete cascade" - using django 2.2.1 with mysql 8.0

2019-05-28 Thread K Tan
Hi, everyone,

This is my first time using Django and I think I'm missing something or
there is a bug. I am following the instructions on (
https://docs.djangoproject.com/en/2.2/intro/tutorial02/) and I've just
added the following chunk of code to "polls/models.py". (I copied/pasted so
I know it's correct.)


from django.db import models


class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')


class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)



Then I ran the following command:


LITTLEBLACK:www samktan$ python3 manage.py makemigrations polls
Migrations for 'polls':
  polls/migrations/0001_initial.py
- Create model Question
- Create model Choice


Which is missing one line compared to the tutorial:

- Add field question to choice



Now when I run this command:


LITTLEBLACK:www samktan$ python3 manage.py sqlmigrate polls 0001
BEGIN;
--
-- Create model Question
--
CREATE TABLE `polls_question` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY
KEY, `question_text` varchar(200) NOT NULL, `pub_date` datetime(6) NOT
NULL);
--
-- Create model Choice
--
CREATE TABLE `polls_choice` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY
KEY, `choice_text` varchar(200) NOT NULL, `votes` integer NOT NULL,
`question_id` integer NOT NULL);
ALTER TABLE `polls_choice` ADD CONSTRAINT
`polls_choice_question_id_c5b4b260_fk_polls_question_id` FOREIGN KEY
(`question_id`) REFERENCES `polls_question` (`id`);
COMMIT;


It is missing the "on delete cascade" clause, which I suspect it caused by
the missing line above.

I have confirmed in MySQL that the "on delete cascade" clause is definitely
missing.


mysql> show create table `polls_choice`;
+--+-+
| Table| Create Table





 |
+--+-+
| polls_choice | CREATE TABLE `polls_choice` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `choice_text` varchar(200) COLLATE utf8mb4_general_ci NOT NULL,
  `votes` int(11) NOT NULL,
  `question_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `polls_choice_question_id_c5b4b260_fk_polls_question_id`
(`question_id`),
  CONSTRAINT `polls_choice_question_id_c5b4b260_fk_polls_question_id`
FOREIGN KEY (`question_id`) REFERENCES `polls_question` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
+--+-+
1 row in set (0.00 sec)


Can someone tell me what I'm doing wrong?


-- 

/ per ardua ad astra /

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


[Solved] How to disable the the Delete button

2019-05-28 Thread Mike Dewhirst

  
  
(I hate my email formatting)
- - - - - - - - - - - - - - - - - - - - - -
I asked too soon. Sorry. 

There is a method in contrib.admin.options.BaseModelAdmin called ...

def has_delete_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.

Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to delete the `obj`
model instance. If `obj` is None, this should return True if the given
request has permission to delete *any* object of the given type.
"""
opts = self.opts
codename = get_permission_codename('delete', opts)
return request.user.has_perm("%s.%s" % (opts.app_label, codename))

 
So I made a callable ...

def see_delete(self, request, obj=None):
from django.contrib.auth import get_permission_codename
opts = self.opts
codename = get_permission_codename('delete', opts)
see = request.user.has_perm("%s.%s" % (opts.app_label, codename))
if obj:
if obj.company == get_user_company(request.user):
return see and True
else:
return False
return see


In myModelAdmin I put ...  has_delete_permission = see_delete_button

And it works nicely :)  Open source is lovely and Django (and the
Admin) is brilliant.

I'm guessing showing the button disabled would be a CSS task which I
don't have the brain-space for just now.

Cheers

Mike

On 29/05/2019 8:37 am, Mike Dewhirst wrote:
Django 1.11 and Python 3.6 but upgrading to
  Django 2.2 (slowly)
  
  Currently I use a get_readonly_fields callable in the Admin as
  documented[1]. The callable determines whether request.user is
  allowed to edit the editable fields or not. This works well.
  
  However, the readonly user can still see/use the Delete button.
  
  The abovementioned callable doesn't make their own records
  readonly so those users do need change (edit) permissions.
  Therefore I cannot use permissions to solve the problem.
  
  Can anyone suggest an approach?
  
  Thanks
  
  Mike
  
  [1]
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields
  
  



  




-- 
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/6b8ea3e3-3931-6274-c605-99622bedc6ef%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


[Solved] How to disable the the Delete button

2019-05-28 Thread Mike Dewhirst

I asked too soon. Sorry.

There is a method in contrib.admin.options.BaseModelAdmin called ...

def has_delete_permission(self, request, obj=None): """ Returns True if 
the given request has permission to change the given Django model 
instance, the default implementation doesn't examine the `obj` 
parameter. Can be overridden by the user in subclasses. In such case it 
should return True if the given request has permission to delete the 
`obj` model instance. If `obj` is None, this should return True if the 
given request has permission to delete *any* object of the given type. 
""" opts = self.opts codename = get_permission_codename('delete', opts) 
return request.user.has_perm("%s.%s" % (opts.app_label, codename))


So I made a callable ...

def see_delete_button(self, request, obj=None): from django.contrib.auth 
import get_permission_codename opts = self.opts codename = 
get_permission_codename('delete', opts) see = 
request.user.has_perm("%s.%s" % (opts.app_label, codename)) if obj: if 
obj.company == get_user_company(request.user): return see and True else: 
return False return see


In myModelAdmin I put ...  has_delete_permission = see_delete_button

And it works nicely :)  Open source is lovely and Django (and the Admin) 
is brilliant.


I'm guessing showing the button disabled would be a CSS task which I 
don't have the brain-space for just now.


Cheers

Mike

On 29/05/2019 8:37 am, Mike Dewhirst wrote:

Django 1.11 and Python 3.6 but upgrading to Django 2.2 (slowly)

Currently I use a get_readonly_fields callable in the Admin as 
documented[1]. The callable determines whether request.user is allowed 
to edit the editable fields or not. This works well.


However, the readonly user can still see/use the Delete button.

The abovementioned callable doesn't make their own records readonly so 
those users do need change (edit) permissions. Therefore I cannot use 
permissions to solve the problem.


Can anyone suggest an approach?

Thanks

Mike

[1] 
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields





--
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/4588f8a8-95ad-14e8-11dc-39ec8ba1fb6a%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


problem with form

2019-05-28 Thread Saeed Pooladzadeh
Hi

I'm trying to make a simple crud applicatio and learn from it. I wonder why 
my form can't save the data. Here cames my view:

from django.shortcuts import render
from saeed.forms import SmodelForm  
from saeed.models import Smodel
from django.shortcuts import render, redirect  



# Create your views here.
def emp(request):  
if request.method == "POST":  
form = SmodelForm(request.POST)  
if form.is_valid():  
try:  
form.save()  
return redirect('/show')  
except  AssertionError as error:

print(error)
pass

 



else:  
form = SmodelForm()  
return render(request,'saeed/index.html',{'form':form})  
#
def show(request):  
smodels = Smodel.objects.all()  
return render(request,'saeed/show.html',{'smodels':smodels}) 
#

def edit(request, id):  
smodels = Smodel.objects.get(id=id)  
return render(request,'saeed/edit.html', {'smodels':smodels})  
#---

def update(request, id):  
smodels = Smodel.objects.get(id=id)  
form = SmodelForm(request.POST, instance = smodels)  
if form.is_valid():  
form.save()  
return redirect("/show")  
return render(request,'saeed/edit.html',{'smodels':smodels})  

#-
def destroy(request, id):  
smodels = Smodel.objects.get(id=id)  
smodels.delete()  
return redirect("/show")  


and here cames the complete app:


https://ln.sync.com/dl/1bf7658d0/pw69mf37-yk85kjaa-qprd4xdx-m8em4rxk

can you please inform me where is wrong?

thanks

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/83aa34e2-2da1-432d-94ba-ec0beea90608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to disable the the Delete button

2019-05-28 Thread Mike Dewhirst

Django 1.11 and Python 3.6 but upgrading to Django 2.2 (slowly)

Currently I use a get_readonly_fields callable in the Admin as 
documented[1]. The callable determines whether request.user is allowed 
to edit the editable fields or not. This works well.


However, the readonly user can still see/use the Delete button.

The abovementioned callable doesn't make their own records readonly so 
those users do need change (edit) permissions. Therefore I cannot use 
permissions to solve the problem.


Can anyone suggest an approach?

Thanks

Mike

[1] 
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields



--
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/cda47e29-3d0a-20a2-be49-9d2a1cc5c7d7%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: How to use permissions on a CreateView class?

2019-05-28 Thread Fellipe Henrique
Hi Jim,

Tried that, as you can see on my code, but not working.. when user type the
url, still see the template..

Any suggestions?

Regards,

T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*


On Tue, May 28, 2019 at 2:36 PM Jim Illback  wrote:

> I think you can also add to your class (right under your *template_name*…
> for example) this statement:
>
>   permission_required = *‘*appname.permission_name'
>
> This will limit to logged on users (as below), and also to users who possess 
> this permission.
>
> Jim
>
>
> On May 28, 2019, at 9:55 AM, Joe Reitman  wrote:
>
> Fellipe,
>
> Here is an example of decorating class based views from the documentation
> 
> :
>
> from django.contrib.auth.decorators import login_requiredfrom 
> django.utils.decorators import method_decoratorfrom django.views.generic 
> import TemplateView
> class ProtectedView(TemplateView):
> template_name = 'secret.html'
>
> @method_decorator(login_required)
> def dispatch(self, *args, **kwargs):
> return super().dispatch(*args, **kwargs)
>
>
> On Tuesday, May 28, 2019 at 6:54:38 AM UTC-5, Fellipe Henrique wrote:
>>
>> Hello,
>>
>> I have these class, based on CreateView class... and I only want allow
>> user with these permissions to add record...
>>
>> class ClienteCreateView(ERPbrViewMixin, CreateView):
>> template_name = 'cadastro/cliente/form.html'
>> permission_required = ('cliente.can_open', 'cliente.can_edit', 
>> 'cliente.can_add')
>> model = Cliente
>> form_class = ClienteForm
>>
>> But, not working... user without these permission, when type the url show
>> the form...
>>
>> Any tips how to do that?
>>
>> Cheers!
>>
>>
>> T.·.F.·.A.·. S+F
>> *Fellipe Henrique P. Soares*
>>
>> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
>> 's/(.)/chr(ord($1)-2*3)/ge'
>> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
>> *
>> *Blog: *http:www.fellipeh.eti.br 
>> *GitHub: https://github.com/fellipeh *
>> *Twitter: @fh_bash*
>>
>
> --
> 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/060a2c59-bf39-456c-a686-bf6ba104e1f7%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/B5E64E45-C1C3-455F-AEC7-167852FE17C7%40hotmail.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/CAF1jwZHCR%3Dn2FMcdPdWsAOKG7wQRhqKBb4is58P61dGCi8_Eqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


SAVING DATA IN FORMTOOL WIZARD MODELFORM

2019-05-28 Thread Simon John
Hi 
Any one can  help on how to save data using formtool wizard and Modelform

The view of my models and form and views and the error are here

-- 
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/ef672c46-4c47-4d45-9838-39dfc5cefbaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Formtools Wizard and Modelform saving data

2019-05-28 Thread Simon John
I am trying to save data to db after all the three from have submited and 
still getting and error, any work around

-- 
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/9370992b-6f04-4bd3-ad70-3813347f2df4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


linking HTML form with database directly without ModelForm

2019-05-28 Thread Fatukasi Kayode
*fase.html*

Email address:
 
  
Phone: 

   
  
 


the models.py contains email and phone number also

-- 
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/055b76f9-d8dd-48ca-9f25-fa6700aff4c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display image in template

2019-05-28 Thread anchal agarwal
Thanks Nitin. It worked !!

-- 
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/CAMT%3DisWznPc66tv%3D_7q0R9mVdDh8VBh%2BZ5MWFxAwEeZmLwzyRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Where to find my web app within mysite directory ?

2019-05-28 Thread Joseph Jones
Hello fellow community members,
>
> I’m working on a Django project using PyCharm on my pc. I’ve run command
> ‘>py manage.py startapp hypotheticalapp’.
> To ensure my app does in fact exist However if I enter into my mysite
> directory on file explorer the ‘hypotheticalapp’ file is nowhere to be
> found any advice on what error I am making and how to correct it would be
> appreciated. Thank you,
>
> Joseph
>

-- 
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/CAJGsC5McHOD8EdsbT2%3Df2ZkqvZiriOoZvbRy64B%3DpAOMh8Z%3Dtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL conf error

2019-05-28 Thread Joe Reitman
What do your views look like?

I see you have an app named 'music' in your project URL Config that 
includes 'music.urls'. Your music app URL Config has a single view that 
calls the index view. When you type 127.0.0.1/music/ in the browser address 
bar you should see your index page. Is the index view setup correctly?  

On Tuesday, May 28, 2019 at 12:31:35 PM UTC-5, Madhur Kabra wrote:
>
> I am getting the url conf error. I  have attached the relevant files. 
> Thanks for the assistance
>

-- 
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/8737deca-f1ad-4f39-b7c8-b009305fc3df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL conf error

2019-05-28 Thread Victor H. Velasquez Rizo
Hi Madhur.

On your urls.py,
*change: *url('^$', views.index, name=index),
*to:* url('^$', views.index, name="index"),

I assume that you imported the *views.*

On Tue, May 28, 2019 at 12:31 PM Madhur Kabra 
wrote:

> I am getting the url conf error. I  have attached the relevant files.
> Thanks for the assistance
>
> --
> 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/37eedb50-637a-45bf-839a-cbe52a410f4e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 



Atte...,.
Vìctor Hugo Velàsquez Rizo
Cali - Colombia

-- 
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/CAFCXTzgfXZBdKLMuZbRZnWt%3DfPz6M_auhbVVJZ-%3DwxmdONbjTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display image in template

2019-05-28 Thread Joe Reitman
Have you looked in inspector on your browser to see if the URL is correctly 
rendered in IMG SRC?
Have you installed Pillow? ImageField requires python Pillow.

On Tuesday, May 28, 2019 at 1:38:49 PM UTC-5, Anchal Agarwal wrote:
>
> Thanks for the answer but  I have already set the MEDIA path 
> here is my urls.py
> from . import settings
> from django.contrib.staticfiles.urls import static
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> urlpatterns += staticfiles_urlpatterns()
> urlpatterns += static(settings.MEDIA_URL, document_root
> =settings.MEDIA_ROOT)
>
> models.py
> from django.db import models
>
> class Album(models.Model):
> artist = models.CharField(max_length=250)
> album_title = models.CharField(max_length=500)
> genre=models.CharField(max_length=100)
> album_logo = models.ImageField(upload_to="gallery")
>
> def __str__(self):
> return self.album_title 
>
>
>  settings.py
> import os
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
> MEDIA_ROOT=os.path.join(BASE_DIR,'media')
> MEDIA_URL= '/media/'
>
> On Tue, May 28, 2019 at 11:42 PM Anirudh Jain  > wrote:
>
>> You will have to setup MEDIA path f8rst. All your uploded files will be 
>> stored in that folder. STATIC path is used only for, well, static content 
>> like css and js.
>>
>> On Tue, 28 May 2019, 23:31 anchal agarwal, > > wrote:
>>
>>> I want to display image dynamically from the database in a django 
>>> template. I have used ImageField for this purpose. The code shows no error 
>>> but it is only displaying an icon of image.
>>> This is my template file,
>>> here album is the context and album_logo is the variable in which i have 
>>> stored my image. please tell me how can i fix this issue
>>> 
>>>
>>> {{ album.album_title}}
>>> {{ album.artist }}
>>>
>>> 
>>> {% for song in album.song_set.all %}
>>> {{song.song_title}}-{{song.file_type}}
>>> {% endfor %}
>>> 
>>>
>>> -- 
>>> 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...@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/CAMT%3DisWxuO9d1tTMacyYauDAmQS%2B2e_B9HawfZP7eY8smCS%3D2Q%40mail.gmail.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@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/CAC3mK7fGps2XR1S7V%2B4WvU-%2Boma-eoUTrtDjEwVJe2QtCTL_Xg%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/428409db-dc0a-4dff-a60e-4a6027e263a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display image in template

2019-05-28 Thread Nitin Kumar
{{ album.album_logo.url }}

On Wed, 29 May, 2019, 12:08 AM anchal agarwal  Thanks for the answer but  I have already set the MEDIA path
> here is my urls.py
> from . import settings
> from django.contrib.staticfiles.urls import static
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> urlpatterns += staticfiles_urlpatterns()
> urlpatterns += static(settings.MEDIA_URL, document_root
> =settings.MEDIA_ROOT)
>
> models.py
> from django.db import models
>
> class Album(models.Model):
> artist = models.CharField(max_length=250)
> album_title = models.CharField(max_length=500)
> genre=models.CharField(max_length=100)
> album_logo = models.ImageField(upload_to="gallery")
>
> def __str__(self):
> return self.album_title
>
>
>  settings.py
> import os
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
> MEDIA_ROOT=os.path.join(BASE_DIR,'media')
> MEDIA_URL= '/media/'
>
> On Tue, May 28, 2019 at 11:42 PM Anirudh Jain 
> wrote:
>
>> You will have to setup MEDIA path f8rst. All your uploded files will be
>> stored in that folder. STATIC path is used only for, well, static content
>> like css and js.
>>
>> On Tue, 28 May 2019, 23:31 anchal agarwal, 
>> wrote:
>>
>>> I want to display image dynamically from the database in a django
>>> template. I have used ImageField for this purpose. The code shows no error
>>> but it is only displaying an icon of image.
>>> This is my template file,
>>> here album is the context and album_logo is the variable in which i have
>>> stored my image. please tell me how can i fix this issue
>>> 
>>>
>>> {{ album.album_title}}
>>> {{ album.artist }}
>>>
>>> 
>>> {% for song in album.song_set.all %}
>>> {{song.song_title}}-{{song.file_type}}
>>> {% endfor %}
>>> 
>>>
>>> --
>>> 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/CAMT%3DisWxuO9d1tTMacyYauDAmQS%2B2e_B9HawfZP7eY8smCS%3D2Q%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAC3mK7fGps2XR1S7V%2B4WvU-%2Boma-eoUTrtDjEwVJe2QtCTL_Xg%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMT%3DisWvaOt-NYXGa-Ps5yO7b-bbTfi3%3Dii4wzQmzVCOH%3DO50A%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKzNicEyaCS_7OFhNU00AsANZ%2Bz%3DpW7_XCL-1pi7Jfo%3DR4bd-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model Forms Dynamic

2019-05-28 Thread Alexis Roda
Something like that?

def model_form_factory(model_class):
class MyModelForm(forms.ModelForm):
class Meta:
model = model_class
return MyModelForm

AuthorForm = model_form_factory(Author)
BookForm = model_form_factory(Book)


Missatge de Yoo  del dia dt., 28 de maig 2019 a les
18:01:

> https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/
>
> In the example of model form, they say
> model = Author
> Is it possible to set a variable to set the model? Like could I make a
> variable and set it to whatever model I’d like, then say model = var?
>
> --
> 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/918196f4-0ab8-45e8-803d-d62a38a1e396%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/CAMDYoXbELKWgyRTWN1WYS5q8-50a-9UQg7brZ3PCvAPvoTq1MA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display image in template

2019-05-28 Thread anchal agarwal
Thanks for the answer but  I have already set the MEDIA path
here is my urls.py
from . import settings
from django.contrib.staticfiles.urls import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

models.py
from django.db import models

class Album(models.Model):
artist = models.CharField(max_length=250)
album_title = models.CharField(max_length=500)
genre=models.CharField(max_length=100)
album_logo = models.ImageField(upload_to="gallery")

def __str__(self):
return self.album_title


 settings.py
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

MEDIA_ROOT=os.path.join(BASE_DIR,'media')
MEDIA_URL= '/media/'

On Tue, May 28, 2019 at 11:42 PM Anirudh Jain 
wrote:

> You will have to setup MEDIA path f8rst. All your uploded files will be
> stored in that folder. STATIC path is used only for, well, static content
> like css and js.
>
> On Tue, 28 May 2019, 23:31 anchal agarwal, 
> wrote:
>
>> I want to display image dynamically from the database in a django
>> template. I have used ImageField for this purpose. The code shows no error
>> but it is only displaying an icon of image.
>> This is my template file,
>> here album is the context and album_logo is the variable in which i have
>> stored my image. please tell me how can i fix this issue
>> 
>>
>> {{ album.album_title}}
>> {{ album.artist }}
>>
>> 
>> {% for song in album.song_set.all %}
>> {{song.song_title}}-{{song.file_type}}
>> {% endfor %}
>> 
>>
>> --
>> 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/CAMT%3DisWxuO9d1tTMacyYauDAmQS%2B2e_B9HawfZP7eY8smCS%3D2Q%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAC3mK7fGps2XR1S7V%2B4WvU-%2Boma-eoUTrtDjEwVJe2QtCTL_Xg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMT%3DisWvaOt-NYXGa-Ps5yO7b-bbTfi3%3Dii4wzQmzVCOH%3DO50A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL conf error

2019-05-28 Thread Madhur Kabra
I am using Django version 2.2.1
Thanks for your answer, but it's not working. Could you help me with 
another solution.

On Tuesday, May 28, 2019 at 11:18:52 PM UTC+5:30, Anchal Agarwal wrote:
>
> which version of django you are using?
>
> i think it should be url(r'^$', views.index, name=index)
>
> On Tue, May 28, 2019 at 11:01 PM Madhur Kabra  > wrote:
>
>> I am getting the url conf error. I  have attached the relevant files. 
>> Thanks for the assistance
>>
>> -- 
>> 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...@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/37eedb50-637a-45bf-839a-cbe52a410f4e%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/d274ce61-1bf1-4f31-b9bc-82c472bf091f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL conf error

2019-05-28 Thread Madhur Kabra
Thanks for your answer, but it's not working. Could you help me with 
another solution.

On Tuesday, May 28, 2019 at 11:30:19 PM UTC+5:30, youri wrote:
>
> replace name=index by name="index"
>
> On Tue, May 28, 2019 at 5:31 PM Madhur Kabra  > wrote:
>
>> I am getting the url conf error. I  have attached the relevant files. 
>> Thanks for the assistance
>>
>> -- 
>> 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...@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/37eedb50-637a-45bf-839a-cbe52a410f4e%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> YAVOUCKO YANGALA Liyé
> Pdg de Teranga-Food
> Mobile: (+221) 778399425
> Fixe: (+221) 338232086
> Adresse: Dakar (Cité Keur Gorgui, Lot 31)
> Site web:www.teranga-food.com
>
>

-- 
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/e15d3340-a0c6-47bf-a652-2e2ee12a0aa5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display image in template

2019-05-28 Thread Anirudh Jain
You will have to setup MEDIA path f8rst. All your uploded files will be
stored in that folder. STATIC path is used only for, well, static content
like css and js.

On Tue, 28 May 2019, 23:31 anchal agarwal, 
wrote:

> I want to display image dynamically from the database in a django
> template. I have used ImageField for this purpose. The code shows no error
> but it is only displaying an icon of image.
> This is my template file,
> here album is the context and album_logo is the variable in which i have
> stored my image. please tell me how can i fix this issue
> 
>
> {{ album.album_title}}
> {{ album.artist }}
>
> 
> {% for song in album.song_set.all %}
> {{song.song_title}}-{{song.file_type}}
> {% endfor %}
> 
>
> --
> 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/CAMT%3DisWxuO9d1tTMacyYauDAmQS%2B2e_B9HawfZP7eY8smCS%3D2Q%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAC3mK7fGps2XR1S7V%2B4WvU-%2Boma-eoUTrtDjEwVJe2QtCTL_Xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Display image in template

2019-05-28 Thread anchal agarwal
I want to display image dynamically from the database in a django template.
I have used ImageField for this purpose. The code shows no error but it is
only displaying an icon of image.
This is my template file,
here album is the context and album_logo is the variable in which i have
stored my image. please tell me how can i fix this issue


{{ album.album_title}}
{{ album.artist }}


{% for song in album.song_set.all %}
{{song.song_title}}-{{song.file_type}}
{% endfor %}


-- 
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/CAMT%3DisWxuO9d1tTMacyYauDAmQS%2B2e_B9HawfZP7eY8smCS%3D2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL conf error

2019-05-28 Thread yavoucko lye
replace name=index by name="index"

On Tue, May 28, 2019 at 5:31 PM Madhur Kabra 
wrote:

> I am getting the url conf error. I  have attached the relevant files.
> Thanks for the assistance
>
> --
> 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/37eedb50-637a-45bf-839a-cbe52a410f4e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
YAVOUCKO YANGALA Liyé
Pdg de Teranga-Food
Mobile: (+221) 778399425
Fixe: (+221) 338232086
Adresse: Dakar (Cité Keur Gorgui, Lot 31)
Site web:www.teranga-food.com

-- 
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/CAHKysxj%3DZAeTgV9kegXGWdrzSPBSsFipJrGUxaLNFMa0%2B5a-EA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL conf error

2019-05-28 Thread anchal agarwal
which version of django you are using?

i think it should be url(r'^$', views.index, name=index)

On Tue, May 28, 2019 at 11:01 PM Madhur Kabra 
wrote:

> I am getting the url conf error. I  have attached the relevant files.
> Thanks for the assistance
>
> --
> 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/37eedb50-637a-45bf-839a-cbe52a410f4e%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/CAMT%3DisXVTCf1oSHS0s_JTpo3AZc2OFpNkO0U9WOExTTZNPS1Zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use permissions on a CreateView class?

2019-05-28 Thread Jim Illback
I think you can also add to your class (right under your template_name… for 
example) this statement:


permission_required = ‘appname.permission_name'

This will limit to logged on users (as below), and also to users who possess 
this permission.

Jim


On May 28, 2019, at 9:55 AM, Joe Reitman 
mailto:jreitma...@gmail.com>> wrote:

Fellipe,

Here is an example of decorating class based views from the 
documentation:


from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView

class ProtectedView(TemplateView):
template_name = 'secret.html'

@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)


On Tuesday, May 28, 2019 at 6:54:38 AM UTC-5, Fellipe Henrique wrote:
Hello,

I have these class, based on CreateView class... and I only want allow user 
with these permissions to add record...


class ClienteCreateView(ERPbrViewMixin, CreateView):
template_name = 'cadastro/cliente/form.html'
permission_required = ('cliente.can_open', 'cliente.can_edit', 
'cliente.can_add')
model = Cliente
form_class = ClienteForm

But, not working... user without these permission, when type the url show the 
form...

Any tips how to do that?

Cheers!


T.·.F.·.A.·. S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
Blog: http:www.fellipeh.eti.br
GitHub: https://github.com/fellipeh
Twitter: @fh_bash

--
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/060a2c59-bf39-456c-a686-bf6ba104e1f7%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/B5E64E45-C1C3-455F-AEC7-167852FE17C7%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.


URL conf error

2019-05-28 Thread Madhur Kabra
I am getting the url conf error. I  have attached the relevant files. 
Thanks for the assistance

-- 
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/37eedb50-637a-45bf-839a-cbe52a410f4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from django.conf.urls import URLPattern, url, include
from . import views

urlpatterns = [
url('^$', views.index, name=index),
]
"""website URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import:  from my_app import views
2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
1. Add an import:  from other_app.views import Home
2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, url

urlpatterns = [
path('admin/', admin.site.urls),
path('music/', include('music.urls')),
]


Re: How to use permissions on a CreateView class?

2019-05-28 Thread Joe Reitman
Fellipe,

Here is an example of decorating class based views from the documentation 

:

from django.contrib.auth.decorators import login_requiredfrom 
django.utils.decorators import method_decoratorfrom django.views.generic import 
TemplateView
class ProtectedView(TemplateView):
template_name = 'secret.html'

@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)


On Tuesday, May 28, 2019 at 6:54:38 AM UTC-5, Fellipe Henrique wrote:
>
> Hello,
>
> I have these class, based on CreateView class... and I only want allow 
> user with these permissions to add record...
>
> class ClienteCreateView(ERPbrViewMixin, CreateView):
> template_name = 'cadastro/cliente/form.html'
> permission_required = ('cliente.can_open', 'cliente.can_edit', 
> 'cliente.can_add')
> model = Cliente
> form_class = ClienteForm
>
> But, not working... user without these permission, when type the url show 
> the form...
>
> Any tips how to do that?
>
> Cheers!
>
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh 
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>

-- 
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/060a2c59-bf39-456c-a686-bf6ba104e1f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What's wrong with this model

2019-05-28 Thread Joe Reitman
By default CharField is not Nullable meaning it can't be created with out 
some data in it. 

You have two options:
Make field nullable:  blank=True
Or add a default: default=default_text

On Monday, May 27, 2019 at 4:52:19 PM UTC-5, Saeed Pooladzadeh wrote:
>
> Hello
>
> I made this model and think everything is fine:
>
> class Smodel(models.Model):
>
> eid=models.AutoField(primary_key=True)
># eid=models.IntegerField(default=0)
> elogin = models.CharField(max_length=8) 
> epassword= models.CharField(max_length=8) 
>   
> elikeDay=models.IntegerField(default=0)
> efollowPerDay=models.IntegerField(default=0)
> 
>
>
> #esession = models.TextField()
> class Meta:  
> db_table = "saeed"  
>
>
>   'But when I try to 'make migration 
> I get this error:
>
> You are trying to add a non-nullable field 'elogin' to smodel without a 
> default; we can't do that (the database needs something to populate 
> existing rows).
> Please select a fix:
>  1) Provide a one-off default now (will be set on all existing rows with a 
> null value for this column)
>  2) Quit, and let me add a default in models.py
> Select an option: 
>
>
> *What is wrong with this model and how can I resolve it?*
>
> regards,
> Saeed 
>

-- 
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/ceb076de-7592-4de1-9732-64bd5c0031dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Model Forms Dynamic

2019-05-28 Thread Yoo
https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/

In the example of model form, they say
model = Author
Is it possible to set a variable to set the model? Like could I make a variable 
and set it to whatever model I’d like, then say model = var?

-- 
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/918196f4-0ab8-45e8-803d-d62a38a1e396%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Selecting Models by Typing an Identifier

2019-05-28 Thread Derek Dong
I have two questions.
The first is: I want to select models in a form. The first is a standard 
User, the second is a Contest form already defined. Let's take the User as 
an example. I want to only have to type a string into the form, and have 
all users with that string as a substring of their username show up as 
options below, as a sort of autocomplete feature. Right now I have a model 
form where the model has User as a ForeignKey, but that requires clicking 
and finding a single user among a potential hundred.
My second question is:
As before, I also need to select a Contest. But in a single inputting 
session, I will be inputting many forms for a single Contest, so I want to 
select it only once, and after that it automatically fills in the last 
contest filled in. Is this possible?
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/e0f5e3d3-af51-48e4-a0f0-06baa8c98f50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: SOLUTION FounD : How to restore Models original Properties - Problem in Models column Exclude

2019-05-28 Thread Alexis Roda
No, it isn't. It's not thread safe.

Changes in shared state in multi-threaded code may lead to race
conditions[1].

Depending on your usage it may be very unlikely, but under the right
circumstances root may end up having some missing fields in the form or dgp
may see fields that it is not intended to see.

Either protect the critical section[2] with some kind of lock or, as I
suggested in my previous answer, create non-shared (request local) state.


[1] https://en.wikipedia.org/wiki/Race_condition
[2] https://en.wikipedia.org/wiki/Critical_section

-- 
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/CAMDYoXa16C5goSadFbSoXQg1-v2zh9vrq%2BAk%3Dkqbq1rk%3DsgSQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


SOLUTION FounD : How to restore Models original Properties - Problem in Models column Exclude

2019-05-28 Thread Balaji Shetty
This is the proper code to customize models column userwise.
Here we are sharing model among multiple user and depending upon right
access, it is visible

in admin.py

  normaluser_fields =
['user','CourtType','SuitType','CaseNumber','CaseYear','CaseAdvocate','CasePartyNames',
'CaseOppositePartyNames','CaseLastDate']
  superuser_fields =
['UserNext','UserNextDate','UserNextDepartment','CaseStatus']
  inward_fields =
['InwardNumber','CaseNoticeDate','CaseNoticeSubject','CaseReceiverName','CaseInwardDate','CaseActionTaken']


  def get_form(self, request, obj=None, **kwargs):

username = request.user.username

print("- Inside get_exclude Method")
print (username)

if username == 'dgp': # if user is not a superuser

# if request.user.is_superuser:
# print("-  ***  Inside ROOT LOGIN ***---")

self.fields = self.normaluser_fields
elif username == 'inumber':
print("-  ***  Inside DGP LOGIN ***---")
self.fields = self.inward_fields
else:
self.fields = self.normaluser_fields + self.superuser_fields +
self.inward_fields


return super(ProfileAdmin, self).get_form(request, obj, **kwargs)



On Tue, May 28, 2019 at 1:02 PM Balaji Shetty 
wrote:

> Dear  Alexis Roda Sir
>
> Thank You very much for your nice reply. I check it.
>
> On Tue, May 28, 2019 at 1:55 AM Alexis Roda <
> alexis.roda.villalo...@gmail.com> wrote:
>
>> Not an admin expert here.
>>
>> You are modifying the modeladmin instance and, by the behavior you're
>> describing, it looks like it is a global (shared) object. I'm guessing, you
>> can confirm this by printing id(self) in add_view(). I'll bet you get
>> the same value in each request, so the instance is shared, so the change is
>> visible (persisted) across request boundaries.
>>
>> You may think about adding self.exclude = () in the else branch in order
>> to not exclude anything. Don't do that, you may end up leaking private
>> information to dgp if both root and dgp are logged in at the same time.
>>
>> Instead override the get_exclude method.
>>
>> See
>> https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_exclude
>>
>> --
>> 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/CAMDYoXbb42hpu3jAATXTwxPw9kO8XeZpLOczbNa-Bzw5QAdGuQ%40mail.gmail.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*
>
>

-- 


*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/CAECSbOsDv%2Byx-D382S45y2%3DqfYo3FHxyUytqYDm%2B62DYkZopig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread Abdulrasheed Ibrahim
For security reasons, It's not recommended to use csrf_exempt, use it only
where security doesn't matter

On Tue, May 28, 2019, 1:13 PM Jeyakanth T  Hi,
> add one more line in your view.py header
>
> from django.views.decorators.csrf import csrf_exempt
>
>
> then add decorator  before your function
>
> @csrf_exempt
>
> With Regards,
>
> Jeyakanth Thangam,
>
>  +91 89739 - 70708, +91 79046 - 48182
>
> jeyakanth0...@gmail.com 
>
>
> On Tue, May 28, 2019 at 5:26 PM isorae dennis 
> wrote:
>
>> Did you indent accurately
>>
>> On Tue, May 28, 2019, 12:32 The Aryas  wrote:
>>
>>> hello guys, i was working on a clone project and got stuck on a problem.
>>> the {% csrf_token %} that i have applied is not verified ...and the error
>>> login module is following>>
>>>
>>>
>>> 
>>> Forbidden (403)
>>>
>>> CSRF verification failed. Request aborted.
>>> Help
>>>
>>> Reason given for failure:
>>>
>>> CSRF token missing or incorrect.
>>>
>>>
>>> In general, this can occur when there is a genuine Cross Site Request
>>> Forgery, or when Django's CSRF mechanism
>>>  has not been used
>>> correctly. For POST forms, you need to ensure:
>>>
>>>- Your browser is accepting cookies.
>>>- The view function passes a request to the template's render
>>>
>>> 
>>> method.
>>>- In the template, there is a {% csrf_token %} template tag inside
>>>each POST form that targets an internal URL.
>>>- If you are not using CsrfViewMiddleware, then you must use
>>>csrf_protect on any views that use the csrf_token template tag, as
>>>well as those that accept the POST data.
>>>- The form has a valid CSRF token. After logging in in another
>>>browser tab or hitting the back button after a login, you may need to
>>>reload the page with the form, because the token is rotated after a 
>>> login.
>>>
>>> You're seeing the help section of this page because you have DEBUG =
>>> True in your Django settings file. Change that to False, and only the
>>> initial error message will be displayed.
>>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>>
>>>
>>> 
>>>
>>> I have applied all the requirements but still that occurs. here is my
>>> code>>
>>>
>>> 
>>>
>>> {% extends 'blog/base.html' %}
>>> {% block content %}
>>> 
>>>   Please login!
>>>   (must be suoer user , please check with site admin)
>>> 
>>> {% if forms.errors %}
>>>   Your user name and password did not match please try again!
>>> {% endif %}
>>>
>>> 
>>> {% csrf_token %}
>>> {{ form.as_p }}
>>>   
>>>   
>>> 
>>> {% endblock %}
>>>
>>>
>>> ===
>>> 
>>>
>>>
>>> from django.contrib import admin
>>> from django.http import HttpResponse
>>> from django.shortcuts import get_object_or_404, render
>>> from django.urls import path
>>> from django.conf.urls import include
>>> from django.contrib.auth import views
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> path('',include('blog.urls')),
>>> path('accounts/login/',views.LoginView.as_view(), name='login'),
>>> path('accounts/logout/',views.LogoutView.as_view(),
>>> name='logout',kwargs={'next_page':'/'})
>>> ]
>>>
>>>
>>> ===
>>> 
>>> *from django.shortcuts import render,get_object_or_404,redirect*
>>> *from django.utils import timezone*
>>> *from blog.models import Post,Comment*
>>> *from blog.forms import PostForm,CommentForm*
>>> *from django.urls import reverse_lazy*
>>> *from django.contrib.auth.decorators import login_required*
>>> *from django.contrib.auth.mixins import LoginRequiredMixin*
>>> *from django.views.generic import (TemplateView,ListView,*
>>> *DetailView,CreateView,*
>>> *UpdateView,DeleteView)*
>>> *# Create your views here.*
>>>
>>> *class AboutView(TemplateView):*
>>> *template_name='about.html'*
>>>
>>> *class PostListView(ListView):*
>>> *model=Post*
>>>
>>> *def get_queryset(self):*
>>> *return
>>> Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')*
>>>
>>>
>>> *class PostDetailView(DetailView):*
>>> *model=Post*
>>>
>>> *class CreatePostView(LoginRequiredMixin,CreateView):*
>>> *login_url='/login'*
>>> *redirect_field_name='blog/post_detail.html'*
>>>
>>> *form_class=PostForm*
>>>
>>> *model=Post*
>>>
>>>
>>> *class PostUpdateView(LoginRequiredMixin,UpdateView):*
>>> *login_url='/login'*
>>> *

Re: reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread Jeyakanth T
Hi,
add one more line in your view.py header

from django.views.decorators.csrf import csrf_exempt


then add decorator  before your function

@csrf_exempt

With Regards,

Jeyakanth Thangam,

 +91 89739 - 70708, +91 79046 - 48182

jeyakanth0...@gmail.com 


On Tue, May 28, 2019 at 5:26 PM isorae dennis  wrote:

> Did you indent accurately
>
> On Tue, May 28, 2019, 12:32 The Aryas  wrote:
>
>> hello guys, i was working on a clone project and got stuck on a problem.
>> the {% csrf_token %} that i have applied is not verified ...and the error
>> login module is following>>
>>
>>
>> 
>> Forbidden (403)
>>
>> CSRF verification failed. Request aborted.
>> Help
>>
>> Reason given for failure:
>>
>> CSRF token missing or incorrect.
>>
>>
>> In general, this can occur when there is a genuine Cross Site Request
>> Forgery, or when Django's CSRF mechanism
>>  has not been used
>> correctly. For POST forms, you need to ensure:
>>
>>- Your browser is accepting cookies.
>>- The view function passes a request to the template's render
>>
>> 
>> method.
>>- In the template, there is a {% csrf_token %} template tag inside
>>each POST form that targets an internal URL.
>>- If you are not using CsrfViewMiddleware, then you must use
>>csrf_protect on any views that use the csrf_token template tag, as
>>well as those that accept the POST data.
>>- The form has a valid CSRF token. After logging in in another
>>browser tab or hitting the back button after a login, you may need to
>>reload the page with the form, because the token is rotated after a login.
>>
>> You're seeing the help section of this page because you have DEBUG = True in
>> your Django settings file. Change that to False, and only the initial
>> error message will be displayed.
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>>
>> 
>>
>> I have applied all the requirements but still that occurs. here is my
>> code>>
>>
>> 
>>
>> {% extends 'blog/base.html' %}
>> {% block content %}
>> 
>>   Please login!
>>   (must be suoer user , please check with site admin)
>> 
>> {% if forms.errors %}
>>   Your user name and password did not match please try again!
>> {% endif %}
>>
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>>   
>>   
>> 
>> {% endblock %}
>>
>>
>> ===
>> 
>>
>>
>> from django.contrib import admin
>> from django.http import HttpResponse
>> from django.shortcuts import get_object_or_404, render
>> from django.urls import path
>> from django.conf.urls import include
>> from django.contrib.auth import views
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> path('',include('blog.urls')),
>> path('accounts/login/',views.LoginView.as_view(), name='login'),
>> path('accounts/logout/',views.LogoutView.as_view(),
>> name='logout',kwargs={'next_page':'/'})
>> ]
>>
>>
>> ===
>> 
>> *from django.shortcuts import render,get_object_or_404,redirect*
>> *from django.utils import timezone*
>> *from blog.models import Post,Comment*
>> *from blog.forms import PostForm,CommentForm*
>> *from django.urls import reverse_lazy*
>> *from django.contrib.auth.decorators import login_required*
>> *from django.contrib.auth.mixins import LoginRequiredMixin*
>> *from django.views.generic import (TemplateView,ListView,*
>> *DetailView,CreateView,*
>> *UpdateView,DeleteView)*
>> *# Create your views here.*
>>
>> *class AboutView(TemplateView):*
>> *template_name='about.html'*
>>
>> *class PostListView(ListView):*
>> *model=Post*
>>
>> *def get_queryset(self):*
>> *return
>> Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')*
>>
>>
>> *class PostDetailView(DetailView):*
>> *model=Post*
>>
>> *class CreatePostView(LoginRequiredMixin,CreateView):*
>> *login_url='/login'*
>> *redirect_field_name='blog/post_detail.html'*
>>
>> *form_class=PostForm*
>>
>> *model=Post*
>>
>>
>> *class PostUpdateView(LoginRequiredMixin,UpdateView):*
>> *login_url='/login'*
>> *redirect_field_name='blog/post_detail.html'*
>>
>> *form_class=PostForm*
>>
>> *model=Post*
>>
>>
>> *class PostDeleteView(LoginRequiredMixin,DeleteView):*
>> *model=Post*
>> *success_url=reverse_lazy('post_list')*
>>
>>
>> *class DraftListView(LoginRequiredMixin,ListView):*
>> *login_url='/login/'*
>> *

Re: reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread isorae dennis
Did you indent accurately

On Tue, May 28, 2019, 12:32 The Aryas  wrote:

> hello guys, i was working on a clone project and got stuck on a problem.
> the {% csrf_token %} that i have applied is not verified ...and the error
> login module is following>>
>
>
> 
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
> Help
>
> Reason given for failure:
>
> CSRF token missing or incorrect.
>
>
> In general, this can occur when there is a genuine Cross Site Request
> Forgery, or when Django's CSRF mechanism
>  has not been used
> correctly. For POST forms, you need to ensure:
>
>- Your browser is accepting cookies.
>- The view function passes a request to the template's render
>
> 
> method.
>- In the template, there is a {% csrf_token %} template tag inside
>each POST form that targets an internal URL.
>- If you are not using CsrfViewMiddleware, then you must use
>csrf_protect on any views that use the csrf_token template tag, as
>well as those that accept the POST data.
>- The form has a valid CSRF token. After logging in in another browser
>tab or hitting the back button after a login, you may need to reload the
>page with the form, because the token is rotated after a login.
>
> You're seeing the help section of this page because you have DEBUG = True in
> your Django settings file. Change that to False, and only the initial
> error message will be displayed.
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>
>
> 
>
> I have applied all the requirements but still that occurs. here is my
> code>>
>
> 
>
> {% extends 'blog/base.html' %}
> {% block content %}
> 
>   Please login!
>   (must be suoer user , please check with site admin)
> 
> {% if forms.errors %}
>   Your user name and password did not match please try again!
> {% endif %}
>
> 
> {% csrf_token %}
> {{ form.as_p }}
>   
>   
> 
> {% endblock %}
>
>
> ===
> 
>
>
> from django.contrib import admin
> from django.http import HttpResponse
> from django.shortcuts import get_object_or_404, render
> from django.urls import path
> from django.conf.urls import include
> from django.contrib.auth import views
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('',include('blog.urls')),
> path('accounts/login/',views.LoginView.as_view(), name='login'),
> path('accounts/logout/',views.LogoutView.as_view(),
> name='logout',kwargs={'next_page':'/'})
> ]
>
>
> ===
> 
> *from django.shortcuts import render,get_object_or_404,redirect*
> *from django.utils import timezone*
> *from blog.models import Post,Comment*
> *from blog.forms import PostForm,CommentForm*
> *from django.urls import reverse_lazy*
> *from django.contrib.auth.decorators import login_required*
> *from django.contrib.auth.mixins import LoginRequiredMixin*
> *from django.views.generic import (TemplateView,ListView,*
> *DetailView,CreateView,*
> *UpdateView,DeleteView)*
> *# Create your views here.*
>
> *class AboutView(TemplateView):*
> *template_name='about.html'*
>
> *class PostListView(ListView):*
> *model=Post*
>
> *def get_queryset(self):*
> *return
> Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')*
>
>
> *class PostDetailView(DetailView):*
> *model=Post*
>
> *class CreatePostView(LoginRequiredMixin,CreateView):*
> *login_url='/login'*
> *redirect_field_name='blog/post_detail.html'*
>
> *form_class=PostForm*
>
> *model=Post*
>
>
> *class PostUpdateView(LoginRequiredMixin,UpdateView):*
> *login_url='/login'*
> *redirect_field_name='blog/post_detail.html'*
>
> *form_class=PostForm*
>
> *model=Post*
>
>
> *class PostDeleteView(LoginRequiredMixin,DeleteView):*
> *model=Post*
> *success_url=reverse_lazy('post_list')*
>
>
> *class DraftListView(LoginRequiredMixin,ListView):*
> *login_url='/login/'*
> *redirect_field_name='blog/post_list.html'*
> *model=Post*
>
> *def get_queryset(self):*
> *return
> Post.objects.filter(published_date_isnull=True).order_by('created_date')*
>
> *@login_required*
> *def add_comment_to_post(request,pk):*
> *post=get_object_or_404(post,pk=pk)*
> *if request.method == 'POST':*
> *form=CommentForm(request.POST)*
> *if form.is_valid():*
> *Comment=form.save(commit=False)*
> *

How to use permissions on a CreateView class?

2019-05-28 Thread Fellipe Henrique
Hello,

I have these class, based on CreateView class... and I only want allow user
with these permissions to add record...

class ClienteCreateView(ERPbrViewMixin, CreateView):
template_name = 'cadastro/cliente/form.html'
permission_required = ('cliente.can_open', 'cliente.can_edit',
'cliente.can_add')
model = Cliente
form_class = ClienteForm

But, not working... user without these permission, when type the url show
the form...

Any tips how to do that?

Cheers!


T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*

-- 
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/CAF1jwZE6R02FvUqPAywU44z-mEErB17nXOWx9gSV5RijKhPErQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread The Aryas
hello guys, i was working on a clone project and got stuck on a problem. 
the {% csrf_token %} that i have applied is not verified ...and the error 
login module is following>>


Forbidden (403)

CSRF verification failed. Request aborted.
Help

Reason given for failure:

CSRF token missing or incorrect.


In general, this can occur when there is a genuine Cross Site Request 
Forgery, or when Django's CSRF mechanism 
 has not been used 
correctly. For POST forms, you need to ensure:

   - Your browser is accepting cookies.
   - The view function passes a request to the template's render 
   

method.
   - In the template, there is a {% csrf_token %} template tag inside each 
   POST form that targets an internal URL.
   - If you are not using CsrfViewMiddleware, then you must use csrf_protect on 
   any views that use the csrf_token template tag, as well as those that 
   accept the POST data.
   - The form has a valid CSRF token. After logging in in another browser 
   tab or hitting the back button after a login, you may need to reload the 
   page with the form, because the token is rotated after a login.

You're seeing the help section of this page because you have DEBUG = True in 
your Django settings file. Change that to False, and only the initial error 
message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting. 



I have applied all the requirements but still that occurs. here is my code>>



{% extends 'blog/base.html' %}
{% block content %}

  Please login!
  (must be suoer user , please check with site admin)

{% if forms.errors %}
  Your user name and password did not match please try again!
{% endif %}


{% csrf_token %}
{{ form.as_p }}
  
  

{% endblock %}

===



from django.contrib import admin
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.urls import path
from django.conf.urls import include
from django.contrib.auth import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('blog.urls')),
path('accounts/login/',views.LoginView.as_view(), name='login'),
path('accounts/logout/',views.LogoutView.as_view(), 
name='logout',kwargs={'next_page':'/'})
]

===

*from django.shortcuts import render,get_object_or_404,redirect*
*from django.utils import timezone*
*from blog.models import Post,Comment*
*from blog.forms import PostForm,CommentForm*
*from django.urls import reverse_lazy*
*from django.contrib.auth.decorators import login_required*
*from django.contrib.auth.mixins import LoginRequiredMixin*
*from django.views.generic import (TemplateView,ListView,*
*DetailView,CreateView,*
*UpdateView,DeleteView)*
*# Create your views here.*

*class AboutView(TemplateView):*
*template_name='about.html'*

*class PostListView(ListView):*
*model=Post*

*def get_queryset(self):*
*return 
Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')*


*class PostDetailView(DetailView):*
*model=Post*

*class CreatePostView(LoginRequiredMixin,CreateView):*
*login_url='/login'*
*redirect_field_name='blog/post_detail.html'*

*form_class=PostForm*

*model=Post*


*class PostUpdateView(LoginRequiredMixin,UpdateView):*
*login_url='/login'*
*redirect_field_name='blog/post_detail.html'*

*form_class=PostForm*

*model=Post*


*class PostDeleteView(LoginRequiredMixin,DeleteView):*
*model=Post*
*success_url=reverse_lazy('post_list')*


*class DraftListView(LoginRequiredMixin,ListView):*
*login_url='/login/'*
*redirect_field_name='blog/post_list.html'*
*model=Post*

*def get_queryset(self):*
*return 
Post.objects.filter(published_date_isnull=True).order_by('created_date')*

*@login_required*
*def add_comment_to_post(request,pk):*
*post=get_object_or_404(post,pk=pk)*
*if request.method == 'POST':*
*form=CommentForm(request.POST)*
*if form.is_valid():*
*Comment=form.save(commit=False)*
*comment.post=post*
*comment.save()*
*return redirect('post_detail',pk=post.pk)*
*else:*
*form=CommentForm()*
*return render(request,'blog/comment_form.html',{'form':form})*
*@login_required*
*def comment_approve(request,pk):*
*comment=get_object_or_404(Comment,pk=pk)*
*

Re: Theme for django admin interface.

2019-05-28 Thread Mayank Priy
I will send you templates link for admin panel

On Tue 28 May, 2019, 1:29 PM Akshay Jain,  wrote:

> Hello,
>
> Is anyone aware of any django admin theme for creating a dashboard(similar
> to django-suit). I've been working with django-suit or quite a while now,
> but as it's way too outdated and python2.7 is also retiring, I want to use
> the latest version of django and python. But as per the requirements of my
> company, there has to be some robust theme for the admin interface.
>
> Can anyone suggest some good theme?
>
> --
> Regards,
> Akshay Jain
>
> --
> 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/CADn2MUPW5uV2rNZd5zRYQryUMxFFY4WnRXbOCWXpmSrmTa2F8A%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEyEc5QXHOZCdG9rkU6W1NCHZ%2BCszSSdSJpzrrfsiJ85Ey1X5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Theme for django admin interface.

2019-05-28 Thread Akshay Jain
Hello,

Is anyone aware of any django admin theme for creating a dashboard(similar
to django-suit). I've been working with django-suit or quite a while now,
but as it's way too outdated and python2.7 is also retiring, I want to use
the latest version of django and python. But as per the requirements of my
company, there has to be some robust theme for the admin interface.

Can anyone suggest some good theme?

-- 
Regards,
Akshay Jain

-- 
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/CADn2MUPW5uV2rNZd5zRYQryUMxFFY4WnRXbOCWXpmSrmTa2F8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to restore Models original Properties - Problem in Models column Exclude

2019-05-28 Thread Balaji Shetty
Dear  Alexis Roda Sir

Thank You very much for your nice reply. I check it.

On Tue, May 28, 2019 at 1:55 AM Alexis Roda <
alexis.roda.villalo...@gmail.com> wrote:

> Not an admin expert here.
>
> You are modifying the modeladmin instance and, by the behavior you're
> describing, it looks like it is a global (shared) object. I'm guessing, you
> can confirm this by printing id(self) in add_view(). I'll bet you get the
> same value in each request, so the instance is shared, so the change is
> visible (persisted) across request boundaries.
>
> You may think about adding self.exclude = () in the else branch in order
> to not exclude anything. Don't do that, you may end up leaking private
> information to dgp if both root and dgp are logged in at the same time.
>
> Instead override the get_exclude method.
>
> See
> https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_exclude
>
> --
> 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/CAMDYoXbb42hpu3jAATXTwxPw9kO8XeZpLOczbNa-Bzw5QAdGuQ%40mail.gmail.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/CAECSbOv-cB_VgQgp6V6SgkyvpyxScJuoEOB2nwi3C%3D7Ahi6aWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.