Re: Add filter to admin add page?

2019-10-23 Thread Nelson Varela
Or even better... whu not use django's own auto complete feature in the 
admin: 
https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields

Op dinsdag 22 oktober 2019 00:07:40 UTC+2 schreef Wil Moskal:
>
> I have a model registered to the admin page, AuthUserFilePermissions, 
> which consists of 2 foreign keys, a key to the defined groups, and a key to 
> the filepatterns. Within the add AuthUserFilePermissions, there is a select 
> for each. For the group this is fine, as there is only like 7-8. for the 
> file patterns this is not good, as there are over 1000 file patterns. What 
> I am trying to do is implement a search filter for the file pattern entry, 
> similar to how in the add group page there is a filter for the permissions, 
> around the select. Any Idea how I could complete this?
>
> On a side note, the fields that I am entering within my modelAdmins are 
> not appearing on the add page, so it would also be good to know why not. 
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7d64be84-4f32-486f-804a-897f674dd749%40googlegroups.com.


Re: Expire Password Reset Link

2019-10-23 Thread Nelson Varela
Why give out more than one link? Why not use get_or_create to make link or 
use existing link for that user?



Op woensdag 23 oktober 2019 15:06:17 UTC+2 schreef prabhakaran karthikeyan:
>
> If an user requests a password reset link, clicking on it will make the 
> link expirable. Suppose, user requests more than one link mistakenly, just 
> need to expire the first link . The user should get reset form only from 
> recent link. Any help is appreciated. Thank You.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d1bd6182-8583-42ed-b767-36e1c4d1eed8%40googlegroups.com.


Re: Django redirect to a view function after selecting an item from dropdown box

2019-09-13 Thread Nelson Varela
check the value of your form field in the post. Based on that value you van 
do stuff

Op woensdag 11 september 2019 14:39:12 UTC+2 schreef Rudolph Louis Cabeltis:
>
> Hello,
>
> I am using Forms by Django. And that form has a select box with two 
> options.
> After a user selected an option. I would like the user to do the function 
> in the django view.
> Will I be able to do this without using AJAX or Javascript?
>
> Thank you.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f194d750-3a48-4c28-83b2-ca12c1394c73%40googlegroups.com.


Re: Django Post request erro

2019-09-13 Thread Nelson Varela
You have to close your first form.

So put  somewhere before the second form

Op vrijdag 13 september 2019 15:53:48 UTC+2 schreef Ruturaj Singare:
>
> Hi Everyone I got one problem I have 2 form in index.html but having its 
> own url pattern but both forms redirects to on e url using post request can 
> you please help me.  
>
> I am your regular subscriber on youtube 
> Please help
>
> My url patterns :
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', views.index, name='index'),
> path('home', views.index, name='index'),
> path('paid', views.paid, name='paid')
> ]
>
>
> My index.html form section
>
>  
> 
> {% csrf_token %}
> 
> 
>
>   
>   
> 
>   Sr. No
>   Menu Items
>   Quantity
> 
>   
>   
>  {% for order in orderList %}
> 
>   {{ forloop.counter }}
>   {{ order.MenuItem }}
>   {{ order.Qty }}
> 
> {% endfor %}
>   
> 
>  
>   {% csrf_token %}
>   
>   
>  
>   
>
>
>
> 
>
> I think all ok but not working
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9052b0d8-576b-48f6-bf22-3d657316c762%40googlegroups.com.


Re: Django html form post request error

2019-09-13 Thread Nelson Varela
You have to close your first form.

So put  somewhere before the second form

Op vrijdag 13 september 2019 15:54:11 UTC+2 schreef Ruturaj Singare:
>
> Hi Everyone I got one problem I have 2 form in index.html but having its 
> own url pattern but both forms redirects to on e url using post request can 
> you please help me.  
>
> Both are forms are going to redirect on same url that is /home why second 
> form are not going to on /paid
> I didn't understand. Please help
>
>
> My url patterns :
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', views.index, name='index'),
> path('home', views.index, name='index'),
> path('paid', views.paid, name='paid')
> ]
>
>
> My index.html form section
>
>  
> 
> {% csrf_token %}
> 
> 
>
>   
>   
> 
>   Sr. No
>   Menu Items
>   Quantity
> 
>   
>   
>  {% for order in orderList %}
> 
>   {{ forloop.counter }}
>   {{ order.MenuItem }}
>   {{ order.Qty }}
> 
> {% endfor %}
>   
> 
>  
>   {% csrf_token %}
>   
>   
>  
>   
>
>
>
> 
>
> I think all ok but not working
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5dcf72a3-1f2d-4bd2-b4d5-5043b029914e%40googlegroups.com.


