CSS not rendering on local server development

2012-10-02 Thread Jim Wombles
Greetings,

I am at a loss as to why local server is unable to render the css and js
files.  I have the static_dirs setting correct and the href link to the
files is correct, and the html file is rendering yet when I track what is
going on with Chrome Dev Tools it is unable to find the CSS and JS files
returning an Internal Server Error 500

Any idea what may be going on ?

Thanks for any advice.

Jim
Fanbouts.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSS not rendering on local server development

2012-10-02 Thread Jim Wombles
Well, your suggestion actually caused an error that helped me debug what 
was going on.  Silly mistake of forgetting the comma at the end of the 
tuple in staticfiles_dirs.  Cheers to you.

On Wednesday, October 3, 2012 12:07:33 AM UTC-4, JJ Zolper wrote:
>
> Off the top of my head I forget what kinks I ran into when trying to get 
> CSS to load on my development server. I'll try and come up with things I 
> remembered and let you know if I do.
>
> One thing in Chrome that I tend to have to do (probably why firefox is 
> better in this case) is I have to clear my browsing data. That way the 
> files propagate through to my browser. Here's how to do that:
>
> http://www.wikihow.com/Clear-Your-Browser's-Cache#Chrome_v10_.2B
>
> Did you run python manage.py collectstatic? and restart your local 
> development server with python manage.py runserver?
>
> Cheers,
>
> JJ
>
> On Tuesday, October 2, 2012 11:23:11 PM UTC-4, Jim Wombles wrote:
>>
>> Greetings,
>>
>> I am at a loss as to why local server is unable to render the css and js 
>> files.  I have the static_dirs setting correct and the href link to the 
>> files is correct, and the html file is rendering yet when I track what is 
>> going on with Chrome Dev Tools it is unable to find the CSS and JS files 
>> returning an Internal Server Error 500
>>
>> Any idea what may be going on ?
>>
>> Thanks for any advice.
>>
>> Jim
>> Fanbouts.com
>>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/qEhzFOSJra0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Class Based Views tutorials

2015-01-06 Thread Jim Wombles
Two Scoops of Django is definitely the book you are looking for. I don't know 
if it's out for 1.7 yet, but I purchased the book for Django 1.6 and it covers 
l of the best practices that you won't read about just from the Django docs. 

-- 
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/0c859a0a-a997-4c3e-aed0-0b93588b6a9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why isn't user.photo being saved in UpdateView?

2018-11-30 Thread Jim Wombles
For some reason, the updateview will save all of the other user fields (and 
update them if changed) to the database.  Do I need to handle the 
user.photo field differently? 

# views.py
class UserUpdateView(LoginRequiredMixin, UpdateView):

model = User
fields = ["name", "photo", "city", "experience", "domain", "bio"]

def get_success_url(self):
return reverse("users:detail", kwargs={"username": self.request.user
.username})

def get_object(self):
return User.objects.get(username=self.request.user.username)

user_update_view = UserUpdateView.as_view()


The form:
# form.py
from django.contrib.auth import get_user_model, forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _


User = get_user_model()

class UserChangeForm(forms.UserChangeForm):

class Meta(forms.UserChangeForm.Meta):
model = User




It does save the photo though in the Admin.
# admin.py
from django.contrib import admin
from django.contrib.auth import admin as auth_admin
from django.contrib.auth import get_user_model

from lexpy.users.forms import UserChangeForm, UserCreationForm

User = get_user_model()

@admin.register(User)
class UserAdmin(auth_admin.UserAdmin):


form = UserChangeForm
add_form = UserCreationForm
fieldsets = (("User", {"fields": ("name", "photo", "height_field", 
"width_field",
"city", "experience", "domain", "bio")}),) + auth_admin.
UserAdmin.fieldsets
list_display = ["username", "name", "is_superuser"]
search_fields = ["name"]
Enter code here...


My Models:

# models.py
from datetime import date


