Re: CSRF token still needed today?

2020-04-19 Thread Alex Heyden
Django supports samesite on session cookies now, and it's on (set to lax)
by default. Whether or not that completely covers your surface risk to CSRF
attacks is a somewhat different question.

On Sun, Apr 19, 2020 at 3:12 PM guettli 
wrote:

> iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
> ... and then I look at this page: https://scotthelme.co.uk/csrf-is-dead/
>
> Is a CSRF token still needed today?
>
> All my users use a modern browser.
>
> It would be very nice if I could get rid of the CSRF token.
>
> Is there a safe way to avoid CSRF tokens in  my Django project?
>
> Regards,
>   Thomas
>
> --
> 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/487c7392-e874-4a1e-a1ff-488ab933ae42%40googlegroups.com
> 
> .
>

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


Re: [Django] How to retrieve the saved password in raw format

2019-10-21 Thread Alex Heyden
Password tables should never be human-readable. Never ever. No exceptions.

If the intent is to power automation, store that password where the test
agent can read it. If you don't know the password, reset it, then save it.
Don't expect your web server to leak a password, though. Not even if you
ask it nicely.

On Mon, Oct 21, 2019 at 1:16 PM Dilipkumar Noone  wrote:

> Dear Django group,
>
> In one of my View i need UserName & Password details in raw format but
> Django uses *PBKDF2*  algorithm to
> store the password.
>
> I would like to know how to retrieve the saved password from
> Authentication Form.
>
> Using these Username and password details from my Django app , i need to
> use the same credentials to access another website to perform web
> automation on it using selenium chrome webdriver.
>
> Please let us know how to get the password in raw format once user
> authenticated using below LoginForm and login_view.
>
> *My forms.py:*
> *===*
>
> forms.py:
> ===
>
> class LoginForm(AuthenticationForm):
>
> remember_me = forms.BooleanField(required=True, initial=False)
>
> def __init__(self, *args, **kwargs):
>
> super(LoginForm, self).__init__(*args, **kwargs)
> self.helper = FormHelper()
> self.helper.form_action = '.'
> self.helper.layout = Layout(
> Field('username', placeholder="Enter Username", autofocus=""),
> Field('password', placeholder="Enter Password"),
> Field('remember_me'),
> Submit('sign_in', 'Log in',
>css_class="btn btn-lg btn-primary btn-block"),
> )
>
> def apply_gsp_request_form(request, id=None):
>
> if id:
> action = 'edit'
> model = get_object_or_404(ApplyGSP, pk=id)
> else:
> action = 'submit'
> model = ApplyGSP()
>
> message = ""
>
> if request.method == 'POST':
> form = ApplyGSPForm(request.POST, instance=model)
>
> if form.is_valid():
> form.save()
> username = request.user.username
> print("password:", request.user.password)
>* # How to get password details ? If i get pwd here using
> request.user.password it is displaying
> in $$$ format.*
> * # but i need in raw(clear text format)*
> *applyselenium*(username,password*)*
>
> *def applyselenium():*
>   ---
>   --
>
>
> My Views.py:
> ===
> views.py:
> 
> def login_view(request):
> logout(request)
>
> username = password = ''
> redirect_to = request.GET.get('next', '/gspapp/')
>
> form = LoginForm()
>
> if request.POST:
>
> form = LoginForm(request.POST)
>
> username = request.POST['username']
> password = request.POST['password']
>
> user = authenticate(request, username=username, password=password)
>
>
> if user is not None:
> login(request, user)
>
> remember_me = request.POST.get('remember_me', False)
>
> if remember_me == "on":
> ONE_MONTH = 30 * 24 * 60 * 60
> expiry = getattr(settings, "KEEP_LOGGED_DURATION",
> ONE_MONTH)
> request.session.set_expiry(expiry)
> else:
> request.session.set_expiry(0)
>
> return HttpResponseRedirect(redirect_to)
>
> context = {'form': form, 'page_title': page_title,
> 'loginpage_heading': loginpage_heading}
> return render(request, 'login.html', context)
>
>
>
>
> Regards
> N.Dilip Kumar.
>
> --
> 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/11a515fc-8b06-4130-8a0d-5ab6c9a21497%40googlegroups.com
> 
> .
>

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


Re: Rails to Django Application Architecture Question

2019-05-24 Thread Alex Heyden
What you're describing is how you'd lay out the models in an app. It sounds
like you may have one Django app. If I were writing this in Django, I might
try to spin the workflow and task logic off into its own application if I
thought that the core ideas of users and projects might feed some other bit
of logic elsewhere, but YAGNI may apply.

On Fri, May 24, 2019 at 12:19 PM Steve R  wrote:

> Hi All -
>
> I am a new Django user, coming from RoR. I am having some difficulty
> wrapping my head around the whole 'apps' thing.
>
> Here is my specific use case, and I would appreciate feedback on if I am
> thinking about this correctly, and if not, how to think about it.
>
> I have a project management application I built in RoR that I am
> reimplementing in Django.
>
> A User has one or more Projects, each Project has one or more Workflows,
> and each Workflow has one or more Tasks. Tasks are assigned to users, who
> may or may not be the Project owner.
>
> In Django, a User would be an app, but...
>
> Would a Project be an app, with all the functionality of Workflow and Task
> below it? Separate apps 'feels' wrong, because a task is such a minor
> element (for example), but if I squint, I could see why someone might want
> a Task for something else.
>
> Or
>
> Would I have an app each for Projects, Workflows and Tasks, then set up
> logic linking the apps together?
>
> I thing the question for me is, at what point are the reusable apps in
> Django intended to be independent - I get the impression, the answer is
> 'wherever possible', but does that apply even to very small apps, as Task
> would be?
>
> Thanks in advance for your insight.
>
> SR
>
> --
> 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/eed74b23-f8a7-44ee-8e9f-bc19a56e50c0%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/CA%2Bv0ZYV7NseBC69JdDocz_pC%2BZcoGEu7Q7q5RhfOcAMu9j6jVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Info

2019-05-06 Thread Alex Heyden
When a message goes out to here, it's sent to everyone on the group. When
you reply to it, it also goes out to the group. What you're seeing is
someone's auto-reply. I couldn't say for sure if it's a malicious attempt
to passively get some money or if it's someone not realizing his personal
spam filter is spamming a bunch of people in the group. Either way, just
block the sender and ignore it.

On Mon, May 6, 2019 at 1:49 PM Soumen Khatua 
wrote:

> Then why one bit bounce application is coming everytime after sending any
> problem and saying if you will pay the we will allow your request to our
> inbox.
>
> Thanks buddy for help.
>
>
>
> On Mon, 6 May 2019, 23:25 charan,  wrote:
>
>> No folk
>>
>> No need to pay
>>
>>
>>
>> Sent from Mail  for
>> Windows 10
>>
>>
>>
>> *From: *Soumen Khatua 
>> *Sent: *06 May 2019 16:52
>> *To: *django-users@googlegroups.com
>> *Subject: *Info
>>
>>
>>
>> Hi Folks,
>>
>>
>>
>> Should I need to pay for asking questions or problem in this group?
>>
>>
>>
>>
>>
>> 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/CAPUw6WaUeKf%3D9%2BAgkXbek46gNhL7dWzSOZHdk6pTXPrvam8gVA%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/5cd0752a.1c69fb81.cdc85.081b%40mx.google.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/CAPUw6WaRX4GwZ2ru7-T5u9%2BQRntpEq6rLYg1EYuDFV_0KgApBw%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/CA%2Bv0ZYWD62dqujZoQ7EbhFZvXXCfNeFhT%2BbHnQuQiBXBE9kyFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Website slowed down drasticaly

2019-05-03 Thread Alex Heyden
Definitely echoing Scott's sentiment here. Start with what changed.

