Re: Why is this acting like a permanent redirect?

2021-02-23 Thread Robert F
Thanks David.  I'll give this a try.

On Monday, February 22, 2021 at 4:56:11 PM UTC-8 David Nugent wrote:

> Hi Robert,
>
> To point out the most likely cause of the issue: LOGIN_REDIRECT_URL is a 
> url, not a route name.
>
> Possibly could use a reverse_lazy('login-redirect') here after import 
> django.urls, but - untested.
>
> Regards,
> David
>
> On 23 February 2021 at 07:07:52, Robert F (robe...@gmail.com) wrote:
>
> I have a Django view that I redirect a user to after they login:
>
> # settings.py
> LOGIN_REDIRECT_URL = 'login-redirect'
>
> # account/urls.py
> urlpatterns = [
> path('', include('django.contrib.auth.urls')),
> ...
> ]
>
> # home/views.py
> from account.models import Member
>
> def login_redirect(request):
> """
> Redirect member to appropriate page when they log in.
> """
> member = Member.objects.get(user__id__exact=request.user.id)
> if member.has_profile:
> return redirect('homepage', member_id=member.id)
> else:
> return redirect('profile-create', member_id=member.id)
>
> If I start Django's development server and execute this code when the 
> condition ```member.has_profile = True```, Django redirects me to the 
> homepage view as expected.  But if I then go into the database and set 
> has_profile to False, restart the web server, and execute code again, my 
> website acts as if the code isn't executed.  Instead, I'm sent immediately 
> to the homepage view again.  I can see this by looking at the terminal 
> console:
>
> [19/Feb/2021 ...] "GET /account/login/ HTTP/1.0" 200 4268   # I'm 
> using Django's default login method
> [19/Feb/2021 ...] "POST /account/login HTTP/1.0" 302 0
> [19/Feb/2021 ...] "GET /home/login_redirect/ HTTP/1.0" 200 4599
>
> This happens even though I am restarting the server and clearing my 
> browser's cache.  In fact, I can edit the login_redirect function so that 
> it only contains a single line ```pass``` and I'm still sent to the 
> homepage after logging in.
>
> def login_redirect(request):
> pass
>
> Why is this happening?  I'm not doing a permanent redirect.  And should I 
> not be using the redirect method in my login_redirect method to send a user 
> to a different page depending on whether or not they have a profile?
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/8423cc0d-b83b-4115-b9fa-6a28e93210d8n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/8423cc0d-b83b-4115-b9fa-6a28e93210d8n%40googlegroups.com?utm_medium=email_source=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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d108d8e4-9ffa-4747-890c-ae5c3dc0367an%40googlegroups.com.


Why is this acting like a permanent redirect?

2021-02-22 Thread Robert F
I have a Django view that I redirect a user to after they login:

# settings.py
LOGIN_REDIRECT_URL = 'login-redirect'

# account/urls.py
urlpatterns = [
path('', include('django.contrib.auth.urls')),
...
]

# home/views.py
from account.models import Member

def login_redirect(request):
"""
Redirect member to appropriate page when they log in.
"""
member = Member.objects.get(user__id__exact=request.user.id)
if member.has_profile:
return redirect('homepage', member_id=member.id)
else:
return redirect('profile-create', member_id=member.id)

If I start Django's development server and execute this code when the 
condition ```member.has_profile = True```, Django redirects me to the 
homepage view as expected.  But if I then go into the database and set 
has_profile to False, restart the web server, and execute code again, my 
website acts as if the code isn't executed.  Instead, I'm sent immediately 
to the homepage view again.  I can see this by looking at the terminal 
console:

[19/Feb/2021 ...] "GET /account/login/ HTTP/1.0" 200 4268   # I'm 
using Django's default login method
[19/Feb/2021 ...] "POST /account/login HTTP/1.0" 302 0
[19/Feb/2021 ...] "GET /home/login_redirect/ HTTP/1.0" 200 4599

This happens even though I am restarting the server and clearing my 
browser's cache.  In fact, I can edit the login_redirect function so that 
it only contains a single line ```pass``` and I'm still sent to the 
homepage after logging in.

