Re: [PROBLEM] Creacion de primera apps de djangogirls, error en models.py

2020-04-19 Thread lucas bonet
Si, seguí toda la instalación de djangogirls que la instala con Pip

El El dom, 19 abr. 2020 a la(s) 22:22, Gavin Wiener 
escribió:

> ¿Has instalado Django con pip?
>
> On Saturday, April 18, 2020 at 5:35:22 AM UTC+8, lucas bonet wrote:
>>
>> Hola, estoy creando la primera aplicacion de django con pyton y cuando
>> llega el momento de configurar en el directorio de blog--> model.py copio
>> las lineas de comando del tutrorial y me reporta errores. los erorres me
>> los marca en From, como que no tiene una carpeta otra de acceso llamada
>> django.conf y asi con los otros dos archivos. A donde tendria que cambiar
>> esa configuracion para poder continuar?
>>  Muchas gracias y espero poder sumarme a la comunidad para ir creciendo.
>> Saludos!
>> from django.conf import settings
>> from django.db import models
>> from django.utils import timezone
>>
>>
>> --
> 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/af187256-78fb-46c2-9e22-4a71c1fcb30c%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/CAOEMdptz_ETsn7RoCugFe0cxtQzcoEOG_QDFsC%2BduMdkT_32Mg%40mail.gmail.com.


Re: [PROBLEM] Creacion de primera apps de djangogirls, error en models.py

2020-04-19 Thread Gavin Wiener
¿Has instalado Django con pip?

On Saturday, April 18, 2020 at 5:35:22 AM UTC+8, lucas bonet wrote:
>
> Hola, estoy creando la primera aplicacion de django con pyton y cuando 
> llega el momento de configurar en el directorio de blog--> model.py copio 
> las lineas de comando del tutrorial y me reporta errores. los erorres me 
> los marca en From, como que no tiene una carpeta otra de acceso llamada 
> django.conf y asi con los otros dos archivos. A donde tendria que cambiar 
> esa configuracion para poder continuar?
>  Muchas gracias y espero poder sumarme a la comunidad para ir creciendo. 
> Saludos!
> from django.conf import settings
> from django.db import models
> from django.utils import timezone
>
>
>

-- 
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/af187256-78fb-46c2-9e22-4a71c1fcb30c%40googlegroups.com.


I have a problem concerning duplicate adminfields

2020-04-19 Thread Franklin Tazuh
Hey guys, am getting this error in my django ecommerce website using cartridge ,
ERRORS:
: (admin.E012) There are duplicate field(s) 
in 'fieldsets[0][1]'.

System check identified 1 issue (0 silenced).
This is my admin.py file

from django.contrib import admin
from mezzanine.pages.admin import PageAdmin
from mezzanine.galleries.models import Gallery
from mezzanine.galleries.admin import GalleryAdmin
from mezzanine.forms.models import Form
from mezzanine.forms.admin import FormAdmin
from mezzanine.core.admin import StackedDynamicInlineAdmin
from mezzanine.core.admin import TabularDynamicInlineAdmin
from mezzanine.utils.admin import SingletonAdmin
from mezzanine.blog.admin import BlogPostAdmin
from cartridge.shop.admin import ProductAdmin
from .models import IconBlurb,Homepage, FaqPage, FaqEntry, SiteConfiguration


class IconBlurbAdmin(StackedDynamicInlineAdmin):
"""Admin class for IconBlurb model."""

model = IconBlurb


class HomePageAdmin(PageAdmin):
"""Admin class for Homepage model.

Inline IconBlurbAdmin for adding/removing
arbitrary number of Icon Blurbs
"""

inlines = [IconBlurbAdmin, ]


class FaqEntryAdmin(TabularDynamicInlineAdmin):
"""Admin class for FaqEntry model."""

model = FaqEntry


class FaqPageAdmin(PageAdmin):
"""Admin class for FaqPage model.

Inlines FaqEntryAdmin for adding/removing
arbitrary number of FAQ entries.
"""

inlines = [FaqEntryAdmin, ]


class NoCSSGalleryAdmin(GalleryAdmin):
"""Remove css from GalleryAdmin."""

class Media:
extend = False


class CustomFormAdmin(FormAdmin):
"""Add IconBlurbs to FormAdmin.

Used in Contact page for displaying
address, email, etc blocks in contact page.
"""

def init(self, *args, kwargs):
"""Extend parent class inlines tuple."""
super(CustomFormAdmin, self).init(*args, kwargs)
self.inlines += (IconBlurbAdmin, )

# Add custom fields to product admin and blogpost admin. Both fields
# are  defined in EXTRA_MODEL_FIELDS setting in settings.py file
ProductAdmin.fieldsets[0][1]["fields"].extend(["image_back"])
BlogPostAdmin.fieldsets[0][1]["fields"].insert(-2, "lead")