Re: Hi

2019-07-09 Thread Nelson Varela
Yes

-- 
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/44156c4c-10f2-4dd4-bf25-9bf70f20f153%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to

2019-05-17 Thread Nelson Varela
Take a look at django permissions/groups models where you can make groups 
and put these models in each group. After that you add the users to the 
group so they can only edit models in that group

On Monday, May 13, 2019 at 9:30:08 AM UTC+2, Balaji Shetty wrote:
>
> Hi
> Consider the demo Example
>
> models.py
>
>
>
> *from django.db import models
>
> class Musician(models.Model):
> first_name = models.CharField(max_length=50)
> last_name = models.CharField(max_length=50)
> instrument = models.CharField(max_length=100)
>
> class Album(models.Model):
> artist = models.ForeignKey(Musician, on_delete=models.CASCADE)
> name = models.CharField(max_length=100)
> release_date = models.DateField()
> num_stars = models.IntegerField()*
>
> *class Fan(models.Model):
> artist = models.ForeignKey(Musician, on_delete=models.CASCADE)
> Conutry = models.CharField(max_length=100)
> **Name = models.CharField(max_length=100)
> *
>
> Here We have to keep Track of Musician Album as well as all Fan/Follower 
> of respective Musician.
>
>
> Admin.py
>
>
>
> *class AlbumInline(admin.TabularInline):
> model = Album*
>
> *class FanInline(admin.TabularInline):
> model = Fan*
>
>
> class MusicianAdmin(admin.ModelAdmin):
>
> inlines = [*AlbumInline,FanInline *, ]
>
> # code to register these 3 models
> -
>
> I have seperate Login User Account for Album 
> I have seperate Login User Accpunt for Fan 
>
>
> *My Question is*
>
>
> *I want to add only Album record in Album Login Account*
>
>
>
> *I want to add only Fan Record in Fan Login Account*
>
>
> *Currently *
> *In both login, Album and Fan Records can be added.  How cam i restrict 
> these?*
>
> -- 
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bssh...@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/e4a2ad0a-901c-4862-b313-9492783628cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: no migrations to apply after deleting a field in models

2019-05-08 Thread Nelson Varela
Don't delete the 0001_initial file!
That is your first state. Just delete the field from you model and do 
makemigrations again.. You wil get a 0002_ file which deletes the field.


-- 
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/2dab1505-795b-491b-9bf9-18d65ca85634%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reverse not found problem

2019-05-02 Thread Nelson Varela
I think you can not render variable in a template tag, so:

{% static "/icons/{{newspaper}}.png" %}

maybe should be

{% static "/icons/" %}{{newspaper}}.png


-- 
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/4f2a0b3a-ab7c-46b2-8fdd-020c2bf8fd2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models and forms

2019-04-29 Thread Nelson Varela
What do you have so far. show some code or explain what you have so far

On Monday, April 22, 2019 at 1:40:06 PM UTC+2, Shereyne Casimsiman wrote:
>
> I am current making a project and django is very new to me, I've been 
> following tutorials but it did not answer my concern..
> My project is to build a quiz that will have an audio as the question . I 
> already installed  the django-audiofield and successfully added it into the 
> admin but my problem is that I don't know how to show it in the templates 
> please help me ... I am running out of time  
>

-- 
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/c126f0ba-21c3-4123-9a43-37fd92121bd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Set user permission via python

2019-04-11 Thread Nelson Varela
Correction:

