Re: Use one correspondig database user for each application user

2017-07-13 Thread guettli
Just for the records, I found a blog post how to use row level security in 
postgres with one application db-user:

https://blog.2ndquadrant.com/application-users-vs-row-level-security/

Here is the essential code:

SET my.username = 'tomas'

CREATE POLICY chat_policy ON chat
USING (current_setting('my.username') IN (message_from, message_to))
WITH CHECK (message_from = current_setting('my.username'))

Regards,
  Thomas Güttler



Am Dienstag, 11. Juli 2017 11:40:53 UTC+2 schrieb guettli:
>
> I guess most applications have exactly one database user.
>
> Why not use one database for each application user?
>
> Example: User "foo" in my web application has a corresponding database 
> user "foo".
>
> This way you could use row level security from the database.
>
> PostgreSQL has a lot of interesting features: 
> https://www.postgresql.org/docs/devel/static/ddl-rowsecurity.html
>
> Use case: Show me all items which user "foo" is allowed to see.
>

-- 
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/31eae2b7-d473-49c0-9342-07cb8a5a1358%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Use one correspondig database user for each application user

2017-07-13 Thread Antonis Christofides
BTW,

another idea for "connecting" to PostgreSQL as different users would be to
actually have Django connect to PostgreSQL as a superuser and then (probably in
some early middleware) execute SET SESSION AUTHORIZATION to switch permissions.
This is probably easier and more robust and it's easier to reuse connections.

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com

On 2017-07-13 11:13, guettli wrote:
> Just for the records, I found a blog post how to use row level security in
> postgres with one application db-user:
>
> https://blog.2ndquadrant.com/application-users-vs-row-level-security/
>
> Here is the essential code:
>
> SET my.username = 'tomas'
>
> CREATE POLICY chat_policy ON chat
> USING (current_setting('my.username') IN (message_from, message_to))
> WITH CHECK (message_from = current_setting('my.username'))
>
> Regards,
>   Thomas Güttler
>
>
>
> Am Dienstag, 11. Juli 2017 11:40:53 UTC+2 schrieb guettli:
>
> I guess most applications have exactly one database user.
>
> Why not use one database for each application user?
>
> Example: User "foo" in my web application has a corresponding database
> user "foo".
>
> This way you could use row level security from the database.
>
> PostgreSQL has a lot of interesting features:
> https://www.postgresql.org/docs/devel/static/ddl-rowsecurity.html
> 
>
> Use case: Show me all items which user "foo" is allowed to see.
>
> -- 
> 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/31eae2b7-d473-49c0-9342-07cb8a5a1358%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/ffb7c5c2-3b43-3d8a-252d-832a082742f1%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: Vim plugin that does Django code completion?

2017-07-13 Thread 'Tom Evans' via Django users
Hi Robert

Ignore the helpful people telling you to stop using vim and use some
god awful UI, the plugin you are looking for is called jedi.vim

https://github.com/davidhalter/jedi-vim

Debian has a package, vim-python-jedi, or you can install using
Pathogen or Vundle.

Cheers

Tom

On Fri, Jul 7, 2017 at 4:27 PM, Robert F.  wrote:
> Is there a Vim plugin that does code completion for Django?  I'd like to be
> able to type something like "foobar = models." and hit Tab and see a list of
> classes like CharField or Foreign key.  Alternately, I'd be OK with entering
> an abbreviation that would bring up the proper code snippet.  The Django
> documentation suggests YouCompleteMe but it appears to only handle Python
> code, not Django specifically.  Also, I haven't been able to get it to work
> on my Mac laptop.
>
> I almost exclusively do editing of Django files on a remote Debian server
> from my Mac laptop.  I know PyCharm provides the ability to edit remote
> files and it has Vim emulation but it's pretty expensive and I'm not sure
> how closely the emulator emulates Vim.  SublimeText appears to have a
> "Djaneiro" package that does what I need but it looks like editing remote
> files is rather difficult with Sublime.  Doesn't Vim have better support for
> Django code completion that's comparable to these two applications?
>
> --
> 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/166226ca-2fc6-4454-9baf-0d871c552a8f%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/CAFHbX1LySk_S4BBrTOho8mWD6AcJM8JO231%2B25rmnZOBjS0YWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Crispy forms not showing bootstrap and save/submit button

2017-07-13 Thread Taufiq Rahman
Hey guys. I'm having trouble with Crispy forms with my models. The form 
shows up plain without the bootstrap and there seems to be no save button 
which i need to save data to my model. I have tried many ways and tutorials 
but have failed. Any help would be highly appreciated! 