admin.site.register(SiteConfiguration, SingletonAdmin)
admin.site.register(Homepage, HomePageAdmin)
admin.site.register(FaqPage, FaqPageAdmin)
admin.site.unregister(Gallery)
admin.site.register(Gallery, NoCSSGalleryAdmin)
admin.site.unregister(Form)
admin.site.register(Form, CustomFormAdmin)

-- 
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/807374f7-32ca-4bd7-ac27-34dce6fe3733%40googlegroups.com.


Re: CSRF token still needed today?

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

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

> iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
> ... and then I look at this page: https://scotthelme.co.uk/csrf-is-dead/
>
> Is a CSRF token still needed today?
>
> All my users use a modern browser.
>
> It would be very nice if I could get rid of the CSRF token.
>
> Is there a safe way to avoid CSRF tokens in  my Django project?
>
> Regards,
>   Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/487c7392-e874-4a1e-a1ff-488ab933ae42%40googlegroups.com
> 
> .
>

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


Re: [PROBLEM] Creacion de primera apps de djangogirls, error en models.py

2020-04-19 Thread lucas bonet
Hola Juan, gracias por tu respuesta, te adjunto la imagen de VS para que
veas el error.

El vie., 17 abr. 2020 a las 19:59, Juan Pablo Romero Bernal (<
jromerober...@gmail.com>) escribió:

> Saludos Lucas,
>
> Sería de mucha utilidad que nos mostraras los mensajes de error que
> obtienes para
> poder ayudarte.
>
> Saludos,
>
> On Fri, Apr 17, 2020 at 4:34 PM lucas bonet 
> wrote:
>
>> Hola, estoy creando la primera aplicacion de django con pyton y cuando
>> llega el momento de configurar en el directorio de blog--> model.py copio
>> las lineas de comando del tutrorial y me reporta errores. los erorres me
>> los marca en From, como que no tiene una carpeta otra de acceso llamada
>> django.conf y asi con los otros dos archivos. A donde tendria que cambiar
>> esa configuracion para poder continuar?
>>  Muchas gracias y espero poder sumarme a la comunidad para ir creciendo.
>> Saludos!
>> from django.conf import settings
>> from django.db import models
>> from django.utils import timezone
>>
>>
>> --
>> 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/24d95b2d-d336-440c-b816-57820afa57f0%40googlegroups.com
>> 
>> .
>>
>
>
> --
> Juan
>
> --
> 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/CAJK1Jg1OtZ-AO-SwxL-hLn1pd9V%3D3VqqPp2WPUyLEkso%2BXTn-g%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/CAOEMdpuHHZ_Yj_s0R4aA-C2KShsbZG5VGt6pWxMkbsga6Hpq%3Dg%40mail.gmail.com.


Re: CSRF token still needed today?

2020-04-19 Thread Jorge Gimeno
On Sun, Apr 19, 2020 at 1:12 PM guettli 
wrote:

> iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
> ... and then I look at this page: https://scotthelme.co.uk/csrf-is-dead/
>
> Is a CSRF token still needed today?
>
> All my users use a modern browser.
>
> It would be very nice if I could get rid of the CSRF token.
>
> Is there a safe way to avoid CSRF tokens in  my Django project?
>
> Regards,
>   Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/487c7392-e874-4a1e-a1ff-488ab933ae42%40googlegroups.com
> 
> .
>

For my projects, I am going to keep CSRF tokens. The time taken to put one
in a template is minimal, and I don't run the risk of turning off CSRF
somewhere and having that be the reason for an incident.

-Jorge

-- 
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%3DK_PepV5HtWE34W-7CR-cQiPTsyv%2BTM5JNA7b7iocH0Uow%40mail.gmail.com.


CSRF token still needed today?

2020-04-19 Thread guettli
iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
... and then I look at this page: https://scotthelme.co.uk/csrf-is-dead/

Is a CSRF token still needed today?

All my users use a modern browser.

It would be very nice if I could get rid of the CSRF token.

Is there a safe way to avoid CSRF tokens in  my Django project?

Regards,
  Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/487c7392-e874-4a1e-a1ff-488ab933ae42%40googlegroups.com.


Re: [django-channels] How to close websocket connection from server?

2020-04-19 Thread krnrrr
another thing I managed to think of is send specific message to a specific 
room of a user, like:

async_to_sync(channel_layer.group_send)("238", {"type": "send_text", 
"text": "close"})

and check in consumer's handler:

async def send_text(self, event):
if event == "close":
await self.send(text_data="closed", close=True)

or 