def login_redirect(request):
pass

Why is this happening?  I'm not doing a permanent redirect.  And should I 
not be using the redirect method in my login_redirect method to send a user 
to a different page depending on whether or not they have a profile?

-- 
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/8423cc0d-b83b-4115-b9fa-6a28e93210d8n%40googlegroups.com.


How to programmatically set the model when using Django CreateView?

2021-01-29 Thread Robert F.
I am trying to programmatically set the model for a Django class-based view 
that inherits from CreateView and displays a form for creating a 'member' 
object. My problem is that  my template is not displaying the form itself. 
Note that I override the 'get' method to determine what model the view 
should use. The template page renders and I see the submit button but when 
I view the page's source code, the form is missing. Here's my code:

# urls.py
path('profile/create/', views.ProfileCreate.as_view(), 
name='profile-create'),

# views.py
class ProfileCreate(CreateView):
model = None
template_name = None

def get(self, request, *args, **kwargs):
member = Member.objects.get(user=request.user)
if member.is_couple:
self.model = ProfileCouple
self.template_name = 'account/profile_couple_create.html'
self.fields = ['person1_name', 'person2_name',
   'person1_dob', 'person2_dob']
else:
self.model = ProfileSingle
self.template_name = 'account/profile_single_create.html'
self.fields = ['person1_name', 'person1_dob']

context = {}
return render(request, self.template_name, context)

# models.py
class ProfileSingle(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, 
null=True)
person1_name = models.CharField(_("Name"), max_length=50)
person1_dob = models.DateField()

def __str__(self):
return self.user.username

class ProfileCouple(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, 
null=True)
person1_name = models.CharField(_("Name 1"), max_length=50)
person1_dob = models.DateField()
person2_name = models.CharField(_("Name 2"), max_length=50)
person2_dob = models.DateField()

def __str__(self):
return self.user.username

# forms.py
class CreateSingleProfileForm(forms.ModelForm):
class Meta:
model = ProfileSingle
fields = ('user', 'person1_name', 'person1_dob')
labels = {'user': _('Username'), 'person1_name': _(
'Person 1 Name'), 'person1_dob': _('Person 1 DOB')}

class CreateCoupleProfileForm(forms.ModelForm):
class Meta:
model = ProfileCouple
...

# profile_single_create.html

  Create Your Profile
  {% csrf_token %}
  {{ form.as_p }}
  
  


# profile_couple_create.html
(Code similar to single template)

I know that with CBVs, Django will build the form for me.  But there will 
be times when I need to customize the form as I do here. What am I missing?

-- 
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/6d394628-6132-4927-8324-466347c8c427n%40googlegroups.com.


Re: Good Django libraries to read to really understand class-based views?

2021-01-12 Thread Robert F.
Thank you to everyone who took time to answer my question!  I will check 
out the resources you mentioned.

On Tuesday, January 12, 2021 at 7:21:33 AM UTC-8 David Nugent wrote:

> Robert,
>
> I think the ultimate resource you can use on this beyond the documentation 
> is the django source code itself.
>
> It may look confusing at first, but if you check out the class hierarchy 
> from the starting points in the docs, how classes are related and mix-ins 
> are used, you gain a lot of insight you don't and can't get from the docs. 
>  With that understanding you are able to author with your own CBVs derived 
> from the bits provided by Django to create a great deal of customisation 
> for you applications where the stock ones may not fit.
>
> There is no better teacher than trying things yourself, working out what 
> went wrong when it does not work.
>
> But I'll provide a nutshell version:
>
> Essentially a CBV is a class that provides functionality around 
> dispatching a web request. At the core is the 
> dispatch() method, which passes the request onto specific method handlers. 
>  Anything else beyond that supports more specific use cases that usually 
> simplifies handling the request - i.e. templates - and each of those 
> provides its own set of patterns.
>
> HTH, 
> /d
>
>
> On 12 January 2021 at 02:15:11, Robert F. (robert@gmail.com) wrote:
>
> Are there any Django libraries that make extensive use of class-based 
> views that I might study if I want to gain an in-depth understanding of how 
> to use them? The Django documentation is OK at explaining what they are and 
> how they work but most of the examples are very trivial in nature. I'd like 
> to become a "power user" and for that I need lots of code to study. I've 
> looked at the Classy Class-Based Views <https://ccbv.co.uk/> examples but 
> they seem too "meta" to me to shed any real light on how to use them in 
> practice. 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/eda0feed-fb61-4882-bbc3-14531b13526fn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/eda0feed-fb61-4882-bbc3-14531b13526fn%40googlegroups.com?utm_medium=email_source=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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/41a1019d-3da5-40cc-9abe-5b69d77cc542n%40googlegroups.com.