forms.py

from django import forms
from crispy_forms.helper import FormHelper
from .models import Plot


class PlotForm(forms.ModelForm):
helper = FormHelper()
helper.form_tag = False
helper.form_method = 'POST'

class Meta:
model = Plot
fields = '__all__'


the html:





Plot form


{% load crispy_forms_tags %}

{% block content %}
   {% crispy form %}
{% endblock %}






views.py

def plot_form(request):
return render(request, 'plot_form.html', {'form': PlotForm()})



-- 
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/3e334309-2f7c-4df1-8065-e57d864be378%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


help with Django tutorial "writting our first Django app" part 4

2017-07-13 Thread Rafael Valle Cabrera

Hi everyone

I am getting started with Django. 

My doubt is about the tutorial called ‘Writing our first Django app’

For everyone who doesn’t know about it, it’s a tutorial where you start 
developing a polls app.
I am in the part where i have to do the forms.

I am doing part 4:
https://docs.djangoproject.com/en/1.11/intro/tutorial04/
and it’s happening to me the following situation:


polls/templates/polls/detail.html

{{ question.question_text }}

{% if error_message %}{{ error_message }}{% endif %}


{% csrf_token %}
{% for choice in question.choice_set.all %}
    
    {{ choice.choice_text 
}}
{% endfor %}




polls/views.py

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect, HttpResponse
from django.urls import reverse