async_to_sync(channel_layer.group_discard)("room__36", 
"specific.aEuecdIR!DTiuBsxYfldN")

when we want to drop him from one specific room and it requires to keep his 
channel name in some persistent storage.

-- 
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/6cc40327-8a4e-4877-ac99-97917deefcd2%40googlegroups.com.


Re: Production deployments and Version Control for DJango projects

2020-04-19 Thread JEGATHEESWARAN SUNDARAVADIVEL
Hi ,
Try Jenkins also for Continuous Integration (CI)

Regards
Jegatheeswaran sundaravadivel

On Sun, 19 Apr 2020 at 22:23, Ram  wrote:

> Thank you, all. We started with GIT hub and planning to add
> ansible-playbook later in our development phase.
>
> Best regards
> ~Ram
>
> On Sat, Feb 15, 2020 at 2:55 AM Kasper Laudrup 
> wrote:
>
>> Hi Aldian,
>>
>> On 15/02/2020 05.57, Aldian Fazrihady wrote:
>> > Try ansible-playbook
>> >
>>
>> That's exactly what Ansible was designed for, so I agree that this would
>> be the obvious route to go.
>>
>> No reason not to use git for source control and then Ansible to automate
>> the deployment.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> --
>> 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/3bb1d4ef-5c6e-4c78-756c-908e4f17d073%40stacktrace.dk
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BOi5F03sNF-Xxk8XCf5tG0%2BBaAwiqQ6jX1_A0ryWqyKtq%3Ddyw%40mail.gmail.com
> 
> .
>
-- 
JAGATHEESWARAN

-- 
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/CAHM%2BSVqxunT3gu78E2ay6U4phK3g7OEz_BbEPsT4s%2BVi8PXV1Q%40mail.gmail.com.


Re: Migrated code is not working in Django

2020-04-19 Thread Ram
Thank you, all. Once we started using GIT process for our first code base
deployment, we did not see any issue with deployment.

Best regards,
~Ram

On Sat, Feb 8, 2020 at 12:22 PM Integr@te System 
wrote:

> Hi Ram,
>
> plz show error code.
>
> On Sun, Feb 9, 2020, 01:03 Ram  wrote:
>
>> Hi,
>>
>> I just noticed that the migrations table in Postgres is not updated
>> though we reset all the previous migrations. Do I need to run any step in
>> the database side whenever integrate new code drop? Unfortunately, we are
>> not using the GIT method yet to bring over the new code.
>>
>> Best regards,
>> ~Ram
>>
>> On Sat, Feb 8, 2020 at 10:22 AM Ram  wrote:
>>
>>> Hello DC,
>>>
>>> Thank you for your email. We have added code for user's registration
>>> where users use
>>>
>>> 1. sign up form and submit the form
>>> 2. upon submission users get a message about the next steps for
>>> activating their registration
>>>
>>> Issue # 1 The issue here is users are not getting any activation email
>>> Issue # 2 confirmation message is also incorrect. " *Your Registration
>>> is successful! Please contact Admin for Emails validation Link* " I
>>> searched for this message in all files and did not find it.
>>>
>>> Here are the code snippets
>>>
>>> # signup page
 #
 def signup_view(request):
if request.method == 'POST':
form = CustomerForm(request.POST)
if form.is_valid():
cust_item = form.cleaned_data
print(cust_item)
saveform = rim_customer(email=cust_item['email'],
reemail=cust_item['reemail'],
password=cust_item['password'],
repassword=cust_item['repassword'],
 firstname=cust_item['firstname'],
state=cust_item['state'],
Zip=cust_item['Zip'],
cust_status='0',
mailing=cust_item['mailing'],
referred_by=cust_item['referred_by'])
saveform.save()

# Added the code for sending mail when a customer registered
 here EmailMessage is used from Django
activate = ">>> + "> Click Here"
sendMailStaus =  EmailMessage('Registration Confirmation',
  "Thank you for
 registering with us!. You Activation is pending. Please " + activate +
 "",
  settings.EMAIL_HOST_USER,
  [cust_item['email']])
sendMailStaus.content_subtype="html"
sendMailStaus.send()

form = CustomerForm()
return render(request, 'signup.html',{'form':form,
 'success': 'mail succesfully send'})
else:
messages.error(request, form)
# return render(request,"form.html", {'error':error})
else:
form = CustomerForm()
return render(request, "signup.html", {'form': form})