Good Django libraries to read to really understand class-based views?

2021-01-11 Thread Robert F.
Are there any Django libraries that make extensive use of class-based views 
that I might study if I want to gain an in-depth understanding of how to 
use them? The Django documentation is OK at explaining what they are and 
how they work but most of the examples are very trivial in nature. I'd like 
to become a "power user" and for that I need lots of code to study. I've 
looked at the Classy Class-Based Views  examples but 
they seem too "meta" to me to shed any real light on how to use them in 
practice. 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eda0feed-fb61-4882-bbc3-14531b13526fn%40googlegroups.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Robert F.


On Thursday, February 20, 2020 at 8:52:31 AM UTC-8, Stephen J. Butler wrote:
>
> Django only serves up static files itself when run using runserver. This 
> is meant for development and not production use. When you run it through 
> gunicorn the Django framework won't serve up static files. That's why you 
> connections to :8000 (gunicorn directly, bypassing nginx) don't work right.
>
> For running in production/gunicorn you need to run "collectstatic" after 
> changes, and connect to nginx (probably port 80/443) so that the 
> "location/alias" block works as intended and you get your static files.
>
>
>> I understand what you're saying but I don't understand specifically what 
>> it is that I'm doing wrong.  Should I not start Gunicorn with ":8000"?  Do 
>> I need to modify my Nginx configuration file?  I don't quite see how all of 
>> these pieces work together and which piece (or pieces) are wrong.  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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f1cd8e78-17ae-47c0-91e8-732a52c9%40googlegroups.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Robert F.
Thanks but I'm not interested in using Whitenoise.

