Monday, August 16, 2021

Error: NoReverseMatch at

Hi All,

I have a customized/override "changelist_view.html" to display hierarchical data in Django admin panel.

The problem is that the default form to add the Model data throws below error when clicked the button "add category". Please refer to the attached screenshot.

dj_1.jpg

NoReverseMatch at /admin/category/category/add/

Reverse for 'app_list' with keyword arguments '{'app_label': ''}' not found. 1 pattern(s) tried: ['admin/(?P<app_label>category|auth)/$']

dj_2.jpg

If I remove the function "def changelist_view(self, request, extra_context={}):", the model starts appearing fine. Please refer to the screenshot below. But then I loose the functionality to display custom hierarchical data.

dj_3.jpg

How can I still show the default form to add data to the model and override the  changelist_view.html" .

Appreciate any help in advance.

Thanks
Rahul

This e-mail is intended only for the named person or entity to which it is addressed and contains valuable business information that is privileged, confidential and/or otherwise protected from disclosure. If you received this e-mail in error, any review, use, dissemination, distribution or copying of this e-mail is strictly prohibited. Please notify us immediately of the error via e-mail to disclaimer@email-abuse.com and please delete the e-mail from your system, retaining no copies in any media. We appreciate your cooperation.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a3088233-47f7-4433-ae5c-3cd37b1fd9dbn%40googlegroups.com.

Sunday, August 15, 2021

Re: Added new column to model and run migrations but not applied to database table

Hi,
I am hitting this problem again with new code merges into the deployment server. Last time, I fixed the issue by doing like this

"I have tried all the ways what you guys suggested me But here I don't want change database why because it is deployment server so, when I run manage.py makemigrations migrations are applied and changes are reading but when I run manage.py migrate changes are not taken to database so, Manually I queried queries to add columns into respected tables into database."

I really think this might not be a sustainable solution. So, I would really like to fix this permanently. I would appreciate it if someone could suggest a remedy for this issue.

Thank you in advance
~Salima

On Tue, Jul 27, 2021 at 5:18 AM guna visva <gunaselanv@gmail.com> wrote:
having had the unfortunate phase of dealing with it , sorting it requires some patience

the issue is the tables in django_migrations is not in sync with rest the rest of your database or migrations files. 

You have to first remove the addition in field etc and make sure the database tables are first in sync with your models, then 1. delete migrations files and 2. delete django_migrations. Then 3.makemigrations and 4. migrate fake.  All risks are yours to take

Then finally just add your fields and makemigrations and migrate

The above might/or not work as it might give some content type errors 




On Wednesday, July 21, 2021 at 2:39:56 AM UTC+8 sebasti...@gmail.com wrote:
Is in settings.py also in installed app? Without that migrations don't work

Salima Begum <sali...@rohteksolutions.com> schrieb am Di., 20. Juli 2021, 19:00:
Hi ,
Thank you for your responses.
 I have tried all the ways Which you people suggested I am not getting any error while running makemigrations or migrate and 
python manage.py migrate --fake-initial. But those migrations are not applying to the database. How can I fix this issue without deleting the database? 

Thank you
~Salima
 

On Mon, Jul 19, 2021 at 7:02 PM Aman Vyas <amanv...@gmail.com> wrote:
if it is saying no changes detected while running makemigrations and you are sure that you changed models.py  then these things you can try:

1: python manage.py makemigrations appname

if this will not work then do that

2: delete migrations folder from your app and delete database then run again python manage.py makemigrations




On Mon, Jul 19, 2021 at 6:07 AM Salima Begum <sali...@rohteksolutions.com> wrote:
Hi all,

I have added a new column to the existing model while developing. Then I run makemigrations and migrate. It is not applied to the database table which is created based on that model. How can I fix this issue? Please help me to complete this issue.

The below issue I am facing in deployment server after adding new field and deployed into server.

```
psycopg2.errors.UndefinedColumn: column shopping_ls_product_search.quality_prdct does not exist
LINE 1: ... Col1 FROM "shopping_ls_product_search" WHERE ("shopping_...
```
Thank you
~Salima