>>>
>>>
>>>  # SiginUp_With_Transaction
 def Popup_signup_view(request):
 if request.method == 'POST':
 form = CustomerForm(request.POST)
 if form.is_valid():
 cust_item = form.cleaned_data
 saveform = rim_customer(email=cust_item['email'],
 reemail=cust_item['reemail'],
 password=cust_item['password'],
 repassword=cust_item['repassword'],

 firstname=cust_item['firstname'], state=cust_item['state'],
 Zip=cust_item['Zip'],
 mailing=cust_item['mailing'], cust_status='0',

 referred_by=cust_item['referred_by'])
 saveform.save()
 email = cust_item['email']
 # noinspection PyUnresolvedReferences
 sentMailStatus = sendEmail(email, request, saveform.id)
 form = CustomerForm()
 productid = request.POST['id']
 result = transation_Cast(productid, email)

 if sentMailStatus == True:
 return HttpResponseRedirect(result)
 else:
 return HttpResponseRedirect(result)
 else:
 messages.error(request, form)
 # return render(request,"form.html",{'error':error})
 else:
 form = CustomerForm()
 return render(request, "signup.html", {'form': form})

>>>
>>> Mail server settings in settings.py
>>>
>>> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'  # added
 by me
 EMAIL_HOST = 'smtp.gmail.com

Re: Production deployments and Version Control for DJango projects

2020-04-19 Thread Ram
Thank you, all. We started with GIT hub and planning to add
ansible-playbook later in our development phase.

Best regards
~Ram

On Sat, Feb 15, 2020 at 2:55 AM Kasper Laudrup 
wrote:

> Hi Aldian,
>
> On 15/02/2020 05.57, Aldian Fazrihady wrote:
> > Try ansible-playbook
> >
>
> That's exactly what Ansible was designed for, so I agree that this would
> be the obvious route to go.
>
> No reason not to use git for source control and then Ansible to automate
> the deployment.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> 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/3bb1d4ef-5c6e-4c78-756c-908e4f17d073%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BOi5F03sNF-Xxk8XCf5tG0%2BBaAwiqQ6jX1_A0ryWqyKtq%3Ddyw%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 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
> 
> .
>

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


General Question Regarding Django Password Validation differences

2020-04-19 Thread Ahmed Khairy
I have used UserCreationForm and got this result below with no validations 
regarding the password while there are other Usercreationforms with 
password validations.

I am using Django 2.2 

 


-- 
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/2822d82b-7854-46f6-88b9-89ab37325816%40googlegroups.com.


Re: [django-channels] How to close websocket connection from server?

2020-04-19 Thread krnrrr
i gave it another shot and still don't get it.

when I connect the first time i have:

- browser A which serves as a source of "connect" command
- AsyncJsonWebsocketConsumer which handles group_add, accepting incoming 
socket and setting the "connection A"

when I have a call from the other browser:

- browser B which sends another "connect"
- another consumer. how does it know about "connection A" to close it? it 
handles it's own connection B

and all the time browser is the initiator of commands. I still don't 
understand what call i should make when I return a newly create JWT to 
close connection A.

i still don't get it. I saw this 

 
code and this 

 
in the sources, but how shou;d a layer know which of thousands websockets 
to close? I tried to send

async_to_sync(channel_layer.group_discard)("notifications.36", 
"specific.WrFJFDXq!rIkVZzwQtBCC")

async_to_sync(channel_layer.group_send)("notifications.36", {"type": 
"websocket_close"})

and neither of these calls succeeded - browser still receives messages sent 
from notification (the last one succeeds actually, but it closes room for 
ALL participants, not to specific one. and they promptly reconnect). And 
I'm not surprised, when the call is made from specific ws consumer, the 
channel layers knows what to close (as far as I understand). and when it's 
done simply from the shell...

-- 
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/ef0b9926-d9b4-476a-93f3-21f749ca6fc2%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 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
>> 
>> .
>>
>
> --
> 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: Tutorial "Writing your first Django App": NoReverseMatch at /polls/ - down at the end of part 3

2020-04-19 Thread Jorge Gimeno
If settings.DEBUG == False, then you have to put the allowed addresses
in settings.ALLOWED_HOSTS.  If Debug is True, then I'm not sure what's
going on.

-Jorge

On 4/18/20, Markus Grossniklaus  wrote:
> Thanks a lot Chucky!
> No error message
> displays at least one dot! fine
>
> http://127.0.0.1:8000/admin/
> shows ERR_CONNECTION_REFUSED
> even with no Proxy active and iptables shows no restrictions e.g.
> everything is allowed
> How could I debug this?
>
>
> On Wednesday, April 15, 2020 at 12:27:21 AM UTC+2, Markus Grossniklaus
> wrote:
>>
>> a) I worked the whole tutorial down to the bottom of part 3
>> b) I connect with the browser to http://127.0.0.1:8000/polls/
>> c) the result is: NoReverseMatch at /polls/
>> d) all project data are attached to this POST in mysite.zip
>> e) I think it cannot be a difficult problem -> does anybody see it?
>> Thanx for any help!
>>
>> [image: NoReverseMatch.PNG]
>>
>>
>
> --
> 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/f3ecb032-80c9-49bf-89da-e1656752fe89%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/CANfN%3DK-9g60pvGj4%2B2Ls8nhstb%3DUWY%3Di-ew7AC7SrARcq-hCuw%40mail.gmail.com.