u, created = User.objects.get_or_create(username="user_name", defaults={'
email': 'user...@example.com', 'password': 'blah'})


-- 
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/0c6782d4-ee22-4f90-a299-a6010e5626ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Set user permission via python

2019-04-11 Thread Nelson Varela
Glad you've found the solution. 
One thing I wanted to advice you is to use the get_or_create method on User.
For more detail check the django documentation.
So:
u, created = User.objects.get_or_create(username="user_name", defaults={
email='user...@example.com', password='blah'})

-- 
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/f426be95-6606-4ab8-851a-8b3e6d87c434%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need some sample project coding in Django t

2019-03-28 Thread Nelson Varela
The django documentation will help you build a project yourself which can 
help you a lot understanding django:


https://docs.djangoproject.com/en/2.1/intro/tutorial01/

On Thursday, March 28, 2019 at 2:59:12 PM UTC+1, Anbarasi Ayyannan wrote:
>
> Hi,
>  I am Django learner need some help for learning.Can you please help me 
> with providing me some sample project ? so that i can understand better.
>
> Regards,
> Anbarasi 
>

-- 
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/4a4ae89d-3238-457c-a025-68be04b9684e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to override the ModelAdmin "change" form ?

2019-02-28 Thread Nelson Varela
You maybe want a model admin view where you can send the user to and 
collect the data you want to comare and show warnings

-- 
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/2b4e6166-2f8a-40f0-9f0d-a5c7c8df494e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Loading Django views inside template with JQuery

2019-01-23 Thread Nelson Varela
Use iframes which loads the three different views

-- 
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/b041c366-cafc-49b9-905f-8b681a9e15c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I need help guys please

2019-01-23 Thread Nelson Varela
Say what 

> Say what?
>

-- 
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/49402962-6631-446e-8c71-24526b4bf9db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Confusion in user and superuser

2018-12-14 Thread Nelson Varela
Superusers are users with special powers... they can do everything!
I don't think you want to add a superuser via a form...
If you want a form to create a superuser you should make your own 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/f2837942-dab6-49cb-8caa-0ce14df1a615%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModelMultipleChoiceField doesn't display objects

2018-12-12 Thread Nelson Varela
Check: 
https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_horizontal
Maybe this helps

-- 
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/89fe6f40-6036-4d08-8f15-aca6103a6e36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why created_at is greater than updated_at while inserting data in table

2018-11-28 Thread Nelson Varela
I think it has to do with django adding timezone.now() on each field with 
auto_now on it when saving to the databse.. the code for the first field 
will get timezone.now() slightly earlier then the second one 

-- 
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/c3ab68d5-386b-46a9-a7b3-bcb033e2ad3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Logging a button click

2018-11-27 Thread Nelson Varela
Look good but what is going wrong? Do you see an error or ...?

-- 
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/bb00ea13-56e9-4f6c-a529-5e45272d6f03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Human Readable Values

2018-11-27 Thread Nelson Varela
show your code that renders the values

-- 
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/bed468b7-eed5-4b57-a060-eef1793795a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: help

2018-11-27 Thread Nelson Varela
where is your view and your template in which you show the form and handle 
the from

-- 
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/63c77d1a-f4f6-48a2-82e5-25101b752ed7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template

2018-11-15 Thread Nelson Varela
This is just a guess... but I think no... I am really sure you can 
find it. here:
https://docs.djangoproject.com/en/2.1/topics/templates/

-- 
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/e3accace-4f3b-4b0a-a8e5-4ad2f548eed5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to move readonly_fields on top of page?

2018-11-05 Thread Nelson Varela
Yeah. If you define read only fields in django model admin it places the 
read only fields after non-readonly fields by default in the change view

-- 
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/973221ba-1df3-40e6-ab1e-45b5d2773cb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: foreign key is not working

2018-11-02 Thread Nelson Varela
Please do add some code so we can see what is going wrong



On Friday, November 2, 2018 at 5:44:38 AM UTC+1, amit pant wrote:
>
> i used all method which is on docs but still it's not working properly.
>  i am using django 2 with pyhton 3
>
>
> On Wed, Oct 31, 2018 at 5:28 PM Paras Patidar  > wrote:
>
>> Use:
>> on_delete = models.CASCADE
>> In Foreign Key
>>
>> On Wed 31 Oct, 2018, 5:15 PM amit pant, > 
>> wrote:
>>
>>> i used foreign key for make relationship between two model class but it 
>>> does not work properly, i used this for make subscription and on first 
>>> model their is choices for subscription.
>>> help me why it is not working
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/ccb94b40-2c2d-4202-bfb9-37459770b99a%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...@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/CAK-hKekN4hsqHexxoWww2Y%3DzsJukwx2PfH02D%2B%3DAF_qqfYQYyg%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/020c93ba-d543-4ac1-bdd2-71eaf61eda3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: new to django

2018-10-18 Thread Nelson Varela

did you install django... 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/359e2b8a-fc18-4c22-870a-27713f73768c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin Filtering Drop Down Menu by Date

2018-10-12 Thread Nelson Varela

>
> You could make a custom form for your admin which is a model form which 
> points to EmployeeSchedule. And in the form its init you can change the 
> queryset of the events field:
>

self.fields['events'].queryset = WineryEvents.objects.filter(publish='Y').
filter(event_date__gte=datetime.now()).order_by('event_date')

 

-- 
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/bc032148-9263-4ae9-adaa-51f90d8f3cb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "Project object has no attribute review_set"

2018-10-12 Thread Nelson Varela
Use the .review you've defined as related name. The _set is when you don't 
have a related name.

-- 
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/1e336950-7f74-4da6-b34d-767a485743a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: While registering the user with django form, it gives "UNIQUE constraint failed: auth_user.username" error

2018-10-08 Thread Nelson Varela
You do not have to save the user 2 times in your form:

user = user_form.save()
user.save()

Maybe this is also the problem...

-- 
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/16c6d1c3-4698-4ad4-bcb2-81ff8f1c4f8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: same card can belong to multiple users but only in different time periods

2018-10-08 Thread Nelson Varela
Django has DateRangeField but that is only available if you are using 
postgres

On Monday, October 8, 2018 at 1:10:04 PM UTC+2, Shareef 617 wrote:
>
> Consider a project where users can have many cards (or anything else, card 
> is just an example), and the same card can belong to multiple users *but 
> only in different time periods*. So if a card is assigned to user from 
> 1.09.2014 to 1.10.2014 (dd/mm/), then the same card can be assigned to 
> another user but only for time period that ends before 1.09.2014 or starts 
> after 1.10.2014. I hope you get it.
>
> I've created the following models:
>
> class User(models.Model):
> cards = models.ManyToManyField(Card, through="UsersCards")
>
> class UsersCards(models.Model):
> user = models.ForeignKey(User)
> card = models.ForeignKey(Card)
> start_date = models.DateField()
> end_date = models.DateField()
>
>

-- 
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/051e2658-0a5a-4002-a973-dcb12bc04b9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When I click on submit button on login page, its redirecting to an random csrf token page in django

2018-09-24 Thread Nelson Varela
Do you have 'django.middleware.csrf.CsrfViewMiddleware' in your list of 
middlewares in your settings?

On Monday, September 24, 2018 at 2:52:33 PM UTC+2, Srinivas Gadi wrote:
>
>
> When I clock on the login page, it supposed to save the data in DB but 
> instead URL being redirected to csrf token page.
>
> url.py
>
> from django.conf.urls import urlfrom . import viewsfrom 
> django.contrib.auth.views import login, logout
>
> urlpatterns = [
> url(r'^$', views.home),
> url(r'home',views.home, name='home page'),
> url(r'login',login,{'template_name':'section/login.html'}),
> url(r'logout',logout,{'template_name':'section/logout.html'}),
> url(r'register',views.register, name='register')
>
> ] views.py
>
> def register(request):if  request.method == 'POST':
> form = UserCreationForm(request.POST)
> if form.is_valid:
> form.save()
> print('data has been saved')
> return redirect('section/home')
> else:
> form = UserCreationForm()
> args={'form':form}
> return render(request,'section/reg_form.html',args)
>
> reg_form.html
>
> {% extends "base.html" %}{% block body %}
> {%  csrf_token %}
> {{ form.as_p }}Login{% endblock  %}
>
> Please advise
>
> -- 
> Srinivas .G
>   9966559383
>

-- 
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/6be4f994-abdf-4045-af80-da17eabdf886%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at / ' homepage' is not a registered namespace

2018-06-29 Thread Nelson Varela
You don't have of did not configure the urls.py
there should be an url which points to the view

-- 
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/e5ecca0b-e638-470d-98d7-32ce1477f62a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie : Object copy - weird error :-)

2018-06-26 Thread Nelson Varela
The following class is kinda weird:
class DataModel(DataModel):

A class which inherits itself???



On Tuesday, June 26, 2018 at 11:31:24 AM UTC+2, mickae...@gmail.com wrote:
>
> Hi all :-)
>
> I'd like to archive some data.
>
> I did that :
>
> class AbstractDataModel(models.Model):
> xxx
>
> class Meta:
> abstract = True
>
>
> def __iter__(self):
>
> return iter([self.xxx, self.yyy, self.zzz, self.aaa,
> self.qqq, self.mode_bbb])
>
>
> class DataModel(DataModel):
>
> pass
>
>
> class DataModelArchive(DataModel):
> # 
> https://stackoverflow.com/questions/21699707/python-how-to-copy-all-attibutes-from-base-class-to-derived-one
> def __init__(self, source=None):
> if source is not None:
> self.__dict__.update(source.__dict__)
>
>
> But when I want to access data in DataModelArchive, like 
> DataModelArchive.objects.all() for example,
> I get 
>
> Traceback (most recent call last):
>   File "/home/.../tests.py", line 1090, in test_archive
> print(DataModelArchive.objects.all())
>   File 
> "/home/.../venv/lib/python3.6/site-packages/django/db/models/query.py", 
> line 248, in __repr__
> data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File 
> "/home/.../venv/lib/python3.6/site-packages/django/db/models/query.py", 
> line 272, in __iter__
> self._fetch_all()
>   File 
> "/home/.../venv/lib/python3.6/site-packages/django/db/models/query.py", 
> line 1179, in _fetch_all
> self._result_cache = list(self._iterable_class(self))
>   File 
> "/home/.../venv/lib/python3.6/site-packages/django/db/models/query.py", 
> line 63, in __iter__
> obj = model_cls.from_db(db, init_list, row[model_fields_start:
> model_fields_end])
>   File "/home/.../lib/python3.6/site-packages/django/db/models/base.py", 
> line 507, in from_db
> new = cls(*values)
> TypeError: __init__() takes from 1 to 2 positional arguments but 11 were 
> given
>
> What am I doing wrong ?
>
> Thx
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/39aca8ec-6d6c-4e33-8a91-4dadda6620b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TemplateDoesNotExist at / Error WIth Django 1.8.4 (URGENT)