In my personal experience, if the answer is "nothing," you can narrow it
down very quickly. Start by reloading with the browser network monitor in
the foreground. If the first response comes back very quickly, Django
itself is off the hook and you proceed with front-end optimizations. If it
doesn't, and you're really sure that no one changed anything (check top or
the process manager to make sure there's nothing new running!), it's your
database. You need your data set to be shrunk, indices to be improved, or
queries to be optimized. Django Debug Toolbar will help you see which of
these apply to you. If you see hundreds of queries where you expected just
one or two, look for any model reference in a loop, including template code.

If you'd like extra reassurance that that's the problem, point your config
to an empty database, run the migrations, and see the difference.

On Fri, May 3, 2019 at 10:59 AM Scott Miesbauer 
wrote:

> I apologize if I missed it but did someone find out what started happening
> in Feb that might have some impact on the performance lag?
>
> The very first thing I ask when troubleshooting is “What changed?”
>
> So what changed in your environment in February?  Other teams changes?
> Application? Network?
>
> If you find what changed then the solution might end up being right there
> in front of you.
>
> Good luck!
>
> Sent from my iPhone
>
> On May 3, 2019, at 1:26 AM, Saurabh Adhikary 
> wrote:
>
> Hello Uri,
>
> The project I handle is quite big , so before taking it up as a major
> task, I wish to get it from the experts that is the django version the
> issue or python version or am I missing out on something major.
>
> The issue started to escalate from Feb '19 , after which even a new
> powerful server could'nt give us good performance.
> *Now after adding extra indexes , at least the website is loading.*
>
> We are still not sure if we can handle around 5K - 10K concurrent request
> with a 128GB SSD server.
>
> On Thursday, 2 May 2019 18:11:05 UTC+5:30, Uri Even-Chen wrote:
>>
>> Why don't you upgrade Django at least to 1.11? Django 1.8 extended
>> support ended last year.
>>
>> https://www.djangoproject.com/download/
>> אורי
>> u...@speedy.net
>>
>>
>> On Thu, May 2, 2019 at 2:39 PM Saurabh Adhikary 
>> wrote:
>>
>>> Hello ,
>>>
>>> I'm using Django version 1.8.1  and Python version 2.7.12 . Suddenly
>>> since Feb '19 there has been a drastic decrease in my website's response
>>> rate.
>>> For sure , there has been some minor increase in the no of hits, but the
>>> performance is too bad.
>>>
>>> Initially , the thought came that the hardware of the server was old ,
>>> so a new server with high configuration was bought.
>>> We have done the new indexing also on it.
>>> Still the sought for a higher performance is awaited.
>>>
>>>
>>> Is it that the Django support for 1.8.1 or Python support for 2.7.12 has
>>> reduced and that is casing the website to slow down or I am missing out on
>>> something ?
>>> Kindly help.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@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/238a6da2-8f34-4b8b-939c-e20d4306545b%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/08bc1409-322e-41ce-a94b-5dd9db888e86%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/dj

Re: In the browser it looks ugly, why?

2019-04-06 Thread Alex Heyden
Short answer, it's giving you exactly what you asked for: the query set
inside  tags.
What you probably want is to loop through the ingredients and place them
inside  tags. Something like:

{% for ingredient in object.ingredientes.all %}
{{ ingredient.cantidad }} {{ ingredient.nombre }}
{% endfor %}


On Sat, Apr 6, 2019 at 4:28 PM Barkalez XX  wrote:

> Why does this happen to me?
>
>
>
>  https://pasteboard.co/I8VU79E.png
>
>
>
>  html:https://dpaste.de/AVti
>
>
>  views.py:https://dpaste.de/44Jz
>
>
>  models.py: https://dpaste.de/Dfwy
>
>
>
> I want to list all the ingredients in that recipe and make it look
> beautiful.
>
> --
> 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/07ff0403-914f-46ae-a418-6c42a9de8ac2%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/CA%2Bv0ZYUMiGD0ZWXwWXOih%2BbGuWoX8nSDAKkC5V75scuDcs2JhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: AES Encryption

2019-01-19 Thread Alex Heyden
PyCrypto would be the Python-side library if you wanted to handle this in
application code, but personally, I'd prefer to handle it in my database of
choice. A lot of us use Postgres, and there's a django-pgcrypto library for
that.

That being said, reversible ciphers are hard to do meaningfully. You'd need
some sort of attack vector that includes getting unauthorized access to the
database, but not via the authorized application, an authorized user, or
access to the machine where the keys are readable. Often enough, that means
you messed up the auth rules on your database, RBAC in your application
code, or your OS read permissions, and you can't cipher your way out of
those issues. A lot of that isn't really Django-centric, and because it's
so rare to have a risk that's mitigated like that, most developers just
don't do it, and not just out of laziness.

What you might actually want is row-level read access, and something like
django-guardian would help you manage object-level permissions in the admin
screen.

If you're looking for further reading, OWASP really is the gold standard
for web security information. The site looks like amateur hour, but it's
not maintained by UI experts, it's maintained by security experts. It's
practically required reading in most security-conscious corporate
environments.

And finally, when in doubt, throw it away. It's a lot harder to have a
breach of data you didn't store anywhere.

On Sat, Jan 19, 2019 at 8:59 PM  wrote:

> Is there a blog or website dedicated to helping Django developers handle
> PII? I'd like to use AES 256 encryption to store all of our fields but have
> no guidance on the best practices for implementing security measures.
>
> --
> 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/64a50014-df54-4ec7-a4b1-f60879385c15%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/CA%2Bv0ZYWCuj5%3DjH8hmC%2BV2cPY%2BxFNP8go6dNnW%2BpTsRLjpPVgkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re:

2019-01-19 Thread Alex Heyden
You missed the +unsubscribe in the email name to accomplish that. From the
footer:

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/BL0PR0102MB3524B2BC6D8F8BBF9DC7B624F39E0%40BL0PR0102MB3524.prod.exchangelabs.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.


On Sat, Jan 19, 2019 at 6:34 PM Vikash Verma 
wrote:

> Please remove me
>
> Get Outlook for iOS 
>
> --
> 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/BL0PR0102MB3524B2BC6D8F8BBF9DC7B624F39E0%40BL0PR0102MB3524.prod.exchangelabs.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/CA%2Bv0ZYVBC1i%2BZaMjkg8qotKE4XvUE6jwFMpddnpDoncAjJOpCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Log into existing Django site

2019-01-16 Thread Alex Heyden
The last Mac I owned had 512kB of memory and no hard drive, but it did have
that newfangled 3.5" floppy drive.

The wider internet probably knows. You might try
https://accc.uic.edu/answer/how-do-i-use-ssh-and-sftp-mac-os-x

On Wed, Jan 16, 2019 at 9:41 AM TheShoff  wrote:

> Also, how would I access the server with SSH (I have a MAC and can use
> Terminal)? I have already set up private and public keys and provided the
> public key to the hosting provider, however I used FTP to login into the
> server. Do you know how I would go about logging in with Terminal?
>
> On Tuesday, January 15, 2019 at 7:59:24 PM UTC-7, Alex Heyden wrote:
>>
>> The server that is hosting the site. The one you're trying to FTP onto.
>> Your quality of life will be greatly improved if you can SSH onto the
>> machine rather than using FTP, because the actual server software that
>> hosts Python processes usually needs to be restarted. It's unlikely (but
>> not unheard of) that you have anything like CPanel controlling a Django
>> instance. It's *probably* going to be GUnicorn or uWSGI, but there's a
>> half dozen options on that front too.
>>
>> I know that all sounds really wishy-washy, but I don't want to mislead
>> you accidentally. The overall architecture isn't that different from a PHP
>> app, but you might not recognize the configuration and file server
>> technologies being used. The further along you get, the easier it'll be for
>> people to figure out what's going on and help you at least figure out what
>> files need to be changed.
>>
>> On Tue, Jan 15, 2019 at 6:39 PM TheShoff  wrote:
>>
>>> Thank you for your response! By host machine, do you mean the machine
>>> (computer) the site was created on or the server that is hosting the site?
>>> I have always worked in PHP and HTML and am used to downloading/uploading
>>> files to the server to make changes.
>>>
>>> On Tuesday, January 15, 2019 at 2:30:44 PM UTC-7, Alex Heyden wrote:
>>>>
>>>> Assuming you're familiar with web technologies in general, you'd make
>>>> these changes on the host machine itself, ideally through the same
>>>> mechanism that handles deployments of source code. Code for application
>>>> logic is often in files called "views.py" or similar, and the HTML will be
>>>> in a folder called "templates" by convention, either near the top of the
>>>> code or contained within the directories (called "applications" in Django)
>>>> that hold server code.
>>>>
>>>> The FTP client is probably the closest you've gotten so far, but
>>>> "denied access" can mean anything from permissions to authentication
>>>> issues. You might want to start there.
>>>>
>>>> On Tue, Jan 15, 2019 at 3:04 PM TheShoff  wrote:
>>>>
>>>>> I am trying to add reCaptcha to an existing Django website that was
>>>>> created by a company we no longer work with. I have server access to the
>>>>> website, but cannot figure out how to edit the files or add the reCaptcha
>>>>> form (I tried to manually add the code into the HTML and .py files and
>>>>> uploading it on my FTP client and was denied access). Do I need to login 
>>>>> to
>>>>> the website using Python to add the reCaptcha form? If so, can someone 
>>>>> tell
>>>>> me how? I am not looking to make any other changes at this time.
>>>>>
>>>>> ***Please note I am new to Django and trying to figure out how it
>>>>> works.***
>>>>>
>>>>> --
>>>>> 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/da98679f-180b-4433-9c94-faa13e27ec3d%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/da98679f-180b-4433-9c94-faa13e27ec3d%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>

Re: Log into existing Django site

2019-01-15 Thread Alex Heyden
The server that is hosting the site. The one you're trying to FTP onto.
Your quality of life will be greatly improved if you can SSH onto the
machine rather than using FTP, because the actual server software that
hosts Python processes usually needs to be restarted. It's unlikely (but
not unheard of) that you have anything like CPanel controlling a Django
instance. It's *probably* going to be GUnicorn or uWSGI, but there's a half
dozen options on that front too.

I know that all sounds really wishy-washy, but I don't want to mislead you
accidentally. The overall architecture isn't that different from a PHP app,
but you might not recognize the configuration and file server technologies
being used. The further along you get, the easier it'll be for people to
figure out what's going on and help you at least figure out what files need
to be changed.

On Tue, Jan 15, 2019 at 6:39 PM TheShoff  wrote:

> Thank you for your response! By host machine, do you mean the machine
> (computer) the site was created on or the server that is hosting the site?
> I have always worked in PHP and HTML and am used to downloading/uploading
> files to the server to make changes.
>
> On Tuesday, January 15, 2019 at 2:30:44 PM UTC-7, Alex Heyden wrote:
>>
>> Assuming you're familiar with web technologies in general, you'd make
>> these changes on the host machine itself, ideally through the same
>> mechanism that handles deployments of source code. Code for application
>> logic is often in files called "views.py" or similar, and the HTML will be
>> in a folder called "templates" by convention, either near the top of the
>> code or contained within the directories (called "applications" in Django)
>> that hold server code.
>>
>> The FTP client is probably the closest you've gotten so far, but "denied
>> access" can mean anything from permissions to authentication issues. You
>> might want to start there.
>>
>> On Tue, Jan 15, 2019 at 3:04 PM TheShoff  wrote:
>>
>>> I am trying to add reCaptcha to an existing Django website that was
>>> created by a company we no longer work with. I have server access to the
>>> website, but cannot figure out how to edit the files or add the reCaptcha
>>> form (I tried to manually add the code into the HTML and .py files and
>>> uploading it on my FTP client and was denied access). Do I need to login to
>>> the website using Python to add the reCaptcha form? If so, can someone tell
>>> me how? I am not looking to make any other changes at this time.
>>>
>>> ***Please note I am new to Django and trying to figure out how it
>>> works.***
>>>
>>> --
>>> 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/da98679f-180b-4433-9c94-faa13e27ec3d%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/da98679f-180b-4433-9c94-faa13e27ec3d%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ce4b4cc7-0082-4474-a6c3-d393665f6e32%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ce4b4cc7-0082-4474-a6c3-d393665f6e32%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYWmL5FYdhAi63Jx_RKNevEU6CySJWD3SsEZwMnbni14pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Log into existing Django site

2019-01-15 Thread Alex Heyden
Assuming you're familiar with web technologies in general, you'd make these
changes on the host machine itself, ideally through the same mechanism that
handles deployments of source code. Code for application logic is often in
files called "views.py" or similar, and the HTML will be in a folder called
"templates" by convention, either near the top of the code or contained
within the directories (called "applications" in Django) that hold server
code.

The FTP client is probably the closest you've gotten so far, but "denied
access" can mean anything from permissions to authentication issues. You
might want to start there.

On Tue, Jan 15, 2019 at 3:04 PM TheShoff  wrote:

> I am trying to add reCaptcha to an existing Django website that was
> created by a company we no longer work with. I have server access to the
> website, but cannot figure out how to edit the files or add the reCaptcha
> form (I tried to manually add the code into the HTML and .py files and
> uploading it on my FTP client and was denied access). Do I need to login to
> the website using Python to add the reCaptcha form? If so, can someone tell
> me how? I am not looking to make any other changes at this time.
>
> ***Please note I am new to Django and trying to figure out how it works.***
>
> --
> 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/da98679f-180b-4433-9c94-faa13e27ec3d%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/CA%2Bv0ZYV_QbGojTrmAZ3qfh6MY_cUtBbvXmyQiOStK-Gfnn8i5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to run a shell script, using input value from Django?

2019-01-02 Thread Alex Heyden
So, a lot of this doesn't have much to do with Django, but I'm not sure how
familiar you are with web server best practices in general, so apologies if
some of this is remedial for you.

If something takes two minutes to finish, you don't want it being handled
on the request handler itself. Split the job off into a separate worker,
then return *something* to the user. Ideally, that something will allow the
user to continue polling for job updates.

Sounds simple, but the details can be obnoxious. First, you have to figure
out how to track the job. Personally, I prefer to not have to watch a
worker directly. I'd rather watch the results come through. For example, if
your script takes two minutes because it's updating a few thousand items
somewhere, I'd rather watch the items change by OS mtime or auto_now on a
model or whatever makes sense in your context. That means less complexity
in my workers and less complexity in my database. You might not be so
lucky. If one user can kick off a dozen or so of these jobs, and they only
do one thing each, you're probably going to have to track Celery workers
individually by sending to the user a job identifier and storing them in
your database with a foreign key out to your User model. Regardless of how
you decide to do it, the job of the initial request handler is to take care
of this piece of the puzzle: how am I going to track this, kick off the
job, send the tracking information to the user.

The script itself is probably pretty easy. A Celery worker using subprocess
from the standard library will be sufficient, with maybe a little bit
watching stdout to figure out how far along the job is if you need to. Have
the worker write its progress to the database row associated with the job,
or use celery-progress if you'd rather use someone else's implementation of
that idea.

In your UI, you'll want some sort of AJAX loop so the user can watch the
job go. This is usually pretty simple too: just an endpoint that queries
the job's status as recorded in the database and returns it without fanfare.

You probably don't want to automatically delete the database entry for the
job once its done, because you don't know if the user was there to see the
end of it. Save that for a periodic task or a response to the user
acknowledging the end of the job run.

On Wed, Jan 2, 2019 at 4:01 PM Chris Robinson  wrote:

>
> Hello,
>
> I'm going to attempt to generalize my question to make this easier to
> answer.
>
> Lets say I have a simple terminal based shell script (e.g.
> multiply_by_two) that takes a number argument, then multiplies that number
> by 2, and returns the result into a result.txt file.
>
> I would enter something like this:
> multiply_by_two -n 6
>
> The -n flag asks what number I would like to multiply by 2. The result of
> this would be a result.txt, containing the number 12 inside.
>
>
> What I would like to do is develop a simple Djano application that
> contains a text field allowing me to input the number 6, then click
> "Submit."
>
> This job will start on the server by running my custom multiply_by_two
> application with my input parameter (6), but when the job is finished and
> the result.txt is available, the browser will automatically download the
> file.
>
> To make this a tad bit more complex, lets say that the job takes 2 minutes
> to run. What would be the best way to monitor the job? Maybe I accidentally
> close the window.
>
> Not looking for anyone to solve this, I'm just new to Django and want to
> know if someone can give me any pointers on where to start. Are there any
> apps existing that will help me not need to write everything from scratch,
> especially if 'monitoring' is needed? Would Celery be ideal for this?
>
> Thanks for any input!
>
> Regards,
> Chris
>
> --
> 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/7da4b068-ac58-4c26-a0bc-ed4925f8a4f9%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/CA%2Bv0ZYX7NGU3PSJhAEDGPnx8V

Re: Django on IIS

2018-12-17 Thread Alex Heyden
I have recently, and it was equal parts misery and pain. FastCGI via
wfastcgi, as outlined at
http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html

I also had to downgrade from Python 3.7 to Python 3.6

I wouldn't really consider myself an expert on the subject. All I can say
is that it is possible.

On Mon, Dec 17, 2018 at 5:19 PM Larry Martell 
wrote:

> Anyone have any experience setting up a Django app to work with IIS? I
> have inherited what I was told is a working system, but it's not
> working. Before I post details of my issues and questions I wanted to
> see if anyone here has successfully got a Django app to run with IIS.
>
> --
> 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/CACwCsY7bk-c7Za-PGUbaEkftA8Xxqd%2BaCUPkaQryW-1kXX0_nQ%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/CA%2Bv0ZYVWO5bFTx%3D6im_dLWwPWz1FoDcFVDN9GXREj%3Dp49f2FcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Should I store offline calculation results in the cache?

2017-05-27 Thread Alex Heyden
Seven years ago, that may very well have been a true statement. I wouldn't
stand by it today. Disk caching should be perfectly stable, even if it's a
pretty poor solution for the average use case.

The part that hasn't changed is memcached. Memcached should be everyone's
default caching solution, not just on Django, but everywhere. You use
memcached until you've proven you have a use case that makes memcached
explicitly the wrong choice, and even then, you have someone else sanity
check your assumptions.

On Sat, May 27, 2017 at 9:17 AM, Alexandre Pereira da Silva <
aletes@gmail.com> wrote:

> Redis caching is a good solution for this. You can have persistence, it's
> fast and only limited by your available RAM.
>
> Your implementation should be more robust about missing itens from the
> cache. If for any reason the cache is lost, your code should rebuild the
> values in a background task.
>
>
>
> On Sat, May 27, 2017 at 6:25 AM, Antonis Christofides <
> anto...@djangodeployment.com> wrote:
>
>> Hello all,
>>
>> I have an application that calculates and tells you whether a specific
>> crop at a specific piece of land needs to be irrigated, and how much. The
>> calculation lasts for a few seconds, so I'm doing it offline with Celery.
>> Every two hours new meteorological data comes in and all the pieces of land
>> are recalculated.
>>
>> The question is where to store the results of the calculation. I thought
>> that since they are re-creatable, the cache would be the appropriate place.
>> However, there is a difference with the more common use of the cache: they
>> are re-creatable, but they are also necessary. You can't just go and delete
>> any item in the cache. This will cripple the website, which expects to find
>> the calculation results in the cache. Viewing something on the site will
>> never trigger a recalculation (and if I make it trigger, it will be a
>> safety procedure for edge cases and not the normal way of doing things).
>> The results must also survive reboots, so I chose the file-based cache.
>>
>> I didn't know about culling, so when the pieces of land grew to 100, and
>> the items in the cache to 400 (4 items need to be stored for each piece of
>> land), I spent a few hours trying to find out what the heck is going on. I
>> solved the problem by tweaking the culling parameters. However all this has
>> raised a few issues:
>>
>>1. The filesystem cache can't grow too much because of issue 11260
>>, which is marked
>>wontfix. According to Russell Keith-Magee
>>,
>>
>> "the filesystem cache is intended as an easy way to test caching, not as
>> a serious caching strategy. The default cache size and the cull strategy
>> implemented by the file cache should make that obvious. If you need a cache
>> capable of holding 10 items, I strongly recommend you look at memcache.
>> If you insist on using the filesystem as a cache, it isn't hard to subclass
>> and extend the existing cache."
>>
>> If these comments are correct, then the documentation needs some fixing,
>> because not only does in not say that the filesystem cache is not for
>> serious use, but it implies the opposite:
>>
>> "Without a really compelling reason, ... you should stick to the cache
>> backends included with Django. They’ve been well-tested and are easy to
>> use."
>>
>> Is Russell not entirely correct perhaps, or is the documentation? Or am I
>> missing something?
>>
>>
>>1. In the end, is it a bad idea to use the cache for this particular
>>case? I also have a similar use case in an unrelated app: a page that 
>> needs
>>about a minute to render. Although I've implemented a quick-and-dirty
>>solution of increasing the web server's timeout and caching the page, I
>>guess the correct way would be to produce that page offline with Celery or
>>so. Where would I store such a page if not in the cache?
>>
>> --
>> Antonis Christofideshttp://djangodeployment.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/a5a8d1ab-f4e0-a6b5-b1da-acc9dc2dbf9d%40djan
>> godeployment.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

Re: browser testing

2017-01-04 Thread Alex Heyden
Everyone who wants into that space compares themselves to Selenium, because
Selenium is that good and has that much market share. It's obnoxious to
use, excludes some less technical users, but behaves very predictably in
skilled hands and has plenty of community support.

If I needed to include less technically inclined testers, I'd pursue Kantu
from https://a9t9.com/. I don't have any direct experience with iMacros,
but out in the wild, I see more people asking how to migrate their iMacros
scripts to Selenium than the other way around. This could be because of the
difference in relative difficulty between the two. Selenium has a learning
curve that makes it better suited to professional testers than, say, random
client representatives doing UAT.

On Wed, Jan 4, 2017 at 6:30 PM, Mike Dewhirst  wrote:

> Does anyone have any recommendations for testing via the browser?
>
> I have heard Selenium mentioned and saw a feature contrast between
> Selenium and Imacro which indicated Imacro is the best choice. Before I do
> the right thing and dig into it myself, are there any war stories or
> testimonials out there?
>
> The objective is to help users to automate their acceptance testing and,
> like unit tests, keep adding new tests as new features are delivered.
>
> Thanks for any advice
>
> Cheers
>
> Mike
>
> --
> 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/c98cdb60-8490-cc58-f614-e64dd4384faa%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYUbW69B5NyfxfmCyXTTRZBYcKOxDZVNaxoK5Oery%2Br21A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get_profile() function can not resolve keyword 'user' -- no 'user' field exists in model.py or data tables.

2016-12-12 Thread Alex Heyden
Someone familiar with the internals might have an idea, but from a
non-contributor's perspective, the different management commands seem to
have different strategies for loading up the models. An error in syncdb
doesn't mean you'll get the same error in shell or runserver.

Debuggers will always be a matter of personal preference, but I use the one
in PyCharm.

On Mon, Dec 12, 2016 at 2:23 PM, Darrell Jonsson  wrote:

> Hi Alex,
>
> Is there anyway on the command line I can determine what models,
> the app actually sees in the module in question?
>
> Otherwise can you recommend a debugger that might help.
>
> Thanks
>
>
>
>
> On 12/12/2016 9:07 PM, Alex Heyden wrote:
>
>> The first place to look would be the INSTALLED_APPS setting in your
>> settings file, but honestly that's one of those errors that could
>> ultimately mean a lot of things. I've had it thrown on things ranging from
>> circular imports to admin configuration issues to bad migrations. It might
>> be time to spin up a debugger.
>>
>> On Mon, Dec 12, 2016 at 1:52 PM, NoviceSortOf > <mailto:dljonsson2...@gmail.com>> wrote:
>>
>>
>> Thanks Alex,
>>
>> Following the links you posted I've moved forward towards adding a
>> custom user and getting rid of get_profile().
>>
>> This process though has introduced other issues.
>>
>> The error occurs both when running manage syncdb and when
>> debugging view that calls user.
>> "AUTH_USER_MODEL refers to model 'books.user' that has not been
>> installed"
>>
>> My settings file clearly contains AUTH_USER_MODEL = 'books.user'
>>
>> And class user is defined per instructions online regarding
>> migrating to a custom user
>> inside of books.models.py <http://books.models.py>.
>>
>> It appears to me that user as defined in books.models.py
>> <http://books.models.py> is installed on the code level and am
>> wondering where else the error message might be referencing that
>> tells me it is not 'installed'.
>>
>> Any suggested appreciated.
>>
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at https://groups.google.com/group/django-users
>> <https://groups.google.com/group/django-users>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/afc26acd-3d2c
>> -47ce-b696-4be15fb61357%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/afc26acd-3d2
>> c-47ce-b696-4be15fb61357%40googlegroups.com?utm_medium=email
>> &utm_source=footer>.
>>
>>
>> For more options, visit https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>>
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/django-users/oPW7Vy2YNqY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscri
>> b...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto: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/CA%2Bv0ZYVw-bUTLFJ65%2B7bgGLjeMz7RUtQ6g9sA
>> j3MO73znwPP-A%40mail.gmail.com <https://groups.google.com/d/m
>> sgid/django-users/CA%2Bv0ZYVw-bUTLFJ65%2B7bgGLjeMz7RUtQ6g9sA
>> j3MO73znwPP-A%40mail.gmail.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 pos

Re: get_profile() function can not resolve keyword 'user' -- no 'user' field exists in model.py or data tables.

2016-12-12 Thread Alex Heyden
The first place to look would be the INSTALLED_APPS setting in your
settings file, but honestly that's one of those errors that could
ultimately mean a lot of things. I've had it thrown on things ranging from
circular imports to admin configuration issues to bad migrations. It might
be time to spin up a debugger.

On Mon, Dec 12, 2016 at 1:52 PM, NoviceSortOf 
wrote:

>
> Thanks Alex,
>
> Following the links you posted I've moved forward towards adding a custom
> user and getting rid of get_profile().
>
> This process though has introduced other issues.
>
> The error occurs both when running manage syncdb and when debugging view
> that calls user.
>
> "AUTH_USER_MODEL refers to model 'books.user' that has not been installed"
>
> My settings file clearly contains AUTH_USER_MODEL = 'books.user'
>
> And class user is defined per instructions online regarding migrating to a
> custom user
> inside of books.models.py.
>
> It appears to me that user as defined in books.models.py is installed on
> the code level and am wondering where else the error message might be
> referencing that tells me it is not 'installed'.
>
> Any suggested appreciated.
>
> 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/afc26acd-3d2c-47ce-b696-4be15fb61357%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/CA%2Bv0ZYVw-bUTLFJ65%2B7bgGLjeMz7RUtQ6g9sAj3MO73znwPP-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get_profile() function can not resolve keyword 'user' -- no 'user' field exists in model.py or data tables.

2016-12-07 Thread Alex Heyden
The offending lines are these right here:

File "/var/www/MYPROJECT/data/bookstor/profiles/views.py" in create_profile
  49. profile_obj = request.user.get_profile() ## If existing
profile found
File "/usr/lib/python2.7/site-packages/django/contrib/auth/models.py" in
get_profile
  449. self._profile_cache = model._default_manager.using(
self._state.db).get(user__id__exact=self.id)

Line 49 in profiles.views is calling get_profile on the user object. In
turn, it's trying to dereference the user id in django.contrib.auth.models.

The get_profile() method is deprecated as of 1.5 (although not removed
until 1.7). Your best bet is to stop using it in favor of custom user
models (
https://docs.djangoproject.com/en/1.10/releases/1.5/#auth-profile-module
and
https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#auth-custom-user)
because eventually you'll want to get yourself to a version of Django
that's actually getting security updates.

On Wed, Dec 7, 2016 at 1:13 PM, NoviceSortOf 
wrote:

>
> While in the process of upgrading from 1.1 to 1.6
>
> get_profile() returns a field error.
> 
> Exception Type: FieldError
> Exception Value: Cannot resolve keyword 'user' into field. Choices are:
> date_joined, email, first_name, groups, id, is_active, is_staff,
> is_superuser, last_login, last_name, logentry...
> 
>
> On close inspection there is no 'user' field defined in
> _ myproject.profiles.models
> _ ...\site-packages\django\contrib\auth\models.py
> _ or in the db auth_user or profile tables.
>
> Drilling into all of the files listed in the traceback, (including site
> packages)
> I can find no instance of 'user' being assigned as a field.
>
> *  Where else can I look to find 'user' and/or what is causing the problem.
>
>
> Please advise
>
>
> *
> TRACEBACK
> *
> Environment:
>
> Request Method: GET
> Request URL: http://myproject.com/profiles/create/
>
> Django Version: 1.6.12
> Python Version: 2.7.5
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'django.contrib.humanize',
>  'django.contrib.redirects',
>  'bookstor',
>  'bookstor.registration',
>  'bookstor.profiles',
>  'django_extensions',
>  'django.contrib.admin',
>  'bookstor.cart')
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.transaction.TransactionMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.contrib.redirects.middleware.RedirectFallbackMiddleware')
>
>
> Traceback:
> File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in
> get_response
>   120. response = wrapped_callback(request,
> *callback_args, **callback_kwargs)
> File "/var/www/MYPROJECT/data/bookstor/profiles/views.py" in
> create_profile
>   49. profile_obj = request.user.get_profile() ## If existing
> profile found
> File "/usr/lib/python2.7/site-packages/django/contrib/auth/models.py" in
> get_profile
>   449. self._profile_cache = model._default_manager.using(
> self._state.db).get(user__id__exact=self.id)
> File "/usr/lib/python2.7/site-packages/django/db/models/query.py" in get
>   301. clone = self.filter(*args, **kwargs)
> File "/usr/lib/python2.7/site-packages/django/db/models/query.py" in
> filter
>   593. return self._filter_or_exclude(False, *args, **kwargs)
> File "/usr/lib/python2.7/site-packages/django/db/models/query.py" in
> _filter_or_exclude
>   611. clone.query.add_q(Q(*args, **kwargs))
> File "/usr/lib/python2.7/site-packages/django/db/models/sql/query.py" in
> add_q
>   1204. clause = self._add_q(where_part, used_aliases)
> File "/usr/lib/python2.7/site-packages/django/db/models/sql/query.py" in
> _add_q
>   1240. current_negated=current_negated)
> File "/usr/lib/python2.7/site-packages/django/db/models/sql/query.py" in
> build_filter
>   1103. allow_explicit_fk=True)
> File "/usr/lib/python2.7/site-packages/django/db/models/sql/query.py" in
> setup_joins
>   1363. names, opts, allow_many, allow_explicit_fk)
> File "/usr/lib/python2.7/site-packages/django/db/models/sql/query.py" in
> names_to_path
>   1283.  "Choices are: %s" % (name, ",
> ".join(available)))
>
> Exception Type: FieldError at /profiles/create/
> Exception Value: Cannot resolve keyword 'user' into field. Choices are:
> date_joined, email, first_name, firstpass, groups, id, is_active, is_staff,
> is_superuser, last_login, last_name, logentry, password,
> registrationprofile, user_permissio

Re: Help with runserver

2016-11-20 Thread Alex Heyden
Is there anything at mysite/urls.py?

Also, how sure are you that you're actually hitting the Django server? If
you turn off the Django server, do you get the same page? If you navigate
to http://localhost:8000/ with runserver running, do you see the GET
request in the console?

On Sun, Nov 20, 2016 at 11:30 AM, NS  wrote:

> """
> Django settings for mysite project.
>
> Generated by 'django-admin startproject' using Django 1.10.3.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/1.10/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/1.10/ref/settings/
> """
>
> import os
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = '_'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> ]
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'mysite.urls'
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'mysite.wsgi.application'
>
>
> # Database
> # https://docs.djangoproject.com/en/1.10/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> }
> }
>
>
> # Password validation
> # https://docs.djangoproject.com/en/1.10/ref/settings/#
> auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME': 'django.contrib.auth.password_validation.
> UserAttributeSimilarityValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.
> MinimumLengthValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.
> CommonPasswordValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.
> NumericPasswordValidator',
> },
> ]
>
>
> # Internationalization
> # https://docs.djangoproject.com/en/1.10/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/1.10/howto/static-files/
>
> STATIC_URL = '/static/'
>
>
> On Saturday, November 19, 2016 at 9:36:30 PM UTC-5, Alex Heyden wrote:
>>
>> We'd need to see your settings file and maybe your top-level urls.py to
>> answer it conclusively, but in general terms, some view that's been mapped
>> to root on your project is returning that there JSON response. This is not
>> a default Django behavior, or at least wasn't in 1.10 or earlier.
>>
>> On Sat, Nov 19, 2016 at 7:58 PM, NS  wrote:
>>
>>> When I run python manage.py runserv

Re: Help with runserver

2016-11-19 Thread Alex Heyden
We'd need to see your settings file and maybe your top-level urls.py to
answer it conclusively, but in general terms, some view that's been mapped
to root on your project is returning that there JSON response. This is not
a default Django behavior, or at least wasn't in 1.10 or earlier.

On Sat, Nov 19, 2016 at 7:58 PM, NS  wrote:

> When I run python manage.py runserver, I get this shown on localhost:8000
>
> {"status": "fail",  "method": "", "error":""}
>
>
>
> What happened?
>
> --
> 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/24a87f66-8799-489b-acc4-db779eb811df%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/CA%2Bv0ZYUtZh0JuRBruFn1eRT0_cnggecOi8%2BmcDWHGckLDCP48g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Am I missing a design pattern? My views code somehow isn't as elegant as it should be...