Re: Django Project Created in Pycharm using App Engine Does not include Django boiler files

2020-04-19 Thread Jorge Gimeno
I believe you can still install Django the old fashioned way into your
virtual environment, i.e. (with your environment active, and from the
command prompt):

pip install django
django-admin startproject test_project

-Jorgge

On 4/17/20, kelvin smith  wrote:
> Guys, I Just started using google cloud and I'm trying to set up a Django
> app in Pycharm using app Engine.
> I have followed all the steps recommend by JetBrain
>
> But it worries that each time I generate a project it doesn't always
> include the Django files
>
> Here are the steps I followed to generate my app after setting up my local
> machine with GCloud
> I have also downloaded the* app-engine-python-extras*
>
> *Step1:*
>
> [image: Screen Shot 2020-04-18 at 1.08.29 AM.png]
>
> *Step: 2*
>
> [image: Screen Shot 2020-04-18 at 1.08.19 AM.png]
>
> *Step: 3*
>
> [image: Screen Shot 2020-04-18 at 1.10.07 AM.png]
>
>
> And finally, the project is missing the base files
>
> Please I cloud use your help, I've spent so much time trying to figure out
> why and I don't really know what I'm missing.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a274a470-a7ee-48df-a32a-981c1c31bc70%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/CANfN%3DK_Jq5ks8OFz4Dw9JCLM6n5L3cc8mxMLsZQzWrT5UzVa-g%40mail.gmail.com.


Re: Reg: Django signal not working