--
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/CAMSz6bnLkeN001UnxO3PdCg06Jc%3Dcr22kZXc71KL4w5CbYq_Cw%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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKZY6%3DAgrWzCmrBHpouSJG_Vfy7i6LQu81Q7EWBRq44Yf3053A%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...@googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f8458021-e0c0-4c30-8188-0c08932b1deen%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMSz6bki3qrsof6JJC3PhcAGcFECEo-iOttsgXvQ3c2SBcyEWg%40mail.gmail.com.

Re: GeoDjango with SpatialLite on Windows 10

OK, I got it.

As it turns out, GDAL has everything you need, including the SQLite database. There is only one important fact, you have to load the DLL prior Django loads his SQLite. Because Django loads the one from Python it self. Therefore i did put the necessary code into the settings.py. Because Django has first to load the settings, before it can load the correct database middleware (SQLite, PostgreSQL, MariaDB,...). The code is in the Picture below.

P.S.: The Tutorial is not quiet accurate. The Geographic Model from there (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/#defining-a-geographic-model) should allow NULL for the polygon field:
mpoly = models.MultiPolygonField(null=True)
This is neccessary because the ZIP you offer there has incomplete data. At least good old England (to be precise: United Kingdom) has no pylogon data, maybe some more countries. I didn't check further. Therefore you can't load the "TM_WORLD_BORDERS-0.3.shp" as instructed (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/#layermapping).

Should I open a ticket for this, or is this mailing list enough?
settings.png
Tugg Speedman schrieb am Freitag, 13. August 2021 um 18:41:22 UTC+2:
Ah OK, this was helpful. I never thought about this, but as it turns out on Windows, Python ships with it's own compiled version of SQLite (see picture below). This is problematic. If i just swap this DLL with another one, I would change every other Python Script on my machine. Hmm..., is it possible to change some environment Paths in a venv and just point to another DLL? I have to look this up. Thanks a lot Micheal.

sqlite.png

Michael Ross schrieb am Freitag, 13. August 2021 um 00:51:02 UTC+2:
On Thu, 12 Aug 2021 04:15:57 -0700 (PDT)
Tugg Speedman <ts.sim...@gmail.com> wrote:

>
> Hello everyone,
>
> I'm new to GeoDjango and therefore I tried to follow the tutorial
> (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/) first.
> But the problem is, it doesn't work with SQLite a.k.a SpatialLite. When I
> try to build the migrations, a Windows error pops up (see picture below).
> It's german and says there is no entry point in gdal301.dll.
>
> So why do I post this problem here in Django mailing list? Because the
> Tutorial is very fuzzy for Spatial & Windows. It basically just says
> download the SQLite files from here: https://www.gaia-gis.it/gaia-sins/
>
> But what to do with this files? Can I put them wherever I want? Do I have
> to add them on System/Python path?
>
> I would really appreciate any help
> Thank you[image: error.png]

Maybe this helps:

https://stackoverflow.com/questions/53682315/error-on-libcurl-dll-when-using-gdal-of-osgeo4w-in-django

TLDR: IntelliJ loads wrong sqlite3.dll?

--
Michael Ross <g...@ross.cx>

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e0fb9baa-dbcb-4d6a-a566-a91c7b8d362cn%40googlegroups.com.

Friday, August 13, 2021

Re: GeoDjango with SpatialLite on Windows 10

Ah OK, this was helpful. I never thought about this, but as it turns out on Windows, Python ships with it's own compiled version of SQLite (see picture below). This is problematic. If i just swap this DLL with another one, I would change every other Python Script on my machine. Hmm..., is it possible to change some environment Paths in a venv and just point to another DLL? I have to look this up. Thanks a lot Micheal.

sqlite.png

Michael Ross schrieb am Freitag, 13. August 2021 um 00:51:02 UTC+2:
On Thu, 12 Aug 2021 04:15:57 -0700 (PDT)
Tugg Speedman <ts.sim...@gmail.com> wrote:

>
> Hello everyone,
>
> I'm new to GeoDjango and therefore I tried to follow the tutorial
> (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/) first.
> But the problem is, it doesn't work with SQLite a.k.a SpatialLite. When I
> try to build the migrations, a Windows error pops up (see picture below).
> It's german and says there is no entry point in gdal301.dll.
>
> So why do I post this problem here in Django mailing list? Because the
> Tutorial is very fuzzy for Spatial & Windows. It basically just says
> download the SQLite files from here: https://www.gaia-gis.it/gaia-sins/
>
> But what to do with this files? Can I put them wherever I want? Do I have
> to add them on System/Python path?
>
> I would really appreciate any help
> Thank you[image: error.png]

Maybe this helps:

https://stackoverflow.com/questions/53682315/error-on-libcurl-dll-when-using-gdal-of-osgeo4w-in-django

TLDR: IntelliJ loads wrong sqlite3.dll?

--
Michael Ross <g...@ross.cx>

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/771326b9-4f29-4a5f-9e48-7171d6221878n%40googlegroups.com.

Thursday, August 12, 2021

Re: Async Help Needed

The example you presented should Just Work - that error generally only occurs if you return an un-awaited coroutine, which if you're just returning a response, should be impossible.

What version of Python and Django are you running?

Andrew

On Thu, Aug 12, 2021, at 11:03 AM, Steven Mapes wrote:
Does anyone have some links to good guides on getting asnyc to work with Django? I have a use case where I really need to have a view give an async response but I can't get even the most basic of examples working.

I've tried the examples from https://testdriven.io/blog/django-async-views/ with a simple view of:

async def test_view(request):
    return HttpResponse("Hello, async Django!")

I've installed uvicorn and am running it with  uvicorn my_project.asgi:application --reload

My sync views work as expected but the async one just returns an error of "The view sample.views.test_view didn't return an HttpResponse object. It returned an unawaited coroutine instead. You may need to add an 'await' into your view."



--
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+unsubscribe@googlegroups.com.

Async Help Needed

Does anyone have some links to good guides on getting asnyc to work with Django? I have a use case where I really need to have a view give an async response but I can't get even the most basic of examples working.

I've tried the examples from https://testdriven.io/blog/django-async-views/ with a simple view of:

async def test_view(request):
    return HttpResponse("Hello, async Django!")

I've installed uvicorn and am running it with  uvicorn my_project.asgi:application --reload

My sync views work as expected but the async one just returns an error of "The view sample.views.test_view didn't return an HttpResponse object. It returned an unawaited coroutine instead. You may need to add an 'await' into your view."


--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/64f90a01-76fe-4e01-ab3a-a6a0910038c9n%40googlegroups.com.

Wednesday, August 11, 2021

url_conf workaround causes warning

I know I'm doing things the wrong way so the solution to this problem is
to learn how to do it correctly if anyone can help please.

WARNINGS:
?: (urls.W005) URL namespace 'admin' isn't unique. You may not be able
to reverse all URLs in this namespace

In my home page template I have ...

{% if channel %}
    {% include channel %}
{% endif %}

... where 'channel' is a short paragraph (one of six) aimed at six
different kinds of customers for the site. They are plain html with no
templating at all. The home page has a top menu of links one of which
has six sub-menu links each one pointing to a different 'channel'.

This worked well at inserting the selected paragraph. But it also picked
up random stuff and generated 404 errors. So I made the view only serve
the nominated six paras. Unfortunately 'admin' generated a 404 as well.

The solution was to rearrange url_conf as follows ...

urlpatterns = [
    ...
    re_path(r"^admin/", adminurls),
    # need this "admin" to gazump <channel> ... is a bit fragile
    path("admin", adminurls),
    path("<channel>", company_views.channel, name="channel"),
]


Here is the view ...

def channel(request, channel):
    if channel in [
        "formulators",
        "regaffairs",
        "cosmetics",
        "coatings",
        "polymers",
        "consultants",
        "disruption",
    ]:
        templ = "home.html"
        cont = {
            "title": settings.BRAND,
            "privacy": "/privacy",
            "security": "/security",
            "licence": "/licence",
            "about": "/about",
            "contact": "/contact",
            "support": "/support",
            "manager": ismanager(request),
        }
        cont["channel"] = f"{channel}.html"
    else:
        templ = "404.html"
        cont = {}
    return render(request=request, template_name=templ, context=cont)

Many thanks for advice

Cheers

Mike



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/447e7c8d-355b-1c39-a3d6-e40183c9e0a8%40dewhirst.com.au.