2015-10-06 Thread Nelson Varela
Did you notice the name of your template? It says login.html.html


On Tuesday, October 6, 2015 at 12:23:45 PM UTC+2, dannette opot wrote:
>
> I get the above error when I try to access the login.html.
>
> Attached are my application files.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a72d4f97-d508-454d-a918-a85558e2c03e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What's the better way to get settings.DEBUG in a view?

2015-04-30 Thread Nelson Varela
from django.conf import settings

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d6b46b7-12d6-4ce9-8cf9-caf69f98247e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Login in all pages

2015-02-06 Thread Nelson Varela
Take a look at middleware.

You can create a middleware which runs for every request. In 'process_request' 
you can check if the user is authenticated. If not... show or redirect to the 
login view.

The advantage is that you don't have to worry about placing decorators above 
your views.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bb02623a-2439-4c51-b05d-9f0f1bc2a78a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Putting picture thumbnails within admin page

2015-01-30 Thread Nelson Varela
Make sure you are serving the media fles usins django's static server

from django.conf import settings 
urlpatterns += patterns('', 
url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': 
settings.MEDIA_ROOT, 'show_indexes': False}), )





On Tuesday, January 27, 2015 at 1:31:54 AM UTC+1, bradford li wrote:
>
>
> I am trying to put thumbnail pictures of my photos within my admin page. I 
> am currently running into the issue where the thumbnail isn't displayed, 
> when I click on thumbnail I am redirected to the homepage of my project 
> with this as the URL: 
>
> http://127.0.0.1:8000/media/tumblr_ngotb4IY8v1sfie3io1_1280.jpg
>
> Here is a gist of my code: 
>
> https://gist.github.com/liondancer/678752e8bf31cc7d2c63
>
> Stackoverflow question:
>
>
> http://stackoverflow.com/questions/28159740/configuring-admin-to-display-thumnails
>
> If anything else is needed please let me know! 
>
>
>
> 
>
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/28015f00-5b4c-45ea-97d5-d19955763c49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Help a newb with authentication and registration

2015-01-18 Thread Nelson Varela
Hi,

I don't know what allauth does but you can check the django docs about custom 
auth and user model:

https://docs.djangoproject.com/en/1.7/topics/auth/customizing/

Maybe not what you are looking for but it's a good documentation whichs can 
help you understand more about this topic.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4d3e863d-6047-47ea-9bf2-99538d53e952%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.