2016-10-21 Thread Alex Heyden
Are you intentionally sending the whole request into that constructor and
concatenating it to a URL string? I can't imagine any way this doesn't end
in disaster.

I'm sure the community would happily help, but it's not at all obvious from
the supplied code what you're trying to do here.

On Fri, Oct 21, 2016 at 6:11 AM, Andrew Chiw 
wrote:

> In my views, I have this:
> def questionnaire(request):
> def save_the_lead(cleaned_data, ipinfo):
> email = cleaned_data.pop('email', None)
> lead, created = Lead.objects.update_or_create(email=email)
> lead.q = cleaned_data
> lead.ipinfo = ipinfo
> lead.save()
> return lead
>
> form = LeadForm(request.POST or request.GET or None)
> """
> Why am I still checking for request.method == "POST"?
> if POST (valid data) to questionnaire, process it.
> if GET (valid data) to questionnaire, display it first. Even if it's
> all valid.
> """
> if request.method == "POST":
> if form.is_valid():
> i = IPInfo(get_ip(request), dummy=True)
> lead = save_the_lead(form.cleaned_data, i.get_result())
> m = Matcher()
> m.match([lead])
> e = Emailer(lead)
> e.send()
> return redirect('results', lead.id)
>
> return render(request, 'wizard/questionnaire.html', {'form': form})
>
> And IPInfo looks like this:
> import requests
> import ipdb
>
>
> class IPInfo:
> def __init__(self, ip, dummy=False):
> self.result = dict()
> if (ip and not dummy):
> response = requests.get('http://ipinfo.io/' + ip)
> self.result = response.json()
> elif (ip and dummy):
> self.result = {"ip": ip}
>
> def get_result(self):
> return self.result
>
>
> The part I'm worried about is the IPInfo lookup class and how it is used
> in the view. I know you can mock classes in tests, but maybe I should use
> dependency injection instead? or is that not needed in Python?
> If I'm missing dependency injection: I don't have control over the code
> that runs before the view, so I cannot tell it to inject another instance
> of IPInfo in there.
>
> --
> 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/2777f9b7-ec87-4dc5-ac8f-de971860c83b%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/CA%2Bv0ZYWePE8Kh%2BQo0%2BPbZBNz8-8PWOBtW1FuzOY4h-OwL2CjxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: forms.Form, models.Model, forms.ModelForm? (self.django)

2016-08-14 Thread Alex Heyden
forms.Form makes front-end widgets and some validation logic. models.Model
defines a database interface and wraps it in a Python class. The two have
nothing to do with each other aside from vaguely similar APIs for defining
the classes.

The intersection of the two is forms.ModelForm, which uses a model to
populate form fields.

GET vs POST is a functionality difference. GET should be used where the
request could be repeated multiple times and get the same response. POST
should be used where a request has meaningful side effects. (If you're
saving things to a model from a user perspective, you almost certainly want
POST.) There's middle ground between the two where it's a bit of a matter
of opinion, but those are the broad strokes.

On Sun, Aug 14, 2016 at 2:04 PM, Andrew Emory  wrote:

> Would someone explain to me when you would choose one class over the
> other? Does forms.Form not create a database? Can't you just render
> models.Model as a form?
>
>
> I understand forms.ModelForm is a helper class for creating a form from a
> model. But I still don't really understand why you would choose one over
> the other, like when?
>
>
> Are forms.Form more for GET requests? And the others are POST?
>
>
> Most of what I am trying to do is serve some forms, have the user POST
> some data, and then query the database.
>
>
> Thanks guys.
>
> --
> 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/0db5cf5f-23d2-43c1-8d1c-87ce5eab7efe%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/CA%2Bv0ZYUvnf1p-GCa%3DyrHUfGLORQeSDeBbBnUaDCrvdyEPR5wCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: null=True and blank=False within model fields

2016-08-06 Thread Alex Heyden
The obvious use case there is something that can't be initialized with a
reasonable default value. Null is valid because you just plain need it, but
blank is false because you never want it to be null ever again except if
the back end explicitly demands it.

On Thu, Aug 4, 2016 at 1:35 AM, James Schneider 
wrote:

> On Aug 3, 2016 5:18 PM, "Kevin Brown"  wrote:
> >
> > Within Django REST framework a discussion sparked about how the
> combination of null=True and blank=False should be handled with validation.
> What side is right in the discussion isn't the question here.
> >
> > Are there cases where it makes sense to set both `null=True`, which
> should allow for `None` to be set on a field, and to set `blank=False`,
> which does not allow blank values to be set on the field?
> >
> > And what is considered to be a "blank value" for a field?
> >
>
> blank= is a helper attribute for forms, not directly on the model or
> database itself. If you have null=True and blank=False, then an entry by
> way of a form will not allow an empty/null value, but you would still be
> able to set that same model field to null/False via the ORM directly,
> either through the shell, a management command, or a 3rd party process that
> may be using that table directly.
>
> Serializers in DRF are akin to Forms in Django. If you are performing
> validation at the serializer level in DRF, my expectation would be that
> blank=False would be taken into account, and that a value would be required
> to pass validation.
>
> At the ORM level (Model.objects.create(), etc.) I would NOT want that to
> apply.
>
> If you need to bypass that restriction for a particular form/serializer, a
> custom class definition would be used.
>
> An example would be a user object. An email address may be required for
> every account, but an admin may want to create accounts via the ORM without
> an email address because they may not know the correct one, or it is an
> internal system account, etc. Your code should account for that situation
> if that's the case.
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciUb-K4%3DuioVa7F%3DHn0-8_
> LQwr_o3S9Zp1dehbQX693EQw%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/CA%2Bv0ZYUhvK6Y2zJ2HtnX04ZxcoCj491cZ%2BSB7aX5JE4tUK1SNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best Practices URL Patterns

2016-07-06 Thread Alex Heyden
Primary keys as URL parameters are considered a security vulnerability by
OWASP (https://www.owasp.org/index.php/Forced_browsing) and may affect how
your code is viewed after an audit.

Consider instead how sites like Reddit handle this. The URL of a comments
page has a human-readable slug at the end for increased usability, but the
actual page is keyed to a hash value. Some sites take this a step further
and require the slug and the hash to match to further limit forced browsing.

On Wed, Jul 6, 2016 at 3:18 PM, ludovic coues  wrote:

> You want a value to identify a specific job, different from the
> job_id, to put in the url.
> I would add a slug field in the model and use that.
>
> The slug could be derived from the job title, maybe concatenated to an
> UUID for uniqueness or simply an UUID different from the id.
>
> If you are using views based on generic.DetailView, set the url to
> something like r'^job/(?P[\w-]+)/$' and job done. If the slug
> field isn't named slug, don't forget to set slug_field to the correct
> name.
>
>
> 2016-07-06 19:46 GMT+02:00 'David Turner' via Django users
> :
> > As far as putting the id in the url it was a way of distinguishing the
> job
> > form others. As I said a number of listings will be made on the same day
> > with exactly the same content with regard to the title. My thoughts
> > therefore were that if the id plus the tile were included in the url then
> > this would distinguish them. If this is not a good idea then any
> suggestions
> > would be welcomed as to alternatives.
> >
> > Thanks
> >
> > On 6 July 2016 at 16:46, William Caruso  wrote:
> >>
> >> As far as putting the ID into the url, I would suggest not. Even though
> >> the ID is secure and anonymous, django's urls allow for much better
> ways to
> >> determine a user and put them on a page. What is your purpose for using
> the
> >> ID in the URL?
> >>
> >> On Wednesday, July 6, 2016 at 10:09:59 AM UTC-4, davidt wrote:
> >>>
> >>> I am looking for advice with regard to the following:
> >>>
> >>> I have a model which has as part of the structure these two fields
> >>>
> >>> job_id = models.AutoField(primary_key=True,)
> >>> job_reference = job_id = ShortUUIDField()
> >>>
> >>> My question is if I include the job_id in the url, which is public
> facing
> >>> then it is easy to guess the rest of the urls within the site.
> >>> Beacuse there are a number of items that will have the same url
> >>> structure, and are posted on the same day, using the id is what makes
> them
> >>> unique.
> >>>
> >>> My questions are is this right way to proceed or is there a better
> >>> alternative?
> >>>
> >>> Thanks in advance
> >>>
> >> --
> >> You received this message because you are subscribed to a topic in the
> >> Google Groups "Django users" group.
> >> To unsubscribe from this topic, visit
> >> https://groups.google.com/d/topic/django-users/ieysN9sRyT0/unsubscribe.
> >> To unsubscribe from this group and all its topics, 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/d39d267b-cdfc-45e8-9065-2c8521a8213f%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/CALwQ%2B-uu_-%3DSGoYpuc18AVquSJtN4wZ0i7Rps-PFP0iufyBWXw%40mail.gmail.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTaPG%3DWy5n_MUjnU04-QbRdiPRw88_nPJ-eJHUiUxx1EYg%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@googleg

Re: Storing images in a database using Django.

2016-05-06 Thread Alex Heyden
There's an ImageField for use in models, but to really understand it, start
with FileField

https://docs.djangoproject.com/en/1.9/topics/files/
https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.FileField

The general idea is that you have a directory configured by Django's
settings that you can use to hold uploaded files. You can also use Django
to serve these files if you want. (I tend to use nginx directly for this
for performance reasons, but you do what works for you.)

I wouldn't go so far as to say that there's no use case for storing images
in databases, but in general, André's advice is solid: store the path
instead. Your OS is good at managing files. Let it do its job.

On Fri, May 6, 2016 at 2:53 PM, André Machado 
wrote:

> NEVER store images in DB, store its path so you can use it in a img tag
> later. =)
>
> Em sexta-feira, 6 de maio de 2016 16:06:08 UTC-3, Mlati Mudan escreveu:
>>
>>
>> Hi guys, I'm a TOTAL noob when it comes to django and web development for
>> that matter. I have an idea for a web app and I do have a basic
>> understanding of programming. I've gone through a few Django tutorials and
>> I'm confident I can do it, I just need help along the way :)
>>
>> So, my "brilliant" idea is to make an app for cooking for dummies.
>> Basically, I'd have a repository of recipes. Each recipe consists of:
>> recipe_ID, name, and 10 instruction-photo pairs ("now do this" + photo of
>> that).
>>
>> The photos are relatively lightweight (less than 50k each) so I think
>> storing them in a database is the way to go. The only snag - I have
>> absolutely no idea how to do it. I've googled a lot but I'm either too
>> thick or my needs are too specific.
>>
>> I don't actually need to be able to store the images in the database
>> through the web app. I was thinking of creating folders that contain the
>> pertinent photos and "somehow" storing them in the database for further
>> use. The name of the folder would be the same as the recipe_ID, and the
>> photos would be named recipe_ID_01.jpg, recipe_ID_02.jpg, ...
>>
>> Thanks in advance for any help you can give me :)
>>
>> --
> 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/5dcad641-8837-477c-8a43-e7328c11850e%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/CA%2Bv0ZYW%2Bb0di3f9T3isNp5zjQo7_aqaa%2BkC%3DsvuFu5_AWSm8PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: No Downtime Code Releases