from .models import Choice, Question
# ...
def vote(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    try:
    selected_choice = question.choice_set.get(pk=request.POST['choice'])
    except (KeyError, Choice.DoesNotExist):
    # Redisplay the question voting form.
    return render(request, 'polls/detail.html', {
    'question': question,
    'error_message': "You didn't select a choice.",
    })
    else:
    selected_choice.votes += 1
    selected_choice.save()
    # Always return an HttpResponseRedirect after successfully dealing
    # with POST data. This prevents data from being posted twice if a
    # user hits the Back button.
    return HttpResponseRedirect(reverse('polls:results', 
args=(question.id,)))

def results(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    return render(request, 'polls/results.html', {'question': question})



polls/templates/polls/results.html

{{ question.question_text }}


{% for choice in question.choice_set.all %}
    {{ choice.choice_text }} -- {{ choice.votes }} vote{{ 
choice.votes|pluralize }}
{% endfor %}


Vote again?


I am doing the polls app, and when i hit the button ‘Vote’, the page always 
shows me the error message:
“You didn’t select any choice.”

Moreover, it doesn’t show any radio button to select a certain choice and once 
i have hit the button, it never redirects me to the results page. Also, i can’t 
see the number of votes in the results page.

I have reviewed several times the code, and it looks like the same as the 
tutorial one. (Even, i have replaced it but it doesn’t work)

Any idea about why the input element doesn’t show in the choice page and 
doesn’t allow me to vote?

Thanks for help beforehand
Rafa



Libre de virus. www.avast.com 


---
El software de antivirus Avast ha analizado este correo electrónico en busca de 
virus.
https://www.avast.com/antivirus

-- 
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/59676a29.4c3e1c0a.f78f.862b%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: save cropped image with PIL to database

2017-07-13 Thread 'Tom Evans' via Django users
On Mon, Jul 3, 2017 at 11:09 AM, shahab emami  wrote:
> hello
>
> i have a question and i cant find answer with search.
>
> i want to save cropped image in database then :
> this is my model:
>
> class Photo(models.Model):
> file= models.ImageField(upload_to='%Y/%m/%d',
> blank=True,null=True)
>
>
> i have a form then user can select image and send to view like this:
>
> 
> {% csrf_token %}
>
>   
>
> 
>
>   
>
>
> and in the view i have this :
>
> from PIL import Image
>
>
> def save_photo(request):
>
> _photo, created = models.Photo.objects.get_or_create(pk=1)
>
> if request.method == 'POST':
> photo = request.FILES.get('file')

This is a django.core.files.File (or subclass) object. It is file-like
and can be treated as a file.

>
> image = Image.open(photo)
>
> cropped_image = image.crop((100, 100, 200, 200))
> resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS)

resized_image is a pil.Image. Again, it is file-like, but it is not a
django.core.files.File...

> _photo.file = resized_image
> _photo.save()

so this doesn't work. You will need to wrap the PIL.Image file-like
object with the django File class (remember appropriate imports):

_photo.file = File(resized_image)
_photo.save()


Cheers

Tom

-- 
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/CAFHbX1%2BTeg-joCvt%3DosHTThpzduQ0_ZYr%2BKvMfbD%3DJJPHZ2gcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django implementation group by every two hours,

2017-07-13 Thread 'Tom Evans' via Django users
On Tue, Jul 11, 2017 at 10:22 AM, kanhaiya yadav
 wrote:
> Hi,
>
> I have a model
> class XyzModel (models.Model):
>name = models.CharField(max_length=NAME_LENGTH)
>unique_id = models.CharField(max_length=NAME_LENGTH)
>info = models.CharField(max_length=NAME_LENGTH, blank=True)
>violation_time = models.DateTimeField()
>
>
>
>
> I have many rows in the database. So I want to group by the results for
> every two hours or for every four hours.
> I want the result something like
>
> name   violation_date
> interval counts
> abc   2017-07-01
> 06:00 - 08:00   20
> xyz   2017-07-01
> 08:00 - 10:00   30
>
> My query is
> XyzModel.objects
> .extra({"day": "date_trunc('hour',violation_time)"}
> .values("day")
> .order_by("day")
> .annotate(count=Count("id"))
> But using this query I can only group the result by one hour interval. I
> want to group by more than one hour interval.

You realise your "day" parameter is actually hours, right?

.extra({'day', 'TRUNC(EXTRACT(hour FROM violation_time) / 2)'})

'day' will then be the 0-based index of the 2 hour periods, starting
from midnight, so a value of 5 would mean 10 AM - 12 AM.

Cheers

Tom

-- 
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/CAFHbX1KQBaTFkwV6Ar%3DfK9RM-vU-8GB_C6MsaPrLwQSko6Yv3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create a fixed-length binary field with a unique constraint?

2017-07-13 Thread 'Tom Evans' via Django users
On Tue, Jul 11, 2017 at 12:05 AM, Mike Morris  wrote:
> From your description (save a SHA-256 checksum),  you do not need a binary
> field. Binaries are always of indeterminant length; they can hold photos,
> executables, sound files, etc.
>
> By definition, a SHA -256 is 256 bytes of ASCII.
>
> You probably want a CharField(length=256).
>

BinaryField is arbitrary size, binaries are not. The binary
representation of a SHA-256 is significantly smaller (it's 256 *bits*,
or 32 bytes), hence why the OP wants to store his binary objects in
the most efficient format possible, not 2 or 8 times that size.

Its like storing an IPv4 address as the 15 bytes string
"10.123.132.254" or the 4 byte integer 175867134.

Guido:

You can make your own custom database types quite simply (completely untested):

class FixedSizedBinaryField(models.BinaryField):
  def __init__(self, num_bytes=None, *args, **kwargs):
self.nbytes = num_bytes
super(FixedSizedBinaryField, self).__init__(*args, **kwargs)

  def deconstruct(self):
name, path, args, kwargs = super(FixedSizedBinaryField, self).deconstruct()
kwargs[''num_bytes'] = self.nbytes
return name, path, args, kwargs

  def db_type(self, connection):
return "binary(%d)" % self.nbytes

For more details, check out the docs on custom fields:

https://docs.djangoproject.com/en/1.11/howto/custom-model-fields/

Cheers

Tom

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


Re: Problem with views PasswordChangeView vs. password_change

2017-07-13 Thread Carsten Fuchs

Am 13.07.2017 um 16:56 schrieb Carsten Fuchs:

the   success_url='lori:pwd_done'   seems to be a problem


This seems to be the root also of the original problem (SuspiciousOperation…): 
If I insert a plain URL, e.g. success_url='/pwd_done/', then I can no longer 
reproduce the original problem either.


Best regards,
Carsten

--
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/a2656884-54a3-c465-e7e9-f1bf1720db5c%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: How to create a fixed-length binary field with a unique constraint?

2017-07-13 Thread winkelmann
On Thursday, July 13, 2017 at 4:06:38 PM UTC+2, Tom Evans wrote:
 [...]

> Guido: 
>
> You can make your own custom database types quite simply (completely 
> untested): 
>
> class FixedSizedBinaryField(models.BinaryField): 
>   def __init__(self, num_bytes=None, *args, **kwargs): 
> self.nbytes = num_bytes 
> super(FixedSizedBinaryField, self).__init__(*args, **kwargs) 
>
>   def deconstruct(self): 
> name, path, args, kwargs = super(FixedSizedBinaryField, 
> self).deconstruct() 
> kwargs[''num_bytes'] = self.nbytes 
> return name, path, args, kwargs 
>
>   def db_type(self, connection): 
> return "binary(%d)" % self.nbytes 
>
> For more details, check out the docs on custom fields: 
>
> https://docs.djangoproject.com/en/1.11/howto/custom-model-fields/ 
>

Thanks for the suggestion. I am now working with this custom field class (I 
actually found the relevant documentation and the solution myself in the 
meantime. It's almost identical to yours, except without a configurable 
length):

class SHA256Field(models.BinaryField):
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 32
super(SHA256Field, self).__init__(*args, **kwargs)

def deconstruct(self):
name, path, args, kwargs = super(SHA256Field, self).deconstruct()
del kwargs["max_length"]
return name, path, args, kwargs

def db_type(self, connection):
return "BINARY(32)"

This works very well for me - in MySQL/MariaDB. I haven't tested it with 
any other database systems.

Regards,

Guido
 

-- 
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/15f8406e-998f-4822-8afe-a636f8699177%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Crispy forms not showing bootstrap and save/submit button

2017-07-13 Thread JHeasly
Hello Taufiq —

Have you tried using the "instance level helper"?
See 
http://django-crispy-forms.readthedocs.io/en/latest/crispy_tag_forms.html#crispy-tag-with-forms
>From the docs link above:

from crispy_forms.helper import FormHelper
class ExampleForm(forms.Form):
[...]
def __init__(self, *args, **kwargs):
super(ExampleForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()



Hope this helps,
John

-- 
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/0ece72e2-2890-4c9c-9520-27608f57a198%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django multi table on same model

2017-07-13 Thread Kalvin Handilist


down votefavorite 


I have huge table that needed to be sliced into some smaller table, ex: 
campaign_01, campaign_02, ... While using django queryset with different 
table name for same model, what I only know to set table name on a model 
is: Model._meta.db_table = 'tableXXX'

However this method doesn't work in single shell/request. (only work for 
first time, but not for the next) -> maybe because it still on same 
instance? After the second time we tried to set _meta.db_table = 
'tableYYY', it will occur an error "django.db.utils.ProgrammingError: 
missing FROM-clause entry for table "tableXXX""

I also have tried some suggestion I read for this problem answer like:

class ListingManager(models.Manager):
def get_custom_obj(self, table_name):
self.model._meta.db_table = table_name
return self
class ObjectName(models.Model):
objects = ListingManager()

Try to create an Object manager to get new object, but it not work, it 
still throw same error as before (on the second time setting _meta.db_table)

The only way to make it work if we want to set multiple times for 
_meta.db_table is we need to exit() the shell first, then re-enter the 
shell mode (which means for loop is not gonna work).

I know it can be achieved with raw query 'Insert into tableXXX values ()', 
but any method to do it using django queryset? 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/fba2ca9e-874f-45b8-b285-3c116fefb036%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bug: Manually changing "_meta.db_table" for model causes "missing FROM-clause entry for table" error

2017-07-13 Thread Kalvin Handilist
Hi I encounter same problem as your, do you already got the solution? Any 
help will be appreciated, thank you~

On Saturday, November 14, 2015 at 1:40:21 AM UTC+7, evil...@gmail.com wrote:
>
> Hello.
> I've got the same model in two projects and want to copy data from one to 
> another using model meta 'db_table' option:
>
>
> my_model_original_table_name = MyModel._meta.db_table
> MyModel._meta.db_table = 'old_project_table_name' 
>
> old_objects = MyModel.objects.using('old_project_data_base').values('name')
> old_objects = list(old_objects)
>
> MyModel._meta.db_table = my_model_original_table_name
>
> for old_object in old_objects:
> new_object, created = 
> MyModel.objects.update_or_create(name=old_object['name'])
>
>
> Old data retrieving works great, but when i try to execute last statement 
> i get:
> "django.db.utils.ProgrammingError: missing FROM-clause entry for table 
> "old_project_table_name""
>
> I tied to fetch data at the last stage instead of updating/creating 
> (MyModel.objects.all()) and get the same error.
> The sql-query created by ORM is:
> SELECT "old_project_table_name"."name" FROM "new_project_table_name"
>
> Why is it so?
>
> I am using django 1.8.6 and PostgreSQL 9.4.5
> Django 1.7.* work fine.
>
>
> 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/0b3e71a1-ac34-459b-a2b0-32086492077d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Crispy forms not showing bootstrap and save/submit button

2017-07-13 Thread JHeasly
Also, do you have any FormActions defined? That's where the Bootstrap 
button comes from:
http://django-crispy-forms.readthedocs.io/en/latest/layouts.html#bootstrap-layout-objects

-- 
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/75fb72c8-00d9-42fe-896e-66fa0a938cee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bug: Manually changing "_meta.db_table" for model causes "missing FROM-clause entry for table" error

2017-07-13 Thread Guilherme Leal
I don't think that sould be possible to change real table name "on the
fly". If I'm not mistaken, that kind of attribute is used by model's meta
class during class creation process to populate the django model cache,
which in turn only occurs during the django configuration step.

2017-07-13 14:08 GMT-03:00 Kalvin Handilist :

> Hi I encounter same problem as your, do you already got the solution? Any
> help will be appreciated, thank you~
>
> On Saturday, November 14, 2015 at 1:40:21 AM UTC+7, evil...@gmail.com
> wrote:
>>
>> Hello.
>> I've got the same model in two projects and want to copy data from one to
>> another using model meta 'db_table' option:
>>
>>
>> my_model_original_table_name = MyModel._meta.db_table
>> MyModel._meta.db_table = 'old_project_table_name'
>>
>> old_objects = MyModel.objects.using('old_pro
>> ject_data_base').values('name')
>> old_objects = list(old_objects)
>>
>> MyModel._meta.db_table = my_model_original_table_name
>>
>> for old_object in old_objects:
>> new_object, created = MyModel.objects.update_or_crea
>> te(name=old_object['name'])
>>
>>
>> Old data retrieving works great, but when i try to execute last statement
>> i get:
>> "django.db.utils.ProgrammingError: missing FROM-clause entry for table
>> "old_project_table_name""
>>
>> I tied to fetch data at the last stage instead of updating/creating
>> (MyModel.objects.all()) and get the same error.
>> The sql-query created by ORM is:
>> SELECT "old_project_table_name"."name" FROM "new_project_table_name"
>>
>> Why is it so?
>>
>> I am using django 1.8.6 and PostgreSQL 9.4.5
>> Django 1.7.* work fine.
>>
>>
>> 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/ms
> gid/django-users/0b3e71a1-ac34-459b-a2b0-32086492077d%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/CAOs3Lp6-30AfypgUbFhC%2Bhtq6i9p7dXQBiKgS_ih4%2Bij8D9Kug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


BPMN and django

2017-07-13 Thread tatoluffy
Are there any part o framework in django to use notation BPMN? 
Could be possible integrate interface of SAP in django forms?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e6a5cf1-a903-4afe-b8a1-9ec3cf62354b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with views PasswordChangeView vs. password_change

2017-07-13 Thread Tim Graham
The success_url of PasswordChangeView (actually the behavior comes from the 
inherited FormView) only accepts a URL, not a URL name. You can update to 
your code like this: 

from django.urls import reverse_lazy
...
success_url=reverse_lazy('lori:pwd_done')

On Thursday, July 13, 2017 at 11:44:43 AM UTC-4, Carsten Fuchs wrote:
>
> Am 13.07.2017 um 16:56 schrieb Carsten Fuchs: 
> > the   success_url='lori:pwd_done'   seems to be a problem 
>
> This seems to be the root also of the original problem 
> (SuspiciousOperation…): 
> If I insert a plain URL, e.g. success_url='/pwd_done/', then I can no 
> longer 
> reproduce the original problem either. 
>
> Best regards, 
> Carsten 
>

-- 
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/dbc3d0cd-2ae1-4a31-878b-b8ba9ac71ad0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django beginner

2017-07-13 Thread Amir Pirmoradian
Hey Guys, i'm a absolute beginner  at Django. I started to learn django 
from https://www.djangoproject.com but it's too confusing.
I know python completely.
My question is:Should i know anything else except python to learn 
Django?because i don't understand Django at all.Or i should try harder?

-- 
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/1d33e1c7-42fb-414d-b8d7-b6441a6d0cfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django beginner

2017-07-13 Thread Lachlan Musicman
Amir

You will need a basic - very basic - understanding of databases and
webservers.

The webserver will serve your content.
The database will store your content.

For databases, you need to know: how to create one, add a user, give that
user a password. (easy, can google)
For webservers, you need to know how to config to get it serving your
content. (medium, can google - although if you are just developing and
testing locally while you learn, you don't even need to use this - just
./manage runserver )

After that, it's all python.

So - what is it you don't understand?

The Django Tutorial remains one of the best tutorials I've ever used:
https://docs.djangoproject.com/en/1.11/intro/tutorial01/

Cheers
L.


--
"Mission Statement: To provide hope and inspiration for collective action,
to build collective power, to achieve collective transformation, rooted in
grief and rage but pointed towards vision and dreams."

 - Patrisse Cullors, *Black Lives Matter founder*

On 14 July 2017 at 09:48, Amir Pirmoradian 
wrote:

> Hey Guys, i'm a absolute beginner  at Django. I started to learn django
> from https://www.djangoproject.com but it's too confusing.
> I know python completely.
> My question is:Should i know anything else except python to learn
> Django?because i don't understand Django at all.Or i should try harder?
>
> --
> 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/1d33e1c7-42fb-414d-b8d7-b6441a6d0cfc%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/CAGBeqiNn-LqYgSGCNK%2B28i6d9RUzbh1BQc52okVo18vadfRXaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django beginner

2017-07-13 Thread Mike Morris

Start with the Tutorial on the djangoproject.com website. Finish it.

Then, some other sources I like:

 * https://tutorial.djangogirls.org/en/
 * http://www.tangowithdjango.com/

Google "django tutorials", there are lots




On 07/13/2017 04:48 PM, Amir Pirmoradian wrote:
Hey Guys, i'm a absolute beginner  at Django. I started to learn 
django from https://www.djangoproject.com but it's too confusing.

I know python completely.
My question is:Should i know anything else except python to learn 
Django?because i don't understand Django at all.Or i should try harder?

--
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/1d33e1c7-42fb-414d-b8d7-b6441a6d0cfc%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/41a2f397-6250-29c3-cae8-00ef47e508d3%40musicplace.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django beginner

2017-07-13 Thread Oladipupo Elegbede
Hi Amir,

You seem to know what you need to do.

Try harder, be positive and pay attention to those little things you think
Python has taken care of for you.

Get yourself through the Django tutorial and you would be good to go.

On Jul 13, 2017 6:51 PM, "Amir Pirmoradian" 
wrote:

> Hey Guys, i'm a absolute beginner  at Django. I started to learn django
> from https://www.djangoproject.com but it's too confusing.
> I know python completely.
> My question is:Should i know anything else except python to learn
> Django?because i don't understand Django at all.Or i should try harder?
>
> --
> 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/1d33e1c7-42fb-414d-b8d7-b6441a6d0cfc%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/CAHjgLX6CuE%3DziWEzzqL7THwht1mr1jZ9aF8BGjLOeKg1wgZeGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django beginner

2017-07-13 Thread yingi keme
Try getting the book 'django unleashed'. It is one of the most comprehensive 
books for absolute beginners in django.

Also learn http basics, it will be valuable to understand the client/server 
model of django.

Yingi Kem

> On 14 Jul 2017, at 12:48 AM, Amir Pirmoradian  
> wrote:
> 
> Hey Guys, i'm a absolute beginner  at Django. I started to learn django from 
> https://www.djangoproject.com but it's too confusing.
> I know python completely.
> My question is:Should i know anything else except python to learn 
> Django?because i don't understand Django at all.Or i should try harder?
> -- 
> 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/1d33e1c7-42fb-414d-b8d7-b6441a6d0cfc%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/ADC9787D-0B56-4011-9E0C-65379BD3CC66%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django beginner

2017-07-13 Thread Mike Dewhirst

On 14/07/2017 9:48 AM, Amir Pirmoradian wrote:
Hey Guys, i'm a absolute beginner  at Django. I started to learn 
django from https://www.djangoproject.com but it's too confusing.

I know python completely.
My question is:Should i know anything else except python to learn 
Django?because i don't understand Django at all.Or i should try harder?


You should be OK. But don't try and understand *how* the python in 
Django does what it does. Just figure out what you want to do and use 
Django to achieve that.


You might need a reasonable understanding of data relationships because 
Django converts your pythonic description of those relationships into 
actual PostgreSQL tables and provides the API for you to create and use 
the data.


You also need to understand the client request and server response 
architecture of the web. Again, don't try to figure out the python in 
Django which does that. Just use Django methods to save yourself the 
effort of coding it yourself.


You'll be good to go as soon as you dive in.

IMO Django is fabulous!


--
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/1d33e1c7-42fb-414d-b8d7-b6441a6d0cfc%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/f05775a4-28a0-7619-c474-a95b2d2170d2%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.