Re: New User of Django

2023-11-17 Thread utibe solomon
You just have to search Django up and follow it's documentation or search
it on youtube

On Wed, Nov 15, 2023, 4:31 PM Yonis Abdulkadir 
wrote:

> I need you to give me an explanation about how i can install and use it
> thank you so much
>
> --
> 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/b2406948-cfdb-4383-b78d-242e4aebb9efn%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/CAJkiqy7skNgugoUKW6DANyC67Vcc-JrzA2GPy9EAeeyCrDD06g%40mail.gmail.com.


Re: New User of Django

2023-11-15 Thread 'Kasper Laudrup' via Django users

On 15/11/2023 13.57, Yonis Abdulkadir wrote:

I need you to give me an explanation about how i can install and use it
thank you so much



https://docs.djangoproject.com/en/4.2/intro/

--
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/ced00921-c486-4421-870b-8eda6a3f757a%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: New User of Django

2023-11-15 Thread Lutaaya Jamil
You have python?
Google django, and follow the instructions or you can follow mosh here, I 
learnt from him though it was years back https://youtu.be/rHux0gMZ3Eg


On Wednesday, 15 November 2023 at 18:32:39 UTC+3 Yonis Abdulkadir wrote:

> I need you to give me an explanation about how i can install and use it 
> thank you so much
>
>

-- 
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/c1fec1ed-c361-4de3-b819-0c34adb87987n%40googlegroups.com.


New User of Django

2023-11-15 Thread Yonis Abdulkadir
I need you to give me an explanation about how i can install and use it 
thank you so much

-- 
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/b2406948-cfdb-4383-b78d-242e4aebb9efn%40googlegroups.com.


Re: NEW USER

2023-06-05 Thread Jeff Kingsley
Hello Jawad Khan! It's great to hear that you've started working with
Django and are looking for guidance on how to start and complete a proper
website. Django is a powerful web framework that can help you build robust
and scalable websites.

To help you get started and complete your website, here are some general
steps to follow:

   1.

   Planning and Requirements Gathering:
   - Define the purpose and goals of your website.
  - Identify the target audience and their needs.
  - Gather requirements and determine the core features and
  functionality.
   2.

   Designing the Database:
   - Identify the data entities and relationships needed for your website.
  - Design the database schema using Django's Object-Relational Mapping
  (ORM) features.
  - Define models in Django to represent the database structure.
   3.

   Setting up the Django Project:
   - Install Django using pip.
  - Create a new Django project using the django-admin command.
  - Configure the project settings, such as database connection and
  static files.
   4.

   Creating Django Apps:
   - Divide your website's functionality into smaller, reusable components
  called apps.
  - Create Django apps for each major functionality of your website.
  - Define models, views, and templates specific to each app.
   5.

   Implementing Views and Templates:
   - Define views that handle user requests and render the appropriate
  templates.
  - Create HTML templates using Django's template language, which
  allows dynamic rendering of data.
   6.

   Implementing URLs and Routing:
   - Define URL patterns in your Django project's URL configuration file (
  urls.py).
  - Map URLs to appropriate views and apps.
   7.

   Testing and Debugging:
   - Write tests to ensure your website's functionality works as expected.
  - Use Django's built-in testing framework to run tests and identify
  any issues.
  - Debug and fix any errors or bugs that arise during development.
   8.

   Adding User Authentication and Security:
   - Implement user authentication and authorization using Django's
  built-in authentication system.
  - Apply security measures like input validation, CSRF protection, and
  secure handling of user data.
   9.

   Styling and Front-end Development:
   - Apply CSS styles and design elements to enhance the visual appearance
  of your website.
  - Use front-end frameworks like Bootstrap to create responsive and
  user-friendly interfaces.
   10.

   Deployment and Hosting:
   - Choose a hosting platform or server to deploy your Django website.
  - Configure the production settings, including database, static
  files, and security measures.
  - Deploy your Django project to the chosen server and ensure it is
  accessible to users.


On Sat, Jun 3, 2023 at 5:16 PM Jawad khan  wrote:

> I hope you are all doing well, I am Jawad Khan from Peshawar Pakistan,
> recently start working in Django. Please can any one help how to start and
> complete a proper website.
>
> --
> 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/aa14b313-d077-4992-a56b-994ea6b5cca9n%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/CAA9WjmF%2BmRZqPc%2BkAeWfduuohazLGAH7vrsJo59yG7KVLJ78gg%40mail.gmail.com.


Re: NEW USER

2023-06-05 Thread Jeff Kingsley
Hello Jawad Khan! It's great to hear that you've started working with
Django and are looking for guidance on how to start and complete a proper
website. Django is a powerful web framework that can help you build robust
and scalable websites.

To help you get started and complete your website, here are some general
steps to follow:

   1.

   Planning and Requirements Gathering:
   - Define the purpose and goals of your website.
  - Identify the target audience and their needs.
  - Gather requirements and determine the core features and
  functionality.
   2.

   Designing the Database:
   - Identify the data entities and relationships needed for your website.
  - Design the database schema using Django's Object-Relational Mapping
  (ORM) features.
  - Define models in Django to represent the database structure.
   3.

   Setting up the Django Project:
   - Install Django using pip.
  - Create a new Django project using the django-admin command.
  - Configure the project settings, such as database connection and
  static files.
   4.

   Creating Django Apps:
   - Divide your website's functionality into smaller, reusable components
  called apps.
  - Create Django apps for each major functionality of your website.
  - Define models, views, and templates specific to each app.
   5.

   Implementing Views and Templates:
   - Define views that handle user requests and render the appropriate
  templates.
  - Create HTML templates using Django's template language, which
  allows dynamic rendering of data.
   6.

   Implementing URLs and Routing:
   - Define URL patterns in your Django project's URL configuration file (
  urls.py).
  - Map URLs to appropriate views and apps.
   7.

   Testing and Debugging:
   - Write tests to ensure your website's functionality works as expected.
  - Use Django's built-in testing framework to run tests and identify
  any issues.
  - Debug and fix any errors or bugs that arise during development.
   8.

   Adding User Authentication and Security:
   - Implement user authentication and authorization using Django's
  built-in authentication system.
  - Apply security measures like input validation, CSRF protection, and
  secure handling of user data.
   9.

   Styling and Front-end Development:
   - Apply CSS styles and design elements to enhance the visual appearance
  of your website.
  - Use front-end frameworks like Bootstrap to create responsive and
  user-friendly interfaces.
   10.

   Deployment and Hosting:
   - Choose a hosting platform or server to deploy your Django website.
  - Configure the production settings, including database, static
  files, and security measures.
  - Deploy your Django project to the chosen server and ensure it is
  accessible to users.


On Sat, Jun 3, 2023 at 5:37 PM Abubakar Siddique 
wrote:

> Hi jawad,
> Yes, I can help you to achieve your goal
>
> Contct me
> Whatstapp
> 03158090326
>
> Thanks
>
> On Sat, Jun 3, 2023, 7:17 PM Jawad khan  wrote:
>
>> I hope you are all doing well, I am Jawad Khan from Peshawar Pakistan,
>> recently start working in Django. Please can any one help how to start and
>> complete a proper website.
>>
>> --
>> 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/aa14b313-d077-4992-a56b-994ea6b5cca9n%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/CAL2GMxSFXx6NFepKbijNaqVKD-JTwL_SCstd-Q-OoghboX1k0g%40mail.gmail.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/CAA9WjmEadivRwsetYF41Oe8dy88qqqrK7P80NKYD9ZbpbR%2BQHQ%40mail.gmail.com.


Re: NEW USER

2023-06-03 Thread Muhammed Lawal
Hello Jawad, I would suggest you start with the tutorial on Django official
website.
Best regards

On Sat, 3 Jun 2023, 3:37 p.m. Abubakar Siddique, 
wrote:

> Hi jawad,
> Yes, I can help you to achieve your goal
>
> Contct me
> Whatstapp
> 03158090326
>
> Thanks
>
> On Sat, Jun 3, 2023, 7:17 PM Jawad khan  wrote:
>
>> I hope you are all doing well, I am Jawad Khan from Peshawar Pakistan,
>> recently start working in Django. Please can any one help how to start and
>> complete a proper website.
>>
>> --
>> 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/aa14b313-d077-4992-a56b-994ea6b5cca9n%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/CAL2GMxSFXx6NFepKbijNaqVKD-JTwL_SCstd-Q-OoghboX1k0g%40mail.gmail.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/CAOzVPC8ZHuRm%3DGJFdqvs2%3DEqK6oqMSVSGMGLK8eF8iREnA%3DCOw%40mail.gmail.com.


Re: NEW USER

2023-06-03 Thread Abubakar Siddique
Hi jawad,
Yes, I can help you to achieve your goal

Contct me
Whatstapp
03158090326

Thanks

On Sat, Jun 3, 2023, 7:17 PM Jawad khan  wrote:

> I hope you are all doing well, I am Jawad Khan from Peshawar Pakistan,
> recently start working in Django. Please can any one help how to start and
> complete a proper website.
>
> --
> 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/aa14b313-d077-4992-a56b-994ea6b5cca9n%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/CAL2GMxSFXx6NFepKbijNaqVKD-JTwL_SCstd-Q-OoghboX1k0g%40mail.gmail.com.


NEW USER

2023-06-03 Thread Jawad khan
I hope you are all doing well, I am Jawad Khan from Peshawar Pakistan, 
recently start working in Django. Please can any one help how to start and 
complete a proper website.

-- 
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/aa14b313-d077-4992-a56b-994ea6b5cca9n%40googlegroups.com.


If save a new row, then save a new user in AUTH_USER

2022-06-11 Thread Gabriel Araya Garcia


Tengo una template, la cual sirve para incorporar vendedores, en esta, 
existe un campo username. ¿ Que debería hacer cuando graba un nuevo 
registro vaya e inserte también dicho vendedor en auth_user.

En mi template tengo varios campos del mismo nombre que usa auth_user, por 
lo cual sería interesante que los grabara inmediatamente.

Gracias por vuestra ayuda

Devilsito

-- 
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/76c98fa9-51fd-46e4-b7c8-03244762cbfbn%40googlegroups.com.


Re: profile page and new user will not save

2022-03-09 Thread 'Delvin Alexander' via Django users
Sorry for the late reply, but here is my signlay.py file

from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.dispatch import receiver
from .models import Profile


@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)


@receiver(post_save, sender=User)
def save_profile(sender, instance, **kwargs):
instance.Profile.save()

On Wednesday, February 23, 2022 at 1:28:58 AM UTC-8 omkar...@gmail.com 
wrote:

> Something went wrong with the signals. Paste your signals.py file. 
>
> On Wed, Feb 23, 2022, 10:52 AM 'Delvin Alexander' via Django users <
> django...@googlegroups.com> wrote:
>
>> Hello Everyone,
>>
>> I am having trouble saving a new profile, and user when they are created. 
>> Upon creating a new user and profile, i get this:
>>
>> "TypeError: Profile.save() got an unexpected keyword argument 
>> 'force_insert'"
>>
>> Would anyone know why this is popping up for me
>>
>>
>> Here is my work for that particular page as well.
>>
>> from django.shortcuts import render, redirect
>> from django.contrib import messages
>> from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
>> from django.contrib.auth.decorators import login_required
>>
>>
>> def register(request):
>> if request.method == 'POST':
>> form = UserRegisterForm(request.POST)
>> if form.is_valid():
>> form.save()
>> username = form.cleaned_data.get('username')
>> messages.success(request, f'Your Account has been created you 
>> are now able to log in {username}!')
>> return redirect('login')
>> else:
>> form = UserRegisterForm()
>> return render(request, 'users/register.html', {'form': form})
>>
>> @login_required
>> def profile(request):
>> if request.method == 'POST':
>> u_form = UserUpdateForm(request.POST, instance=request.user)
>> p_form = ProfileUpdateForm(request.POST, request.FILES, 
>> instance=request.user.profile)
>> if u_form.is_valid() and p_form.is_valid():
>> u_form.save()
>> p_form.save()
>> messages.success(request, f'Your Account has been updated!')
>> return redirect('profile')
>> else:
>> u_form = UserUpdateForm(instance=request.user)
>> p_form = ProfileUpdateForm(instance=request.user.profile)
>> 
>> context = {
>> 'u_form': u_form,
>> 'p_form': p_form,
>> }
>> 
>> return render(request, 'users/profile.html', context)
>>
>> -- 
>> 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/39c57e72-9e09-403e-97db-562ef943db4an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/39c57e72-9e09-403e-97db-562ef943db4an%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/b7e20438-fa2d-4f72-9fa9-dfa761194c72n%40googlegroups.com.


Re: profile page and new user will not save

2022-02-23 Thread Omkar Parab
Something went wrong with the signals. Paste your signals.py file.

On Wed, Feb 23, 2022, 10:52 AM 'Delvin Alexander' via Django users <
django-users@googlegroups.com> wrote:

> Hello Everyone,
>
> I am having trouble saving a new profile, and user when they are created.
> Upon creating a new user and profile, i get this:
>
> "TypeError: Profile.save() got an unexpected keyword argument
> 'force_insert'"
>
> Would anyone know why this is popping up for me
>
>
> Here is my work for that particular page as well.
>
> from django.shortcuts import render, redirect
> from django.contrib import messages
> from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
> from django.contrib.auth.decorators import login_required
>
>
> def register(request):
> if request.method == 'POST':
> form = UserRegisterForm(request.POST)
> if form.is_valid():
> form.save()
> username = form.cleaned_data.get('username')
> messages.success(request, f'Your Account has been created you
> are now able to log in {username}!')
> return redirect('login')
> else:
> form = UserRegisterForm()
> return render(request, 'users/register.html', {'form': form})
>
> @login_required
> def profile(request):
> if request.method == 'POST':
> u_form = UserUpdateForm(request.POST, instance=request.user)
> p_form = ProfileUpdateForm(request.POST, request.FILES,
> instance=request.user.profile)
> if u_form.is_valid() and p_form.is_valid():
> u_form.save()
> p_form.save()
> messages.success(request, f'Your Account has been updated!')
> return redirect('profile')
> else:
> u_form = UserUpdateForm(instance=request.user)
> p_form = ProfileUpdateForm(instance=request.user.profile)
>
> context = {
> 'u_form': u_form,
> 'p_form': p_form,
> }
>
> return render(request, 'users/profile.html', context)
>
> --
> 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/39c57e72-9e09-403e-97db-562ef943db4an%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/39c57e72-9e09-403e-97db-562ef943db4an%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/CAJY8mfyGCYeL1xFxsQ-ZtuyxkEdS_gGAYbfvwSPYG7BbusRPww%40mail.gmail.com.


profile page and new user will not save

2022-02-22 Thread 'Delvin Alexander' via Django users
Hello Everyone,

I am having trouble saving a new profile, and user when they are created. 
Upon creating a new user and profile, i get this:

"TypeError: Profile.save() got an unexpected keyword argument 
'force_insert'"

Would anyone know why this is popping up for me


Here is my work for that particular page as well.

from django.shortcuts import render, redirect
from django.contrib import messages
from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
from django.contrib.auth.decorators import login_required


def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
messages.success(request, f'Your Account has been created you 
are now able to log in {username}!')
return redirect('login')
else:
form = UserRegisterForm()
return render(request, 'users/register.html', {'form': form})

@login_required
def profile(request):
if request.method == 'POST':
u_form = UserUpdateForm(request.POST, instance=request.user)
p_form = ProfileUpdateForm(request.POST, request.FILES, 
instance=request.user.profile)
if u_form.is_valid() and p_form.is_valid():
u_form.save()
p_form.save()
messages.success(request, f'Your Account has been updated!')
return redirect('profile')
else:
u_form = UserUpdateForm(instance=request.user)
p_form = ProfileUpdateForm(instance=request.user.profile)

context = {
'u_form': u_form,
'p_form': p_form,
}

return render(request, 'users/profile.html', context)

-- 
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/39c57e72-9e09-403e-97db-562ef943db4an%40googlegroups.com.


Re: New user

2021-11-07 Thread Lalit Suthar
good one
https://www.youtube.com/playlist?list=PLEsfXFp6DpzTD1BD1aWNxS2Ep06vIkaeW

On Tue, 2 Nov 2021 at 15:40, Indrajeet Singh Yadav 
wrote:

> Hi,
> Like you I also started django a while back. And i feel like djangogirls
> is a good place to start.
> Its a tutorial site. Search google.
> They will help you get started with the basics of django.
> They have quite a well explained tutorial.
> Also if you find some other way which is good for learning django please
> do share.
> Good Luck.
> On Tuesday, November 2, 2021 at 2:55:18 AM UTC+5:30 lanza...@gmail.com
> wrote:
>
>> Hi, I want to learn Django, so if someone now the best way I appreciate.
>>
> --
> 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/422a5f9f-70e4-43df-968b-f8b3514f5ba4n%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/CAGp2JVE4c-k4-H-t3Dj5gOJ01d0BR3aPx3yWS-83VA4%3Dng7vWQ%40mail.gmail.com.


Re: New user

2021-11-02 Thread Indrajeet Singh Yadav
Hi,
Like you I also started django a while back. And i feel like djangogirls is 
a good place to start.
Its a tutorial site. Search google.
They will help you get started with the basics of django.
They have quite a well explained tutorial.
Also if you find some other way which is good for learning django please do 
share.
Good Luck.
On Tuesday, November 2, 2021 at 2:55:18 AM UTC+5:30 lanza...@gmail.com 
wrote:

> Hi, I want to learn Django, so if someone now the best way I appreciate.
>

-- 
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/422a5f9f-70e4-43df-968b-f8b3514f5ba4n%40googlegroups.com.


Re: New user

2021-11-02 Thread Sebastian Jung
Hello,

i find in beginning Django Girls tutorial very helpful:
https://tutorial.djangogirls.org/de/

Am Mo., 1. Nov. 2021 um 22:24 Uhr schrieb Dalys Lanzas <
lanzasda...@gmail.com>:

> Hi, I want to learn Django, so if someone now the best way I appreciate.
>
> --
> 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/73f4327d-63b2-4da1-a87f-63da662a912an%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/CAKGT9mwNxj3k-6zxbL0tquo-LRQ7a8fMhqc3Ov9Zha83nqTWwQ%40mail.gmail.com.


Re: New user

2021-11-02 Thread Gwanghyeon Gim
Hi, 

here are my recommendations for beginner.

Youtube: Corey M Schafer
Book: Django for Beginners by W. S. Vincent

Good luck.

On Tuesday, 2 November 2021 at 06:25:18 UTC+9 lanza...@gmail.com wrote:

> Hi, I want to learn Django, so if someone now the best way I appreciate.
>

-- 
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/b8ad4713-2e77-41ef-a6ce-fdfb0f2b8fa1n%40googlegroups.com.


New user

2021-11-01 Thread Dalys Lanzas
Hi, I want to learn Django, so if someone now the best way I appreciate.

-- 
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/73f4327d-63b2-4da1-a87f-63da662a912an%40googlegroups.com.


Re: Hello from a new user

2021-03-17 Thread Mr. X Offencer
You can search on YouTube for django tutorials.
Some of which are
Django by code with harry - In Hindi Language
Django by code with harry - In English Language

On Wed, 17 Mar 2021, 20:57 Mahmood Ahmad,  wrote:

> Hello Ryan,
>
> You are right. I sound as if I am only looking for tutorials.
>
> Indeed, I am joining for specific Q's and A's.
>
> Regards
>
> On Wed, Mar 17, 2021 at 1:41 PM Mahmood  wrote:
>
>> Hi All,
>>
>> I am a new user to Django and am exploring it for Web development using
>> Python. I am looking for Django tutorials.
>>
>> Please guide me to some tutorials,
>>
>> Regards
>> Mahmood
>>
>> --
>> 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/unewlXcSxkw/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/b8bb849e-e68b-4688-b4d9-b555fa5766e2n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/b8bb849e-e68b-4688-b4d9-b555fa5766e2n%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/CAPefhB77XkeQzL5eYErYC0sdX0Aq5fKWvjik5k1OZd4D0H%3DhrQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPefhB77XkeQzL5eYErYC0sdX0Aq5fKWvjik5k1OZd4D0H%3DhrQ%40mail.gmail.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/CABz7kDSSXbC_mNAnwHovvB%2BSvrkJKhcL9xxMH%3DYfZLZK-3pF3g%40mail.gmail.com.


Re: Hello from a new user

2021-03-17 Thread Mahmood Ahmad
Hello Ryan,

You are right. I sound as if I am only looking for tutorials.

Indeed, I am joining for specific Q's and A's.

Regards

On Wed, Mar 17, 2021 at 1:41 PM Mahmood  wrote:

> Hi All,
>
> I am a new user to Django and am exploring it for Web development using
> Python. I am looking for Django tutorials.
>
> Please guide me to some tutorials,
>
> Regards
> Mahmood
>
> --
> 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/unewlXcSxkw/unsubscribe.
> To unsubscribe from this group and all its topics, 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/b8bb849e-e68b-4688-b4d9-b555fa5766e2n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b8bb849e-e68b-4688-b4d9-b555fa5766e2n%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/CAPefhB77XkeQzL5eYErYC0sdX0Aq5fKWvjik5k1OZd4D0H%3DhrQ%40mail.gmail.com.


Re: Hello from a new user

2021-03-17 Thread Ryan Nowakowski
Hey Mahmood,

Welcome!  Just curious, why reach out to a mailing list for tutorial 
recommendations? I find that Google and other web search engines have this 
covered pretty well.  Do you find that you get better results from mailing 
lists? Do you like the mailing list experience better than web search?

I find that mailing lists are good for detailed Q and A and I prefer web search 
for everything else. 

In any case, I hope we can help you along your journey with Django!

- Ryan

On March 17, 2021 8:01:10 AM CDT, Mahmood  wrote:
>Hi All,
>
>I am a new user to Django and am exploring it for Web development using
>
>Python. I am looking for Django tutorials.
>
>Please guide me to some tutorials,
>
>Regards
>Mahmood
>
>-- 
>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/b8bb849e-e68b-4688-b4d9-b555fa5766e2n%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/B770CC45-9CBE-489B-81DE-FB09A7DD3E1E%40fattuba.com.


Hello from a new user

2021-03-17 Thread Mahmood
Hi All,

I am a new user to Django and am exploring it for Web development using 
Python. I am looking for Django tutorials.

Please guide me to some tutorials,

Regards
Mahmood

-- 
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/b8bb849e-e68b-4688-b4d9-b555fa5766e2n%40googlegroups.com.


Re: No Reverse Match Error, When creating a new user (new user application) it should direct back to home (to the core application)

2020-04-19 Thread Farai M
You can use Httpresponse(reverse_lazy('appname'))

On Sun, Apr 19, 2020, 6:35 AM Ahmed Khairy 
wrote:

> For this project, I have made 2 applications: Core and Users
>
> Creating a new user is the 2nd application.
> I am trying to direct the new user after registration to 'home'
>
> I keep getting NoReverse Match Error
>
> This is the view.py this is the code:
>
> def register(request):
> if request.method == 'POST':
> form = UserCreationForm(request.POST)
> if form.is_valid():
> form.save()
> username = form.cleaned_data.get('username')
> messages.success(
> request, f'Account created for {username}
> ! Show us your Designs')
> return redirect('home')
> else:
> form = UserCreationForm()
> return render(request, 'register.html', {'form': form})
>
> This is the url.py in the core application:
>
> urlpatterns = [
> path('', HomeView.as_view(), name='home'),
> path('checkout/', checkout, name='checkout'),
> path('product//', ItemDetailView.as_view(), name='product'),
> path('score/', PostListView.as_view(), name='score'),
> path('register/', user_views.register, name='register'),
> ]
>
>
> What do I need to do to fix this issue,
>
> Thank you all in advance
>
> --
> 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/4584668f-3cf5-40fe-930c-69c75b74b23d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4584668f-3cf5-40fe-930c-69c75b74b23d%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/CAMeub5OoTnXuJbkyMwY7B8hxr%3D9MLTqwOHX1Wm7S3u5R%3DuX1tg%40mail.gmail.com.


Re: No Reverse Match Error, When creating a new user (new user application) it should direct back to home (to the core application)

2020-04-19 Thread Jorge Gimeno
I would try to replace return redirect('home') with return
redirect(reverse('home'))

-Jorge

On 4/18/20, Motaz Hejaze  wrote:
> اعمل اسم الفانكشن الحقيقي مكان اسم ال url او استخدم redirect reverse
>
> On Sun, 19 Apr 2020, 6:35 am Ahmed Khairy, 
> wrote:
>
>> For this project, I have made 2 applications: Core and Users
>>
>> Creating a new user is the 2nd application.
>> I am trying to direct the new user after registration to 'home'
>>
>> I keep getting NoReverse Match Error
>>
>> This is the view.py this is the code:
>>
>> def register(request):
>> if request.method == 'POST':
>> form = UserCreationForm(request.POST)
>> if form.is_valid():
>> form.save()
>> username = form.cleaned_data.get('username')
>> messages.success(
>> request, f'Account created for {username}
>> ! Show us your Designs')
>> return redirect('home')
>> else:
>> form = UserCreationForm()
>> return render(request, 'register.html', {'form': form})
>>
>> This is the url.py in the core application:
>>
>> urlpatterns = [
>> path('', HomeView.as_view(), name='home'),
>> path('checkout/', checkout, name='checkout'),
>> path('product//', ItemDetailView.as_view(), name='product'),
>> path('score/', PostListView.as_view(), name='score'),
>> path('register/', user_views.register, name='register'),
>> ]
>>
>>
>> What do I need to do to fix this issue,
>>
>> Thank you all in advance
>>
>> --
>> 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/4584668f-3cf5-40fe-930c-69c75b74b23d%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/4584668f-3cf5-40fe-930c-69c75b74b23d%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/CAHV4E-eymYMWLhd23iEN%2BJqMMkdLNrA9OxHq41x8EuRrj0bh2Q%40mail.gmail.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/CANfN%3DK9nwLpqxwFMFdqKM%2B4dpRNZgJ8c5LSU6FoCf%2BgsHVH7oA%40mail.gmail.com.


Re: No Reverse Match Error, When creating a new user (new user application) it should direct back to home (to the core application)

2020-04-19 Thread Motaz Hejaze
اعمل اسم الفانكشن الحقيقي مكان اسم ال url او استخدم redirect reverse

On Sun, 19 Apr 2020, 6:35 am Ahmed Khairy, 
wrote:

> For this project, I have made 2 applications: Core and Users
>
> Creating a new user is the 2nd application.
> I am trying to direct the new user after registration to 'home'
>
> I keep getting NoReverse Match Error
>
> This is the view.py this is the code:
>
> def register(request):
> if request.method == 'POST':
> form = UserCreationForm(request.POST)
> if form.is_valid():
> form.save()
> username = form.cleaned_data.get('username')
> messages.success(
> request, f'Account created for {username}
> ! Show us your Designs')
> return redirect('home')
> else:
> form = UserCreationForm()
> return render(request, 'register.html', {'form': form})
>
> This is the url.py in the core application:
>
> urlpatterns = [
> path('', HomeView.as_view(), name='home'),
> path('checkout/', checkout, name='checkout'),
> path('product//', ItemDetailView.as_view(), name='product'),
> path('score/', PostListView.as_view(), name='score'),
> path('register/', user_views.register, name='register'),
> ]
>
>
> What do I need to do to fix this issue,
>
> Thank you all in advance
>
> --
> 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/4584668f-3cf5-40fe-930c-69c75b74b23d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4584668f-3cf5-40fe-930c-69c75b74b23d%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/CAHV4E-eymYMWLhd23iEN%2BJqMMkdLNrA9OxHq41x8EuRrj0bh2Q%40mail.gmail.com.


No Reverse Match Error, When creating a new user (new user application) it should direct back to home (to the core application)

2020-04-18 Thread Ahmed Khairy
For this project, I have made 2 applications: Core and Users

Creating a new user is the 2nd application.
I am trying to direct the new user after registration to 'home'

I keep getting NoReverse Match Error

This is the view.py this is the code:

def register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
messages.success(
request, f'Account created for {username}
! Show us your Designs')
return redirect('home')
else:
form = UserCreationForm()
return render(request, 'register.html', {'form': form})

This is the url.py in the core application: 

urlpatterns = [
path('', HomeView.as_view(), name='home'),
path('checkout/', checkout, name='checkout'),
path('product//', ItemDetailView.as_view(), name='product'),
path('score/', PostListView.as_view(), name='score'),
path('register/', user_views.register, name='register'),
]


What do I need to do to fix this issue, 

Thank you all in advance

-- 
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/4584668f-3cf5-40fe-930c-69c75b74b23d%40googlegroups.com.


New User Authentication Guide (:

2019-08-06 Thread Aaron Harris
Hi all, pretty excited about our new guide to Django User authentication on 
the Kite Blog .
Nice to have a reference if authentication maybe isn't your *favorite* part 
of webdev.
https://kite.com/blog/python/django-authentication/

-- 
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/a2ad325c-6874-4cab-ba2f-e6dc257e3516%40googlegroups.com.


Re: New user question: Where to put non-form validation code?

2019-07-25 Thread Matt Zand
Hi everyone,
Does anyone know how to post blog at below page:
https://www.djangoproject.com/community/blogs/

I am really frustrated as I submitted last week but nothing is there. Who
is in charge of blog posts on Django site?

Thx,
Matt



On Thu, Jul 25, 2019 at 12:38 AM Mike Dewhirst 
wrote:

> On 25/07/2019 1:03 pm, Jim Illback wrote:
> > I had a slight variation on this thread - where to put some M2M field
> > validation/deletion logic.
> >
> > I have a purely model-based form where a checkbox’s value determines
> > whether another field (it’s a M2M field) in the form should be NULL or
> > keep its values to be saved in the database. So, following the
> > appropriate separation of concerns as advocated below, I added logic
> > in both the models' clean and save override methods. Neither approach
> > set the other field to NULL when it should have been. The reason is
> > the form still contained M2M values even though the model said to
> > delete them (delete the set, actually).
> >
> > After a lot of trial and error, it turns out that the model’s save
> > seems to be run BEFORE the form’s save. To me, that seems backwards.
> > Shouldn’t the model’s processes (which are directly relate to the
> > database, the ultimate data source) occur last and well before the
> > form’s (which are merely an interaction with the user)? What was
> > happening was my model’s delete actually did the deletions (those IDs
> > were gone), but then the form’s processing came along afterwards and
> > re-inserted them again (with brand new IDs).
>
> Don't know what's happening here but you can be sure Django is doing it
> the right way.
>
> Maybe you need to look at your on_delete constants. models.CASCADE
> versus models.SET_NULL or models.PROTECT
>
> >
> > Can someone help me understand why Django has chosen this seemingly
> > “inversion” of processing - first models’ processes, then forms’? And,
> > perhaps more importantly, where should this either/or logic should be
> > placed so it will take effect?
> >
> > Thanks very much,
> > Jim Illback
> >
> >> On Jul 13, 2019, at 11:48 PM, Mike Dewhirst  >> > wrote:
> >>
> >> Well yes it could be called multifaceted.
> >>
> >> Usually but not always the interface with the user is the form. You
> >> can have non-database fields as well as model fields so either way
> >> there has to be a full suite of validation functionality available in
> >> both types of forms. Luckily, model forms automatically call
> >> model.clean() for you.
> >>
> >> Unit tests don't though. You have deliberately call obj.clean() if
> >> you want to test things. obj.save() doesn't call obj.clean().
> >>
> >> Actually, I also do a bit in view code too especially if there are
> >> non-database or hidden fields in the form. I know you are not
> >> supposed to validate data in a view for proper separation of concerns
> >> but it does keep my forms neater.
> >>
> >> The bottom line for me is that if I can imagine non-form access ...
> >> eg through an API ... then all validation possible has to be via
> >> model.clean() and the API has to remember to call clean() before
> >> saving every time there is a POST
> >>
> >> Hence I*always*put business rules validation in model.clean() and
> >> leave 'local' validation for the form.
> >>
> >> You are right. There are quite a few moving parts
> >>
> >> /Connected by Motorola/
> >>
> >>
> >> Dean Karres mailto:dean.kar...@gmail.com>>
> wrote:
> >>
> >> Thank you. There are way more parts to this than I would have imagined.
> >>
> >>
> >>
> >> On Sat, Jul 13, 2019, 8:01 PM Mike Dewhirst  >> > wrote:
> >>
> >> On 14/07/2019 10:37 am, Dean Karres wrote:
> >>> Hi,
> >>>
> >>> I am learning Django.  I am using CBVs.  My default "index.py"
> >>> view is basically a dashboard for the app I am playing with.  As
> >>> my models and views become more complicated I want to be able to
> >>> ask, for any model instance, is this instance "valid" or
> >>> "complete".  Valid means that all Required elements are present
> >>> and have reasonable values.  "Complete" means that an instance
> >>> is "valid" but also some specific bits of additional info are
> >>> also ok.
> >>>
> >>> For example I have a Student model that has name and address
> >>> info.  There is a ManyToMany relation to the Class(es) in which
> >>> that Student is enrolled.  A "student" instance is valid if the
> >>> name and address fields are filled.  A student is "complete" if
> >>> the student is valid and has signed up for one or more classes.
> >>>
> >>> So, my question is: where should the valid and complete methods
> >>> live?  Should they be in the Student model or CBV? Someplace
> >>> else?  Does it matter?
> >>
> >> I like to put that sort of stuff into model methods then add
> >> model.clean() to call them and raise whatever error may be
> >> appropriate if they fail.

Re: New user question: Where to put non-form validation code?

2019-07-24 Thread Mike Dewhirst

On 25/07/2019 1:03 pm, Jim Illback wrote:
I had a slight variation on this thread - where to put some M2M field 
validation/deletion logic.


I have a purely model-based form where a checkbox’s value determines 
whether another field (it’s a M2M field) in the form should be NULL or 
keep its values to be saved in the database. So, following the 
appropriate separation of concerns as advocated below, I added logic 
in both the models' clean and save override methods. Neither approach 
set the other field to NULL when it should have been. The reason is 
the form still contained M2M values even though the model said to 
delete them (delete the set, actually).


After a lot of trial and error, it turns out that the model’s save 
seems to be run BEFORE the form’s save. To me, that seems backwards. 
Shouldn’t the model’s processes (which are directly relate to the 
database, the ultimate data source) occur last and well before the 
form’s (which are merely an interaction with the user)? What was 
happening was my model’s delete actually did the deletions (those IDs 
were gone), but then the form’s processing came along afterwards and 
re-inserted them again (with brand new IDs).


Don't know what's happening here but you can be sure Django is doing it 
the right way.


Maybe you need to look at your on_delete constants. models.CASCADE 
versus models.SET_NULL or models.PROTECT




Can someone help me understand why Django has chosen this seemingly 
“inversion” of processing - first models’ processes, then forms’? And, 
perhaps more importantly, where should this either/or logic should be 
placed so it will take effect?


Thanks very much,
Jim Illback

On Jul 13, 2019, at 11:48 PM, Mike Dewhirst > wrote:


Well yes it could be called multifaceted.

Usually but not always the interface with the user is the form. You 
can have non-database fields as well as model fields so either way 
there has to be a full suite of validation functionality available in 
both types of forms. Luckily, model forms automatically call 
model.clean() for you.


Unit tests don't though. You have deliberately call obj.clean() if 
you want to test things. obj.save() doesn't call obj.clean().


Actually, I also do a bit in view code too especially if there are 
non-database or hidden fields in the form. I know you are not 
supposed to validate data in a view for proper separation of concerns 
but it does keep my forms neater.


The bottom line for me is that if I can imagine non-form access ... 
eg through an API ... then all validation possible has to be via 
model.clean() and the API has to remember to call clean() before 
saving every time there is a POST


Hence I*always*put business rules validation in model.clean() and 
leave 'local' validation for the form.


You are right. There are quite a few moving parts

/Connected by Motorola/


Dean Karres mailto:dean.kar...@gmail.com>> wrote:

Thank you. There are way more parts to this than I would have imagined.



On Sat, Jul 13, 2019, 8:01 PM Mike Dewhirst > wrote:


On 14/07/2019 10:37 am, Dean Karres wrote:

Hi,

I am learning Django.  I am using CBVs.  My default "index.py"
view is basically a dashboard for the app I am playing with.  As
my models and views become more complicated I want to be able to
ask, for any model instance, is this instance "valid" or
"complete".  Valid means that all Required elements are present
and have reasonable values.  "Complete" means that an instance
is "valid" but also some specific bits of additional info are
also ok.

For example I have a Student model that has name and address
info.  There is a ManyToMany relation to the Class(es) in which
that Student is enrolled.  A "student" instance is valid if the
name and address fields are filled.  A student is "complete" if
the student is valid and has signed up for one or more classes.

So, my question is: where should the valid and complete methods
live?  Should they be in the Student model or CBV? Someplace
else?  Does it matter?


I like to put that sort of stuff into model methods then add
model.clean() to call them and raise whatever error may be
appropriate if they fail.


https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/#interaction-with-model-validation

and


https://docs.djangoproject.com/en/2.1/ref/models/instances/#validating-objects

and


https://docs.djangoproject.com/en/2.1/ref/models/instances/#django.db.models.Model.clean

You can raise your own errors which inherit from ValidationError
to fine tune the process. For example, I differentiate between
BusinessRuleViolation and InvalidToken and a couple of others
where that delivers better control.




Cheers
--
You received this message because you are subscribed to the
Google Groups "Django users" group.
To unsubscribe from this 

Re: New user question: Where to put non-form validation code?

2019-07-24 Thread Mike Dewhirst

On 25/07/2019 1:03 pm, Jim Illback wrote:
I had a slight variation on this thread - where to put some M2M field 
validation/deletion logic.


I have a purely model-based form where a checkbox’s value determines 
whether another field (it’s a M2M field) in the form should be NULL or 
keep its values to be saved in the database. So, following the 
appropriate separation of concerns as advocated below, I added logic 
in both the models' clean and save override methods. Neither approach 
set the other field to NULL when it should have been. The reason is 
the form still contained M2M values even though the model said to 
delete them (delete the set, actually).


There's a bit of trapeze happening here. The form is always in mid-air. 
No matter what happens in the form the model save is only called when 
all the validation (ie form first for the obvious errors then model for 
business rules) has succeeded.


So, boolean (or any other) field values don't make it into the database 
until model.save() succeeds.


And, the framework logic has to cope with database rejection of the 
values as well. So the entire transaction needs to be able to roll back 
if something goes awry at the last moment. Keep your eye on 
transactions. I think PostgreSQL is probably the best of the open source 
RDBMSs for that. I know Django seems to have no problems with it.


My typical approach in the model to see things before and after the save 
is ...


def save(self, *args, **kwargs:
    var_to_be_passed = self._pre_save()
    super(ThisModel, self).save(*args, **kwargs)
    self._post_save(var_to_be_passed)

I use self._post_save() usually to do additional database things like 
creating child models.


If your user-initiated change relies on a value in the database then you 
have to save it first so it gets there.


Also, remember that the model's clean() method is only ever called by 
Django when a ModelForm is used. Otherwise you have to call it yourself. 
That's where I put all my business rule validation. I typically have 
separate mofel methods and just call thin in clean() and raise 
validation errors if necessary. That is totally appropriate because a 
Django form knows how to deal with them.


As I said previously, in unti tests you have to call clean() explicitly.



After a lot of trial and error, it turns out that the model’s save 
seems to be run BEFORE the form’s save. To me, that seems backwards. 
Shouldn’t the model’s processes (which are directly relate to the 
database, the ultimate data source) occur last and well before the 
form’s (which are merely an interaction with the user)? What was 
happening was my model’s delete actually did the deletions (those IDs 
were gone), but then the form’s processing came along afterwards and 
re-inserted them again (with brand new IDs).


Can someone help me understand why Django has chosen this seemingly 
“inversion” of processing - first models’ processes, then forms’? And, 
perhaps more importantly, where should this either/or logic should be 
placed so it will take effect?


Thanks very much,
Jim Illback

On Jul 13, 2019, at 11:48 PM, Mike Dewhirst > wrote:


Well yes it could be called multifaceted.

Usually but not always the interface with the user is the form. You 
can have non-database fields as well as model fields so either way 
there has to be a full suite of validation functionality available in 
both types of forms. Luckily, model forms automatically call 
model.clean() for you.


Unit tests don't though. You have deliberately call obj.clean() if 
you want to test things. obj.save() doesn't call obj.clean().


Actually, I also do a bit in view code too especially if there are 
non-database or hidden fields in the form. I know you are not 
supposed to validate data in a view for proper separation of concerns 
but it does keep my forms neater.


The bottom line for me is that if I can imagine non-form access ... 
eg through an API ... then all validation possible has to be via 
model.clean() and the API has to remember to call clean() before 
saving every time there is a POST


Hence I*always*put business rules validation in model.clean() and 
leave 'local' validation for the form.


You are right. There are quite a few moving parts

/Connected by Motorola/


Dean Karres mailto:dean.kar...@gmail.com>> wrote:

Thank you. There are way more parts to this than I would have imagined.



On Sat, Jul 13, 2019, 8:01 PM Mike Dewhirst > wrote:


On 14/07/2019 10:37 am, Dean Karres wrote:

Hi,

I am learning Django.  I am using CBVs.  My default "index.py"
view is basically a dashboard for the app I am playing with.  As
my models and views become more complicated I want to be able to
ask, for any model instance, is this instance "valid" or
"complete".  Valid means that all Required elements are present
and have reasonable values.  "Complete" means that an instance
is "valid" but 

Re: New user question: Where to put non-form validation code?

2019-07-24 Thread Jim Illback
I had a slight variation on this thread - where to put some M2M field 
validation/deletion logic.

I have a purely model-based form where a checkbox’s value determines whether 
another field (it’s a M2M field) in the form should be NULL or keep its values 
to be saved in the database. So, following the appropriate separation of 
concerns as advocated below, I added logic in both the models' clean and save 
override methods. Neither approach set the other field to NULL when it should 
have been. The reason is the form still contained M2M values even though the 
model said to delete them (delete the set, actually).

After a lot of trial and error, it turns out that the model’s save seems to be 
run BEFORE the form’s save. To me, that seems backwards. Shouldn’t the model’s 
processes (which are directly relate to the database, the ultimate data source) 
occur last and well before the form’s (which are merely an interaction with the 
user)? What was happening was my model’s delete actually did the deletions 
(those IDs were gone), but then the form’s processing came along afterwards and 
re-inserted them again (with brand new IDs).

Can someone help me understand why Django has chosen this seemingly “inversion” 
of processing - first models’ processes, then forms’? And, perhaps more 
importantly, where should this either/or logic should be placed so it will take 
effect?

Thanks very much,
Jim Illback

On Jul 13, 2019, at 11:48 PM, Mike Dewhirst 
mailto:mi...@dewhirst.com.au>> wrote:

Well yes it could be called multifaceted.

Usually but not always the interface with the user is the form. You can have 
non-database fields as well as model fields so either way there has to be a 
full suite of validation functionality available in both types of forms. 
Luckily, model forms automatically call model.clean() for you.

Unit tests don't though. You have deliberately call obj.clean() if you want to 
test things. obj.save() doesn't call obj.clean().

Actually, I also do a bit in view code too especially if there are non-database 
or hidden fields in the form. I know you are not supposed to validate data in a 
view for proper separation of concerns but it does keep my forms neater.

The bottom line for me is that if I can imagine non-form access ... eg through 
an API ... then all validation possible has to be via model.clean() and the API 
has to remember to call clean() before saving every time there is a POST

Hence I always put business rules validation in model.clean() and leave 'local' 
validation for the form.

You are right. There are quite a few moving parts 

Connected by Motorola


Dean Karres mailto:dean.kar...@gmail.com>> wrote:

Thank you. There are way more parts to this than I would have imagined.



On Sat, Jul 13, 2019, 8:01 PM Mike Dewhirst 
mailto:mi...@dewhirst.com.au>> wrote:
On 14/07/2019 10:37 am, Dean Karres wrote:
Hi,

I am learning Django.  I am using CBVs.  My default "index.py" view is 
basically a dashboard for the app I am playing with.  As my models and views 
become more complicated I want to be able to ask, for any model instance, is 
this instance "valid" or "complete".  Valid means that all Required elements 
are present and have reasonable values.  "Complete" means that an instance is 
"valid" but also some specific bits of additional info are also ok.

For example I have a Student model that has name and address info.  There is a 
ManyToMany relation to the Class(es) in which that Student is enrolled.  A 
"student" instance is valid if the name and address fields are filled.  A 
student is "complete" if the student is valid and has signed up for one or more 
classes.

So, my question is: where should the valid and complete methods live?  Should 
they be in the Student model or CBV?  Someplace else?  Does it matter?

I like to put that sort of stuff into model methods then add model.clean() to 
call them and raise whatever error may be appropriate if they fail.

https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/#interaction-with-model-validation

and

https://docs.djangoproject.com/en/2.1/ref/models/instances/#validating-objects

and

https://docs.djangoproject.com/en/2.1/ref/models/instances/#django.db.models.Model.clean

You can raise your own errors which inherit from ValidationError to fine tune 
the process. For example, I differentiate between BusinessRuleViolation and 
InvalidToken and a couple of others where that delivers better control.



Cheers
--
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 

Re: New user question: Where to put non-form validation code?

2019-07-14 Thread Mike Dewhirst
Well yes it could be called multifaceted.  

Usually but not always the interface with the user is the form. You can have 
non-database fields as well as model fields so either way there has to be a 
full suite of validation functionality available in both types of forms. 
Luckily, model forms automatically call model.clean() for you. 

Unit tests don't though. You have deliberately call obj.clean() if you want to 
test things. obj.save() doesn't call obj.clean().

Actually, I also do a bit in view code too especially if there are non-database 
or hidden fields in the form. I know you are not supposed to validate data in a 
view for proper separation of concerns but it does keep my forms neater.

The bottom line for me is that if I can imagine non-form access ... eg through 
an API ... then all validation possible has to be via model.clean() and the API 
has to remember to call clean() before saving every time there is a POST

Hence I always put business rules validation in model.clean() and leave 'local' 
validation for the form. 

You are right. There are quite a few moving parts  :-) 

Connected by Motorola

Dean Karres  wrote:

>Thank you. There are way more parts to this than I would have imagined.
>
>
>
>
>On Sat, Jul 13, 2019, 8:01 PM Mike Dewhirst  wrote:
>
>On 14/07/2019 10:37 am, Dean Karres wrote:
>
>Hi, 
>
>
>I am learning Django.  I am using CBVs.  My default "index.py" view is 
>basically a dashboard for the app I am playing with.  As my models and views 
>become more complicated I want to be able to ask, for any model instance, is 
>this instance "valid" or "complete".  Valid means that all Required elements 
>are present and have reasonable values.  "Complete" means that an instance is 
>"valid" but also some specific bits of additional info are also ok.
>
>
>For example I have a Student model that has name and address info.  There is a 
>ManyToMany relation to the Class(es) in which that Student is enrolled.  A 
>"student" instance is valid if the name and address fields are filled.  A 
>student is "complete" if the student is valid and has signed up for one or 
>more classes.
>
>
>So, my question is: where should the valid and complete methods live?  Should 
>they be in the Student model or CBV?  Someplace else?  Does it matter?
>
>
>I like to put that sort of stuff into model methods then add model.clean() to 
>call them and raise whatever error may be appropriate if they fail.
>
>https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/#interaction-with-model-validation
>
>and
>
>https://docs.djangoproject.com/en/2.1/ref/models/instances/#validating-objects
>
>and
>
>https://docs.djangoproject.com/en/2.1/ref/models/instances/#django.db.models.Model.clean
>
>You can raise your own errors which inherit from ValidationError to fine tune 
>the process. For example, I differentiate between BusinessRuleViolation and 
>InvalidToken and a couple of others where that delivers better control.
>
>
>
>Cheers
>
>-- 
>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/22801669-96ec-4a43-a264-fd50c2544604%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/ajujeafh6d4qa4vvpfv2bxf9.1563085360028%40email.android.com.
For more options, visit https://groups.google.com/d/optout.


RE: New user question: Where to put non-form validation code?

2019-07-13 Thread laya
Hi
If I got your meaning Truly. It should be mentioned that as I know there is not 
any difference for using validation in model or View . Usually in model, we use 
regex for validation and in View  it needs to use some methods for Email 
Validation and etc.

Sent from Mail for Windows 10

From: Dean Karres
Sent: Saturday, July 13, 2019 5:40 PM
To: Django users
Subject: New user question: Where to put non-form validation code?

Hi,

I am learning Django.  I am using CBVs.  My default "index.py" view is 
basically a dashboard for the app I am playing with.  As my models and views 
become more complicated I want to be able to ask, for any model instance, is 
this instance "valid" or "complete".  Valid means that all Required elements 
are present and have reasonable values.  "Complete" means that an instance is 
"valid" but also some specific bits of additional info are also ok.

For example I have a Student model that has name and address info.  There is a 
ManyToMany relation to the Class(es) in which that Student is enrolled.  A 
"student" instance is valid if the name and address fields are filled.  A 
student is "complete" if the student is valid and has signed up for one or more 
classes.

So, my question is: where should the valid and complete methods live?  Should 
they be in the Student model or CBV?  Someplace else?  Does it matter?

Cheers
-- 
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/22801669-96ec-4a43-a264-fd50c2544604%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/5d2ab038.1c69fb81.ede47.7dde%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user question: Where to put non-form validation code?

2019-07-13 Thread Dean Karres
Thank you. There are way more parts to this than I would have imagined.



On Sat, Jul 13, 2019, 8:01 PM Mike Dewhirst  wrote:

> On 14/07/2019 10:37 am, Dean Karres wrote:
>
> Hi,
>
> I am learning Django.  I am using CBVs.  My default "index.py" view is
> basically a dashboard for the app I am playing with.  As my models and
> views become more complicated I want to be able to ask, for any model
> instance, is this instance "valid" or "complete".  Valid means that all
> Required elements are present and have reasonable values.  "Complete" means
> that an instance is "valid" but also some specific bits of additional info
> are also ok.
>
> For example I have a Student model that has name and address info.  There
> is a ManyToMany relation to the Class(es) in which that Student is
> enrolled.  A "student" instance is valid if the name and address fields are
> filled.  A student is "complete" if the student is valid and has signed up
> for one or more classes.
>
> So, my question is: where should the valid and complete methods live?
> Should they be in the Student model or CBV?  Someplace else?  Does it
> matter?
>
>
> I like to put that sort of stuff into model methods then add model.clean()
> to call them and raise whatever error may be appropriate if they fail.
>
>
> https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/#interaction-with-model-validation
>
> and
>
>
> https://docs.djangoproject.com/en/2.1/ref/models/instances/#validating-objects
>
> and
>
>
> https://docs.djangoproject.com/en/2.1/ref/models/instances/#django.db.models.Model.clean
>
> You can raise your own errors which inherit from ValidationError to fine
> tune the process. For example, I differentiate between
> BusinessRuleViolation and InvalidToken and a couple of others where that
> delivers better control.
>
>
>
> Cheers
> --
> 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/22801669-96ec-4a43-a264-fd50c2544604%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/CAO%2B1Q_uv_PN%3Dm8Ny5zWyQVGbSkY2mnwZJO-dYQy2yL8CbOTgsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user question: Where to put non-form validation code?

2019-07-13 Thread Mike Dewhirst

On 14/07/2019 10:37 am, Dean Karres wrote:

Hi,

I am learning Django.  I am using CBVs.  My default "index.py" view is 
basically a dashboard for the app I am playing with.  As my models and 
views become more complicated I want to be able to ask, for any model 
instance, is this instance "valid" or "complete".  Valid means that 
all Required elements are present and have reasonable values.  
"Complete" means that an instance is "valid" but also some specific 
bits of additional info are also ok.


For example I have a Student model that has name and address info.  
There is a ManyToMany relation to the Class(es) in which that Student 
is enrolled.  A "student" instance is valid if the name and address 
fields are filled.  A student is "complete" if the student is valid 
and has signed up for one or more classes.


So, my question is: where should the valid and complete methods live?  
Should they be in the Student model or CBV? Someplace else?  Does it 
matter?


I like to put that sort of stuff into model methods then add 
model.clean() to call them and raise whatever error may be appropriate 
if they fail.


https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/#interaction-with-model-validation

and

https://docs.djangoproject.com/en/2.1/ref/models/instances/#validating-objects

and

https://docs.djangoproject.com/en/2.1/ref/models/instances/#django.db.models.Model.clean

You can raise your own errors which inherit from ValidationError to fine 
tune the process. For example, I differentiate between 
BusinessRuleViolation and InvalidToken and a couple of others where that 
delivers better control.





Cheers
--
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/22801669-96ec-4a43-a264-fd50c2544604%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/d97da99d-4d15-1467-251b-487e604f0b18%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


New user question: Where to put non-form validation code?

2019-07-13 Thread Dean Karres
Hi,

I am learning Django.  I am using CBVs.  My default "index.py" view is 
basically a dashboard for the app I am playing with.  As my models and 
views become more complicated I want to be able to ask, for any model 
instance, is this instance "valid" or "complete".  Valid means that all 
Required elements are present and have reasonable values.  "Complete" means 
that an instance is "valid" but also some specific bits of additional info 
are also ok.

For example I have a Student model that has name and address info.  There 
is a ManyToMany relation to the Class(es) in which that Student is 
enrolled.  A "student" instance is valid if the name and address fields are 
filled.  A student is "complete" if the student is valid and has signed up 
for one or more classes.

So, my question is: where should the valid and complete methods live?  
Should they be in the Student model or CBV?  Someplace else?  Does it 
matter?

Cheers

-- 
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/22801669-96ec-4a43-a264-fd50c2544604%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


extend New user model

2019-06-23 Thread laya Mahmoudi
Hi , I am new to django. 
my project is about a system which some users suck as student and 
Professors can sign up and login in the system and there are some courses 
which are defined with a professor and students can take the course.
my model is as follow:

class User(AbstractUser):
is_student = models.BooleanField(default=False)
is_professor = models.BooleanField(default=False)


class Student(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
username = models.PositiveIntegerField()
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=100)
student_no = models.PositiveIntegerField()


and my serializer is:

from rest_framework.serializers import ModelSerializer

from accounts.models import Student

User = get_user_model()


class StudentCreateSerializer(ModelSerializer):
class Meta:
model = Student
fields = (
'username',
'first_name',
'last_name',

)

def save(self, **kwargs):
if Student.objects.last():
new_student = Student.objects.last()
student_no = new_student.student_no
student_no = student_no+1
Student.student_no = student_no
else:
student_no = 98012346
Student.student_no = student_no
user = User.objects.create_user(username=student_no, 
password=Student.username)
Student.save(user)
return Student

and my view is:

class StudentSigUpView(CreateAPIView):
serializer_class = StudentCreateSerializer
queryset = Student.objects.all()

I ask you to help me .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/d86398b5-cd28-4ba1-8301-5dec4514ab0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


SocialAuth through Odnoklassniki: does not register new user

2019-03-03 Thread Roman Izutov
Hi mates,
   I read through the man , created an 
odnoklassniki app, received these things to email:
 Application ID NNN 
 Публичный ключ приложения 
 Секретный ключ приложения 
 Ссылка на приложение https://ok.ru/game/ 
NNN


   And as per instruction from the link  
created a ref on login.html:

> "https://connect.ok.ru/oauth/authorize?client_id=NNN=VALUABLE_ACCESS_type=code_uri=192.168.1.8:1=w;
>> >OK
>>
>
Then on clicking the link on login(in my local app ) it redirects me to the 
odnoklassniki site and asks to use the odnoklassniki account with prompt to 
enter credentials. 
It checks credentianls and forwards me to the link 192.168.1.8:1

But the registration magic has not been done as expected. The site still offers 
to enter credentials. 
With VK the only thing I added is this link
VK
and it works fine. (it's working out of the box of social auth, the same 
success with Google+)

Could someone please forward me to the detailed howto man for odnoklassniki 
authorization(example is prefered)?

Thanx in advance!

-- 
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/c7c6835b-c37f-4def-861e-781ff258230c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to use oauth2client in django 2.0 for google login new user and exiting user

2019-01-15 Thread Manas Nikam
Create a view to accept the auth token from Google and pass it to your
authentication backend (Register the GoogleAuthBackend in settings first)
verify the token in the backend and return the user from db if email exists
else create a new user and return the token and pass this user object to
login function from django.contrib.auth.login function and start his
session in there

On Wed, Jan 16, 2019, 12:18 PM arvind yadav  how to use google  oauth2client for new user and exiting user  in django
> help help me any share any link
>
> --
> 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/501631fa-85bc-4364-8a11-23ce519be57c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/501631fa-85bc-4364-8a11-23ce519be57c%40googlegroups.com?utm_medium=email_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/CAF%2BYYc5J8U9nxk4u%3D1zn2d9TugByT3Xw9TXZR%2BPg7obPn4O8aQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how to use oauth2client in django 2.0 for google login new user and exiting user

2019-01-15 Thread arvind yadav
how to use google  oauth2client for new user and exiting user  in django 
help help me any share any link

-- 
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/501631fa-85bc-4364-8a11-23ce519be57c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create a new user with django rest framework and custom user model

2017-03-26 Thread Andréas Kühne
I think you have a few errors in your code.

In views.py you write:
User.objects.create_user(
serialized.save()
)

serialized.save() is probably calling User.objects.create - which you
shouldn't do. If you want to create a user the way you are doing you will
need to override the default create_user method on the User model. Add
support for handling the password1 and password2 fields and then add
support for the first_name and last_name fields.

Then you can override the create method on the serializer class like this:

def create(self, validated_data):
"""
Override default implementation of the create method. Make sure
user gets password.

:param validated_data: the validated data sent to the method

:return: the newly created user if successful
"""
if self.is_valid(True):
return User.create_user(validated_data.get("email"),
validated_data.get("password"),
validated_data.get("first_name"),
validated_data.get("last_name"))


Regards,

Andréas

2017-03-26 18:23 GMT+02:00 Aamu Padi <aamup...@gmail.com>:

> I have a custom user model and I am using django-rest-framework to create
> API
>
> models.py:
>
> class User(AbstractBaseUser, PermissionsMixin):
> email = models.EmailField(
> unique=True,
> max_length=254,
> )
> first_name = models.CharField(max_length=15)
> last_name = models.CharField(max_length=15)
> mobile = models.IntegerField(unique=True)
> date_joined = models.DateTimeField(default=timezone.now)
> is_active = models.BooleanField(default=True)
> is_admin = models.BooleanField(default=False)
>
>
> serializers.py:
>
> class UserSerializer(serializers.ModelSerializer):
> password1 = serializers.CharField(write_only=True)
> password2 = serializers.CharField(write_only=True)
>
> class Meta:
> model = User
> fields = ('first_name', 'last_name', 'email', 'mobile',
> 'password1', 'password2')
>
>
> views.py:
>
> @api_view(['POST'])
> @permission_classes((AllowAny,))
> def create_user(request):
> serialized = UserSerializer(data=request.data)
> if serialized.is_valid():
> User.objects.create_user(
> serialized.save()
> )
> return Response(serialized.data, status=status.HTTP_201_CREATED)
> else:
> return Response(serialized._errors, status=status.HTTP_400_BAD_
> REQUEST)
>
>
> However, when I try to create a new user I am getting this error:
>
> *Got a TypeError when calling User.objects.create(). This may be because
>> you have a writable field on the serializer class that is not a valid
>> argument to User.objects.create(). You may need to make the field
>> read-only, or override the UserSerializer.create() method to handle this
>> correctly.*
>
>
> This maybe because there's no password1 or password2 fields in the User
> model. But so, how can I create an API to create a new user using
> django-rest-framework?
>
> --
> 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/CAHSNPWtWmifpo6BuWQmp3-Y-pXyJAPBELf90MmeWLQBB9nGmyw%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHSNPWtWmifpo6BuWQmp3-Y-pXyJAPBELf90MmeWLQBB9nGmyw%40mail.gmail.com?utm_medium=email_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/CAK4qSCe5CqajAZs7wOdoRh7-yzj%3DZVxXpbDRas3znndubymddA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to create a new user with django rest framework and custom user model

2017-03-26 Thread Aamu Padi
I have a custom user model and I am using django-rest-framework to create
API

models.py:

class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
unique=True,
max_length=254,
)
first_name = models.CharField(max_length=15)
last_name = models.CharField(max_length=15)
mobile = models.IntegerField(unique=True)
date_joined = models.DateTimeField(default=timezone.now)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)


serializers.py:

class UserSerializer(serializers.ModelSerializer):
password1 = serializers.CharField(write_only=True)
password2 = serializers.CharField(write_only=True)

class Meta:
model = User
fields = ('first_name', 'last_name', 'email', 'mobile',
'password1', 'password2')


views.py:

@api_view(['POST'])
@permission_classes((AllowAny,))
def create_user(request):
serialized = UserSerializer(data=request.data)
if serialized.is_valid():
User.objects.create_user(
serialized.save()
)
return Response(serialized.data, status=status.HTTP_201_CREATED)
else:
return Response(serialized._errors,
status=status.HTTP_400_BAD_REQUEST)


However, when I try to create a new user I am getting this error:

*Got a TypeError when calling User.objects.create(). This may be because
> you have a writable field on the serializer class that is not a valid
> argument to User.objects.create(). You may need to make the field
> read-only, or override the UserSerializer.create() method to handle this
> correctly.*


This maybe because there's no password1 or password2 fields in the User
model. But so, how can I create an API to create a new user using
django-rest-framework?

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


Re: Django 1.8.13 saving new user gets error NOT NULL constraint failed: auth_user.last_login

2016-07-21 Thread bobhaugen
Hah! You are right! My fault.

On Thursday, July 21, 2016 at 11:55:29 AM UTC-5, Simon Charette wrote:
>
> If you upgraded from Django 1.7 you should make sure to run all auth 
> migrations.
>
> If you're using a custom user model make sure to makemigrations for its 
> app and proceed to migrate it.
>
> Simon
>
> Le jeudi 21 juillet 2016 11:46:37 UTC-4, bobhaugen a écrit :
>>
>> NOT NULL constraint failed: auth_user.last_login
>>>
>>>
>>>
>> This is a new user. Why should it have a last_login value? 
>>
>> I coded around it by giving the new user a fictitious last_login value, 
>> but still...
>>
>

-- 
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/2866e047-43e6-4801-86a7-e5cbb2a115d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.8.13 saving new user gets error NOT NULL constraint failed: auth_user.last_login

2016-07-21 Thread Simon Charette
If you upgraded from Django 1.7 you should make sure to run all auth 
migrations.

If you're using a custom user model make sure to makemigrations for its app 
and proceed to migrate it.

Simon

Le jeudi 21 juillet 2016 11:46:37 UTC-4, bobhaugen a écrit :
>
> NOT NULL constraint failed: auth_user.last_login
>>
>>
>>
> This is a new user. Why should it have a last_login value? 
>
> I coded around it by giving the new user a fictitious last_login value, 
> but still...
>

-- 
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/a7406d2a-38f0-4b07-b325-570925ab03cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.8.13 saving new user gets error NOT NULL constraint failed: auth_user.last_login

2016-07-21 Thread bobhaugen

>
> NOT NULL constraint failed: auth_user.last_login
>
>
>
This is a new user. Why should it have a last_login value? 

I coded around it by giving the new user a fictitious last_login value, but 
still...

-- 
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/10b0a641-0557-4602-954c-95892b526be2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I can not create a new user via admin Django?

2016-03-10 Thread setivolkylany

I create project with my authuser model where login via email, not through 
name



Models.py



import imghdr
import string
import datetime

from django_countries.fields import CountryField

from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, 
PermissionsMixin
from django.core.urlresolvers import reverse
from django.core.exceptions import ValidationError
from django.core.validators import MinLengthValidator
from django.conf import settings

from libs.validators import OnlyLowercaseAndDigits


ALLOWED_CHARS = string.ascii_lowercase + string.digits
MAX_LENGTH = 8


class AccountUserManager(BaseUserManager):
"""
Manager for my user model
"""

def create_user(self, email, name, password=None):
"""
Creates and saves a user with the given email, name of account and 
password.
"""
if not email:
raise ValueError('User must have an email address')
if not name:
raise ValueError('User must have a name of account')
user = self.model(email=self.normalize_email(email), name=name)
user.set_password(password)
user.save()
return user

def create_superuser(self, email, name, password):
"""
Creates and saves a superuser with the given email, name of account 
and password.
"""
if not password:
raise ValueError('Superuser must be have a password')
user = self.create_user(email=self.normalize_email(email), 
name=name, password=password)
user.is_superuser = True
user.save()
return user

def make_random_password(self, length=10, allowed_chars=ALLOWED_CHARS):
return super().make_random_password(length, allowed_chars)


class AccountUser(AbstractBaseUser, PermissionsMixin):
"""
Model for users, registering by email and unique name of account
"""

email = models.EmailField('Email of account', max_length=50, 
unique=True)
name = models.CharField('Account of name', max_length=50, validators=[
OnlyLowercaseAndDigits,
MinLengthValidator(MAX_LENGTH, 'Field must be at least {0} 
chars'.format(MAX_LENGTH)),
])
is_active = models.BooleanField(default=True)
date_joined = models.DateTimeField('Date joined', auto_now_add=True)

objects = AccountUserManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['name']

class Meta:
db_table = 'account_user'
verbose_name = "AccountUser"
verbose_name_plural = "AccountUsers"
get_latest_by = 'date_joined'
ordering = ['-date_joined']

def __str__(self):
return '{0.email}'.format(self)

def save(self, *args, **kwargs):
try:
self.full_clean()
except ValidationError as errors_message:
print('Was happened next 
errors:\n-')
for error in errors_message:
print(error)
else:
super().save(*args, **kwargs)
account = AccountUser.objects.get(email=self.email)
if not hasattr(account, 'accountuserinfo'):
AccountUserInfo.objects.create(account=account)

def get_absolute_url(self):
return reverse('app_accounts:account_profile')

def get_full_name(self):
return '{0.name} ({0.email})'.format(self)

def clean(self):
if len(self.password) < MAX_LENGTH:
raise ValidationError({
'password': 'Length of password must be at least 
{0}'.format(MAX_LENGTH)
})
if all(i in string.digits for i in self.password):
raise ValidationError({
'password': 'Your password can\'t be entirely numeric'
})

def get_short_name(self):
return '{0.email}'.format(self)

@property
def is_staff(self):
return self.is_superuser

def all_dictionaries_created_user(self):
count_translators = self.translators.count()
count_glossaries = self.glossaries.count()
if any([count_translators, count_glossaries]):
result = 'User have: translators - {0}; glossaries - 
{1}.'.format(count_translators, count_glossaries)
else:
result = 'User have not nothing!!!'
return result

def last_created_dictionaries(self, types_dictionaries=['translators', 
'glossaries']):
result = list()
for type_dictionary in types_dictionaries:
if type_dictionary == 'translators':
created_translators = self.translators.all()[:3]
if created_translators:
result.append('User have next translators: 
{0}'.format(created_translators))
else:
result.append('User have not translators')
if type_dictionary == 'glossaries':
created_glossaries = self.glossaries.all()[:3]

Re: New User Tips?

2015-08-25 Thread Lachlan Musicman
1. Do the tutorial if you've never used Django before
2. Keep your code in a repo, have a dev site and a prod site at least
3. Use virtualenv
4. This list is a good place to come for support. Also, the IRC channel
with FunkyBob.


--
The most dangerous phrase in the language is, "We've always done it this
way."

- Grace Hopper

On 26 August 2015 at 08:09, John Thomas 
wrote:

> Hi Django-Users:
>
> I am starting a project.  I just saw the tip below.  I was wondering if
> you would share other tips you have.
>
>1. I _always_ start every project with a custom User model, to avoid
>this problem ["this problem" = "difficult to transfer to a custom user
>model."]
>
>
> John Thomas
>
>
> If you are not the intended recipient of this message, please promptly
> notify the sender of the transmission error, delete this message and do not
> disclose or make improper use of it. Electronic messages are not
> necessarily secure or error-free and can contain viruses, and the sender is
> not liable for any of these occurrences.
>
> --
> 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/CAJ22gMD11fRGrCr-oE89Y1dCgEK2TUc%2BFc7batbdzTk3qf9T9A%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiMSNsqMt-DQ4551%3DbKj7jDe-GdEgYcbiJfUonUBJ1M2Aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


New User Tips?

2015-08-25 Thread John Thomas
Hi Django-Users:

I am starting a project.  I just saw the tip below.  I was wondering if you
would share other tips you have.

   1. I _always_ start every project with a custom User model, to avoid
   this problem ["this problem" = "difficult to transfer to a custom user
   model."]


John Thomas

-- 
If you are not the intended recipient of this message, please promptly 
notify the sender of the transmission error, delete this message and do not 
disclose or make improper use of it. Electronic messages are not 
necessarily secure or error-free and can contain viruses, and the sender is 
not liable for any of these occurrences.

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


Re: New user - struggling with database design

2014-09-02 Thread Derek
That looks like a database error - check in your database as to which 
tables have been created.

On Thursday, 28 August 2014 18:05:01 UTC+2, Jason G wrote:
>
> Ok - here is where I am stuck now. Any thoughts?
>
> If I try to render {{ vessel.CurrentBrew }} in a view, I get something 
> like this:
>  0x7f76f0088e10>
>
> and this errors out:
>
> {% for Brew in vessel.CurrentBrew.all %}X{{ Brew.ActualName }}{% 
> endfor %}
>
> (1146, "Table 'dbLunawireBrewing.brewlog_vessel_CurrentBrew' doesn't exist")
>
>
>
> The vessel model looks like this:
>
> class Vessel(models.Model):
> Name = models.CharField(max_length=20)
> ShortName = models.CharField(max_length=4)
> Gallons = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
> blank=True)
> Weight = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
> blank=True)
> CurrentBrew  = models.ManyToManyField('Brew', related_name="brew")
> def __unicode__(self):
> return self.Name
>
>
>

-- 
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/41928000-f83d-4403-aa9d-086429f1fa80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user - struggling with database design

2014-08-28 Thread Jason G
Ok - here is where I am stuck now. Any thoughts?

If I try to render {{ vessel.CurrentBrew }} in a view, I get something like 
this:


and this errors out:

{% for Brew in vessel.CurrentBrew.all %}X{{ Brew.ActualName }}{% 
endfor %}

(1146, "Table 'dbLunawireBrewing.brewlog_vessel_CurrentBrew' doesn't exist")



The vessel model looks like this:

class Vessel(models.Model):
Name = models.CharField(max_length=20)
ShortName = models.CharField(max_length=4)
Gallons = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
blank=True)
Weight = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
blank=True)
CurrentBrew  = models.ManyToManyField('Brew', related_name="brew")
def __unicode__(self):
return self.Name


-- 
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/2363ed3e-a787-46a0-b887-7706d0a9c315%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user - struggling with database design

2014-08-28 Thread Jason G
Hi Gerald - thanks for the quick reply! Turns out it was just an issue with 
quotes...not sure I am doing it right just yet, but at least I've passed 
the error.

>  

-- 
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/7b725cda-6078-4859-8e20-4ef05d2d2c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user - struggling with database design

2014-08-28 Thread Gerald Klein
their order if I am understanding you right does not effect this, the last
part is just  a join between the tables, you don't have to create another
table


On Thu, Aug 28, 2014 at 8:46 AM, Jason G  wrote:

> Hi all,
>
> I am building an app to track my home brewing.
>
> I have two tables, one for vessels, and another for brews.
>
> I want the Brew table to have a pick-list, relation to Vessels so I can
> say what vessel the brew is in.
>
> I also want to render a table that shows all Vessels and what Brew is in
> each. There should be a one-to-one relationship until the Brew is 'Kicked',
> which could be a vessel or maybe a null value in the Brew table.
>
> My code currently doesn't work, but looks something like this:
>
> class Vessel(models.Model):
> Name = models.CharField(max_length=20)
> Gallons = models.DecimalField(max_digits=4, decimal_places=2,
> null=True, blank=True)
> Weight = models.DecimalField(max_digits=4, decimal_places=2,
> null=True, blank=True)
> CurrentBrew  = models.ForeignKey(Brew, db_column='Vessel')
>  <--this is what I'm trying to add
> def __unicode__(self):
> return self.Name
>
> class Brew(models.Model):
> ...
> Name = models.CharField(max_length=40, null=True, default='TBD')
> InformalName = models.CharField(max_length=40)
> Status = models.IntegerField(max_length=1, choices=STATUS_CHOICES,
> default=1, null=False, blank=False)
> Gallons = models.DecimalField(max_digits=4, decimal_places=2,
> null=True, blank=True)
> Vessel = models.ForeignKey(Vessel)
> Style = models.ForeignKey(Style)
> Event = models.CharField(max_length=40, null=True, blank=True)
>
> In this model, which I'm not sure is the best way to do it, the Vessel
> class does not yet know about the Brew model that is below it.
>
> I'm starting to grasp this language (and love it, coming from doing
> asp/sql several years ago) but I'm stuck here. 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/dd40f53a-c398-4806-b09d-1605d3f15ead%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

geraldklein.wordpress.com

j...@zognet.com

708-599-0352


Arch, Gentoo I3, Ranger & Vim the coding triple threat.

Linux registered user #548580

Brought to you by the Amish Mafia

-- 
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/CAP8NtCz9%2BURQG23wR%3DXSkUozJ7vFvDXOnp5cfyRPMFdXTOJ%2BzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


New user - struggling with database design

2014-08-28 Thread Jason G
Hi all,

I am building an app to track my home brewing.

I have two tables, one for vessels, and another for brews.

I want the Brew table to have a pick-list, relation to Vessels so I can say 
what vessel the brew is in.

I also want to render a table that shows all Vessels and what Brew is in 
each. There should be a one-to-one relationship until the Brew is 'Kicked', 
which could be a vessel or maybe a null value in the Brew table.

My code currently doesn't work, but looks something like this:

class Vessel(models.Model):
Name = models.CharField(max_length=20)
Gallons = models.DecimalField(max_digits=4, decimal_places=2, 
null=True, blank=True)
Weight = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
blank=True)
CurrentBrew  = models.ForeignKey(Brew, db_column='Vessel') 
 <--this is what I'm trying to add
def __unicode__(self):
return self.Name

class Brew(models.Model):
...
Name = models.CharField(max_length=40, null=True, default='TBD')
InformalName = models.CharField(max_length=40)
Status = models.IntegerField(max_length=1, choices=STATUS_CHOICES, 
default=1, null=False, blank=False)
Gallons = models.DecimalField(max_digits=4, decimal_places=2, 
null=True, blank=True)
Vessel = models.ForeignKey(Vessel)
Style = models.ForeignKey(Style)
Event = models.CharField(max_length=40, null=True, blank=True)

In this model, which I'm not sure is the best way to do it, the Vessel 
class does not yet know about the Brew model that is below it.

I'm starting to grasp this language (and love it, coming from doing asp/sql 
several years ago) but I'm stuck here. 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dd40f53a-c398-4806-b09d-1605d3f15ead%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: new user having trouble displaying images stored on local disk drive

2013-07-17 Thread evh
Thanks, but my real problem turned out to be a missing comma after the 
staticfiles_dirs entry.  After adding it I was able to see files stored on 
my hard drive.


On Wednesday, July 17, 2013 2:07:42 AM UTC-4, Lukáš Němec wrote:
>
> Hi, 
>
> You are not the first to have trouble when serving images from django's 
> built-in server. 
> It is not only images, but all staticfiles. 
>
> I'd like to clarify your settings.py 
>
> The directory you have put in STATICFILES_DIRS will be available to 
> django as /static/ in your web app, but you need to have 
>
> STATICFILES_FINDERS = 
>
> ("django.contrib.staticfiles.finders.FileSystemFinder", 
>   "django.contrib.staticfiles.finders.AppDirectoriesFinder") 
>
>
> Also the django test server needs to have correct permissions to open 
> and read that folder, 
> but when you go just to /static/, you will not see anything, it will not 
> list the files, you need to specify exact name of the file. 
>
> Django help: 
> https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/ 
>
> If this didn't help, try stackowerflow 
>
> Lukas 
>
>
> On 07/16/2013 07:09 PM, evh wrote: 
> > Working in a Windows environment without a production server - 
> > everything on one machine for ease of development (or so I thought). 
> >  Can display images pulled from the web, but not any stored on local 
> > hard drive.  Some of the relevant items in my settings.py looks like 
> > this: 
> > MEDIA_ROOT = 'C:/djcode/images/' 
> > MEDIA_URL = 'C:/djcode/images/' 
> > STATIC_ROOT = '' 
> > STATIC_URL = '/static/' 
> > STATICFILES_DIRS = ( 
> > # Put strings here, like "/home/html/static" or 
> > "C:/www/django/static". 
> > # Always use forward slashes, even on Windows. 
> > # Don't forget to use absolute paths, not relative paths. 
> > "C:/djcode/images/" 
> > ) 
> > Would appreciate any guidance or suggestions on what I am missing or 
> > doing incorrectly.  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 http://groups.google.com/group/django-users. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: new user having trouble displaying images stored on local disk drive

2013-07-17 Thread Lukas Nemec

Hi,

You are not the first to have trouble when serving images from django's 
built-in server.

It is not only images, but all staticfiles.

I'd like to clarify your settings.py

The directory you have put in STATICFILES_DIRS will be available to 
django as /static/ in your web app, but you need to have


STATICFILES_FINDERS =

("django.contrib.staticfiles.finders.FileSystemFinder",
 "django.contrib.staticfiles.finders.AppDirectoriesFinder")


Also the django test server needs to have correct permissions to open 
and read that folder,
but when you go just to /static/, you will not see anything, it will not 
list the files, you need to specify exact name of the file.


Django help:
https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/

If this didn't help, try stackowerflow

Lukas


On 07/16/2013 07:09 PM, evh wrote:
Working in a Windows environment without a production server - 
everything on one machine for ease of development (or so I thought). 
 Can display images pulled from the web, but not any stored on local 
hard drive.  Some of the relevant items in my settings.py looks like 
this:

MEDIA_ROOT = 'C:/djcode/images/'
MEDIA_URL = 'C:/djcode/images/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or 
"C:/www/django/static".

# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"C:/djcode/images/"
)
Would appreciate any guidance or suggestions on what I am missing or 
doing incorrectly.  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.
For more options, visit https://groups.google.com/groups/opt_out.




--
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.
For more options, visit https://groups.google.com/groups/opt_out.




new user having trouble displaying images stored on local disk drive

2013-07-16 Thread evh
Working in a Windows environment without a production server - everything 
on one machine for ease of development (or so I thought).  Can display 
images pulled from the web, but not any stored on local hard drive.  Some 
of the relevant items in my settings.py looks like this:
MEDIA_ROOT = 'C:/djcode/images/'
MEDIA_URL = 'C:/djcode/images/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"C:/djcode/images/"
)
Would appreciate any guidance or suggestions on what I am missing or doing 
incorrectly.  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.
For more options, visit https://groups.google.com/groups/opt_out.




New user: example database tables not found

2013-06-27 Thread rshepard
I'm working my way through the django-1.5.1 manual. Following instructions 
to create the polls sample site I see on page 29 to run 'python manage.py 
syncdb' to create the model tables in the postgres database. However, when 
I run 'psql -l' I do not see the sample database. What might I have done 
incorrectly?

Rich

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: New user - template errors.

2013-05-22 Thread Nigel Legg
Cool, thanks.  And sorry - I should have gone there first.

Regards,
Nigel Legg
07722 652866
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 22 May 2013 17:01, Michael  wrote:

> Hi Nigel, take a look at these, they might provide some answers:
>
>
> http://stackoverflow.com/questions/14892462/django-error-upolls-is-not-a-registered-namespace
>
>
> http://stackoverflow.com/questions/16049972/django-tutorial-04-noreversematch-at-polls-1-upolls-is-not-a-registered-na
>
>
> On Wednesday, 22 May 2013 11:10:02 UTC+1, Nigel Legg wrote:
>>
>> Morning/Afternoon - I am new to django, and I have been working through
>> the tutorial.  I have reached Tutorial 4, https://docs.djangoproject.**
>> com/en/1.5/intro/tutorial04/,
>> which is about getting the voting on the polls app to work, but when I set
>> detail.html I get an error, "
>> NoReverseMatch at /polls/2/
>>
>> u'polls' is not a registered namespace
>>
>> What would cause that?
>>
>> Many thanks.
>>
>> Regards,
>> Nigel Legg
>> 07722 652866
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/**nigellegg
>>
>>   --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: New user - template errors.

2013-05-22 Thread Michael
Hi Nigel, take a look at these, they might provide some answers:

http://stackoverflow.com/questions/14892462/django-error-upolls-is-not-a-registered-namespace

http://stackoverflow.com/questions/16049972/django-tutorial-04-noreversematch-at-polls-1-upolls-is-not-a-registered-na

On Wednesday, 22 May 2013 11:10:02 UTC+1, Nigel Legg wrote:
>
> Morning/Afternoon - I am new to django, and I have been working through 
> the tutorial.  I have reached Tutorial 4, 
> https://docs.djangoproject.com/en/1.5/intro/tutorial04/, which is about 
> getting the voting on the polls app to work, but when I set detail.html I 
> get an error, "
> NoReverseMatch at /polls/2/ 
>
> u'polls' is not a registered namespace
>
> What would cause that?
>
> Many thanks. 
>
> Regards,
> Nigel Legg
> 07722 652866
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>  

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




New user - template errors.

2013-05-22 Thread Nigel Legg
Morning/Afternoon - I am new to django, and I have been working through the
tutorial.  I have reached Tutorial 4,
https://docs.djangoproject.com/en/1.5/intro/tutorial04/, which is about
getting the voting on the polls app to work, but when I set detail.html I
get an error, "
NoReverseMatch at /polls/2/

u'polls' is not a registered namespace

What would cause that?

Many thanks.

Regards,
Nigel Legg
07722 652866
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multi-tenant database model with new user model?

2013-05-02 Thread Venkatraman S
I think i had stumbled on django-multitenant or django-simple-multitenant
sometime back. I took some ideas from there and implemented my own version
of custom multi-tenancy.


On Wed, May 1, 2013 at 8:31 PM, Dan Gentry  wrote:

> Something I'm looking forward to learning as well.  My app uses the older
> user_profile approach.
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multi-tenant database model with new user model?

2013-05-01 Thread Dan Gentry
Something I'm looking forward to learning as well.  My app uses the older 
user_profile approach.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Multi-tenant database model with new user model?

2013-04-30 Thread Subodh Nijsure
Hi,

We have old model for one of my django application that requires
multi-tenant deployment. The database model I came up with is kind of
_ugly_ to support the multi-tenancy.

Are there any good examples of how one can write multi-tenant django
application using the new AbstractUser classes?

-Subodh

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [django-users] Error when registering a new user - Django 1.5

2013-03-23 Thread Russell Keith-Magee
Variations on this problem report have been made a couple of times

UserCreateForm is a ModelForm. That means the line in your Meta clause for
model=get_user_model() is invoked at the time the module is loaded.
However, there's no guarantee at the time that module is loaded that the
user model has been defined yet -- so you can end up with errors.

There are two options here.

Option 1: We try to define a truly dynamic UserCreateForm that can adapt to
the changing requirements of a User model (and remember, this means
adapting to the REQUIRED_FIELDS as well). This code would be complex and
potentially fragile, since it needs to work with *any* User model, with
*any* collection of required fields.

Option 2: We provide a UserCreateForm that works with the default User
model, and with any AbstractUser descendent that isn't too significantly
modified, and we leave the UserCreateForm for any other User model an an
activity for the developer.

We've chosen Option 2, and documented as such:

https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#custom-users-and-the-built-in-auth-forms

Yours,
Russ Magee %-)

On Sat, Mar 23, 2013 at 12:00 PM, Leonardo S <leonardo.s.c...@gmail.com>wrote:

> I did it and aparently it worked:
>
> *# forms.py*
> *class UserCreateForm(UserCreationForm):*
> *
> *
> *
> def clean_username(self):
> username = self.cleaned_data["username"]
> try:
> self._meta.model._default_manager.get(username=username)
> except self._meta.model.DoesNotExist:
> return username
> raise
> forms.ValidationError(self.error_messages['duplicate_username'])
> *
> *
> *
> *class Meta:*
> *model = get_user_model()*
> *fields = ('email', 'password1', 'password2', 'first_name',
> 'last_name', 'bio', 'username')*
> *
> *
> From:
> https://groups.google.com/forum/?fromgroups=#!topic/django-users/kOVEy9zYn5c
> Should not it be the UserCreationForm standard?
>
>
> 2013/3/23 Leonardo S <leonardo.s.c...@gmail.com>
>
>> Hi,
>>
>> I am getting an error when registering a new user in a Django 1.5 app.
>> It is the postgres' log:
>>
>> *BRT ERROR:  relation "auth_user" does not exist at character 280*
>> *BRT COMMAND:  SELECT "auth_user"."id", "auth_user"."password",
>> "auth_user"."last_login", "auth_user"."is_superuser",
>> "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
>> "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
>> "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."username" =
>> E'teste'*
>> *
>> *
>> My code is very simple:
>> *
>> *
>> *# models.py*
>> *class User(AbstractUser):*
>> *bio = models.CharField(max_length=255, blank=True, null=True)*
>> *objects = UserManager()*
>>
>> *# forms.py*
>> *class UserCreateForm(UserCreationForm):*
>> *class Meta:*
>> *model = get_user_model()*
>> *fields = ('email', 'password1', 'password2', 'first_name',
>> 'last_name', 'bio', 'username')*
>>
>> *# views.py*
>> *class UserCreateView(CreateView):*
>> *form_class = UserCreateForm*
>> *model = get_user_model()*
>> *
>> *
>> I think that UserCreationForm yet search for auth_user table.
>> A possible solution would be this:
>>
>> *# models.py*
>> *class User(AbstractUser):*
>> *bio = models.CharField(max_length=255, blank=True, null=True)*
>> *objects = UserManager()*
>> *class Meta:*
>> * db_table = u'auth_user'*
>>
>> But i would like to use a correct Django 1.5 approach to register a new
>> user.
>> Can anyone spot the problem?
>>
>> Regards,
>>   Leonardo
>>
>
>  --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [django-users] Error when registering a new user - Django 1.5

2013-03-22 Thread Leonardo S
I did it and aparently it worked:

*# forms.py*
*class UserCreateForm(UserCreationForm):*
*
*
*
def clean_username(self):
username = self.cleaned_data["username"]
try:
self._meta.model._default_manager.get(username=username)
except self._meta.model.DoesNotExist:
return username
raise
forms.ValidationError(self.error_messages['duplicate_username'])
*
*
*
*class Meta:*
*model = get_user_model()*
*fields = ('email', 'password1', 'password2', 'first_name',
'last_name', 'bio', 'username')*
*
*
From:
https://groups.google.com/forum/?fromgroups=#!topic/django-users/kOVEy9zYn5c
Should not it be the UserCreationForm standard?


2013/3/23 Leonardo S <leonardo.s.c...@gmail.com>

> Hi,
>
> I am getting an error when registering a new user in a Django 1.5 app.
> It is the postgres' log:
>
> *BRT ERROR:  relation "auth_user" does not exist at character 280*
> *BRT COMMAND:  SELECT "auth_user"."id", "auth_user"."password",
> "auth_user"."last_login", "auth_user"."is_superuser",
> "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
> "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
> "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."username" =
> E'teste'*
> *
> *
> My code is very simple:
> *
> *
> *# models.py*
> *class User(AbstractUser):*
> *bio = models.CharField(max_length=255, blank=True, null=True)*
> *objects = UserManager()*
>
> *# forms.py*
> *class UserCreateForm(UserCreationForm):*
> *class Meta:*
> *model = get_user_model()*
> *fields = ('email', 'password1', 'password2', 'first_name',
> 'last_name', 'bio', 'username')*
>
> *# views.py*
> *class UserCreateView(CreateView):*
> *form_class = UserCreateForm*
> *model = get_user_model()*
> *
> *
> I think that UserCreationForm yet search for auth_user table.
> A possible solution would be this:
>
> *# models.py*
> *class User(AbstractUser):*
> *bio = models.CharField(max_length=255, blank=True, null=True)*
> *objects = UserManager()*
> *class Meta:*
> * db_table = u'auth_user'*
>
> But i would like to use a correct Django 1.5 approach to register a new
> user.
> Can anyone spot the problem?
>
> Regards,
>   Leonardo
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[django-users] Error when registering a new user - Django 1.5

2013-03-22 Thread Leonardo S
Hi,

I am getting an error when registering a new user in a Django 1.5 app.
It is the postgres' log:

*BRT ERROR:  relation "auth_user" does not exist at character 280*
*BRT COMMAND:  SELECT "auth_user"."id", "auth_user"."password",
"auth_user"."last_login", "auth_user"."is_superuser",
"auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
"auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
"auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."username" =
E'teste'*
*
*
My code is very simple:
*
*
*# models.py*
*class User(AbstractUser):*
*bio = models.CharField(max_length=255, blank=True, null=True)*
*objects = UserManager()*

*# forms.py*
*class UserCreateForm(UserCreationForm):*
*class Meta:*
*model = get_user_model()*
*fields = ('email', 'password1', 'password2', 'first_name',
'last_name', 'bio', 'username')*

*# views.py*
*class UserCreateView(CreateView):*
*form_class = UserCreateForm*
*model = get_user_model()*
*
*
I think that UserCreationForm yet search for auth_user table.
A possible solution would be this:

*# models.py*
*class User(AbstractUser):*
*bio = models.CharField(max_length=255, blank=True, null=True)*
*objects = UserManager()*
*class Meta:*
* db_table = u'auth_user'*

But i would like to use a correct Django 1.5 approach to register a new
user.
Can anyone spot the problem?

Regards,
  Leonardo

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: new user

2012-12-21 Thread Mario Gudelj
Mate. What's up?
On 22 Dec, 2012 10:08 AM, "hardik juneja"  wrote:

>
> hello sir,
> i m new to django and need some hep can u help me
>
>  --
> 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/-/BiaGVHvURw4J.
> 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.
>

-- 
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: new user

2012-12-21 Thread hardik juneja

hello sir,
i m new to django and need some hep can u help me

-- 
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/-/BiaGVHvURw4J.
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: new user

2012-12-21 Thread peter

On 12/21/2012 02:13 PM, Satinderpal Singh wrote:

On Fri, Dec 21, 2012 at 5:57 PM, senthil mariyappan
 wrote:

hi friends, i new one to django..

  Welcome, man. I hope we can help you!!.

Welcome to the Django family.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/



--
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: new user

2012-12-21 Thread Satinderpal Singh
On Fri, Dec 21, 2012 at 5:57 PM, senthil mariyappan
 wrote:
> hi friends, i new one to django..

Welcome to the Django family.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

-- 
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.



new user

2012-12-21 Thread senthil mariyappan
hi friends, i new one to django..

-- 
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/-/SDpcDnlGgxMJ.
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: New user login problem

2011-09-16 Thread marios
OK, thank you.

The problem is already solved.

Mario

On 16 sep, 09:44, Jacco Flenter <django-us...@putpixel.nl> wrote:
> How did you set the password? There is a password field in the "change user"
> form in the admin, but it does not contain the user's password in clear
> text: it is the result of some cryptography on the password. It might be a
> good idea to go to the change user form and check if the password field
> contains something in the lines of "sha1$x$xxx..."
>
> Regards,
> Jacco
>
>  P.s. if you are on the "change user" page you can use the "change password
> form" below the password field to modify the current password
>
>
>
>
>
>
>
> On Fri, Sep 16, 2011 at 2:20 PM, marios <mst...@gmail.com> wrote:
> > Thank you.
>
> > I did what you are saying. And I have tried creating several new
> > users, but the error message is the same.
>
> > On 16 sep, 08:49, "Szabo, Patrick \(LNG-VIE\)"
> > <patrick.sz...@lexisnexis.at> wrote:
> > > Are you sure you've used the right credentials ?!
> > > Can you log as the admin ?!
> > > If so try to create another user and log in as such.
>
> > > . . . . . . . . . . . . . . . . . . . . . . . . . .
> > > Ing. Patrick Szabo
> > >  XSLT Developer
> > > LexisNexis
> > > Marxergasse 25, 1030 Wien
>
> > > mailto:patrick.sz...@lexisnexis.at
> > > Tel.: 00431 534521573
> > > Fax: +43 (1) 534 52 - 146
>
> > > -Ursprüngliche Nachricht-
>
> > > Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> > Im Auftrag von marios
> > > Gesendet: Freitag, 16. September 2011 13:14
> > > An: Django users
> > > Betreff: New user login problem
>
> > > I am a new user of Django with not much experience in programming. I
> > > am following the tutorial.
> > > In the Administration module I have created a new user with some
> > > permissions, but when I try to logging in as this new user appear an
> > > error message ("Wrong user or password")
> > > Could you help me?
>
> > > --
> > > 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 athttp://
> > groups.google.com/group/django-users?hl=en.
>
> > --
> > 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.

-- 
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: New user login problem

2011-09-16 Thread Jacco Flenter
How did you set the password? There is a password field in the "change user"
form in the admin, but it does not contain the user's password in clear
text: it is the result of some cryptography on the password. It might be a
good idea to go to the change user form and check if the password field
contains something in the lines of "sha1$x$xxx..."

Regards,
Jacco

 P.s. if you are on the "change user" page you can use the "change password
form" below the password field to modify the current password

On Fri, Sep 16, 2011 at 2:20 PM, marios <mst...@gmail.com> wrote:

> Thank you.
>
> I did what you are saying. And I have tried creating several new
> users, but the error message is the same.
>
> On 16 sep, 08:49, "Szabo, Patrick \(LNG-VIE\)"
> <patrick.sz...@lexisnexis.at> wrote:
> > Are you sure you've used the right credentials ?!
> > Can you log as the admin ?!
> > If so try to create another user and log in as such.
> >
> > . . . . . . . . . . . . . . . . . . . . . . . . . .
> > Ing. Patrick Szabo
> >  XSLT Developer
> > LexisNexis
> > Marxergasse 25, 1030 Wien
> >
> > mailto:patrick.sz...@lexisnexis.at
> > Tel.: 00431 534521573
> > Fax: +43 (1) 534 52 - 146
> >
> > -Ursprüngliche Nachricht-
> >
> > Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> Im Auftrag von marios
> > Gesendet: Freitag, 16. September 2011 13:14
> > An: Django users
> > Betreff: New user login problem
> >
> > I am a new user of Django with not much experience in programming. I
> > am following the tutorial.
> > In the Administration module I have created a new user with some
> > permissions, but when I try to logging in as this new user appear an
> > error message ("Wrong user or password")
> > Could you help me?
> >
> > --
> > 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 athttp://
> groups.google.com/group/django-users?hl=en.
>
> --
> 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.
>
>

-- 
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: New user login problem

2011-09-16 Thread marios
OK now.

I missed set is_staff=True.

Thank you.

Mario

(A doubt: Is it OK ask support questions in this forum or its purpose
is another?

On 16 sep, 09:22, Martin Tiršel <dja...@blackpage.eu> wrote:
> Hi,
>
> did you set is_staff to True?
>
> Martin
>
>
>
>
>
>
>
> On Fri, 16 Sep 2011 14:20:14 +0200, marios <mst...@gmail.com> wrote:
> > Thank you.
>
> > I did what you are saying. And I have tried creating several new
> > users, but the error message is the same.
>
> > On 16 sep, 08:49, "Szabo, Patrick \(LNG-VIE\)"
> > <patrick.sz...@lexisnexis.at> wrote:
> >> Are you sure you've used the right credentials ?!
> >> Can you log as the admin ?!
> >> If so try to create another user and log in as such.
>
> >> . . . . . . . . . . . . . . . . . . . . . . . . . .
> >> Ing. Patrick Szabo
> >>  XSLT Developer
> >> LexisNexis
> >> Marxergasse 25, 1030 Wien
>
> >> mailto:patrick.sz...@lexisnexis.at
> >> Tel.: 00431 534521573
> >> Fax: +43 (1) 534 52 - 146
>
> >> -Ursprüngliche Nachricht-
>
> >> Von: django-users@googlegroups.com  
> >> [mailto:django-users@googlegroups.com] Im Auftrag von marios
> >> Gesendet: Freitag, 16. September 2011 13:14
> >> An: Django users
> >> Betreff: New user login problem
>
> >> I am a new user of Django with not much experience in programming. I
> >> am following the tutorial.
> >> In the Administration module I have created a new user with some
> >> permissions, but when I try to logging in as this new user appear an
> >> error message ("Wrong user or password")
> >> Could you help me?
>
> >> --
> >> 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  
> >> athttp://groups.google.com/group/django-users?hl=en.

-- 
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: New user login problem

2011-09-16 Thread Martin Tiršel

Hi,

did you set is_staff to True?

Martin



On Fri, 16 Sep 2011 14:20:14 +0200, marios <mst...@gmail.com> wrote:


Thank you.

I did what you are saying. And I have tried creating several new
users, but the error message is the same.

On 16 sep, 08:49, "Szabo, Patrick \(LNG-VIE\)"
<patrick.sz...@lexisnexis.at> wrote:

Are you sure you've used the right credentials ?!
Can you log as the admin ?!
If so try to create another user and log in as such.

. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573
Fax: +43 (1) 534 52 - 146

-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com  
[mailto:django-users@googlegroups.com] Im Auftrag von marios

Gesendet: Freitag, 16. September 2011 13:14
An: Django users
Betreff: New user login problem

I am a new user of Django with not much experience in programming. I
am following the tutorial.
In the Administration module I have created a new user with some
permissions, but when I try to logging in as this new user appear an
error message ("Wrong user or password")
Could you help me?

--
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  
athttp://groups.google.com/group/django-users?hl=en.


--
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: New user login problem

2011-09-16 Thread marios
Thank you.

I did what you are saying. And I have tried creating several new
users, but the error message is the same.

On 16 sep, 08:49, "Szabo, Patrick \(LNG-VIE\)"
<patrick.sz...@lexisnexis.at> wrote:
> Are you sure you've used the right credentials ?!
> Can you log as the admin ?!
> If so try to create another user and log in as such.
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Ing. Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: 00431 534521573
> Fax: +43 (1) 534 52 - 146
>
> -Ursprüngliche Nachricht-
>
> Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
> Auftrag von marios
> Gesendet: Freitag, 16. September 2011 13:14
> An: Django users
> Betreff: New user login problem
>
> I am a new user of Django with not much experience in programming. I
> am following the tutorial.
> In the Administration module I have created a new user with some
> permissions, but when I try to logging in as this new user appear an
> error message ("Wrong user or password")
> Could you help me?
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
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.



AW: New user login problem

2011-09-16 Thread Szabo, Patrick (LNG-VIE)
Are you sure you've used the right credentials ?!
Can you log as the admin ?!
If so try to create another user and log in as such.


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 


-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von marios
Gesendet: Freitag, 16. September 2011 13:14
An: Django users
Betreff: New user login problem

I am a new user of Django with not much experience in programming. I
am following the tutorial.
In the Administration module I have created a new user with some
permissions, but when I try to logging in as this new user appear an
error message ("Wrong user or password")
Could you help me?

-- 
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.



-- 
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.



New user login problem

2011-09-16 Thread marios
I am a new user of Django with not much experience in programming. I
am following the tutorial.
In the Administration module I have created a new user with some
permissions, but when I try to logging in as this new user appear an
error message ("Wrong user or password")
Could you help me?

-- 
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: New user - Trouble starting

2011-08-15 Thread Landy Chapman
Hopefully this will help
>>  http://weblog.greenpeace.org/it/2006/04/getting_started_with_django_on.html

> I'm trying to start the tutorial (on Windows by the way) and I can't
> get anywhere. When I enter "django-admin.py startproject mysite" into
> either the interpreter or the Python command line I get the same
> message:
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.>>> import 
> django
> >>> django-admin.py startproject mysite
>
>                                                ^
> SyntaxError: invalid syntax

that's fine;  the django-admin.py  "command" is run from the command
line, not python shell.  :-)


> What am I doing wrong?

-- 
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: New user - Trouble starting

2011-08-15 Thread Thomas Weholt
Have you tried this in the command window ( assuming python is
installed in c:\python27 ):

c:\python27\python c:\python27\scripts\django-admin.py startproject mysite

On windows you might need to run python scripts through python like
shown above. And add c:\python27; c:\python27\scripts; to your path.

The other question, about os.chdir; you'll have to import os before
calling methods defined in it, like so :

c:\python27\python
>>> import os
>>> os.chdir('c:\temp')

Hope this helps :-)

PS! It seems like your new to python as well. I strongly recommend you
dive into python first before getting into django.

Thomas

On Mon, Aug 15, 2011 at 11:54 PM, squirrel  wrote:
> I'm trying to start the tutorial (on Windows by the way) and I can't
> get anywhere. When I enter "django-admin.py startproject mysite" into
> either the interpreter or the Python command line I get the same
> message:
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
 import django
 django-admin.py startproject mysite
>                                               ^
> SyntaxError: invalid syntax

>
> I've already made sure "C:\Python27\Lib\site-packages\django\bin" is
> set to my system path settings, and django-admin.py is in bin.
>
> What am I doing wrong?
>
> Also, I haven't been able to cd. I've tried os.chdir(), but it says
> 'os' is not defined. In the Python docs it says that's supposed to
> work on Windows machines, so is that not the right function for what
> I'm trying to do?
>
> --
> 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.
>
>



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

-- 
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.



New user - Trouble starting

2011-08-15 Thread squirrel
I'm trying to start the tutorial (on Windows by the way) and I can't
get anywhere. When I enter "django-admin.py startproject mysite" into
either the interpreter or the Python command line I get the same
message:
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import django
>>> django-admin.py startproject mysite
   ^
SyntaxError: invalid syntax
>>>

I've already made sure "C:\Python27\Lib\site-packages\django\bin" is
set to my system path settings, and django-admin.py is in bin.

What am I doing wrong?

Also, I haven't been able to cd. I've tried os.chdir(), but it says
'os' is not defined. In the Python docs it says that's supposed to
work on Windows machines, so is that not the right function for what
I'm trying to do?

-- 
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: Request for new user account via email Django

2011-08-05 Thread Sheogora
There was a different problem actually,
RequestContext(request) was never called

I removed that line and put it in the above return.
Worked fine :)
thank you for the effort tho

On Aug 4, 5:58 pm, Shawn Milochik  wrote:
> In your view you should be instantiating the form with the data from
> request.POST instead of reading the values directly.
>
> Also, you mention that you get a 403 error when you post your name and
> password, but the form and template you pasted don't include password,
> so I suspect the error is coming from elsewhere.

-- 
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: Request for new user account via email Django

2011-08-04 Thread Shawn Milochik
In your view you should be instantiating the form with the data from 
request.POST instead of reading the values directly.


Also, you mention that you get a 403 error when you post your name and 
password, but the form and template you pasted don't include password, 
so I suspect the error is coming from elsewhere.



--
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.



Request for new user account via email Django

2011-08-04 Thread Sheogora
I am trying to make a little function for a user to request an account
and the information he puts in is sent to a person who will make an
account.
I was following this example mostly http://djangosnippets.org/snippets/261/
but it is very old and might be inaccurate for I have got and thus I
have problems with it.

I have this code currently:


###account/models.py

from django import forms
from django.core.mail import send_mail, BadHeaderError

# A simple contact form with four fields.
class NewAccountForm(forms.Form):
first_name = forms.CharField()
last_name = forms.CharField()
email = forms.EmailField()

###account/views.py

from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from account.models import NewAccountForm
from django import forms
from django.core.mail import send_mail, BadHeaderError

def request_account_view(request):
first_name = request.POST.get('first_name', '')
last_name = request.POST.get('last_name', '')
email = request.POST.get('email', '')
message = (first_name + ' ' + last_name + '  has requested a new
account for the email ' + email)
if first_name and last_name and email:
try:
send_mail('Request for Account', 
message, email,
['exam...@example.com'])
except BadHeaderError:
return HttpResponse('Invalid header 
found.')
return HttpResponseRedirect('/thankyou/')
else:
return render_to_response('new_account.html', {'form':
NewAccountForm()})

return render_to_response('new_account.html', {'form':
NewAccountForm()},
RequestContext(request))

def thankyou(request):
return render_to_response('thankyou.html')

###urls.py

(r'^thankyou/$', 'account.views.thankyou'),
(r'^new_account/$', 'account.views.request_account_view'),

###templates/new_account.html

{% extends "base.html" %}
{% block content %}

{% csrf_token %}
First Name:

Last Name:

Email:



{% endblock %}

I am getting an error for:

Forbidden (403)
CSRF verification failed. Request aborted.

which occurs after I input name and password and click submit.
My email host is working fine because I previously was working on a
"Forgot Password"
function.
I would really appreciate help. Thank you.

-- 
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: Extending new User form

2011-08-02 Thread Sheogora
On Jul 28, 4:27 pm, Derek <gamesb...@gmail.com> wrote:
> On Jul 28, 10:31 am,Shegoroa<trudicavan...@hotmail.com> wrote:
>
> > I am having difficulty figuring out how to make an admin when creating
> > a new user to have an extra field specifying users location.
>
> > I found lots of information on how to extend the user profile and i
> > did so
> > (source of 
> > information)http://stackoverflow.com/questions/44109/extending-the-user-model-wit...
>
> > But now I want the admin every time when he is creating a new user for
> > there to be a new field under Personal Information of a user to have
> > an extra field for Location of user.
>
> That is an old post (2008) - you're better off starting with the
> current 
> documentation:https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional...
>
> Try and follow this and ask back here if you get stuck; showing what
> code you have created and identifying where/how it does not work (also
> see:https://code.djangoproject.com/wiki/UsingTheMailingList)



sorry for the delay in replying
I have added an extra field for the User by doing the whole process
where making User Profile app and extending the User module.

It doesn't seem to error. What I cant figure out, or find anywhere is
how to show this new field in the page where an admin creates a new
user. So under personal information such as First name and last Name I
want there to be Location field that I added to User Profile.

my User Profile:

from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save

class UserProfile(models.Model):
# This field is required.
user = models.OneToOneField(User)

# Other fields here
location = models.CharField(max_length=20)

# definition of UserProfile from above
# ...

def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)

post_save.connect(create_user_profile, sender=User)
also I would like to know how to make the email mandatory, like
password and username. Just changing the user model in the Django
folder to:

 email = models.EmailField(_('e-mail address'), unique=True)
didn't work at all.

-- 
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: Extending new User form

2011-07-28 Thread Derek
On Jul 28, 10:31 am, Shegoroa <trudicavan...@hotmail.com> wrote:
> I am having difficulty figuring out how to make an admin when creating
> a new user to have an extra field specifying users location.
>
> I found lots of information on how to extend the user profile and i
> did so
> (source of 
> information)http://stackoverflow.com/questions/44109/extending-the-user-model-wit...
>
> But now I want the admin every time when he is creating a new user for
> there to be a new field under Personal Information of a user to have
> an extra field for Location of user.

That is an old post (2008) - you're better off starting with the
current documentation:
https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Try and follow this and ask back here if you get stuck; showing what
code you have created and identifying where/how it does not work (also
see: https://code.djangoproject.com/wiki/UsingTheMailingList )

-- 
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.



Extending new User form

2011-07-28 Thread Shegoroa
I am having difficulty figuring out how to make an admin when creating
a new user to have an extra field specifying users location.

I found lots of information on how to extend the user profile and i
did so
(source of information)
http://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django

But now I want the admin every time when he is creating a new user for
there to be a new field under Personal Information of a user to have
an extra field for Location of user.
Any help?

-- 
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: new user having trouble connecting django to postgres with psycopg2

2011-01-08 Thread Jeff Tchang
Can you try logging into the database and running:

SELECT * FROM pg_timezone_names;

Maybe try picking something from that list?

-Jeff

On Sat, Jan 8, 2011 at 8:19 PM, Mark Brazil  wrote:
> Same error
>
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
>     execute_manager(settings)
>   File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py",
> line 438, in execute_manager
>     utility.execute()
>   File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py",
> line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
> 191, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
> 220, in execute
>     output = self.handle(*args, **options)
>   File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
> 351, in handle
>     return self.handle_noargs(**options)
>   File
> "/usr/lib/pymodules/python2.6/django/core/management/commands/syncdb.py",
> line 52, in handle_noargs
>     cursor = connection.cursor()
>   File "/usr/lib/pymodules/python2.6/django/db/backends/__init__.py", line
> 75, in cursor
>     cursor = self._cursor()
>   File
> "/usr/lib/pymodules/python2.6/django/db/backends/postgresql_psycopg2/base.py",
> line 144, in _cursor
>     cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
> psycopg2.DataError: unrecognized time zone name: "Australia/NSW"
>
> or if its set to Sydney
> :
> :
> :
> psycopg2.DataError: unrecognized time zone name: "Australia/Sydney"
>
>
>
>
> On 07/01/11 17:43, Subhranath Chunder wrote:
>
> I guess you'll have to set it to 'Australia/ACT Australia/Canberra
> Australia/NSW Australia/Sydney' in your settings.py instead.
> Thanks,
> Subhranath Chunder.
>
> On Fri, Jan 7, 2011 at 6:22 AM, Mark Brazil  wrote:
>>
>> hi,
>>
>> I've been trying to find the answer to this for a bit, but haven't
>> found anything suitable.
>>
>> I have postgresql 9.01, django 1.2.3 psycopg2 on ubuntu10.10
>>
>> When I try to use syncdb i get an error as follows
>>
>> "psycopg2.DataError: unrecognized time zone name"
>>
>> I currently have my settings.py set to "Australia/Sydney".
>>
>> I logged into postgres and set the TZ variable to AEST and started the
>> database.
>>
>> But still get this.
>>
>> I'm guessing it is something simple, but cannot find the answer.
>>
>> Any ideas would be great,
>> Thanks,
>> Mark.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: new user having trouble connecting django to postgres with psycopg2

2011-01-08 Thread Mark Brazil

Same error

Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File 
"/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 
438, in execute_manager

utility.execute()
  File 
"/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 
379, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", 
line 191, in run_from_argv

self.execute(*args, **options.__dict__)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", 
line 220, in execute

output = self.handle(*args, **options)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", 
line 351, in handle

return self.handle_noargs(**options)
  File 
"/usr/lib/pymodules/python2.6/django/core/management/commands/syncdb.py", line 
52, in handle_noargs

cursor = connection.cursor()
  File "/usr/lib/pymodules/python2.6/django/db/backends/__init__.py", 
line 75, in cursor

cursor = self._cursor()
  File 
"/usr/lib/pymodules/python2.6/django/db/backends/postgresql_psycopg2/base.py", 
line 144, in _cursor

cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
psycopg2.DataError: unrecognized time zone name: "Australia/NSW"

or if its set to Sydney
:
:
:
psycopg2.DataError: unrecognized time zone name: "Australia/Sydney"




On 07/01/11 17:43, Subhranath Chunder wrote:
I guess you'll have to set it to 'Australia/ACT Australia/Canberra 
Australia/NSW Australia/Sydney' in your settings.py instead.


Thanks,
Subhranath Chunder.


On Fri, Jan 7, 2011 at 6:22 AM, Mark Brazil > wrote:


hi,

I've been trying to find the answer to this for a bit, but haven't
found anything suitable.

I have postgresql 9.01, django 1.2.3 psycopg2 on ubuntu10.10

When I try to use syncdb i get an error as follows

"psycopg2.DataError: unrecognized time zone name"

I currently have my settings.py set to "Australia/Sydney".

I logged into postgres and set the TZ variable to AEST and started the
database.

But still get this.

I'm guessing it is something simple, but cannot find the answer.

Any ideas would be great,
Thanks,
Mark.

--
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.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.

To post to this group, send email to django-us...@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.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: new user having trouble connecting django to postgres with psycopg2

2011-01-06 Thread Subhranath Chunder
I guess you'll have to set it to 'Australia/ACT Australia/Canberra
Australia/NSW Australia/Sydney' in your settings.py instead.

Thanks,
Subhranath Chunder.


On Fri, Jan 7, 2011 at 6:22 AM, Mark Brazil  wrote:

> hi,
>
> I've been trying to find the answer to this for a bit, but haven't
> found anything suitable.
>
> I have postgresql 9.01, django 1.2.3 psycopg2 on ubuntu10.10
>
> When I try to use syncdb i get an error as follows
>
> "psycopg2.DataError: unrecognized time zone name"
>
> I currently have my settings.py set to "Australia/Sydney".
>
> I logged into postgres and set the TZ variable to AEST and started the
> database.
>
> But still get this.
>
> I'm guessing it is something simple, but cannot find the answer.
>
> Any ideas would be great,
> Thanks,
> Mark.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



new user having trouble connecting django to postgres with psycopg2

2011-01-06 Thread Mark Brazil
hi,

I've been trying to find the answer to this for a bit, but haven't
found anything suitable.

I have postgresql 9.01, django 1.2.3 psycopg2 on ubuntu10.10

When I try to use syncdb i get an error as follows

"psycopg2.DataError: unrecognized time zone name"

I currently have my settings.py set to "Australia/Sydney".

I logged into postgres and set the TZ variable to AEST and started the
database.

But still get this.

I'm guessing it is something simple, but cannot find the answer.

Any ideas would be great,
Thanks,
Mark.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



manager not getting used by User subclass when new User subclass is created in admin interface

2010-07-09 Thread Jacob Fenwick
I want to change the behavior of what happens when you add User
objects in the admin.

I subclassed the User object and added a custom manager that changes
the behavior of create_user.

Then I created a ModelAdmin corresponding to this subclassed User and
registered them together with the admin.

The trouble is, when I create a user, nothing different happens.

The message "In MyUserManager" should be printed out, but it's not.

I've posted the code below.

Does anyone see any mistakes? Or is there any hooks I'm missing or
holes in my logic?


Thanks,

Jacob


=models.py
from django.contrib.auth.models import User
from django.contrib.auth.models import UserManager
from django.utils.translation import ugettext_lazy as _

class MyUserManager(UserManager):
def create_user(self, username, email, password=None):
"""
Creates and saves a User with the given username, e-mail and password.
"""
print "In MyUserManager"
now = datetime.datetime.now()

# Normalize the address by lowercasing the domain part of the email
# address.
try:
email_name, domain_part = email.strip().split('@', 1)
except ValueError:
pass
else:
email = '@'.join([email_name, domain_part.lower()])

user = self.model(username=username, email=email, is_staff=True,
 is_active=True, is_superuser=False, last_login=now,
 date_joined=now)

if password:
user.set_password(password)
else:
user.set_unusable_password()
user.save(using=self._db)
return user

class MyUser(User):
objects = MyUserManager()


=admin.py
from django.utils.translation import ugettext_lazy as _
from myapp.models import MyUser

class MyUserAdmin(MyUserAdmin):
pass

admin.site.register(MyUser, MyUserAdmin)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New User Stuck on Tutorial Part 2

2010-05-11 Thread Old Davy

Thanks, Mike...  I've got some studying to do!  :)

On 05/10/2010 11:47 PM, Mike Dewhirst wrote:

On 11/05/2010 4:04pm, Mike Dewhirst wrote:

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn

That would make the most sense, and that would be my working 
assumption.

But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my 
settings.py

file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html" 





You want a directory rather than a file (base_site.html) for 
TEMPLATE_DIRS


This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT,
'templates').replace('\\','/'),)

This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want
templates. For example, in one of them I have ...

../templates/admin/base_site.html

Which contains ...

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

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{%
endblock %}

{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the
"base.html" which it extends is actually in ../templates

If I wanted Mysite base_site.html to extend the real Django base.html I
would have to put ... {% extends "admin/base.html" %}


Just realised I could have confused you a little.

So

You can extend anything you want to specifically nominate but if you 
just nominate a bare filename the way I do with base.html in ...


   mysite/templates/admin/base_site.html

... base.html has to exist in TEMPLATE_DIRS (mysite/templates)

If you want to extend "admin/base.html" from the above base_site.html 
then Django looks first in ...


   TEMPLATES_DIR/admin

... and if it doesn't find it then it looks in 
site-packages/django/contrib/admin/templates/admin


Mike



HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it 
was in

my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what 
happens...









--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: New User Stuck on Tutorial Part 2

2010-05-11 Thread Mike Dewhirst

On 11/05/2010 4:04pm, Mike Dewhirst wrote:

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn


That would make the most sense, and that would be my working assumption.
But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my settings.py
file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html"



You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS

This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT,
'templates').replace('\\','/'),)

This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want
templates. For example, in one of them I have ...

../templates/admin/base_site.html

Which contains ...

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

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{%
endblock %}

{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the
"base.html" which it extends is actually in ../templates

If I wanted Mysite base_site.html to extend the real Django base.html I
would have to put ... {% extends "admin/base.html" %}


Just realised I could have confused you a little.

So

You can extend anything you want to specifically nominate but if you 
just nominate a bare filename the way I do with base.html in ...


   mysite/templates/admin/base_site.html

... base.html has to exist in TEMPLATE_DIRS (mysite/templates)

If you want to extend "admin/base.html" from the above base_site.html 
then Django looks first in ...


   TEMPLATES_DIR/admin

... and if it doesn't find it then it looks in 
site-packages/django/contrib/admin/templates/admin


Mike



HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it was in
my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what happens...






--

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9787 6598
M: 0411 704 143

Mike Dewhirst
Certified Scrum Master


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: New User Stuck on Tutorial Part 2

2010-05-11 Thread Mike Dewhirst

On 11/05/2010 4:18pm, Old Davy wrote:

Thank you, Mike.  That DID work!

So, if I have a directory that contains the /admin/base_site.html, all I
have to do is specify the containing directory.

I'll need to study the actual string you used a little more closely once
I get more familiar with the concepts. I can see how that would give you
some added flexibility, but I'm not quite grokking the details yet.


OK - here is more room for confusion ...

In my settings.py ...

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)).replace('\\','/')

This is Python for getting the current directory path to the file in 
which the above code appears. Since it is in settings.py it returns my 
PROJECT_ROOT. The replace() just makes it cross-platform because I work 
in both Windows and Linux.


What follows is also in settings.py and is what makes what I said in my 
previous email true. Notice the comment? If filesystem loader appeared 
*after* the app_directories loader my previous email would have taken 
you right to the fairies at the end of the garden path.


TEMPLATE_LOADERS = (
# filesystem ahead of app_directories looks in project before django
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.eggs.load_template_source',

Mike



Still, at least I can continue the tutorial without that "mired in the
mud" feeling. Thank you very much!!!



On 05/10/2010 11:04 PM, Mike Dewhirst wrote:

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn


That would make the most sense, and that would be my working assumption.
But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my settings.py
file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html"



You want a directory rather than a file (base_site.html) for
TEMPLATE_DIRS

This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT,
'templates').replace('\\','/'),)

This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want
templates. For example, in one of them I have ...

../templates/admin/base_site.html

Which contains ...

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

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{%
endblock %}

{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the
"base.html" which it extends is actually in ../templates

If I wanted Mysite base_site.html to extend the real Django base.html
I would have to put ... {% extends "admin/base.html" %}

HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it was in
my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what happens...







--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: New User Stuck on Tutorial Part 2

2010-05-11 Thread Old Davy

Thank you, Mike.  That DID work!

So, if I have a directory that contains the /admin/base_site.html, all I 
have to do is specify the containing directory.


I'll need to study the actual string you used a little more closely once 
I get more familiar with the concepts.  I can see how that would give 
you some added flexibility, but I'm not quite grokking the details yet.


Still, at least I can continue the tutorial without that "mired in the 
mud" feeling.  Thank you very much!!!




On 05/10/2010 11:04 PM, Mike Dewhirst wrote:

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn


That would make the most sense, and that would be my working assumption.
But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my settings.py
file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html" 



You want a directory rather than a file (base_site.html) for 
TEMPLATE_DIRS


This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 
'templates').replace('\\','/'),)


This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want 
templates. For example, in one of them I have ...


../templates/admin/base_site.html

Which contains ...

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

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% 
endblock %}


{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the 
"base.html" which it extends is actually in ../templates


If I wanted Mysite base_site.html to extend the real Django base.html 
I would have to put ... {% extends "admin/base.html" %}


HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it was in
my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what happens...





--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: New User Stuck on Tutorial Part 2

2010-05-11 Thread Mike Dewhirst

On 11/05/2010 3:42pm, Old Davy wrote:

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely
not in the right place.

Ensure that you have a template dir that your settings knows about,
and that template dir has a subdirectory called 'admin' where that
file is placed.

Shawn


That would make the most sense, and that would be my working assumption.
But I can't for the life of me see where the disconnect is.

this is the string that's in the TEMPLATE_DIRS section of my settings.py
file:

"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html"


You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS

This is mine ...

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),)

This puts my templates directory in the same dir as my settings.py file.

Inside it I have a sub-dir for each application for which I want 
templates. For example, in one of them I have ...


../templates/admin/base_site.html

Which contains ...

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

{% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% endblock %}

{% block branding %}
{% trans 'Mysite administration' %}
{% endblock %}

... and which turns Django Admin into Mysite admin. However, the 
"base.html" which it extends is actually in ../templates


If I wanted Mysite base_site.html to extend the real Django base.html I 
would have to put ... {% extends "admin/base.html" %}


HTH

Mike





That's exactly the path that my directories show, including my
idiosyncratic upper case letters.

I did find the file that my poll app is referencing. Turns out it was in
my '/usr/local/lib/python2.6... path instead of my home directory. So
when I modified THAT file, it used my changes. However, that still
doesn't help, as it's not using the file that I copied to my local
directory.

I suppose I can play with a few more directories and see what happens...



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: New User Stuck on Tutorial Part 2

2010-05-10 Thread Old Davy

On 05/10/2010 08:18 PM, Shawn Milochik wrote:

Exactly what directory is your copied template in? It's most likely not in the 
right place.

Ensure that you have a template dir that your settings knows about, and that 
template dir has a subdirectory called 'admin' where that file is placed.

Shawn

   
That would make the most sense, and that would be my working 
assumption.  But I can't for the life of me see where the disconnect is.


this is the string that's in the TEMPLATE_DIRS section of my settings.py 
file:


"/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html"

That's exactly the path that my directories show, including my 
idiosyncratic upper case letters.


I did find the file that my poll app is referencing.  Turns out it was 
in my  '/usr/local/lib/python2.6... path instead of my home directory.  
So when I modified THAT file, it used my changes.  However, that still 
doesn't help, as it's not using the file that I copied to my local 
directory.


I suppose I can play with a few more directories and see what happens...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: New User Stuck on Tutorial Part 2

2010-05-10 Thread Shawn Milochik
Exactly what directory is your copied template in? It's most likely not in the 
right place.

Ensure that you have a template dir that your settings knows about, and that 
template dir has a subdirectory called 'admin' where that file is placed.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



New User Stuck on Tutorial Part 2

2010-05-10 Thread llanitedave
Using Ubuntu 10.04...

I'm just starting out on django and going through the tutorials.
Everything installed, got the polls working in parts 1 and 2 of the
tutorial, and I think I'm sailing.  Then I get to the bottom of Part
2, to the section "Customize the admin look and feel".

In settings.py I followed the instructions:

"Now copy the template admin/base_site.html  from within the default
Django admin template directory (django/contrib/admin/templates) into
an admin subdirectory of whichever directory you're using in
TEMPLATE_DIRS. For example, if your TEMPLATE_DIRS  includes "/home/
my_username/mytemplates", as above, then copy django/contrib/admin/
templates/admin/base_site.html  to /home/my_username/mytemplates/admin/
base_site.html. Don't forget that admin subdirectory.

Then, just edit the file and replace the generic Django text with your
own site's name as you see fit."

I changed the title in my local admin folder to this:

{% block title %}{{ title }} | {% trans "Dave's Tutorials" %}{%
endblock %}

{% block branding %}
{% trans "Dave's Tutorials" %}
{% endblock %}

Nothing happened.  My page still reads "Django Administration.

I stopped the server, ran syncdb, and restarted the server.  No
change.

Thinking that somehow TEMPLATE_DIRS wasn't registering the new
location, I went back to the default director, which is in the /home/
local/share... directory, renamed the original and edited a new
base_site.html as I had done in my tutorial directory.

As before, ran syncdb and restarted the server.

Still no change.  So now I'm stuck.  Why is settings.py ignoring both
the local and the default files?  Or is the default file someplace
that I haven't found yet?

Thanks for any advice you can give!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



  1   2   >