2016-04-20 Thread Alex Heyden
I wouldn't recommend tying your repository structure to your deployment
needs. Put that in the deployment script instead. You can see if any
migrations are pending with manage.py migrate --list

On Wed, Apr 20, 2016 at 1:59 PM,  wrote:

> My thought process for separating the models into a separate repo is
> something like this:
>
> I am predominately putting up our (heroku) maintenace page when migrations
> are run
> If the models are in separte repo, I only need to run migrations when that
> repo is deployed.  If migrations are not deployed in my non-model repos, I
> would skip putting up the maintenance page.
>
> Most of our db changes are to accommodate back-end data warehousing.  The
> other/additional way I was thinking about spliting our app up was
> separating the backend processes from our front end API's that primarily
> deal with security and authorization.  The security and authorization
> models do not change very often, so an app that only deals with that part
> would not need to restart very often.  That said, there are a couple models
> that we need to run that that are shared with our back-end processes.
> Having those models split out would potentially let us pip install them
> into a separate service.
>
> However it sounds like you guys are saying there are other
> concerns--namely flushing the pyc files.  I'm not exactly sure this is
> relevant to me since we are using heroku, and an entire new server/slug is
> deployed when we do a code release. It's not clear to me if that slug
> deployment would drop connections or cause other kinds of problems.
>
>
>
>
> On Tuesday, April 19, 2016 at 9:13:30 AM UTC-7, Avraham Serour wrote:
>>
>> I don't think you would gain anything by separating your models to a
>> different repository, what are you trying to gain here?
>>
>> if you put a maintenance page when doing migrations it won't matter if
>> the models are from a different package or not.
>>
>> you could still run migrations on a live system, you just should take
>> into account that there could still be parts of the system using something
>> is not there yet/anymore
>>
>> so you should break migrations into 2 whenever you are adding or removing
>> something.
>>
>> when adding a model or field you should first run the migrations and only
>> after that deploy the new code using the new model/field
>>
>> when removing something you should first stop using it and then migrate.
>>
>> you could plan your deployment/releases and know in advance if you are
>> either adding or removing something and never add and remove in the same
>> release
>> meaning commit and deploy the model and only after that commit the code
>> using the new model
>>
>> or you can checkout the code on the side and runs migrations using this
>> separate env, this way you could add a new model and use it in the same
>> commit.
>>
>> for removing you can just do it backwards.
>>
>>
>> Avraham
>>
>>
>>
>> On Tue, Apr 19, 2016 at 3:38 AM,  wrote:
>>
>>> Hey,
>>>
>>> I have two issues I'm looking at solving at work, and I'm looking for a
>>> couple suggestions as to how other people have solved this.  The two things
>>> are:
>>>
>>> * scale out their django installation to allow for smaller releases (I'm
>>> thinking microservices, but it could also be internal django apps or who
>>> knows what else)
>>> * minimizing the impact of migrations during releases (aka we want to be
>>> able to release in the middle of the afternoon
>>>
>>> Currently we put up a maintenance page whenever we are doing database
>>> operations (aka migrations).  This seems like a recommended best practice.
>>>
>>> One way I was thinking about addressing this issue was to break all of
>>> our models out into a separate repo.  That way we'd only need to deploy
>>> migrations when the models themselves have deployed.  For code that needs
>>> the models, we could pip install the repo as an app and away we go.
>>> Likewise it seems like I could break up different parts of our app via a
>>> similar strategy.
>>>
>>> Does this seem viable?  How have other people solved this kind of
>>> problem?
>>>
>>> Thanks,
>>>
>>> -Ben
>>>
>>> --
>>> 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/e5fd0359-9e8b-4cce-b3e1-4880951a2a8e%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.

Re: I might need a different control panel... or do I?

2016-04-08 Thread Alex Heyden
The ability to update a profile can be as simple as a form for the model
object that holds the profile. The company's employees would have access to
Django admin. I've never used it personally, but django-user-accounts looks
like a way to avoid making a registration form if that's important to you.

On Fri, Apr 8, 2016 at 9:54 AM, Andrew Chiw 
wrote:

> I'm making a Django site for a company, and the way I envision it working
> is this:
> The company's employees can manage and validate clients who sign up on the
> site as well as link them to other services.
> Once the clients login, they have their own little control panel where
> they can change their own profile.
> The question is, can I or should I use Django's built in admin control
> panel for the clients' mini control panel?
> If not, then is http://django-user-accounts.readthedocs.org/en/latest/
> what I'm looking for?
>
> --
> 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/9c3dfeb8-4c03-4622-9036-d70fd8a349eb%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/CA%2Bv0ZYWTq_ZM3ipkEHVx-bJOQ0nirwZhuzHwMSf9zqi31H4cYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django admin_tools et file edition

2016-04-01 Thread Alex Heyden
Ignoring security concerns for a moment, you could make a view that loads a
file (using the standard os library) and passes the contents to a textarea
in a template if the request has the GET method, and saves the contents
back to the file if the request has the POST method.

On Fri, Apr 1, 2016 at 2:13 AM, vassilux  wrote:

> One part of the configuration can be loaded from the database and it works
> well.
>
> I have to edit some files of asterisk ipbx.
>
> May be I can overload save / load methodes of djaongo model ?
>
> Or make a "service for file " into server side of my application, à la
> "restful"  ?
>
>
> Le jeudi 31 mars 2016 22:31:44 UTC+2, Alex Heyden a écrit :
>>
>> CKEditor is appropriate for files that need solid typography and
>> formatting. If you're looking for something simpler, Markdown is a common
>> solution. Markdown is a markup syntax widespread on internet forums.
>>
>> None of those really address "configuration files," though. Is fancy
>> formatting actually the problem you're trying to solve? Are you trying to
>> find a way to save and edit files on a hard drive? Save text to a database
>> to affect the behavior of your website? Something else?
>>
>> On Thu, Mar 31, 2016 at 11:51 AM, vassilux  wrote:
>>
>>> Hi alls,
>>> It is my first django project and   I look for a solution to edit files,
>>> for exemple allow to an "advanced user" editing configuration files.
>>>
>>>
>>> I looked into django-ckeditor
>>> <https://www.djangopackages.com/packages/p/django-ckeditor/>  but it is
>>> not clear for the moment
>>>
>>> Where  I can look for informations / examples ?
>>>
>>>
>>> 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...@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/5d9fda07-2a03-4fe9-8046-e853fd616943%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/5d9fda07-2a03-4fe9-8046-e853fd616943%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/19ca0367-da06-496b-adb6-2a2a07c5efa6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/19ca0367-da06-496b-adb6-2a2a07c5efa6%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYULjoF%2BOGiJfNgMv90OSvnqcotRcwxmF8xkFSrnids3jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django admin_tools et file edition

2016-03-31 Thread Alex Heyden
CKEditor is appropriate for files that need solid typography and
formatting. If you're looking for something simpler, Markdown is a common
solution. Markdown is a markup syntax widespread on internet forums.

None of those really address "configuration files," though. Is fancy
formatting actually the problem you're trying to solve? Are you trying to
find a way to save and edit files on a hard drive? Save text to a database
to affect the behavior of your website? Something else?

On Thu, Mar 31, 2016 at 11:51 AM, vassilux  wrote:

> Hi alls,
> It is my first django project and   I look for a solution to edit files,
> for exemple allow to an "advanced user" editing configuration files.
>
>
> I looked into django-ckeditor
>   but it is
> not clear for the moment
>
> Where  I can look for informations / examples ?
>
>
> 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/5d9fda07-2a03-4fe9-8046-e853fd616943%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/CA%2Bv0ZYVzpsutDAj%3Db%2BHxyRZQC3R-EVReyLXDLsa%2BP8TS9-qXvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DjangoCon US 2016

2016-03-23 Thread Alex Heyden
The financial aid is nothing new, but "everyone pays" traditionally meant
that everyone, from speakers to organizers to volunteers, paid for a
ticket. Free tickets for speakers is unusual outside of paid keynote
speakers.

On Wed, Mar 23, 2016 at 6:29 PM, James Bennett 
wrote:

> From reading the CfP page I don't see much of a change; as far as I know
> with DjangoCon (and PyCon) it's always been the case that, as long as there
> was a financial aid program, speakers could make use of it, and I believe
> one or the other or both have prioritized speakers to ensure that getting
> to the conference isn't a hardship for them. It might not always have been
> presented in exactly those terms (or that clearly), though, so perhaps the
> change is being so up-front about it :)
>
> On Wed, Mar 23, 2016 at 2:20 PM, Alex Heyden 
> wrote:
>
>> This is an unexpected break from the old "everyone pays" policy. Has
>> there been trouble getting proposals in the past?
>>
>> On Wed, Mar 23, 2016 at 10:00 AM, Andrew Pinkham 
>> wrote:
>>
>>> We are pleased to announce that DjangoCon US will be hosted by the
>>> Wharton School at the University of Pennsylvania in Philadelphia from July
>>> 17-22!
>>>
>>> The call for proposals is open!
>>> <https://2016.djangocon.us/blog/2016/03/16/call-proposals-open/> We
>>> want to hear about your experience with and around Django. However, talks:
>>>
>>> - Don't need to be about Django specifically
>>> - Don't need to be 100% fleshed out.
>>> - Don't need to be about software directly
>>> - Don't need to be advanced
>>>
>>> Apply now! The deadline is April 18th.
>>> <https://2016.djangocon.us/speaking/>
>>>
>>> Never spoken before? Not a problem! There are speaker mentors that will
>>> help you (see the link above).
>>>
>>> Is cost a concern? Not a problem! Apply for financial aid (deadline
>>> April 25th). <https://2016.djangocon.us/financialaid>
>>>
>>> You can follow all the latest on Twitter <https://twitter.com/djangocon>
>>> .
>>>
>>> Hope to see you in Philly!
>>>
>>> Andrew
>>>
>>> --
>>> 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/AE8F82AA-269C-473E-863D-6E6EAF242219%40andrewsforge.com
>>> <https://groups.google.com/d/msgid/django-users/AE8F82AA-269C-473E-863D-6E6EAF242219%40andrewsforge.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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYU-7%2B4EYAdQnk3qCYdC4DXBS%2B3yu9z9frJkAWBaGKQkDg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYU-7%2B4EYAdQnk3qCYdC4DXBS%2B3yu9z9frJkAWBaGKQkDg%40mail.gmail.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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAL13Cg-WDxXOstO%2BA0TbKqYJBKTZVTt%2Bi8WHKpfy6DSeL3u-Lw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAL13Cg-WDxXOstO%2BA0TbKqYJBKTZVTt%2Bi8WHKpfy6DSeL3u-Lw%40mail.gmail.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVqgavPs%2Bq-jQwkdN_BEbr%2BeXPdJhXMvSFKQi5c9Ohzsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DjangoCon US 2016