2020-04-19 Thread Jorge Gimeno
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> However, the signal that I have written seems not to be working.
>> Whenever, I am filling the form, I am getting below error:
>>
>> AttributeError at /auth/register/
>> 'User' object has no attribute 'profile'
>>
>> *Full traceback log as below:*
>>
>> Installed Applications:
>> ['django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'phone_field',
>>  'AUTHENTICATION']
>> Installed Middleware:
>> ['django.middleware.security.SecurityMiddleware',
>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>>
>>
>>
>> Traceback (most recent call last):
>>   File "C:\Python38\lib\site-packages\django\core\handlers\exception.py",
>>
>> line 34, in inner
>> response = get_response(request)
>>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
>>
>> 115, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
>>
>> 113, in _get_response
>> response = wrapped_callback(request, *callback_args,
>> **callback_kwargs)
>>   File "C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\views.py",
>>
>> line 50, in register_user
>> save1 = form.save()
>>   File "C:\Python38\lib\site-packages\django\contrib\auth\forms.py", line
>>
>> 137, in save
>> user.save()
>>   File "C:\Python38\lib\site-packages\django\contrib\auth\base_user.py",
>> line 66, in save
>> super().save(*args, **kwargs)
>>   File "C:\Python38\lib\site-packages\django\db\models\base.py", line 745,
>>
>> in save
>> self.save_base(using=using, force_insert=force_insert,
>>   File "C:\Python38\lib\site-packages\django\db\models\base.py", line 793,
>>
>> in save_base
>> post_save.send(
>>   File "C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line
>>
>> 173, in send
>> return [
>>   File "C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line
>>
>> 174, in 
>> (receiver, receiver(signal=self, sender=sender, **named))
>>   File "C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\models.py",
>>
>> line 17, in save_user_profile
>> instance.profile.save()
>>
>> Exception Type: AttributeError at /auth/register/
>> Exception Value: 'User' object has no attribute 'profile'
>>
>> I have uploaded the project in google drive with below location link, just
>>
>> in case if somebody wishes to test it.
>>
>>
>> https://drive.google.com/file/d/1COB3BBoRb95a85cLi9k1PdIYD3bmlnc0/view?usp=sharing
>>
>> My environment:
>>
>> Django==3.0.5 python 3.8.2
>>
>> Not sure what is the mistake. Please help.
>>
>> *models.py*
>>
>> from django.db import models
>> from django.contrib.auth.models import User
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>>
>> class SignUp(models.Model):
>> user = models.OneToOneField(User, on_delete=models.CASCADE)
>> Contact = models.TextField(max_length=500, blank=True)
>>
>> @receiver(post_save, sender=User)
>> def create_user_profile(sender, instance, created, **kwargs):
>> if created:
>> SignUp.objects.create(user=instance)
>>
>> @receiver(post_save, sender=User)
>> def save_user_profile(sender, instance, **kwargs):
>> *instance.profile.save()*
>>
>> *forms.py*
>>
>> from django.contrib.auth.forms import UserCreationForm
>> from django.contrib.auth.models import User
>> from django import forms
>> from  .models import SignUp
>>
>> class SignUpForm(UserCreationForm):
>> email = forms.EmailField()
>> first_name = forms.CharField(max_length=100)
>> last_name = forms.CharField(max_length=100)
>> #phone = format()
>>
>> class Meta:
>> model = User
>> fields = ('username', 'first_name', 'last_name', 'email',
>> 'password1', 'password2')
>>
>>
>> class CustomSignUpPage(forms.ModelForm):
>> Contact = forms.CharField(max_length=10)
>> class Meta:
>> model = SignUp
>> fields = ('Contact', )
>>
>> *views.py*
>>
>> from django.shortcuts import render, redirect
>> from django.contrib.auth import authenticate, login, logout
>> from django.contrib import messages
>> #from django.contrib.auth.forms import UserCreationForm
>> from .forms import Sig

Re: Need help whit DJANGO_SETTINGS_MODULE

2020-04-19 Thread Ilie Ioana
After resetting the pc it worked.
Thanks.

On Sunday, April 19, 2020 at 4:39:50 PM UTC+3, Ilie Ioana wrote:
>
> The project structure:
>
>
> (test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ tree
> .
> ├── manage.py
> └── test1
> ├── asgi.py
> ├── __init__.py
> ├── settings.py
> ├── urls.py
> └── wsgi.py
>
>
>
> :~/Workspace/Ioana/test1/test1$ python manage.py runserver
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>  
> line 401, in execute_from_command_line
> utility.execute()
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>  
> line 395, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>  
> line 328, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 60, in execute
> super().execute(*args, **options)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>  
> line 369, in execute
> output = self.handle(*args, **options)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 67, in handle
> if not settings.DEBUG and not settings.ALLOWED_HOSTS:
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>  
> line 76, in __getattr__
> self._setup(name)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>  
> line 61, in _setup
> % (desc, ENVIRONMENT_VARIABLE))
> django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but 
> settings are not configured. You must either define the environment 
> variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
> accessing settings.
>
>
>
>
> On Sunday, April 19, 2020 at 4:35:11 PM UTC+3, Ayser shuhaib wrote:
>>
>> to run the server use:
>> Python manage.py runserver
>>
>> It would be better if you send a picture of the project files structure.
>>
>> On Sun, 19 Apr 2020 at 15:22, Ilie Ioana  wrote:
>>
>>> Hi,I'm new with django and python.
>>> I just strated a new django project in a venv using django 3.0 and seems 
>>> that DJANGO_SETTINGS_MODULE is not set when running django-admin runserver
>>>
>>> Enter code here.(test1) 
 ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ django-admin 
 runserver
 Traceback (most recent call last):
   File "/home/ioana.i/Workspace/Ioana/test1/bin/django-admin", line 8, 
 in 
 sys.exit(execute_from_command_line())
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
  
 line 401, in execute_from_command_line
 utility.execute()
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
  
 line 395, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
  
 line 328, in run_from_argv
 self.execute(*args, **cmd_options)
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
  
 line 60, in execute
 super().execute(*args, **options)
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
  
 line 369, in execute
 output = self.handle(*args, **options)
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
  
 line 67, in handle
 if not settings.DEBUG and not settings.ALLOWED_HOSTS:
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
  
 line 76, in __getattr__
 self._setup(name)
   File 
 "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
  
 line 61, in _setup
 % (desc, ENVIRONMENT_VARIABLE))
 django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, 
 but settings are not configured. You must either define the environment 
 variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
 accessing settings.
 ..


  
>>> I tried to set it myself with export 
>>> DJANGO_SETTINGS_MODULE=te

Re: Need help whit DJANGO_SETTINGS_MODULE

2020-04-19 Thread Ilie Ioana
The project structure:


(test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ tree
.
├── manage.py
└── test1
├── asgi.py
├── __init__.py
├── settings.py
├── urls.py
└── wsgi.py



:~/Workspace/Ioana/test1/test1$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 21, in 
main()
  File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 401, in execute_from_command_line
utility.execute()
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
 
line 328, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 60, in execute
super().execute(*args, **options)
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
 
line 369, in execute
output = self.handle(*args, **options)
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 67, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
 
line 76, in __getattr__
self._setup(name)
  File 
"/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
 
line 61, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but 
settings are not configured. You must either define the environment 
variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
accessing settings.




On Sunday, April 19, 2020 at 4:35:11 PM UTC+3, Ayser shuhaib wrote:
>
> to run the server use:
> Python manage.py runserver
>
> It would be better if you send a picture of the project files structure.
>
> On Sun, 19 Apr 2020 at 15:22, Ilie Ioana > 
> wrote:
>
>> Hi,I'm new with django and python.
>> I just strated a new django project in a venv using django 3.0 and seems 
>> that DJANGO_SETTINGS_MODULE is not set when running django-admin runserver
>>
>> Enter code here.(test1) 
>>> ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ django-admin 
>>> runserver
>>> Traceback (most recent call last):
>>>   File "/home/ioana.i/Workspace/Ioana/test1/bin/django-admin", line 8, 
>>> in 
>>> sys.exit(execute_from_command_line())
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>>>  
>>> line 401, in execute_from_command_line
>>> utility.execute()
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>>>  
>>> line 395, in execute
>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>>>  
>>> line 328, in run_from_argv
>>> self.execute(*args, **cmd_options)
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>>>  
>>> line 60, in execute
>>> super().execute(*args, **options)
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>>>  
>>> line 369, in execute
>>> output = self.handle(*args, **options)
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>>>  
>>> line 67, in handle
>>> if not settings.DEBUG and not settings.ALLOWED_HOSTS:
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>>>  
>>> line 76, in __getattr__
>>> self._setup(name)
>>>   File 
>>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>>>  
>>> line 61, in _setup
>>> % (desc, ENVIRONMENT_VARIABLE))
>>> django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, 
>>> but settings are not configured. You must either define the environment 
>>> variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
>>> accessing settings.
>>> ..
>>>
>>>
>>>  
>> I tried to set it myself with export 
>> DJANGO_SETTINGS_MODULE=test1.settings but i receive  ModuleNotFoundError: 
>> No module named 'test1'
>> Seems like test1 module is not in the path, shouldn't be automatically 
>> added there?
>>
>> (test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ 
>> django-admin shell
>> Python 3.6.9 (default, Nov  7 2019, 10:44

Re: Need help whit DJANGO_SETTINGS_MODULE

2020-04-19 Thread Ayser shuhaib
to run the server use:
Python manage.py runserver

It would be better if you send a picture of the project files structure.

On Sun, 19 Apr 2020 at 15:22, Ilie Ioana  wrote:

> Hi,I'm new with django and python.
> I just strated a new django project in a venv using django 3.0 and seems
> that DJANGO_SETTINGS_MODULE is not set when running django-admin runserver
>
> Enter code here.(test1) 
> ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$
>> django-admin runserver
>> Traceback (most recent call last):
>>   File "/home/ioana.i/Workspace/Ioana/test1/bin/django-admin", line 8, in
>> 
>> sys.exit(execute_from_command_line())
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>> line 401, in execute_from_command_line
>> utility.execute()
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>> line 395, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>> line 328, in run_from_argv
>> self.execute(*args, **cmd_options)
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>> line 60, in execute
>> super().execute(*args, **options)
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>> line 369, in execute
>> output = self.handle(*args, **options)
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>> line 67, in handle
>> if not settings.DEBUG and not settings.ALLOWED_HOSTS:
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>> line 76, in __getattr__
>> self._setup(name)
>>   File
>> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>> line 61, in _setup
>> % (desc, ENVIRONMENT_VARIABLE))
>> django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but
>> settings are not configured. You must either define the environment
>> variable DJANGO_SETTINGS_MODULE or call settings.configure() before
>> accessing settings.
>> ..
>>
>>
>>
> I tried to set it myself with export DJANGO_SETTINGS_MODULE=test1.settings
> but i receive  ModuleNotFoundError: No module named 'test1'
> Seems like test1 module is not in the path, shouldn't be automatically
> added there?
>
> (test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$
> django-admin shell
> Python 3.6.9 (default, Nov  7 2019, 10:44:02)
> [GCC 8.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import sys
> >>> sys.path
> ['/home/ioana.i/Workspace/Ioana/test1/bin', '/usr/lib/python36.zip',
> '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload',
> '/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages']
> >>>
>
>
>
>
> --
> 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/07386bda-38a4-4897-b428-c8a39e52c487%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/CAE0AZGLQQ2ysY4vhFmUhnoJwQ2ZUPO3tTqCqXuL9kaEE5hy%3Diw%40mail.gmail.com.


Need help whit DJANGO_SETTINGS_MODULE

2020-04-19 Thread Ilie Ioana
Hi,I'm new with django and python.
I just strated a new django project in a venv using django 3.0 and seems 
that DJANGO_SETTINGS_MODULE is not set when running django-admin runserver

Enter code here.(test1) 
> ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ django-admin 
> runserver
> Traceback (most recent call last):
>   File "/home/ioana.i/Workspace/Ioana/test1/bin/django-admin", line 8, in 
> 
> sys.exit(execute_from_command_line())
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>  
> line 401, in execute_from_command_line
> utility.execute()
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py",
>  
> line 395, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>  
> line 328, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 60, in execute
> super().execute(*args, **options)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py",
>  
> line 369, in execute
> output = self.handle(*args, **options)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 67, in handle
> if not settings.DEBUG and not settings.ALLOWED_HOSTS:
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>  
> line 76, in __getattr__
> self._setup(name)
>   File 
> "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py",
>  
> line 61, in _setup
> % (desc, ENVIRONMENT_VARIABLE))
> django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but 
> settings are not configured. You must either define the environment 
> variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
> accessing settings.
> ..
>
>
>  
I tried to set it myself with export DJANGO_SETTINGS_MODULE=test1.settings 
but i receive  ModuleNotFoundError: No module named 'test1'
Seems like test1 module is not in the path, shouldn't be automatically 
added there?

(test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ 
django-admin shell
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sys
>>> sys.path
['/home/ioana.i/Workspace/Ioana/test1/bin', '/usr/lib/python36.zip', 
'/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', 
'/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages']
>>> 




-- 
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/07386bda-38a4-4897-b428-c8a39e52c487%40googlegroups.com.


Re: Django render a DynamoDB JSON into a HTML table

2020-04-19 Thread Daniel Pedrajas Pineda
Here the solution: 
https://stackoverflow.com/questions/61285947/django-render-a-dynamodb-json-into-a-html-table

Thank you to https://stackoverflow.com/users/6460856/swetank-poddar 

View.py:


def history(request):
 dynamodb_resource('dynamodb')
 history_table = dynamodb_resource.Table('name_of_the_table')
 all_items = history_table.scan()
 return render(request, 'history.html', { items: all_items['Items'] })


Your template:



  {% for item in items %}

{{ item.id }}
{{ item.agent }}
{{ item.date }}
{{ item.source }}

  {% endfor %}


El sábado, 18 de abril de 2020, 19:23:31 (UTC+2), Daniel Pedrajas Pineda 
escribió:
>
> I'm try to use a Django page as front-end using some AWS DynamoDB tables 
> as back-end. To do so, I use boto3 library and it gets the data from the 
> table correctly but I'm not able to parse the data into a HTML table. I 
> have the following in views.py
>
> def history(request):
>  itemsid = list()
>  agents = list()
>  dates = list()
>  source = list()
>  dynamodb_resource('dynamodb')
>  history_table = dynamodb_resource.Table('name_of_the_table')
>  all_items = history_table.scan()
>  for p in all_items['Items']:
>itemsid.append((p['id'])),
>agents.append((p['agent'])),
>dates.append((p['date'])),
>source.append((p['source']))
> return render(request, 'history.html', {'itemsid':itemsid, 
> 'agents':agents, 'dates':dates, 'source':source}
>
> The issue is that I don't know how to write the html code to show a table 
> with the rows: id, agent, date and source. 
>
> I have the following in history.html
>
>
> 
>   {% for i in itemsid %}
>   
> {{ i }}
> ...
>
> but I don't know how to code it (how to loop it) to show the table with 
> the lists as source. 
>
> Any idea please about how to parse a Json with the following format into a 
> HTML with Django and Python please?. 
>
> JSON from DynamoDB:
>
>
> {
>   'Items: [ {
> 'id': '94f'
> 'agent': 'aws'
> 'date': '04/05
> 'source': 'case1'
>   }, {
> 'id': 'lk42'
>   ...
> Thank you so much. I'm new in Django and in programming in general so any 
> help is much 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/a301efc4-5c67-402d-8986-59faddbc482d%40googlegroups.com.


Page freezing when loggin into admin

2020-04-19 Thread Dylan Reinhold
I had noticed this on a couple existing projects, but just figured I broke
something. But I see this in a couple new projects also.
When I log into admin from the first time after my browser is started, i
enter my user/password and the data is posted, but I never get a redirect
If i immediately just go to the admin url again i'm and logged in. So the
seems like the session token got saved but i never redirected. I don't see
any errors in the web browser network trace or console or the server.

The one common thing seems to be these are small projects just running
sqlite for the DB. If I move the project to postgress seems like the issue
goes away.
I think they are all running uwsgi behind nginx.

Anyone else notice this?

Dylan

-- 
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/CAHtg44CuMY9m4VqsWLo_5Fcig0ZT7ki-j0MH0kBHPzhihpp02w%40mail.gmail.com.