On Friday, February 21, 2020 at 6:22:40 AM UTC-8, Jody Fitzpatrick wrote:
>
> Take a look at whitenoise for django, this should help you. 
>
> On Thursday, February 20, 2020 at 11:35:51 AM UTC-5, Robert F. wrote:
>>
>> I'm trying to understand how static files are served up by Django using a 
>> project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The 
>> website serves up templates correctly except that the templates can't see 
>> my CSS stylesheet.  When I go to a page, for example ```
>> 127.0.0.1:8000/app1/``` <http://127.0.0.1:8000/app1/> and view the 
>> source, I see this in my HTML template:
>>
>> 
>>
>> If I click on the href link, I get a page "Not Found" at the address ```
>> http://127.0.0.1:8000/static/css/main.css``` 
>> <http://127.0.0.1:8000/static/css/main.css>.  This seems like it should 
>> be the correct link but the template can't see the main.css stylesheet as I 
>> would expect.
>>
>> Here are the relevant files in my 'mysite' project located in 
>> /Users/me/projects/django/django-staticfiles:
>>
>> ├── app1
>> │   ├── templates
>> │   │   └── app1
>> │   │   └── index.html
>> ├── mysite
>> │   ├── settings.py
>> │   └── wsgi.py
>> ├── static
>> │   └── css
>> │   └── main.css
>> ├── static-final
>> │   ├── admin
>> │   │   ├── css
>> │   │   ├── fonts
>> │   │   ├── img
>> │   │   └── js
>> │   └── css
>> │   └── main.css
>>
>> Here are the relevant settings:
>>
>> # mysite/settings.py
>> ...
>> DEBUG = False
>> ALLOWED_HOSTS = ['127.0.0.1', ]
>> ...
>> INSTALLED_APPS = [
>> 'django.contrib.staticfiles',
>> 'app1',
>> ]
>> ...
>> STATIC_URL = '/static/'
>> STATICFILES_DIRS = (
>> os.path.join(BASE_DIR, 'static'),
>> )
>> STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
>> ...
>>
>> I installed Gunicorn into my virtual environment and run it with this 
>> command:
>>
>> gunicorn --bind 0.0.0.0:8000 mysite.wsgi
>>
>> I installed Nginx using Homebrew.  Here is the part of nginx.conf that 
>> includes my Nginx settings:
>>
>> # /usr/local/etc/nginx.conf
>> ...
>> http {
>> ...
>> server {
>> listen  8080;
>> server_name localhost;
>> }
>> ...
>> include server/*;
>> }
>>
>> Here is my Nginx configuration:
>>
>> # /usr/local/etc/nginx/servers/django-staticfiles
>> server {
>> listen 80;
>> server_name 127.0.0.1;
>>
>> location / {
>> proxy_pass http://127.0.0.1:8000;
>> }
>>
>> location /static/ {
>> alias /Users/me/projects/django/django-staticfiles/static-final/;
>> }
>> }
>>
>> I should add that when I stop Gunicorn and start Django's development 
>> server with DEBUG = True, the app1 template accesses the main.css file 
>> correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I 
>> realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but 
>> I've just set it up so I can compare and contrast how Django manages static 
>> files in development versus production.
>>
>>

-- 
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/64a79357-c5db-4da6-8320-4b19d5fa51d1%40googlegroups.com.


Why can't Nginx find Django's static files?

2020-02-20 Thread Robert F.
I'm trying to understand how static files are served up by Django using a 
project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The 
website serves up templates correctly except that the templates can't see 
my CSS stylesheet.  When I go to a page, for example 
```127.0.0.1:8000/app1/``` and view the source, I see this in my HTML 
template:



If I click on the href link, I get a page "Not Found" at the address 
```http://127.0.0.1:8000/static/css/main.css```.  This seems like it should 
be the correct link but the template can't see the main.css stylesheet as I 
would expect.

Here are the relevant files in my 'mysite' project located in 
/Users/me/projects/django/django-staticfiles:

├── app1
│   ├── templates
│   │   └── app1
│   │   └── index.html
├── mysite
│   ├── settings.py
│   └── wsgi.py
├── static
│   └── css
│   └── main.css
├── static-final
│   ├── admin
│   │   ├── css
│   │   ├── fonts
│   │   ├── img
│   │   └── js
│   └── css
│   └── main.css

Here are the relevant settings:

# mysite/settings.py
...
DEBUG = False
ALLOWED_HOSTS = ['127.0.0.1', ]
...
INSTALLED_APPS = [
'django.contrib.staticfiles',
'app1',
]
...
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
...

I installed Gunicorn into my virtual environment and run it with this 
command:

gunicorn --bind 0.0.0.0:8000 mysite.wsgi

I installed Nginx using Homebrew.  Here is the part of nginx.conf that 
includes my Nginx settings:

# /usr/local/etc/nginx.conf
...
http {
...
server {
listen  8080;
server_name localhost;
}
...
include server/*;
}

Here is my Nginx configuration:

# /usr/local/etc/nginx/servers/django-staticfiles
server {
listen 80;
server_name 127.0.0.1;

location / {
proxy_pass http://127.0.0.1:8000;
}

location /static/ {
alias /Users/me/projects/django/django-staticfiles/static-final/;
}
}

I should add that when I stop Gunicorn and start Django's development 
server with DEBUG = True, the app1 template accesses the main.css file 
correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I 
realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but 
I've just set it up so I can compare and contrast how Django manages static 
files in development versus production.

-- 
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/75f129a6-2dbf-47cc-b4ea-08008b30b047%40googlegroups.com.


Re: CSRF verification failed when I use smart phone

2019-06-25 Thread Robert F.
Make sure you aren't blocking cookies on whatever device is giving you 
problems.  You'll get this error if you are blocking them.

On Tuesday, January 6, 2015 at 1:09:46 AM UTC-8, Sugita Shinsuke wrote:
>
> Hello.
>
> When I use Django via my smart phone Android and iOS.
> The error sometimes occurred.
>
> Forbidden (403)
> CSRF verification failed. Request aborted.
> Help
> Reason given for failure:
> CSRF token missing or incorrect.
>
> In general, this can occur when there is a genuine Cross Site Request 
> Forgery, or when Django's CSRF mechanism has not been used correctly. For 
> POST forms, you need to ensure:
> Your browser is accepting cookies.
> The view function uses RequestContext for the template, instead of Context.
> In the template, there is a {% csrf_token %} template tag inside each POST 
> form that targets an internal URL.
> If you are not using CsrfViewMiddleware, then you must use csrf_protect on 
> any views that use the csrf_token template tag, as well as those that 
> accept the POST data.
> You're seeing the help section of this page because you have DEBUG = True 
> in your Django settings file. Change that to False, and only the initial 
> error message will be displayed.
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>
> I append django.middleware.csrf.CsrfViewMiddleware', of MIDDLEWARE_CLASSES 
> in settings.py
>
> I use
> Python 2.7.5
> Django 1.6.4
>
> Anyone who know this matter, please 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-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/cb4f6aba-85e6-4105-9fe4-b3cbcddca727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where did admin CSS file "ie.css" go after Django 1.8?

2019-06-17 Thread Robert F.
I've discovered the problem.  The release notes for Django 1.9 say, "The 
admin no longer supports Internet Explorer 8 and below, as these browsers 
have reached end-of-life."  Thus, this file is no longer included in Django.

On Monday, June 17, 2019 at 12:00:08 PM UTC-7, Robert F. wrote:
>
> I'm in the process of upgrading a large Django project from 1.8 to 2.2. 
>  Currently, I'm at 1.9.13.  My project has a couple of admin forms that 
> utilize a Django CSS file admin/css/ie.css.  In Django 1.8, that file was 
> located here:
>
> django/contrib/admin/static/admin/css/ie.css
>
> But in Django 1.9.13 that file is missing.  In it's place is a 'forms.css' 
> file.  Does anyone know what happened to the old ie.css file?  I've 
> searched online and also all 14 of the release notes for Django 1.9 and I 
> don't see this mentioned anywhere.
>
> 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/fc14af29-f0ac-4701-a61c-102d97016772%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Where did admin CSS file "ie.css" go after Django 1.8?

2019-06-17 Thread Robert F.
I'm in the process of upgrading a large Django project from 1.8 to 2.2. 
 Currently, I'm at 1.9.13.  My project has a couple of admin forms that 
utilize a Django CSS file admin/css/ie.css.  In Django 1.8, that file was 
located here:

django/contrib/admin/static/admin/css/ie.css

But in Django 1.9.13 that file is missing.  In it's place is a 'forms.css' 
file.  Does anyone know what happened to the old ie.css file?  I've 
searched online and also all 14 of the release notes for Django 1.9 and I 
don't see this mentioned anywhere.

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/9b4dc2b7-5522-4bdb-9875-25d226a9e126%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Turn off migrations completely in Django 1.7

2017-08-01 Thread Robert F.
I know this is an old topic but I completely agree with Frank.  Nothing 
gives me more headaches and makes me want to move off Django more than 
migrations.  They seldom run smoothly and cause me no end of headaches.  I 
hate them!

On Friday, November 20, 2015 at 2:26:59 PM UTC-8, Frank Malina wrote:
>
> RE: Carl Meyer
> >> To my knowledge, out of the many hundreds of 
> >> thousands of Django users, you are the first and only one to request a 
> >> way to turn off migrations entirely.
>
> No he isn't, Django migrations are ridiculous waste of time, never work 
> and make me angry.
> I work with Django from v0.96 and it never got in the way as much as it 
> does now.
>

-- 
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/0eb69425-7fa5-48ce-b8d1-b2eac4726622%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Vim plugin that does Django code completion?

2017-07-07 Thread Robert F.
Thanks Mulianto and James.  To James, perhaps I don't have a good workflow 
which is why the ability to edit files on a remote server is also a 
necessity.  I grew tired of having to build a development environment on 
both my Mac laptop and my Debian server where my Django app runs so now I 
just log into my dev server and do all my editing there using Vim.  I don't 
have time to setup up a local Debian server using Vagrant and Ansible and 
even if I did, I suspect PyCharm would still think of that local VM as a 
remote server.  I'm not sure.  These environments can easily become 
complicated and confusing to a Django noob like me.  I'm not really sure 
what the optimal development environment setup should be.

On Friday, July 7, 2017 at 10:46:58 AM UTC-7, James Schneider wrote:
>
>
>
> On Jul 7, 2017 8:27 AM, "Robert F." <robert@gmail.com > 
> wrote:
>
> Is there a Vim plugin that does code completion for Django?  I'd like to 
> be able to type something like "foobar = models." and hit Tab and see a 
> list of classes like CharField or Foreign key.  Alternately, I'd be OK with 
> entering an abbreviation that would bring up the proper code snippet.  The 
> Django documentation suggests YouCompleteMe but it appears to only handle 
> Python code, not Django specifically.  Also, I haven't been able to get it 
> to work on my Mac laptop.
>
> I almost exclusively do editing of Django files on a remote Debian server 
> from my Mac laptop.  I know PyCharm provides the ability to edit remote 
> files and it has Vim emulation but it's pretty expensive and I'm not sure 
> how closely the emulator emulates Vim.  SublimeText appears to have a 
> "Djaneiro" package that does what I need but it looks like editing remote 
> files is rather difficult with Sublime.  Doesn't Vim have better support 
> for Django code completion that's comparable to these two applications?
>
>
> PyCharm's Vim emulation is quite excellent. For me, PyCharm pro is worth 
> the money for the extra Django integration. The community version is also 
> quite good, the only place I really missed the pro version is in the 
> template tags. The code completion works great as long as you mark your 
> project directories as source locations correctly.
>
> For editing remote files, you may want to look into using sshfs to mount 
> your project directly locally. It's basically a file share mounted over 
> SSH, so everything is encrypted in transit.
>
> http://www.miscdebris.net/blog/2009/06/29/installing-sshfs-on-mac-os-x/
>
> Typically though, I'm editing/running files locally, then pushing them to 
> the server via git.
>
> -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/21b0e473-07b4-4463-aa61-beb8e71efbf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Vim plugin that does Django code completion?

2017-07-07 Thread Robert F.
Is there a Vim plugin that does code completion for Django?  I'd like to be 
able to type something like "foobar = models." and hit Tab and see a list 
of classes like CharField or Foreign key.  Alternately, I'd be OK with 
entering an abbreviation that would bring up the proper code snippet.  The 
Django documentation suggests YouCompleteMe but it appears to only handle 
Python code, not Django specifically.  Also, I haven't been able to get it 
to work on my Mac laptop.

I almost exclusively do editing of Django files on a remote Debian server 
from my Mac laptop.  I know PyCharm provides the ability to edit remote 
files and it has Vim emulation but it's pretty expensive and I'm not sure 
how closely the emulator emulates Vim.  SublimeText appears to have a 
"Djaneiro" package that does what I need but it looks like editing remote 
files is rather difficult with Sublime.  Doesn't Vim have better support 
for Django code completion that's comparable to these two applications?

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


Strategies for Speeding Up Django 1.8 Tests?

2015-09-22 Thread Robert F.
Does anyone have any strategies or techniques for running their unit tests 
faster in Django 1.8?  My project has seven model modules containing 
twenty-one models (none of which are very complex).  I run my tests using 
the default Django test runner on a 1.86 GHz Mac laptop with 4 GB of RAM 
against a local PostgreSQL 9.4.4 database.  I'm finding that after 
upgrading to Django 1.8, my test suite takes longer to start up (about 
10-11 seconds) than it takes to run the 180+ tests themselves (about 9 
seconds).  I know one strategy would be to use SQLite for testing but I'd 
prefer to run against my actual database server.  I'm also using the 
django-test-without-migrations 
 package to 
avoid running migrations but that only speeds things up a little.  Is there 
anything else I can do?  The longer startup time for tests in Django 1.8 
really makes it difficult to do true test-driven development.

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/72fd74d1-15e7-432d-a11c-82af231ce4ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.