2016-03-23 Thread Alex Heyden
This is an unexpected break from the old "everyone pays" policy. Has there
been trouble getting proposals in the past?

On Wed, Mar 23, 2016 at 10:00 AM, Andrew Pinkham 
wrote:

> We are pleased to announce that DjangoCon US will be hosted by the Wharton
> School at the University of Pennsylvania in Philadelphia from July 17-22!
>
> The call for proposals is open!
>  We want
> to hear about your experience with and around Django. However, talks:
>
> - Don't need to be about Django specifically
> - Don't need to be 100% fleshed out.
> - Don't need to be about software directly
> - Don't need to be advanced
>
> Apply now! The deadline is April 18th.
> 
>
> Never spoken before? Not a problem! There are speaker mentors that will
> help you (see the link above).
>
> Is cost a concern? Not a problem! Apply for financial aid (deadline April
> 25th). 
>
> You can follow all the latest on Twitter .
>
> Hope to see you in Philly!
>
> Andrew
>
> --
> 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/AE8F82AA-269C-473E-863D-6E6EAF242219%40andrewsforge.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/CA%2Bv0ZYU-7%2B4EYAdQnk3qCYdC4DXBS%2B3yu9z9frJkAWBaGKQkDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I don't understand this error - Django 1.9

2016-03-04 Thread Alex Heyden
If you get longer stacktraces back, those might help in identifying what
exactly is going wrong.

As a first pass cleanup, try:
* remove 'ladynerds' from the bottom of INSTALLED_APPS. You're already
including it up top
* change __init__.py to read "default_app_config =
'ladynerds.apps.LadyNerdsConfig'". No import apps, camel casing only at the
end.
* change the name field of the app config to "ladynerds" instead of
"LadyNerds" (but the verbose name should be fine)

On Fri, Mar 4, 2016 at 3:24 PM, Becka R.  wrote:

> Hi,
>
> I'm building a pretty basic CRUD application for a community I'm part of.
>   I'm now getting "ImportError: No module named [myappname]" when I run the
> server, and an operational error in the admin.
>
> I looked at the documentation, and followed the steps, but I'm not doing
> something correctly.  I'd like to 1) fix this, and 2) propose some changes
> to the docs to clarify this issue.
>
> My project is called "ladynerds" (We're a professional association for a
> bunch of women software engineers).
>
> Here's the documentation I'm following:
>
> https://docs.djangoproject.com/en/1.9/ref/applications/
>
> I'm using Django 1.9
>
> *Here's my file structure:*
>
> /ladynerds   (project file)
>  /ladynerds  (app)
>   __init__.py
>   models.py
>   forms.py
>   settings.py
>   urls.py
>   views.py
>   wsgi.py
>   /static
>   /templates
>
>
> *Here's what I put into ladynerds/__init__.py:*
>
>
> import apps
>
> default_app_config = 'LadyNerds.apps.LadyNerdsConfig'
>
>
> I've also tried using 'ladynerds.apps.LadyNerdsConfig'
>
>
> *Here's what I put into ladynerds/apps.py:*
>
> from django.apps import AppConfig
>
> class LadyNerdsConfig(AppConfig):
> name = "LadyNerds"
> verbose_name = "LadyNerds"
>
> *Here's my settings.py INSTALLED_APPS*
>
>
> INSTALLED_APPS = (
> 'ladynerds.apps.LadyNerdsConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'ladynerds'
> )
>
>
> I'm getting:  ImportError: No module named LadyNerds
>
> What am I missing?
>
> And, thanks.
>
> Becka
>
> --
> 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/2e9e6959-0dc6-4cfb-9fe1-5aaf77db852f%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/CA%2Bv0ZYXmk3ib7KaHA9J%2B4Jnp-LozAfSOd0d79wW5cPUHL3k%3D1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL namespaces

2016-02-25 Thread Alex Heyden
Models don't have views. Applications have views. URLs route to views, not
models. Include is basically an import for a urls.py file as a whole, so
there's no reason to import the same file multiple times unless you wanted
it to match multiple URLs.

What are you actually trying to do?

On Thu, Feb 25, 2016 at 2:45 PM, Malik Rumi  wrote:

>
> Assuming it can be done, what is the proper way to namespace two models in
> the same app, where both use slugs in the url but have different views and
> templates?
>
> In the docs,
> https://docs.djangoproject.com/en/1.9/topics/http/urls/#url-namespaces,
> it talks about how to do this, but it always refers to 'applications'
> rather than 'models'.
>
>
> So can I do:
>
> *urls.py*
>
> url(r'^model1/', include('app.urls', appview4model1,
> namespace='app.model1')
>
> url(r'^model2/', include('app.urls', appview4model2,
> namespace='app.model2')
>
>
>
> *app.urls.py *
>
> app_name = "app.model1"
>
> urlpatterns [ ]
>
> app_name = "app.model2"
>
> urlpatterns [ ]
>
>
> Frankly, I want the shortest urls possible, so if there was a way to do
> this without putting 'model1' or 'model2' in the url, that would be great,
> but I'm not seeing a way around it - assuming the app_name = 'app.model1'
> thing even works.
>
> Another option I thought of but don't know if possible:
>
> try url(r'^(?P) )
> except url(r'^modelname(?P) )
>
> I've never seen anything like that, though. If it did work, I doubt it
> would fit inside urlpatterns[ ], but maybe I could put it after?
>
> Or I could hack the code that handles url name collisions (once I find it)
>
>
> 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/fdb1ce25-0840-49d3-ab79-3011128a7207%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/CA%2Bv0ZYVRQvVCF5NUVwhcUX38SCxo_oxoxkS0MVn%3DGHf8y8GaXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django allow Circular Model Relation

2016-02-19 Thread Alex Heyden
You would use it any time the relationship means something different. It
would generally be inappropriate to use it as a simple backwards
relationship (Django does this for you), but there's no reason not to have
multiple relationships in a number of directions. In an HR system, someone
could be both my beneficiary and my employee.

On Fri, Feb 19, 2016 at 9:29 AM, Eddilbert Macharia 
wrote:

> Hello vadim when would such a relationship be needed I'm curious
>
> --
> 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/fbf2ef33-9309-44ce-aa73-f0238264589c%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/CA%2Bv0ZYWJMybd4EaFhYFA2DgBdrhLeoqR2Ko46%2BcB_3250R-eSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: var1 = var2 = var3

2016-02-16 Thread Alex Heyden
That's an assignment statement. See
https://docs.python.org/2/reference/simple_stmts.html for more.

On Tue, Feb 16, 2016 at 2:05 PM, anotherdjangonewby <
anotherdjangone...@gmx.de> wrote:

> Hi,
>
> this may be a bit off-topic, but:
>
> How are expressions like:
>
> var1 = var2 = var3
>
> called Python. Without a hint I cannot goolge this.
>
> Thanks
>
> Kai
>
> --
> 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/56C38119.5040807%40gmx.de.
> 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/CA%2Bv0ZYVcX1Lv5XD_fanPFXtaen%3D-mWnb7uMA5pO5iq7NrdeF6g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [1.8] Odd error on makemigrations when moving model to another application

2015-11-02 Thread Alex Heyden
I tried putting the model back in its original module with some much
smaller changes, but I'm getting the same error. The error is nonsense in
the current context.

Is there some intermediate state saved somewhere when you try to run
makemigrations?

On Mon, Nov 2, 2015 at 4:34 PM, Alex Heyden  wrote:

> Traceback first:
>
> ./manage.py makemigrations
> Traceback (most recent call last):
>   File "./manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 351, in execute_from_command_line
> utility.execute()
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 343, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 394, in run_from_argv
> self.execute(*args, **cmd_options)
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 445, in execute
> output = self.handle(*args, **options)
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py",
> line 125, in handle
> migration_name=self.migration_name,
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
> line 43, in changes
> changes = self._detect_changes(convert_apps, graph)
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
> line 110, in _detect_changes
> self.old_apps = self.from_state.concrete_apps
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/state.py",
> line 170, in concrete_apps
> self.apps = StateApps(self.real_apps, self.models,
> ignore_swappable=True)
>   File
> "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/state.py",
> line 248, in __init__
> raise ValueError(msg.format(field=operations[0][1],
> model=lookup_model))
> ValueError: Lookup failed for model referenced by field
> sdd.Documentation.opportunity: sdd...governance.models.Opportunity
>
> Needless to say, sdd...governance.models.Opportunity is not a valid
> path to anything.
>
> The Opportunity model was moved from the sdd application to the governance
> application. Documentation has a foreign key to Opportunity. The Python
> itself is correct. It used to be a direct reference to the class in the
> module, now it's an imported reference. All of the foreign keys are handled
> in the same way. Nothing is done by string.
>
> I'm ok with a one-off solution for the migration, but I'm more interested
> in *why* the model path is so far off and what I might have done to cause
> it.
>
> --
> 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/d5d6fcf9-8b76-4448-81fb-e38765b66d03%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d5d6fcf9-8b76-4448-81fb-e38765b66d03%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/CA%2Bv0ZYWOTbagf0NUYy9%2BrCwQNPjaDJzdZAaOgCkm7ox7%2BXY60A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[1.8] Odd error on makemigrations when moving model to another application

2015-11-02 Thread Alex Heyden
Traceback first:

./manage.py makemigrations
Traceback (most recent call last):
  File "./manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 351, in execute_from_command_line
utility.execute()
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 394, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 445, in execute
output = self.handle(*args, **options)
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py",
 
line 125, in handle
migration_name=self.migration_name,
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
 
line 43, in changes
changes = self._detect_changes(convert_apps, graph)
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
 
line 110, in _detect_changes
self.old_apps = self.from_state.concrete_apps
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/state.py",
 
line 170, in concrete_apps
self.apps = StateApps(self.real_apps, self.models, 
ignore_swappable=True)
  File 
"/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/state.py",
 
line 248, in __init__
raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
ValueError: Lookup failed for model referenced by field 
sdd.Documentation.opportunity: sdd...governance.models.Opportunity

Needless to say, sdd...governance.models.Opportunity is not a valid 
path to anything.

The Opportunity model was moved from the sdd application to the governance 
application. Documentation has a foreign key to Opportunity. The Python 
itself is correct. It used to be a direct reference to the class in the 
module, now it's an imported reference. All of the foreign keys are handled 
in the same way. Nothing is done by string.

I'm ok with a one-off solution for the migration, but I'm more interested 
in *why* the model path is so far off and what I might have done to cause 
it.

-- 
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/d5d6fcf9-8b76-4448-81fb-e38765b66d03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Alex Heyden
I don't quite follow what you're doing with set_first_call_true and
set_first_call_false. Are you using that to control the for loop behavior?

If you are, take a look at
https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#for. Django's
template language has that built in.

If you're pushing to an array like in your initial example, you don't need
to handle commas at all. Here's an example out of Chrome's dev tools:

> var a = []
> a.push('foo')
> a.push('bar')
> a
< ["foo", "bar"]

If you want to define it in one go, try something more like:


my_markers = [
{% for current_addr in mymodel.addresses.all %}
{
lat: {{ current_addr.lat }},
lon: {{ current_addr.lon }},
description: {{ current_addr.description | safe }}
}{% if not forloop.last %}, {% endif %}
{% endfor %}
];


On Tue, Aug 4, 2015 at 10:53 AM, Déborah Leder  wrote:

> After some more tests, I have managed to understand where my problem is
> (but I don't know how to resolve it).
> Here is my final piece of code :
>  >
>
> 
> my_markers = [
> {{ mymodel.set_first_call_true }}
> {% for current_addr in mymodel.addresses.all %}
> {% if not mymodel.first_call %},{% endif %}
> {
> lat: {{ current_addr.lat }},
> lon: {{ current_addr.lon }},
> description: {{ current_addr.description | safe }}
> }
> {{ mymodel.set_first_call_false }}
> {% endfor %}
> ];
> 
>
>  >
>
>
> I had to add an attribute "first_call" to mymodel, so that my javascript
> declaration was correct (in an array, we should always write the comma
> between 2 elements, but not after each element or before each element).
> The only problem is that every time I call mymodel.set_first_call_true or
> mymodel.set_first_call_false, it inserts a "none" inside my javascript
> code.
> Is it possible to "delete" the "non" statement ?
>
>
> --
> 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/232757e4-0a4b-450f-808d-764453783dea%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/CA%2Bv0ZYVp8Z1S7qXq%3DjELWpWQKd4-KjTw5DX2ZDdTedxKtuja5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: same field in two classes

2015-08-02 Thread Alex Heyden
Sorry, I think there might be a bit of a language barrier. What do you mean
by "take the value of employee salary to payroll salary?"

On Sun, Aug 2, 2015 at 12:12 PM, Giovanny Vizcaya  wrote:

> Good day,i'm new in django and i'm doing a project, i have a class
> "Employee" with atribute "salary", same time i have class "Payroll" with
> atribute "salary", how can i take the value of employee salary to payroll
> salary? thank you in advance for answers
>
> --
> 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/5a479e43-4612-4b2e-92be-638b5eec9124%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/CA%2Bv0ZYWmYsUj1v_q2h4ooK7u_UyrntYqzKGjB00FK3e6s410Zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Want to change template based on full_name(request.user.username)

2015-07-29 Thread Alex Heyden
{{user}} is implicitly sent in the request, so it might be worth trying to
sort out what specifically went wrong when you say
{{user.is_authenticated}} went wrong.

Here's a fully functioning example of some things you can do with the user
object:

{% block header %}


Home

{% if user.is_authenticated %}


Projects
Reports
{% if user.is_staff %}
Usage
{% endif %}


{% if user.is_superuser %}
Settings
{% endif %}


{% if user.first_name %}
Welcome, {{ user.first_name }}
{% else %}
Welcome, {{ user.username }}
{% endif %}


Sign Out




{% endif %}

{% endblock %}

On Wed, Jul 29, 2015 at 4:20 PM, sarfaraz ahmed 
wrote:

> Hello All,
>
> I am facing an issue in my first django project. I am newbie. So, please
> help me in detail. I don't want to use {{full_name}} in all the views. I
> saw few post which says {{user.is_authenticated}} can be used. I tried but
> it was not working. Passing {'full_name':request.user.username} to each is
> very hectic. Also, not sure to this in one of my view where i am using
> password_change. View is mentioned below where i am not able pass full_name.
>
> This is mentioned below is my *navigation.html*
>
>
> 
>   
> 
> 
>data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
> aria-expanded="false">
> Toggle navigation
> 
> 
> 
>   
>   
> 
>
> 
>  id="bs-example-navbar-collapse-1">
>   
> Home  class="sr-only">(current)
> Sale  class="sr-only">(current)
> About Us
>
>   
> 
>   
>
> {%if full_name %}
>
> 
>
>role="button" aria-haspopup="true" aria-expanded="false">{{full_name}} class="caret">
>   
> My Account
> Orders
> Profile
> Change
> Password
> 
> Logout
>   
> 
> {% else %}
> Register
> Login
> {% endif %}
>   
> 
>   
> 
>
>
> 
> @login_required
> def
> my_change_password_view(request,template_name='useraccount/password_change_form.html'):
> return password_change(request,template_name)
>
> --
>
> 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/f8521d79-c2a0-40a9-bd4e-0a90625264fe%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/CA%2Bv0ZYW0S-UpbAvFY4RuVUQXKKRPsK3DhX1qefSQYvgFk3c3aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to django with jquery-mobile

2015-07-29 Thread Alex Heyden
You pretty much answered it yourself.

>there's just one actual html page and inside it we have to create a page
(data-role="page")

Django's template helps you put together the response that gets to the
client. It's unaware of what your CSS and Javascript frameworks will do
with that response.

You can use Django's template features for better organization. Blocks are
an obvious one. You can also split pages and dialogs out into their own
.html files and include them to make a larger single response. That's just
organization, though. Your front-end system is separate from Django. That
would work the same way whether Django served that response or you saved it
to a file on your computer.

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


Re: Django Model field : Ordered List of Foreign Keys

2015-07-23 Thread Alex Heyden
There are options, but here's what I'd do:

class Stop(models.Model):
  name = models.TextField()  #use CharField if not using Postgres
  latitude = models.DecimalField()
  longitude = models.DecimalField()
  route = models.ForeignKey('Route')
  sequence = models.IntegerField()

  class Meta:
unique_together = (('route', 'sequence'), )
ordering = ['route', 'sequence']

class Route(models.Model):
  # I'm sure there's something you want to know about the route,
  # so add it here.

>>> stops = Route.objects.first().stop_set


On Thu, Jul 23, 2015 at 9:21 PM, Ankit Agrawal  wrote:

> I have a `Route` model which should store an ordered list of stops along
> that route. How should I go about modeling this relation?
>
> class Stop(models.Model):
> name = ..
> latitude = ..
> longitude = ..
>
> class Route(models.Model):
> stops_list = # Ordered list of stops on the route
>
>
>  --
> 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/72e84a42-a0ad-4dcb-bfcd-948d1050c8e2%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/CA%2Bv0ZYXhHwWHAovVC7RFhD6bm7Nmz%2BCSQrSSaSeqCZC9g7ybUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Buttons

2015-07-22 Thread Alex Heyden
A fair bit of this is Javascript, which, strictly speaking, is outside the
scope of Django.

>From what you're saying, it sounds like your button does two things: make a
backend database change and make a frontend display change. Ultimately, the
action starts with a Javascript event handler. On button click, do work.

On the Django side, you want a view that will capture the change. There's
more than a few ways to do this, but if you're just talking about a
one-and-done like this and you don't want a bunch of extra libraries, I'd
make a simple, dedicated view that takes whatever parameters you need to
specify the correct boolean field on POST and returns a JSON response to
the effect of {success: [true|false], reason: 'failure reason, if any'}.
Don't forget to update your urls.py to reflect the new view.

On the Javascript side, in the registered function, you write code that
both posts to your Django view in an Ajax call and, if successful, makes
the display change.

On Wed, Jul 22, 2015 at 5:35 PM, Jake Rudolph  wrote:

> I am trying to make a button on the index page that changes the boolean
> field of my object, and then displays that object in a different place on
> the page. I am not sure what to put as the action for this button, and
> where to put and call the function that will actually change the value in
> the database.
>
> --
> 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/564ecb34-8176-474a-8175-eb1c5b134522%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/CA%2Bv0ZYVrTGogQ8vd4eY9NcCy2Xn0KskAcybNJSTSZLEpr0j-FA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Diable basic auth on some pages

2015-06-30 Thread Alex Heyden
Cherie,

By default, there are no authentication controls in Django. Barring some
custom middleware, authentication checks are performed within the views
themselves or through something like the @login_required or
@user_passes_test decorators. Are you certain that authentication is what's
blocking your requests?

On Tue, Jun 30, 2015 at 9:43 AM, Cherie Pun  wrote:

> Hi,
>
> In the dev version of the website, we are using basic auth to limit
> access. However, we are currently developing an api for the website and I
> would like to use the api without going through the basic auth. Is it
> possible to disable basic auth for all the api urls?
>
> Cheers,
> Cherie
>
> --
> 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/0d9a681e-74c4-4b74-9648-e0e6c74beeb6%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/CA%2Bv0ZYV1KjzF3Ao%2By7hp-WA8Txkuoj-uxTtwNv0%2B%2Bm-T0MmZRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.