from django.contrib.auth.models import AbstractUser
from django.db import models
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _


def user_directory_path(instance, filename):
#file will be uploaded to MEDIA_ROOT/user_/
return 'user_{0}/{1}'.format(instance.username, filename)


class User(AbstractUser):
EXPERIENCE_BEGINNER = 'B'
EXPERIENCE_BEGINT = 'BI'
EXPERIENCE_INTERMEDIATE = 'I'
EXPERIENCE_INTERVANCED = 'IA'
EXPERIENCE_ADVANCED = 'A'
DOMAIN_WEB_DEVELOPMENT = 'WD'
DOMAIN_SCIENTIFIC_AND_NUMERIC = 'SN'
DOMAIN_EDUCATION = 'E'
DOMAIN_DESKTOP_GUIS = 'DG'
DOMAIN_GAME_DEVELOPMENT = 'GD'
DOMAIN_SOFTWARE_DEVELOPMENT = 'SD'
DOMAIN_SCRIPTING = 'S'


EXPERIENCE_CHOICES = (
(EXPERIENCE_BEGINNER, 'Beginner'),
(EXPERIENCE_BEGINT, 'Beginner to Intermediate'),
(EXPERIENCE_INTERMEDIATE, 'Intermediate'),
(EXPERIENCE_INTERVANCED, 'Intermediate to Advanced'),
(EXPERIENCE_ADVANCED, 'Advanced / Professional'),
)


DOMAIN_CHOICES = (
(DOMAIN_WEB_DEVELOPMENT, "Web Applications"),
(DOMAIN_SCIENTIFIC_AND_NUMERIC, "Scientific or Numeric Applications"
),
(DOMAIN_EDUCATION, "Education"),
(DOMAIN_DESKTOP_GUIS, "Desktop Software (GUI's)"),
(DOMAIN_GAME_DEVELOPMENT, "Game Development"),
(DOMAIN_SOFTWARE_DEVELOPMENT, "Support Software"),
(DOMAIN_SCRIPTING, "Scripting"),
)


# First Name and Last Name do not cover name patterns
# around the globe.
name = models.CharField(_("Name of User"), blank=True, max_length=255)
photo = models.ImageField(upload_to=user_directory_path,
blank=True,
width_field="width_field",
height_field="height_field")
height_field = models.IntegerField(default=0)
width_field = models.IntegerField(default=0)
city = models.CharField(max_length=50, blank=True)
# Fix default
experience = models.CharField(max_length=2, choices=EXPERIENCE_CHOICES, 
blank=True, null=True)
domain = models.CharField(max_length=2, choices=DOMAIN_CHOICES, blank=
True, null=True)
bio = models.TextField(max_length=500, blank=True)


def get_absolute_url(self):
return reverse("users:detail", kwargs={"username": self.username})






 

-- 
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/9a0c73a2-3e4c-41b8-b905-bb75639a16cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why isn't user.photo being saved in UpdateView?

2018-12-01 Thread Jim Wombles
I solved the problem after digging around in the Django Forms related to 
ImageFields and FileFields.  I needed to add the  attribute in order for Django to process 
forms that contain ImageFields and/or FileFields.
#user_form.html

{% extends "base.html" %}
{% load crispy_forms_tags %}


{% block title %}{{ user.username }}{% endblock %}


{% block content %}

  {{ user.username }}
  
{% csrf_token %}
{{ form|crispy }}

  
Update
  

  

{% endblock %}




