Re: Internal server error

2015-01-18 Thread Edgar Gabaldi
Nicky, Internal server error means that your application has a programming
error. You can see your webserver log to find the error to fix.

On Sun, Jan 18, 2015 at 5:43 PM, Nicky Setia  wrote:

> Hi,
> I am following the Django tutorial and after I put my site up using
> Dreamworks hosting, it is giving me internal server error. Has anyone
> encountered this before? Any help would be appreciated!
>
> Thanks,
> Nicky
>
> --
> 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/D34A328B-1A3A-41F1-894B-7E79FC3ED817%40gmail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPH%3DCBGLL_3w55FfeGFjkyCPr4L4%2BwjMJrMttNzJ8aJxB-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Windows path for django_crontab

2015-01-18 Thread Edgar Gabaldi
To do periodic tasks you can use celery[1]. I believe that on windows works
fine.

[1] http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html

On Sun, Jan 18, 2015 at 9:24 PM, Mike Dewhirst 
wrote:

> On 19/01/2015 8:54 AM, sarfaraz ahmed wrote:
>
>> Hello All,
>>
>> I am trying to use django_crontab to run repetitive task. I want to
>> insert records to database on a particular time. Also, I am in process
>> of learning django hence I m trying to reach every aspect of django.
>>
>> The issue i am facing i m able to configure django_crontab but its not
>> able to find cron.py. I am using windows 7 and i believe it must be
>> something else for windows
>>
>
> There is no cron/crontab on Windows. You need a Linux operating system for
> crontab and for testing django-crontab.
>
> You could install a Linux machine on Windows using Virtualbox or use some
> other VM hosting solution. Or repurpose an old piece of hardware you might
> have floating about.
>
> If you want to go into production on Windows you will have to manually
> schedule the jobs you want. There may be utilities out there which will let
> you interface with the Windows scheduling system.
>
>
>> CRONJOBS = [
>>  ('*/5 * * * *', 'dms.Drop_Slot_Management.cron.my_scheduled_job')
>> ]
>>
>> dms is my project directory.
>>
>> When I run the command manage.py crontab add it gives error saying "The
>> system cannot find the path specified."
>>
>> I am using Windows.
>>
>> Please help..
>>
>> Regards,
>> Sarfaraz Ahmed
>>
>> --
>> 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/9ad0f430-
>> 458f-4113-b6be-2d61ab3ec447%40googlegroups.com
>> > 458f-4113-b6be-2d61ab3ec447%40googlegroups.com?utm_medium=
>> email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/54BC40B5.7070704%40dewhirst.com.au.
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPH%3Dkk4Nf%3DMELq-0ONFk%2Bi-JWvpbmg4D-91-Ye2yJYCQxJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.contrib.auth doesn't support template context processors?

2015-01-20 Thread Edgar Gabaldi
did you register the context processor in settings?

On Tue, Jan 20, 2015 at 3:32 AM, Mark Rogaski  wrote:

> Hello,
>
> I'm coming back to Django after working with 1.4/1.5.  Within a custom
> template for auth.views.password_reset, I'd like to access the request
> data using django.core.context_processors.request.  But it doesn't look
> like any template context processors are applied.
>
> It's not a big problem for me, but it seems that the contrib packages
> should support this ... it's really a lovely feature.  Has anyone else run
> into this or know if this is something that is slated to be added?
>
> Thanks,
> Mark
>
> --
> 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/df79e5ef-67e0-41fd-9ca1-af4d0eaefd4f%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHmx3dMssdOOdTDCHy35hSV-TQoZfSrymYGmA_6Vm0a7qA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django select extremely slow on large table

2015-01-23 Thread Edgar Gabaldi
You can try to put a db_index=True in markid field.

https://docs.djangoproject.com/en/1.7/ref/models/fields/#db-index

On Fri, Jan 23, 2015 at 9:59 AM, Jani Tiainen  wrote:

> On Fri, 23 Jan 2015 03:38:19 -0800 (PST)
> Joris Benschop  wrote:
>
> > And to keep replying to myself:
> >
> > This one is slow:
> > x=Marker.objects.raw("SELECT * from PROD_SCHEMA.MARKER WHERE MARKID=
> > %s",[u'TO1'])
> > print x[0]
> >
> > This one is fast:
> > y=Marker.objects.raw("SELECT * from PROD_SCHEMA.MARKER WHERE MARKID=
> 'TO1'")
> > print y[0]
> >
> > If I copy the table and make the  MARKID field in NVARCHAR2(20), then it
> > uses the index properly on both counts
> >
> > So... so do I make django use ascii? is there a field type?
>
> You could try explicit cast to VARCHAR2, not sure does that help at all:
>
> x=Marker.objects.raw("SELECT * from PROD_SCHEMA.MARKER WHERE
> MARKID=CAST(%s AS VARCHAR2)",[u'TO1'])
>
>
> --
> Jani Tiainen
>
> --
> 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/20150123135923.25a181aa%40jns42-l.w2k.keypro.fi
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHn5R8z1KyKQkCPqUL415VK2Wxgfa%2Bsm3NevU_mMonivtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Restrict downloading files in Django?

2015-01-31 Thread Edgar Gabaldi
i don't know if this is the best way to do that. But you can create a view
that response the file after verify the user credentials.

The problem is:  once the user knows the urls from file, he can share the
url with others.

Its not difficult create an "one time url" to the request to solve this
problem.

On Sat, Jan 31, 2015 at 2:52 PM, Robert Rössler 
wrote:

> Hello,
> what is the best way to restrict downloading files only to authorized
> users?
> I want to let users upload files and let them download them, but restrict
> downloading other users files.
>
> 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 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/f67b7248-72e2-4ed9-95b6-66604598bc62%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHksBZ%3Df_wtyyX-NDM4n-XKWi_LsR3q6os1g17xv%3D%3DAbSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: secretar...@atoutpass.fr

2015-02-03 Thread Edgar Gabaldi
Sorry, i don't speak french.

can i help you?

Merci :)

On Tue, Feb 3, 2015 at 12:12 PM, Alain Abraham  wrote:

>  Bonjour,
> c’est Alain.
>
> Juste une pièce jointe à montrer à Jean-Pierre.
>
> Merci
>
> Alain
>
>   --
> 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/F2A4DCFC-E229-4FC3-B500-B1C9ACD34AC1%40gmail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHmpwZVm-uG2feoYSMO1piU7pH%2B7AbUDwRNY%2BEY3b49sZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: secretar...@atoutpass.fr

2015-02-03 Thread Edgar Gabaldi
Sorry, i think that was a private message.

On Tue, Feb 3, 2015 at 1:27 PM, Edgar Gabaldi  wrote:

> Sorry, i don't speak french.
>
> can i help you?
>
> Merci :)
>
> On Tue, Feb 3, 2015 at 12:12 PM, Alain Abraham  wrote:
>
>>  Bonjour,
>> c’est Alain.
>>
>> Juste une pièce jointe à montrer à Jean-Pierre.
>>
>> Merci
>>
>> Alain
>>
>>   --
>> 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/F2A4DCFC-E229-4FC3-B500-B1C9ACD34AC1%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/F2A4DCFC-E229-4FC3-B500-B1C9ACD34AC1%40gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: Read Only by user in Django Admin

2015-02-08 Thread Edgar Gabaldi
The ModelAdmin has a method get_readonly_fields [1]. You can override this
method and check a custom permission[2].

[1]
https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields
[2] https://docs.djangoproject.com/en/1.7/ref/models/options/#permissions

On Sun, Feb 8, 2015 at 12:44 PM, Hangloser Firestarter 
wrote:

> Hello.
> I am using the admin backend of a system, but not all users of this
> backend can access all system models.
> By default Django is the roles ADD, EDIT and DELETE, I wonder if anyone
> has customized the model auth.permission to generate a permission 'read
> only' to Django Admin? Or if you have used any APP to do that.
>
> Thank
>
> --
> 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/977d9fa7-0f27-4346-8322-e7938f263fac%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHk%2BrhFCgm2V9-qJri0YMkmaOzqdUp%3DZpPQv25rhfp1vaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Read Only by user in Django Admin

2015-02-08 Thread Edgar Gabaldi
In the get_readonly_fields, you have access to the request.user, you can
check the permission inside the method, something like that:


def get_readonly_fields(self, request, obj=None):

if obj and not request.user.has_perm('your_app.your_custom_permission'):
# return a tuple with all fields that needs to be read only.
return None

You can add your custom permission to a group.

On Sun, Feb 8, 2015 at 12:55 PM, Hangloser Firestarter 
wrote:

> Gabaldi.
>
> Can I integrate this get_readonly_fields with auth.groups?
>
> And show whitelisted django admin.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e376a4ce-dd8d-4ba9-9dbd-f0fbfc96bd96%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHmmTuX2%3DoAn24My0j%2BhZdthWcajSPfrLHoa6%3D8ase6jhg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


The best way to mock querysets

2015-04-30 Thread Edgar Gabaldi
Who practices TDD (XP like) says that the tests need to run quickly. For
this, we have to mock all external resources of the method that i want to
test.

In the case of queryset, i think so strange. Eg:
https://gist.github.com/edgabaldi/ffdffa60f2add650f052

Am i doing it wrong? Do i have better way to do that?

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


Re: want some suggestion to learn elastic search

2015-07-01 Thread Edgar Gabaldi
Use the django-haystack[0]. He's a wrapper for some search engines
(including elastic search). it's very simple to use. The getting start
tutorial[1] is very simple too.


[0] http://haystacksearch.org/
[1]http://django-haystack.readthedocs.org/en/v2.4.0/tutorial.html

On Wed, Jul 1, 2015 at 8:37 AM, Code Dish  wrote:

> Hello all,
>
> Can you guys , suggest me what the basic things reguired to learn
> elastic search for django project for learning purpose.
> please reply...
>
> --
> 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/5bf05d6d-b3d4-4e4a-8e75-6899aa6c10c2%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHmjyXS9orLZhriO60isFvFD_HzkSvM3o7MGy2u2734cHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: FormSets with arbitary number of forms

2015-01-01 Thread Edgar Gabaldi
The formset allow you create many instances of an object. What you need is
the inline formset. When you create a Album, you can create one or more
songs.

On Wed, Dec 31, 2014 at 4:59 PM, Some Developer 
wrote:

> I've been reading the documentation on FormSets and must admit that I am a
> bit confused.
>
> I have a model called Album that contains many Songs. But when a user
> creates a new album I have no idea how many songs the Album will contain.
>
> So I want to create a FormSet that has an Album form and many Song forms
> but I need the user to be able to decide how many Song forms there are in
> advance. Is this possible?
>
> I might be misunderstanding the documentation but I couldn't see anything.
>
> --
> 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/54A447A2.4010804%40googlemail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHk3xZ3r_ugBLA_crVWe4dym8nd0-q029B_-A2fP%2BYS9Rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: create unmanaged model to oracle view/synonym

2015-01-01 Thread Edgar Gabaldi
Fabio,

Django ORM support Oracle Database[1].

If you want connect an existing oracle database, i recomend you see the
inspectdb management command.

[1] https://docs.djangoproject.com/en/1.7/ref/databases/#oracle-notes
[2] https://docs.djangoproject.com/en/1.7/howto/legacy-databases/


On Thu, Jan 1, 2015 at 2:40 PM, Shai  wrote:

> Hi Fábio,
>
> On Wednesday, December 31, 2014 6:05:05 PM UTC+2, Fabio Caritas
> Barrionuevo da Luz wrote:
>>
>> Hello, is possible with Django 1.7 create a unmanaged Django model for
>> Oracle database View?
>>
>>
>>
> Yes. In your model's Meta, set managed to False and db_table to the view
> name:
>
> class MyUnManagedModel(models.Model):
> # ...
> # fields
> # ...
> class Meta:
> managed = False
> db_table = 'view_name'
>
> Have you run into difficulties?
>
> HTH,
> Shai.
>
> --
> 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/bf043f16-043a-4f0f-a6bf-2856c405be43%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPH%3DM8k9MWOKuiqL0ABPiG-G9PwGOeJ_4yLLFifz6rVDoZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django form field validation and error display

2015-01-08 Thread Edgar Gabaldi
There is not your problem, but maybe will be in future. The best way to
clean fields that depend of other fields is override the clean method of
form.

https://docs.djangoproject.com/en/1.7/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

On Thu, Jan 8, 2015 at 9:28 AM, 赵飞  wrote:

> That's it!  Thanks very very much, you help me a lot!
>
> 2015-01-08 19:10 GMT+08:00 James Schneider :
>
>> Oh, you are passing a URL to render() instead of a template name. Try
>> something like this:
>>
>> return render(request, 'signup.html', {'form': signup_form})
>>
>> Sorry, didn't catch that the first time.
>>
>> -James
>>
>>
>> On Thu, Jan 8, 2015 at 1:34 AM, 赵飞  wrote:
>>
>>> I want to make a signup page, when user click signup, it will check if
>>> the two password are the same, when not, give a error message after
>>> "confirm password".
>>>
>>> But when I call "return render(request, reverse("accounts:signup"),
>>> {'form': signup_form}) " in my views.py, it shows me an error, the
>>> traceback is:
>>>
>>>  Environment:
>>>
>>> Request Method: POST
>>>Request URL: http://127.0.0.1:8000/accounts/signup_post/
>>>
>>>Django Version: 1.7
>>>Python Version: 2.7.5
>>>Installed Applications:
>>>('django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>> 'accounts')
>>>Installed Middleware:
>>>('django.contrib.sessions.middleware.SessionMiddleware',
>>> 'django.middleware.common.CommonMiddleware',
>>> 'django.middleware.csrf.CsrfViewMiddleware',
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>> 'django.middleware.clickjacking.XFrameOptionsMiddleware')
>>>
>>>Template Loader Error:
>>>Django tried loading these templates, in this order:
>>>Using loader django.template.loaders.filesystem.Loader:
>>>Using loader django.template.loaders.app_directories.Loader:
>>>
>>>Traceback:
>>>File
>>> "/Users/feizhao/.virtualenvs/nahan/lib/python2.7/site-packages/django/core/handlers/base.py"
>>> in get_response
>>>  111. response = wrapped_callback(request,
>>> *callback_args, **callback_kwargs)
>>>File "/Users/feizhao/dropbox/nahan/accounts/views.py" in signup_post
>>>  64. return render(request, reverse("accounts:signup"), {'form':
>>> signup_form})
>>>File
>>> "/Users/feizhao/.virtualenvs/nahan/lib/python2.7/site-packages/django/shortcuts.py"
>>> in render
>>>  48. return HttpResponse(loader.render_to_string(*args,
>>> **kwargs),
>>>File
>>> "/Users/feizhao/.virtualenvs/nahan/lib/python2.7/site-packages/django/template/loader.py"
>>> in render_to_string
>>>  170. t = get_template(template_name, dirs)
>>>File
>>> "/Users/feizhao/.virtualenvs/nahan/lib/python2.7/site-packages/django/template/loader.py"
>>> in get_template
>>>  144. template, origin = find_template(template_name, dirs)
>>>File
>>> "/Users/feizhao/.virtualenvs/nahan/lib/python2.7/site-packages/django/template/loader.py"
>>> in find_template
>>>  136. raise TemplateDoesNotExist(name)
>>>
>>>Exception Type: TemplateDoesNotExist at /accounts/signup_post/
>>>Exception Value: /accounts/signup/
>>>
>>> my account app looks like:
>>>
>>>$ tree -L 3 accounts
>>>accounts
>>>├── __init__.py
>>>├── admin.py
>>>├── forms.py
>>>├── locale
>>>│   └── zh_CN
>>>├── migrations
>>>│   ├── 0001_initial.py
>>>│   ├── __init__.py
>>>├── models.py
>>>├── static
>>>│   └── accounts
>>>│   └── login.css
>>>├── templates
>>>│   └── accounts
>>>│   ├── base.html
>>>│   ├── login.html
>>>│   └── signup.html
>>>├── tests.py
>>>├── urls.py
>>>├── views.py
>>>
>>>  urls.py:
>>>
>>> urlpatterns = patterns(
>>>'',
>>>url(r'^accounts/', include('accounts.urls', namespace="accounts"
>>> )),
>>>url(r'^admin/', include(admin.site.urls)),
>>>)
>>>
>>> accounts/urls.py:
>>>
>>> urlpatterns = patterns(
>>>'',
>>>url(r'^login/$', views.login, name='login'),
>>>url(r'^signup/$', views.signup, name='signup'),
>>>url(r'^login_post/$', views.login_post, name='login_post'),
>>>url(r'^signup_post/$', views.signup_post, name='signup_post'),
>>>)
>>>
>>> signup_post function in views.py:
>>>
>>> def signup_post(request):
>>>if request.method == 'POST':
>>>signup_form = forms.SignupForm(request.POST)
>>>
>>>if signup_form.is_valid():
>>>signup_info = signup_form.cleaned_data
>>>username = signup_info['username']
>>>email = signup_info['email']
>>>   

Re: Django Class-Based CreateView and UpdateView with multiple inline formsets

2015-01-10 Thread Edgar Gabaldi
Use the django-extra-views[1]. You can easily manage multiple inline
formsets with CreateViews and UpdateViews.

[1] https://github.com/AndrewIngram/django-extra-views

On Sat, Jan 10, 2015 at 11:23 AM, Dan Gentry  wrote:

> I would suggest that in the UpdateView you should set the object to the
> master record being updated rather than to none for both get() and post().
>
>
> On Saturday, January 10, 2015 at 8:08:47 AM UTC-5, Ranjith Kumar wrote:
>>
>> Hello all,
>> I have been trying to do Django class-based CreateView and UpdateView
>> with multiple inline formsets
>>
>> CreateView works fine but UpdateView is not working properly, If anyone
>> tried UpdateView with multiple inline formsets, please point me right
>> approach.
>>
>> *models.py*
>> from django.db import models
>>
>> class Recipe(models.Model):
>> title = models.CharField(max_length=255)
>> description = models.TextField()
>>
>> class Ingredient(models.Model):
>> recipe = models.ForeignKey(Recipe)
>> description = models.CharField(max_length=255)
>>
>> class Instruction(models.Model):
>> recipe = models.ForeignKey(Recipe)
>> number = models.PositiveSmallIntegerField()
>> description = models.TextField()
>>
>> *forms.py*
>> from django.forms import ModelForm
>> from django.forms.models import inlineformset_factory
>> from .models import Recipe, Ingredient, Instruction
>>
>> class RecipeForm(ModelForm):
>> class Meta:
>> model = Recipe
>>
>> IngredientFormSet = inlineformset_factory(Recipe, Ingredient, extra=0)
>> InstructionFormSet = inlineformset_factory(Recipe, Instruction, extra=0)
>>
>> *views.py*
>> from django.http import HttpResponseRedirect
>> from django.views.generic.edit import CreateView, UpdateView
>> from django.shortcuts import get_object_or_404
>>
>> from .forms import IngredientFormSet, InstructionFormSet, RecipeForm
>> from .models import Recipe
>>
>> class RecipeCreateView(CreateView):
>> template_name = 'recipe_add.html'
>> model = Recipe
>> form_class = RecipeForm
>> success_url = '/account/dashboard/'
>>
>> def get(self, request, *args, **kwargs):
>> self.object = None
>> form_class = self.get_form_class()
>> form = self.get_form(form_class)
>> ingredient_form = IngredientFormSet()
>> instruction_form = InstructionFormSet()
>> return self.render_to_response(
>> self.get_context_data(form=form,
>>   ingredient_form=ingredient_form,
>>   instruction_form=instruction_form))
>>
>> def post(self, request, *args, **kwargs):
>> self.object = None
>> form_class = self.get_form_class()
>> form = self.get_form(form_class)
>> ingredient_form = IngredientFormSet(self.request.POST)
>> instruction_form = InstructionFormSet(self.request.POST)
>> if (form.is_valid() and ingredient_form.is_valid() and
>> instruction_form.is_valid()):
>> return self.form_valid(form, ingredient_form,
>> instruction_form)
>> else:
>> return self.form_invalid(form, ingredient_form,
>> instruction_form)
>>
>> def form_valid(self, form, ingredient_form, instruction_form):
>> self.object = form.save()
>> ingredient_form.instance = self.object
>> ingredient_form.save()
>> instruction_form.instance = self.object
>> instruction_form.save()
>> return HttpResponseRedirect(self.get_success_url())
>>
>> def form_invalid(self, form, ingredient_form, instruction_form):
>> return self.render_to_response(
>> self.get_context_data(form=form,
>>   ingredient_form=ingredient_form,
>>   instruction_form=instruction_form))
>>
>> class RecipeUpdateView(UpdateView):
>> template_name = 'recipe_add.html'
>> model = Recipe
>> form_class = RecipeForm
>>
>> def get_success_url(self):
>> self.success_url = '/account/dashboard/'
>> return self.success_url
>>
>> def get_context_data(self, **kwargs):
>> context = super(RecipeUpdateView, self).get_context_data(**
>> kwargs)
>> if self.request.POST:
>> context['form'] = RecipeForm(self.request.POST,
>> instance=self.object)
>> context['ingredient_form'] = IngredientFormSet(self.request.POST,
>> instance=self.object)
>> context['instruction_form'] = 
>> InstructionFormSet(self.request.POST,
>> instance=self.object)
>> else:
>> context['form'] = RecipeForm(instance=self.object)
>> context['ingredient_form'] = IngredientFormSet(instance=
>> self.object)
>> context['instruction_form'] = InstructionFormSet(instance=
>> self.object)
>> return context
>>
>> def post(self, request, *args, **kwargs):
>> self.object = None
>> form_class = self.get_form_class()
>> form = 

Re: updating data in a row

2015-01-11 Thread Edgar Gabaldi
add or update multiple rows, maybe you should see a little about
formsets[1].

[1] https://docs.djangoproject.com/en/1.7/topics/forms/formsets/

On Mon, Jan 12, 2015 at 12:30 AM, sum abiut  wrote:

> I want to be able to click on a row, update it and then click on another
> row update it and so on.
>
> On Mon, Jan 12, 2015 at 12:58 PM, sum abiut  wrote:
>
>> Thanks very much Vijay its works. But it doesn't really solve my problem,
>> because i want to be able to edit more than one rows in a table not just
>> one row. any help will be very much appreciated.
>>
>> Cheers,
>>
>>
>>
>>
>> On Mon, Jan 12, 2015 at 11:38 AM, Vijay Khemlani 
>> wrote:
>>
>>> If you changed the url mapping then you need to include the id of the
>>> newleave in the URL you are accessing, for example
>>>
>>> http://10.0.X.X:8000/update_form/1/
>>>
>>> On Sun, Jan 11, 2015 at 7:27 PM, sum abiut  wrote:
>>>
 Hi James,

 I am try to visit this url http://10.0.X.X:8000/update_form/



 here is the traceback:


 Request Method: GET
 Request URL: http://10.0.x.x:8000/update_form/

 Django Version: 1.7.1
 Python Version: 2.7.6
 Installed Applications:
 ('django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'eLeave')
 Installed Middleware:
 ('django.contrib.sessions.middleware.SessionMiddleware',
  'django.middleware.common.CommonMiddleware',
  'django.middleware.csrf.CsrfViewMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  'django.contrib.messages.middleware.MessageMiddleware',
  'django.middleware.clickjacking.XFrameOptionsMiddleware')


 Traceback:
 File
 "/var/www/html/env/local/lib/python2.7/site-packages/django/core/handlers/base.py"
 in get_response
   111. response = wrapped_callback(request,
 *callback_args, **callback_kwargs)

 Exception Type: TypeError at /update_form/
 Exception Value: update_form() takes exactly 2 arguments (1 given)



 thanks,






 On Fri, Jan 9, 2015 at 4:46 PM, James Schneider <
 jrschneide...@gmail.com> wrote:

> What URL are you visiting and can you post the traceback?
> On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:
>
>> Hi,
>> I have change the URL mapping to  url(r'^update_form/(?P\d+)
>> /$', 'eLeave.views.update_form'),
>>
>> but i am getting the error
>>
>> Page not found (404)
>>
>> any advise i am getting this error?
>>
>>
>> cheers
>>
>> On Fri, Jan 9, 2015 at 3:20 PM, Vijay Khemlani 
>> wrote:
>>
>>> You have two choices
>>>
>>> 1. Change the URL mapping and pass the "id" in the url
>>>
>>> url(r'^update_form/(?P\d+)/$', 'eLeave.views.update_form'),
>>>
>>> (then the url is something like /update_form/15/)
>>>
>>> 2, Change the view so that it only accepts the "request" argument
>>>
>>> def update_form(request):
>>>
>>> in that case you can pass the id in the POST body of the request
>>>
>>>
>>> On Fri, Jan 9, 2015 at 12:50 AM, sum abiut 
>>> wrote:
>>>
 hi James,
 here is the url.py

url(r'^update_form/$', 'eLeave.views.update_form'),



 On Fri, Jan 9, 2015 at 2:19 PM, James Schneider <
 jrschneide...@gmail.com> wrote:

> Looks like you aren't sending enough arguments to your view from
> the URL dispatcher. What does your urls.py look like?
>
> -James
> On Jan 8, 2015 6:49 PM, "sum abiut"  wrote:
>
>>
>> Hi,
>> i am trying to update data in a row from an existing database but
>> i keep getting this error.
>>
>> update_form() takes exactly 2 arguments (1 given)
>>
>> can someone advise what i am missing here.
>>
>>
>> here are my code:
>>
>> view.py
>>
>> def update_form(request, id):
>> if request.method == 'POST':
>> a=newleave.objects.get(id=id)
>> form =leave_application(request.POST, instance=a)
>> if form.is_valid():
>>form.save()
>> return HttpResponseRedirect('successful.html')
>> else:
>> a=newleave.objects.get(id=id)
>> form = leave_application(instance=a)
>> return render_to_response('update_form.html', {'form': 
>> form},context_instance=RequestContext(request))
>>
>> form.py
>>
>> class leave_application(forms.ModelForm):
>> class Meta:
>>  

Re: Django Class-based Views with Multiple Forms

2016-07-11 Thread Edgar Gabaldi
Hi paul. There is a package called django-extra-views that solve exactly
this problem.

See CreateViewWithInlines (or something like that).

Em 7h40 Seg, 11/07/2016, Paul  escreveu:

> By default Django’s class-based views support just a single form per view.
>
> I need more forms per view because I want to combine a ForeignKey
> relations with various ModelForm instances and also to appear in the
> FormModel.
>
> In Django documentation and other tutorials I found formsets, but in the
> default examples you repeat the same form multiple times, which is not what
> I need.
>
> Inline formsets looks like what I need , but I didn't found an example for
> GBV like CreateView. Can you give me some examples, link to a tutorial ?
>
> 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/0cd0a748-1d47-4750-b566-1e8451d8b530%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/CAGjPPHkW_71OnkomphxAZV9qSAHeh84O_fd7G3YmB7kcpNPyKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-20 Thread Edgar Gabaldi
The code seems right. Probably your form has some error. Try print
{{form.errors}} in your template to check.

On Thu, Aug 20, 2015 at 4:45 PM, Hugo Kitano  wrote:

> Hi, I'm a beginner using Django, and I'm having trouble using model forms
> to create instances of my model.
> When a user submits a form, the database saves nothing.  Here's my code
> for the view
>
> def submit(request):
>
> SubmissionForm = modelform_factory(Submission, fields=('sub_name',
> 'sub_file'))
>
> if request.method == "POST":
>
> form = SubmissionForm(request.POST)
>
> if form.is_valid():
>
> model_instance = form.save(commit=False)
>
> model_instance.sub_date = timezone.now()
>
> model_instance.save()
>
> return HttpResponseRedirect('http://localhost:8000/stats/')
>
> else:
>
> form = SubmissionForm()
>
> return render(request, 'stats/submit.html', {'form': form})
>
>
> And here's my template:
>
>
>  Submit form: 
> 
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
>
>
> I'd appreciate any help. Thansk!
>
>
> Hugo
>
> --
> 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/af4016f0-65e5-4a5c-99e9-7f544e7ced7c%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHn0f-rdRKDd4J9sA%3DVbH4R7zTvyPmMYv-dCb80%3DiLq%2Bsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Admin actions with select optgroup

2016-03-30 Thread Edgar Gabaldi
Hi everybody,

Someone know if is possible or have a way to change the default action
select by a select with optgroup?

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