On Friday, November 30, 2018 at 5:06:33 PM UTC-5, Jim Wombles wrote:
>
> For some reason, the updateview will save all of the other user fields 
> (and update them if changed) to the database.  Do I need to handle the 
> user.photo field differently? 
>
> # views.py
> class UserUpdateView(LoginRequiredMixin, UpdateView):
>
> model = User
> fields = ["name", "photo", "city", "experience", "domain", "bio"]
>
> def get_success_url(self):
> return reverse("users:detail", kwargs={"username": self.request.
> user.username})
>
> def get_object(self):
> return User.objects.get(username=self.request.user.username)
>
> user_update_view = UserUpdateView.as_view()
>
>
> The form:
> # form.py
> from django.contrib.auth import get_user_model, forms
> from django.core.exceptions import ValidationError
> from django.utils.translation import ugettext_lazy as _
>
>
> User = get_user_model()
>
> class UserChangeForm(forms.UserChangeForm):
>
> class Meta(forms.UserChangeForm.Meta):
> model = User
>
>
>
>
> It does save the photo though in the Admin.
> # admin.py
> from django.contrib import admin
> from django.contrib.auth import admin as auth_admin
> from django.contrib.auth import get_user_model
>
> from lexpy.users.forms import UserChangeForm, UserCreationForm
>
> User = get_user_model()
>
> @admin.register(User)
> class UserAdmin(auth_admin.UserAdmin):
>
>
> form = UserChangeForm
> add_form = UserCreationForm
> fieldsets = (("User", {"fields": ("name", "photo", "height_field", 
> "width_field",
> "city", "experience", "domain", "bio")}),) + auth_admin.
> UserAdmin.fieldsets
> list_display = ["username", "name", "is_superuser"]
> search_fields = ["name"]
> Enter code here...
>
>
> My Models:
>
> # models.py
> from datetime import date
>
>
> from django.contrib.auth.models import AbstractUser
> from django.db import models
> from django.urls import reverse
> from django.utils.translation import ugettext_lazy as _
>
>
> def user_directory_path(instance, filename):
> #file will be uploaded to MEDIA_ROOT/user_/
> return 'user_{0}/{1}'.format(instance.username, filename)
>
>
> class User(AbstractUser):
> EXPERIENCE_BEGINNER = 'B'
> EXPERIENCE_BEGINT = 'BI'
> EXPERIENCE_INTERMEDIATE = 'I'
> EXPERIENCE_INTERVANCED = 'IA'
> EXPERIENCE_ADVANCED = 'A'
> DOMAIN_WEB_DEVELOPMENT = 'WD'
> DOMAIN_SCIENTIFIC_AND_NUMERIC = 'SN'
> DOMAIN_EDUCATION = 'E'
> DOMAIN_DESKTOP_GUIS = 'DG'
> DOMAIN_GAME_DEVELOPMENT = 'GD'
> DOMAIN_SOFTWARE_DEVELOPMENT = 'SD'
> DOMAIN_SCRIPTING = 'S'
>
>
> EXPERIENCE_CHOICES = (
> (EXPERIENCE_BEGINNER, 'Beginner'),
> (EXPERIENCE_BEGINT, 'Beginner to Intermediate'),
> (EXPERIENCE_INTERMEDIATE, 'Intermediate'),
> (EXPERIENCE_INTERVANCED, 'Intermediate to Advanced'),
> (EXPERIENCE_ADVANCED, 'Advanced / Professional'),
> )
>
>
> DOMAIN_CHOICES = (
> (DOMAIN_WEB_DEVELOPMENT, "Web Applications"),
> (DOMAIN_SCIENTIFIC_AND_NUMERIC, "Scientific or Numeric 
> Applications"),
> (DOMAIN_EDUCATION, "Education"),
> (DOMAIN_DESKTOP_GUIS, "Desktop Software (GUI's)"),
> (DOMAIN_GAME_DEVELOPMENT, "Game Development"),
> (DOMAIN_SOFTWARE_DEVELOPMENT, "Support Software"),
> (DOMAIN_SCRIPTING, "Scripting"),
> )
>
>
> # First Name and Last Name do not cover name patterns
> # around the globe.
> name = models.CharField(_("Name of User"), blank=True, max_length=255)
> photo = models.ImageField(upload_to=user_directory_path,
> blank=